rollup-plugin-web-worker-loader
Rollup plugin to bundle web worker code to later be instantiated as a Worker.
Preserves the code so other plugins can modify it and/or transpile it.
Can be
configured to inline a sourcemap.
Getting started
yarn add rollup-plugin-web-worker-loader --dev
Add the plugin to your rollup configuration:
import webWorkerLoader from 'rollup-plugin-web-worker-loader';
export default {
entry: 'src/index.js',
plugins: [
webWorkerLoader(),
],
format: 'esm',
};
Bundle the worker code using the prefix web-worker:
in your imports:
import DataWorker from 'web-worker:./DataWorker';
const dataWorker = new DataWorker();
dataWorker.postMessage('Hello World!');
Configuration
The plugin responds to the following configuration options:
webWorkerLoader({
sourcemap: boolean,
})
Roadmap