-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Main chunk points to the wrong runtime chunk when using Module Federation #19439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've done some attempts and I've figured out something more:
|
@gtempesta-pixartprinting This is expected, because with module federation you have two runtimes - one internal (for loading packages inside federation), the second is for main application (splitting and dynamic chunks) |
I will look deeply soon at this |
@alexander-akait Thanks for taking the time to look into the issue. I've done some further investigation and I'd like to share what I've found. Why I don't think it's expectedI don't think the behavior I'm experiencing is expected, because:
To make it easier to reason about it, I've added a new folder to my repository generated-output-example. In the folder there are two What is happening when running the code in the browserFirst thing, I've discovered that this doesn't only happen when changing code in the file that loads the micro frontend, it happens with every change to any file that's dynamically loaded by the main file (
How to check this in my repository
Let's do the same check inside my generated-output-example folder.
I hope this helps debugging. |
Looks like a bug in https://github.com/gtempesta/webpack-issue-repro/blob/main/webpack/webpack.dev.config.js#L62 or your should use other logic for generations, because in our files we have the valid value and code is working |
But the chunk referenced in app is the one without the changes, so in my opinion there is an issue even without considering the asset-manifest generation. So The changes are in |
If we will have wrong values for runtimes we will generate wrong runtime code and it will be broken, but your code works... |
I wouldn't say that my code works, because the I've done a couple more attempts to prove my point. 1. Overwrite the generated
|
Bug report
What is the current behavior?
When running the
watch
command, at some point theruntime-app
chunk referenced in theapp
chunk is different from the one referenced in theasset-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 differentruntime-app
chunks, one requested by the manifest, and the other by theapp
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:
npm install
to install the dependenciesnpm run watch
to start watching for changesasset-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)app.js
and save itdesign-area.js
file and save itruntime-app
chunk in theasset-manifest.json
file and in theapp
chunk should have different hashesThe issue happens only when using the
watch
command, and not when using thebuild
command (which is not implemented in this repo).What is the expected behavior?
I would expect that the
runtime-app
chunk referenced in theasset-manifest.json
file and in theapp
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:
The text was updated successfully, but these errors were encountered: