vite-plugin-wrap-worker
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i vite-plugin-wrap-worker

Weekly Downloads

4

Version

0.3.0

License

ISC

Unpacked Size

9.33 kB

Total Files

5

Last publish

Collaborators

  • luckydye