Vite plugin that integrates Comlink to simplify Web Worker and SharedWorker usage. Current stable version is 5.3.0, released under MIT license. It removes the need for manual `expose` and `wrap` calls, automatically transforming workers referenced via `ComlinkWorker` and `ComlinkSharedWorker` constructors. Requires Vite >=2.9.6 and comlink as a peer dependency. Key differentiator: zero-config setup for Comlink with Vite, supports both module and classic workers, and provides TypeScript type inference for worker modules.
npm install vite-plugin-comlinkVerified import paths — ran on the pinned version, not inferred.
Configures Vite with the plugin, creates a simple worker, and calls its function via Comlink.
Check for usage of internal plugin options; they may be removed. Update to latest v5.
Add `comlink()` to both arrays in vite.config.js.
Change `worker: { plugins: [comlink()] }` to `worker: { plugins: () => [comlink()] }`.Add `/// <reference types="vite-plugin-comlink/client" />` to your env.d.ts file.
Avoid setting `type: 'module'` unless you understand the implications.
Add `/// <reference types="vite-plugin-comlink/client" />` to your vite-env.d.ts file.
Use `new URL('./worker.js', import.meta.url)` instead of just `'./worker.js'`.Ensure the worker file uses named exports and does not import from the main thread.