Registry / devops / rollup-plugin-workers

rollup-plugin-workers

JSON →
library2.1.1jsnpmunverified

A Rollup plugin that adds code splitting for JavaScript module Workers (Web Workers, Shared Workers, Service Workers) and Worklets (AudioWorklet, PaintWorklet, LayoutWorklet, AnimationWorklet). Current stable version: 2.1.1. Works with Rollup >= 1.11.0. It transforms Worker/Worklet import patterns into separate output chunks, enabling dynamic code splitting for multithreaded applications. Unlike generic worker plugins, this plugin specifically targets module-type workers and supports ES module format in workers. Does not include a module loader; users must handle chunk loading.

npm install rollup-plugin-workers
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-WORK
R
rollup-plugin-workers
devopsjavascriptv2.1.1
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-workers'
const worker = require('rollup-plugin-workers')
Plugin is ESM-only; CommonJS require will fail unless using dynamic import.
worker
import { default as worker } from 'rollup-plugin-workers'
Default export only; named export 'worker' is not available.
Rollup plugin usage
import worker from 'rollup-plugin-workers'; export default { plugins: [worker()] }
import { worker } from 'rollup-plugin-workers'
The function is the default export; using named import will result in undefined.

Demonstrates basic Rollup configuration with the workers plugin to enable code splitting for module workers.

import worker from 'rollup-plugin-workers'; export default { input: 'main.js', output: { dir: 'dist', format: 'esm' }, plugins: [worker()] };
Debug
Known issues
breakingRequires Rollup >= 1.11.0; older versions will fail to load the plugin.
fix
Upgrade Rollup to version 1.11.0 or higher.
affects: <=1.10.x
gotchaPlugin does not include a module loader. You must handle loading of split chunks manually in the browser.
fix
Provide a module loader or use a bundler that supports automatic chunk loading (e.g., Vite).
affects: all
gotchaWorklet calls must exactly follow format '*.*Worklet.addModule(...)'. Arbitrary function calls won't be recognized.
fix
Ensure worklet registration uses the pattern obj.worklet.addModule, where worklet is one of: AudioWorklet, PaintWorklet, LayoutWorklet, AnimationWorklet.
affects: all
gotchaWorkers must be of type 'module' and use the correct constructor signature (e.g., new Worker('./worker.js', { type: 'module' })).
fix
Always pass { type: 'module' } as second argument to Worker/SharedWorker constructors, and for ServiceWorker use { type: 'module' } in register().
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-workers'
Package not installed or CommonJS require used in ESM context.
fix
Install the package: npm install -D rollup-plugin-workers. Use import syntax instead of require.
TypeError: worker is not a function
Named import used instead of default import.
fix
Change import to default import: import worker from 'rollup-plugin-workers'.
Error: The Rollup version is not supported by rollup-plugin-workers
Rollup version is below 1.11.0.
fix
Upgrade Rollup to version >= 1.11.0.
Upgrade
Version history
2.1.1latest on npm
Audit
Dependencies
rolluprequiredpeer dependency; plugin only works with Rollup >= 1.11.0
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-workers — npm install rollup-plugin-workers · libregistry