0.0.6 • Published 6 months ago
bun-plugin-comlink v0.0.6
bun-plugin-comlink
That is comlink loader for Workers in Bun.
Installation
bun add bun-plugin-comlink
Create a plugin.ts
file:
import { plugin } from "bun";
import comlinkPlugin from "bun-plugin-comlink";
await plugin(comlinkPlugin());
Add plugin.ts
to bunfig.toml
:
preload = ["./plugin.ts"]
Usage
Create a functions.worker.ts
file:
export async function sayHello() {
return "Hello from worker!";
}
So later you can import it in your main file:
import { sayHello } from "./functions.worker";
console.log(await sayHello());
Limitations
- You can't have sync functions with comlink
License
Apache-2.0