{"id":20867,"library":"worker-url","title":"worker-url","description":"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.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/popelenkow/worker-url","tags":["javascript","worker-url","web worker","worklet","webpack","typescript"],"install":[{"cmd":"npm install worker-url","lang":"bash","label":"npm"},{"cmd":"yarn add worker-url","lang":"bash","label":"yarn"},{"cmd":"pnpm add worker-url","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for the plugin to function","package":"webpack","optional":false}],"imports":[{"note":"Default import is not available; named import is required. CommonJS require works but is not the preferred pattern.","wrong":"const { WorkerUrl } = require('worker-url');","symbol":"WorkerUrl","correct":"import { WorkerUrl } from 'worker-url'"},{"note":"The plugin is in a separate subpath export 'worker-url/plugin'. Direct import from 'worker-url' does not include it.","wrong":"import { WorkerUrlPlugin } from 'worker-url'","symbol":"WorkerUrlPlugin","correct":"import { WorkerUrlPlugin } from 'worker-url/plugin'"},{"note":"TypeScript users can use type-only import to avoid bundling runtime code. The library ships TypeScript definitions.","wrong":"import { WorkerUrl } from 'worker-url' (used as type only)","symbol":"WorkerUrl type","correct":"import type { WorkerUrl } from 'worker-url'"}],"quickstart":{"code":"// webpack.config.js\nconst { WorkerUrlPlugin } = require('worker-url/plugin');\nmodule.exports = {\n  output: { publicPath: '/' },\n  plugins: [new WorkerUrlPlugin()]\n};\n\n// index.js\nimport { WorkerUrl } from 'worker-url';\nconst workerUrl = new WorkerUrl(new URL('./worker.js', import.meta.url), { name: 'myworker' });\nconst worker = new Worker(workerUrl);\n// For worklet:\n// audioContext.audioWorklet.addModule(workerUrl);","lang":"javascript","description":"Configures webpack plugin and creates a Worker using WorkerUrl helper."},"warnings":[{"fix":"Add `new WorkerUrlPlugin()` to your webpack plugins configuration.","message":"WorkerUrlPlugin must be added to webpack plugins or WorkerUrl will generate an incorrect URL.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to webpack 5 or use alternative worker-loader.","message":"worker-url requires webpack >=5.0.0. Not compatible with webpack 4.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Check the changelog before upgrading major versions.","message":"The `WorkerUrl` constructor options `name` and `customPath` signature may change in future versions.","severity":"deprecated","affected_versions":"1.x"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure you import `WorkerUrlPlugin` from 'worker-url/plugin' (not 'worker-url'). Check if package is installed correctly.","cause":"Plugin is imported from incorrect path or missing export in older version.","error":"Cannot find module 'worker-url/plugin'"},{"fix":"WorkerUrl returns a URL (or string) that can be passed directly to `addModule`. Example: `audioContext.audioWorklet.addModule(workerUrl)`.","cause":"Attempting to use WorkerUrl with AudioWorklet.addModule but the URL object is used incorrectly.","error":"TypeError: (intermediate value).addModule is not a function"},{"fix":"Add `new WorkerUrlPlugin()` to webpack plugins and ensure your webpack config is set up correctly for workers.","cause":"Webpack configuration missing WorkerUrlPlugin or using unsupported syntax (e.g., dynamic import not handled).","error":"Module parse failed: Unexpected character '#'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}