Skip to content

atrium-ui/vite-plugin-wrap-worker

Repository files navigation

vite-wrap-worker

This is an experimental plugin, not intended for production.

Use workers without thinking about using workers.

How

It transforms your importetd file with an .worker. extension to wrap around a Comlink Proxy, without braking any types.

Example

// vite.config.ts
import wrapWorker from "@luckydye/vite-wrap-worker";
import { defineConfig } from "vite";

export default defineConfig({
  base: "",
  plugins: [wrapWorker()],
});
// Process.worker.ts
export default {
  async work() {
    console.log("done", globalThis);
  },
};
// main.ts
import Process from "./Process.worker";
await Process.work()
// done, DedicatedWorkerGlobalScope

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published