question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack 5 worker import fails with "chunks: 'all'" + [contenthash] in output filename

See original GitHub issue

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:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:22 (11 by maintainers)

github_iconTop GitHub Comments

7reactions
alexander-akaitcommented, Aug 20, 2021

Marked as critical, we will fix it in near future

Read more comments on GitHub >

github_iconTop Results From Across the Web

Caching - webpack
This guide focuses on the configuration needed to ensure files produced by webpack compilation can remain cached unless their content has changed. Output...
Read more >
how to change the output format of web worker files in ...
The Webpack 5 docs offer no instructions (that I found) on how to control web workers output. I tried output.chunkFilename also with no...
Read more >
Fixing WebpackChunkName for Dynamic Imports - Time to Hack
As you are using [contenthash] in the output file names, only the changed modules will be cached again by service workers, not all...
Read more >
Adding Hashes to Filenames - SurviveJS
These strings are used to attach specific information to webpack output. ... A content hash is derived based on the chunk content.
Read more >
webpack/webpack - Gitter
ERROR in chunk vendor [entry] app.2795418ee07c48262960.js Cannot use [chunkhash] ... src/main.ts", output: { path: path.join(__dirname, 'dist'), filename: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found