Webpack loader for bundling Web Workers as separate files or inline blobs. Version 3.0.8 is the latest stable release (Feb 2021). Actively maintained as part of the webpack-contrib ecosystem. Key differentiators: supports inline workers via BLOB to avoid separate HTTP requests, allows customization of worker constructor (Worker/SharedWorker), and provides fine-grained control over filename, publicPath, and esModule output. Requires webpack 4 or 5 and Node >=10.13.
npm install worker-loaderVerified import paths — ran on the pinned version, not inferred.
Shows basic webpack config to automatically bundle .worker.js files as Web Workers, and how to import and use the worker in app code.
Replace 'name' with 'filename' in your worker-loader options.
Upgrade Node.js to >=10.13 and webpack to >=4.
Use import instead of require, or set options.esModule to false for backward compatibility.
Use 'inline: 'fallback'' or 'inline: 'no-fallback'' instead of 'fallback'.
Use a separate file worker instead of inline, or adjust CSP to allow blob: scripts.
Upgrade worker-loader to >=3.0.1.
Run 'npm install worker-loader --save-dev'.
Change 'name' to 'filename' in worker-loader options.
Ensure you are using 'import MyWorker from './file.worker.js'' (ESM) and that the file matches the rule pattern.
Install worker-loader and use correct inline syntax: 'worker-loader!./file.js'.