Registry / web-framework / worker-url

worker-url

JSON →
library1.1.0jsnpmunverified

A webpack v5 plugin and helper library to generate URLs for Web Workers and AudioWorklets. Version 1.1.0, released under MIT license. Unlike native webpack 5 worker support which creates Worker instances directly, worker-url gives you a URL object that can be used with both Worker and AudioWorklet. Also solves the missing Worklet support in webpack 5 (github issue #11543). Ships TypeScript type definitions. Peer dependency on webpack >=5.0.0. Maintained by a single developer, low release cadence.

npm install worker-url
INSTALL
IMPORT
SIG · WORKER-URL
W
worker-url
web-frameworkjavascriptv1.1.0
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.

WorkerUrl
import { WorkerUrl } from 'worker-url'
const { WorkerUrl } = require('worker-url');
Default import is not available; named import is required. CommonJS require works but is not the preferred pattern.
WorkerUrlPlugin
import { WorkerUrlPlugin } from 'worker-url/plugin'
import { WorkerUrlPlugin } from 'worker-url'
The plugin is in a separate subpath export 'worker-url/plugin'. Direct import from 'worker-url' does not include it.
WorkerUrl type
import type { WorkerUrl } from 'worker-url'
import { WorkerUrl } from 'worker-url' (used as type only)
TypeScript users can use type-only import to avoid bundling runtime code. The library ships TypeScript definitions.

Configures webpack plugin and creates a Worker using WorkerUrl helper.

// webpack.config.js const { WorkerUrlPlugin } = require('worker-url/plugin'); module.exports = { output: { publicPath: '/' }, plugins: [new WorkerUrlPlugin()] }; // index.js import { WorkerUrl } from 'worker-url'; const workerUrl = new WorkerUrl(new URL('./worker.js', import.meta.url), { name: 'myworker' }); const worker = new Worker(workerUrl); // For worklet: // audioContext.audioWorklet.addModule(workerUrl);
Debug
Known issues
gotchaWorkerUrlPlugin must be added to webpack plugins or WorkerUrl will generate an incorrect URL.
fix
Add `new WorkerUrlPlugin()` to your webpack plugins configuration.
affects: >=1.0.0
breakingworker-url requires webpack >=5.0.0. Not compatible with webpack 4.
fix
Upgrade to webpack 5 or use alternative worker-loader.
affects: >=1.0.0
deprecatedThe `WorkerUrl` constructor options `name` and `customPath` signature may change in future versions.
fix
Check the changelog before upgrading major versions.
affects: 1.x
Errors
Common errors & fixes
Cannot find module 'worker-url/plugin'
Plugin is imported from incorrect path or missing export in older version.
fix
Ensure you import `WorkerUrlPlugin` from 'worker-url/plugin' (not 'worker-url'). Check if package is installed correctly.
TypeError: (intermediate value).addModule is not a function
Attempting to use WorkerUrl with AudioWorklet.addModule but the URL object is used incorrectly.
fix
WorkerUrl returns a URL (or string) that can be passed directly to `addModule`. Example: `audioContext.audioWorklet.addModule(workerUrl)`.
Module parse failed: Unexpected character '#'
Webpack configuration missing WorkerUrlPlugin or using unsupported syntax (e.g., dynamic import not handled).
fix
Add `new WorkerUrlPlugin()` to webpack plugins and ensure your webpack config is set up correctly for workers.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
webpackrequiredpeer dependency required for the plugin to function
Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources
worker-url — npm install worker-url · libregistry