webpack: Webpack 5 worker import fails with "chunks: 'all'" + [contenthash] in output filename
Bug report
What is the current behavior?
Worker import started producing a script loading error as soon as I added [contenthash]
into the output filename.
I see a strange 404 error in the console for a non-existent chunk script with a strange path (note the .undefined.js
postfix):
https://localhost/addin/src_functions_parallelism_caching_passport-worker_ts-_36b50.undefined.js
Where does this .undefined.js
part come from? Does it give anyone any idea?
The actual filename of the chunk that does exist after compilation is src_functions_parallelism_caching_passport-worker_ts-_36b50.8ba2df42b53ad688d69d.js
- instead of undefined
there’s a proper content hash.
Relevant bits of configuration:
output: {
path: path.resolve(__dirname, 'wwwroot'),
publicPath,
filename: '[name].[contenthash].js',
},
optimization: {
moduleIds: 'deterministic',
splitChunks: {
chunks: 'all',
},
runtimeChunk: false,
},
The worker import code in the transpiled code I see:
return new Worker(
new URL(/* worker import */ __webpack_require__.p +
__webpack_require__.u(
"src_functions_parallelism_caching_passport-worker_ts-_36b50"), __webpack_require__.b), {
...
Not sure if it’s OK or relevant to the problem, pasting here just in case.
What is the expected behavior?
The expected behaviour is that worker import is able to resolve the correct script name (with the contenthash appended).
Other relevant information:
webpack version: 5.44.0
Node.js version: 14 LTS
Operating System: Mac OS
Additional tools:
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 22 (11 by maintainers)
Marked as critical, we will fix it in near future
Please try https://github.com/webpack/webpack/releases/tag/v5.51.2
Here is another reproduction: https://github.com/kinsei0916/webpack-worker-contenthash-repro I’m not using any additional plugins other than html-webpack-plugin. This issue occurs when I bump webpack-dev-server from 3.11.2 to 4.0.0.
Reproducible example https://github.com/AprilArcus/webpack-sri-workers-contenthash-repro
I’m having the same issue as @wh1t3cAt1k, in conjunction with waysact/webpack-subresource-integrity.
See also: https://github.com/waysact/webpack-subresource-integrity/issues/165 Minimal reproduction: https://github.com/AprilArcus/webpack-sri-workers-contenthash-repro
unfortunately there can be many problems here, I cannot help without repo 😞