Registry / devops / rollup-plugin-worker

rollup-plugin-worker

JSON →
library3.0.4jsnpmunverified

Rollup plugin to bundle Web Workers using a custom prefix import syntax (e.g., `worker!./worker.js`). v3.0.4 supports Rollup 3.x. It allows specifying worker-specific plugins and enables uglification. Provides TypeScript types. Differentiator: uses a prefix syntax rather than URL or inline blob, enabling easy bundling.

npm install rollup-plugin-worker
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-WORK
R
rollup-plugin-worker
devopsjavascriptv3.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import worker from 'rollup-plugin-worker'
const worker = require('rollup-plugin-worker');
ESM-only since v3; CommonJS require() works in Node.
Worker
import Worker from 'worker!./workers/worker.js'
import { Worker } from 'worker!./workers/worker.js'
Default import from the prefix path, not a named export.
WebWorker (TypeScript declaration)
declare module 'worker!*' { class WebWorker extends Worker { constructor(); } export default WebWorker; }
declare module 'worker!*' { export class WebWorker extends Worker { constructor(); } }
The default export is named WebWorker in the declaration.

Configures rollup-plugin-worker in rollup.config.js and shows usage in main.js with a custom worker import prefix.

// rollup.config.js import worker from 'rollup-plugin-worker'; export default { input: 'src/main.js', plugins: [ worker({ prefix: 'worker!', plugins: [], uglify: false, }), ], output: { file: 'dist/bundle.js', format: 'iife', }, }; // src/main.js import MyWorker from 'worker!./worker.js'; const w = new MyWorker(); w.postMessage('hello');
Debug
Known issues
breakingPlugin requires Rollup ^3.0.0; does not work with Rollup 2.x.
fix
Upgrade to Rollup 3.x or use rollup-plugin-worker@2.x for Rollup 2 compatibility.
affects: >=3.0.0
gotchaThe prefix 'worker!' is required by default; if changed, ensure import statements match.
fix
Use the same prefix in both plugin options and import paths.
affects: all
gotchaPlugins passed in the `plugins` option are used only for worker bundle; do not include the main bundle plugins unintentionally.
fix
Define separate plugins array for worker processing if needed.
affects: all
deprecateduglify option is boolean; consider using terser or other minifier plugins instead.
fix
Set uglify: false and use @rollup/plugin-terser for minification.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-worker'
Package not installed or incorrect import path.
fix
npm install rollup-plugin-worker --save-dev
TypeError: worker is not a function
Using default import incorrectly (e.g., import { worker } instead of import worker).
fix
Use default import: import worker from 'rollup-plugin-worker'
Error: Could not resolve 'worker!./worker.js'
Plugin not properly configured or prefix mismatch.
fix
Check that rollup-plugin-worker is in plugins array and prefix matches import path (e.g., 'worker!').
Upgrade
Version history
3.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-worker — npm install rollup-plugin-worker · libregistry