Skip to content

Chunk names do not respect filename setting if filename is a function #7085

@skylerberg

Description

@skylerberg

Bug report

What is the current behavior?

Chunks will receive names containing a hash with this code:

output: {
      filename: '[name]-[contenthash].js',
}

Chunks will receive names without hashes (e.g., 113.js) with this code:

output: {
      filename: () => '[name]-[contenthash].js',
}

If the current behavior is a bug, please provide the steps to reproduce.

Here is a full minimal reproduction of the issue: https://github.com/skylerberg/webpack-chunk-name-issue

You can observe the behavior by downloading the repo and running:

$ npm install
$ npm run build
$ ls dist

You will see a chunk without a hash in its name.

What is the expected behavior?

I would expect identical behavior between the two examples above because the function version always resolves to the same string as the original snippet.

Other relevant information:
webpack version: 5.89.0
Node.js version: v18.17.1
Operating System: Pop!_OS 20.04

It is possible to workaround this bug by explicitly setting chunkFilename. So I'm fine, but I wanted to report this so that it can get fixed and others won't be impacted by this surprising behavior.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy