Registry /
devops / rollup-plugin-web-worker-loader
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–223 runs
build_error
glibcnode 18–223 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default (plugin function)
✓ import webWorkerLoader from 'rollup-plugin-web-worker-loader';
✗ const webWorkerLoader = require('rollup-plugin-web-worker-loader');
ESM default export; CJS require() works with some bundlers but not recommended.
Web Worker import
✓ import DataWorker from 'web-worker:./DataWorker';
✗ import DataWorker from 'rollup-plugin-web-worker-loader!./DataWorker';
The plugin uses a prefix scheme (default: 'web-worker:') in the import specifier; no query syntax.
Service Worker import
✓ import ServiceWorker from 'service-worker:./ServiceWorker';
✗ const ServiceWorker = require('service-worker:./ServiceWorker');
ESM-only import; ServiceWorker returns a Promise<ServiceWorkerRegistration>.
Minimal Rollup config with the plugin and a Web Worker import example.
import webWorkerLoader from 'rollup-plugin-web-worker-loader';
import { defineConfig } from 'rollup';
export default defineConfig({
input: 'src/index.js',
plugins: [
webWorkerLoader({
targetPlatform: 'auto',
preserveSource: false,
external: []
})
],
output: {
dir: 'dist',
format: 'esm'
}
});
// src/index.js
import MyWorker from 'web-worker:./MyWorker';
const worker = new MyWorker();
worker.postMessage('hello');
// src/MyWorker.js
self.onmessage = (e) => {
postMessage('received: ' + e.data);
};
Errors
Common errors & fixes
SyntaxError: Named export 'default' not found. The requested module 'rollup-plugin-web-worker-loader' is a CommonJS module, which may not support all module.exports as named exports.
The plugin is an ESM-only default export; CommonJS require() or named import destructuring fails.
fixUse import webWorkerLoader from 'rollup-plugin-web-worker-loader' (ESM) or if using CJS, use const webWorkerLoader = require('rollup-plugin-web-worker-loader').default. Error: The 'web-worker' prefix is not configured. Use the 'webWorkerLoader' plugin options to set a custom pattern.
The import specifier uses a custom prefix not defined in the plugin config.
fixEither use the default 'web-worker:' prefix, or configure a custom RegEx in the plugin options under the 'web-worker' key.
Audit
Dependencies
rolluprequiredpeer dependency: required to function as a Rollup plugin, versions ^1.9.2 || ^2.0.0 || ^3.0.0 || ^4.0.0