rollup-plugin-bundle-worker
Bundles a single JS file alongside your main source code as the source for a Web Worker. Provides a fallback for running the code in the main thread if the browser does not support creating Workers from blobs.
Getting started
npm install rollup-plugin-bundle-worker
Require the plugin and add it to your configuration:
; entry: 'src/main.js' plugins: format: 'umd';
For each worker that you want to create, import the file with a worker!
prefix:
; var myWorker = ;myWorker { if evtdata === 'hello' myWorker; };
Usage with Babel
The plugin allows your worker scripts to be transformed by the babel plugin. However, if you specify your preset as a string in the configuration, you will receive an error that the preset cannot be found for the worker file. Instead, you should manually require the preset and pass it to the Babel configuration:
;;; entry: 'src/main.js' plugins: format: 'umd';