Description
Bug report
What is the current behavior?
When running the watch
command, at some point the runtime-app
chunk referenced in the app
chunk is different from the one referenced in the asset-manifest.json
.
Since we load this code in a PHP app, we use the manifest to load the chunks dynamically.
Having the manifest reference a different chunk than the one referenced in the app
chunk means that the browser loads two different runtime-app
chunks, one requested by the manifest, and the other by the app
chunk.
Since the second one is the oldest, the end result is that the watch
command is not doing its job, because from a certain moment, I'm not able to see the changes I make to the code reflected in the browser.
If the current behavior is a bug, please provide the steps to reproduce.
Here is a GitHub repository with the code needed to reproduce the issue: https://github.com/gtempesta/webpack-issue-repro/.
How to reproduce:
- Clone the repository
- Run
npm install
to install the dependencies - Run
npm run watch
to start watching for changes - Open the
asset-manifest.json
file in the public folder, and open theapp
chunk that is referenced in theentry-points
field. Now look for theruntime-app
chunk in theapp
chunk and check that it's the same that is referenced in theasset-manifest.json
file: it should be the same (with the same hash) - Make a change to the code in
app.js
and save it - The issue is still not there
- Now make a change to the
design-area.js
file and save it - The issue should be there now: the
runtime-app
chunk in theasset-manifest.json
file and in theapp
chunk should have different hashes
The issue happens only when using the watch
command, and not when using the build
command (which is not implemented in this repo).
What is the expected behavior?
I would expect that the runtime-app
chunk referenced in the asset-manifest.json
file and in the app
chunk are always the same, so that I can use the manifest to load the chunks dynamically without having to worry about which one is loaded.
Other relevant information:
webpack version: 5.99.5
Node.js version: 18.17.1
Operating System: macOS Sequoia 15.3.2
Additional tools: