Skip to content

HMR broken for shared modules when optimization.splitChunks.name is false #10762

@rhendric

Description

@rhendric

Bug report

What is the current behavior?

Hot reloading of modules that are shared between two entry points doesn't seem to work if optimization.splitChunks.name = false.

(I don't entirely understand what that setting does, but it seems to be recommended in production builds, and create-react-app has it enabled by default. Maybe that setting doesn't make sense in the context of multiple entry points; in that case, it would be nice if webpack issued some kind of error message to that effect.)

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

This repository has a minimal reproduction: https://github.com/rhendric/verbose-octo-telegram

Run npm start, open http://localhost:8080, and then make changes to src/common.js. They will not appear in the browser. Notice that if you edit the webpack config and remove either the second entry point, or the name: false property in optimization.splitChunks, HMR will work again.

What is the expected behavior?

HMR should work for all project files. Alternatively, if this configuration is fundamentally invalid, webpack should alert the user.

Other relevant information:
webpack version: 4.43.0
Node.js version: v13.13.0
Operating System: Arch Linux
Additional tools: N/A

Metadata

Metadata

Assignees

No one assigned

    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