JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12858
  • Score
    100M100P100Q147788F
  • License MIT

Bundle

Package Exports

  • rollup-plugin-web-worker-loader

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rollup-plugin-web-worker-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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,     // should a source map be included in the final output
})

Roadmap

  • Bundle file as web worker blob
  • Support for dependencies using import
  • Include source map
  • Provide capability checks and fallbacks
  • Avoid code duplication