👩🏭 Adds native Web Worker bundling support to Webpack.
new Worker()
options object (#94, thanks @jebbench)Webpack 5 compatibility (in addition to Webpack 4) (#84, thanks @gluck & @dkozma!)
New filename
and chunkFilename
options (#82):
new WorkerPlugin({
filename: '[name].[hash:5].js',
chunkFilename: '[name].[hash:5].js',
})
Reduce non-actionable warnings (#73)
Fix support for output filenames with querystring parameters (#74, thanks @brn!)
Worker Plugin 4 brings a few nice new features:
Using .mjs
now works properly with worker-plugin
, and actually produces better output than the default CommonJS internals (#61).
If you need to compile a module as a standalone set of bundles but don't need the new Worker
parsing stuff, it's now possible to use this plugin's internal functionality as a loader! Just prefix your import with worker-plugin/loader!
and you'll get back the bundle's URL. This is useful for bundling things like Worklets:
import workerUrl from 'worker-plugin/loader!./my-paint-worklet';
CSS.paintWorklet.addModule(workerUrl);
SharedWorker
Pass the {sharedWorker:true}
option to enable automatic bundling of SharedWorker
. (#42 - thanks @stutrek!).
Similarly, you can also now pass {worker:false}
to disable automatic bundling of Worker
. (#57 - thanks @gbmatt!)
Previously, new Worker("./foo.js", { type:"module", })
would result in invalid JavaScript output. This has now been fixed. Unless configured to keep the type
option around, the output is simply new Worker(bundleUrl)
. (#49 - thanks @arturovt!)
This release fixes two bugs relating to worker filename generation when no name is provided.
globalObject
option (#20) - pass false
to disable warnings.Plugins are no longer inherited by default. This behaviour had been added in 2.0.0
, but proved problematic in many configurations.
Instead, a new plugins
option allows specifying which plugins to inherit, or custom plugins to add when bundling workers (#16 #17). Big thanks to @3846masa for making this work!
Note
It is strongly recommended to upgrade to 3.0.0. This 2.x version caused issues in many webpack configurations.
🐛 If you encounter any issues upgrading to this version, please file a bug.
[chunkhash]
or [contenthash]
.{ type: 'module' }
, since it can raise a SyntaxError.Upgrade notes: This should just fix a browser support issue in 1.0.0, so it's not a breaking change. Though it is not recommended, if you're relying on outputting actual module Workers there is a new option to retain
{ type: 'module' }
in the compiled code:new WorkerPlugin({ preserveTypeModule: true })