Rollup plugin to seamlessly use Web Workers with ES modules by shimming AMD/ESM support for workers. Current stable version is 1.0.0. It auto-bundles workers referenced via `new URL` patterns, and also supports importing workers as URLs via the `omt:` scheme. Differentiators: it works with Rollup's native worker support and handles complex worker bundling scenarios, including Service Workers with `useEval`. It enforces AMD or ESM output format for workers due to limited native module support in browsers.
npm install rollup-plugin-off-main-threadsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic Rollup config using OMT plugin. Output format must be 'amd' or 'esm' for workers to work.
Set output.format to 'amd' or 'esm'.
Use new URL('worker.js', import.meta.url) instead.Avoid useEval unless necessary for Service Workers; prefer default <script> tag approach.
Use import OMT from '@surma/rollup-plugin-off-main-thread' instead of import { OMT } from '...'.Add OMT() to the plugins array: plugins: [OMT()].
Set output.format to 'amd' or 'esm'.
Run npm install @surma/rollup-plugin-off-main-thread and ensure your project uses ESM (e.g., 'type': 'module' in package.json).