-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Hot reload doesn't work in 4.x with ModuleFederationPlugin #4378
Comments
Update: I'm also getting this error message:
This happens only if the App react component has other dependencies (in this case the history), if it does not, there is NO message in the logs. If I open this in chrome, I can see those lines there:
where the problematic one seems to be:
|
I also experience this issue. It happens only when MFE exposes some script. Temporary solution is setting FAST_REFRESH=false in .env file. But page will be reloaded after each change. |
We are experiencing the same issue. Falling back to FAST_REFRESH=false however is also not working for us. If I add the ModuleFederationPlugin, the page no longer reloads upon changes (although it shows the But we anyway need hot module replacement as we have complex in-memory state which would get lost upon page reload. |
Anyone tried to debug this and find the problem? |
I digged a bit deeper now. It's still not clear to me where the problem is exactly. I see that messages are exchanged via the websocket and I see that the modules still are reloaded, even with the ModuleFederationPlugin enabled. When debugging, it seems to me that the modules are replaced (hard to judge for me though as I'm not familiar with the webpack dev server code base). When I check the module source in the browser, I also see the updated code. I think the issue might be rather that React somehow doesn't manage to re-render the respective components. So the problem would rather be in the React Refresh plugin, which is used by CRA 5. But not yet sure about it. Will have another look tomorrow. |
For us, it turned out to be this issue in the React Refresh webpack plugin, which comes with CRA: pmmmwh/react-refresh-webpack-plugin#394 I don't see this plugin in the repro steps of the op, so this might be a separate issue. Workaround for us is to opt-into Module Federation when starting the dev server (via a command line arg), so that most developers are not impacted by this when developing the standalone application. When consuming a component via Module Federation, Fast Refresh doesn't work anyway, so we are not losing anything. |
Hi everyone! How can a fix it? |
Thanks, but it doesn't work right. This only works in microfronts where there are no remotes. But where remotes are specified, the page reloads infinitely. (video demo): |
You have a lot of hot entrypoint on an one page, sounds like something wrong with your setup |
@tony-show Can you create a small reproducible example with your configuration and code (no need to provide all code, only piece for an example), this will give me a better look |
|
@tony-show How you run it? You can't use |
After adding the uniqueName property with a unique name for each microfrontend application, those with the remotes setting in Module Federation now have a remoteEntry.js load error, although the file is available. Well and the page displays a white screen. |
Do you really have |
Yes |
@tony-show Sorry for delay in answers, can I use your repo to check it and what commands do you run (sorry for these stupid questions, there are a lot of issues, so hard to track and remember all of them)? |
Hello Alexander! |
Have any ides for this problem? |
@tony-show I will look soon, sorry for delay, a lot of issues |
@alexander-akait Hi! Is there any news about fixing the problem? |
@anatoly-ivashov No, still in my TODO, try looking at it this week, sorry for delay |
@alexander-akait Thank you for your answer. I hope you can find some time to find a solution to this problem. Anyway, thanks Alexander, for your contribution to many useful things for it community! |
Did anyone manage to get this sorted? - It seems to happen when the host-app |
Thanks for the reply, unfortunately, switching to another bundler is not an option for this project I'm working on. |
A temporary workaround that has worked for me involves disabling HMR and enabling live reloading. You can adjust your devServer configuration as follows:
|
Is there still no fix for this issue? |
Bug report
Webpack dev server doesn't perform the hot reload properly in conjunction with
ModuleFederationPlugin
in v4.x but works in v3.xActual Behavior
When I set up a simple project using those dependencies:
I manage to startup my application, I can't see any errors but when I update the source code, the update is not propagated into the browser and the change is visible ONLY after the full reload.
When I downgrade back to 3.x everything works smoothly.
I used this repository as reference: https://github.com/richardtbell/microfrontend-hello-world
Since this repository was quite older, I wanted to update to the latest version of all packages, the only issue I had was with the webpack-dev-server as I mentioned above.
Expected Behavior
A SPA is HOT reloaded as expected
How Do We Reproduce?
packages/helloReact
Please paste the results of
npx webpack-cli info
here, and mention other relevant informationThe text was updated successfully, but these errors were encountered: