This repository contains a minimal reproduction of a Webpack issue, that happens when working with the Module Federation plugin.
The issue didn't start when we first set up the project, so it's probably related to the update of one of the packages, but I'm not able to track down the package or the version.
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.
- Clone the repository
- Run
npm installto install the dependencies - Run
npm run watchto start watching for changes - Open the
asset-manifest.jsonfile in the public folder, and open theappchunk that is referenced in theentry-pointsfield. Now look for theruntime-appchunk in theappchunk and check that it's the same that is referenced in theasset-manifest.jsonfile: it should be the same (with the same hash) - Make a change to the code in
app.jsand save it - The issue is still not there
- Now make a change to the
design-area.jsfile and save it - The issue should be there now: the
runtime-appchunk in theasset-manifest.jsonfile and in theappchunk should have different hashes
This is probably related to the fact that in design-area.js we are importing a module that is loaded using the Module Federation plugin, because if we remove the Module Federation configuration, the issue disappears.
The issue happens only when using the watch command, and not when using the build command (which is not implemented in this repo).
It happens even if the bucket we reference in the Module Federation plugin is not reachable, so I imagine that the technology of the remote application doesn't matter.
I would espect 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.