question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Component modifications are not applied in module federation

See original GitHub issue

I’m having an issue getting react refresh working on a project with module fedration. The ws connection is working, also in the console it seems its working, but the modifications are not applied to the component.

[webpack-dev-server] App updated. Recompiling...
index.js:3210 [webpack-dev-server] App hot update...
log.js:24 [HMR] Checking for updates on the server...
log.js:24 [HMR] Updated modules:
log.js:24 [HMR]  - ./src/Button.js
log.js:24 [HMR] App is up to date.

I have created an basic example: https://github.com/kabel2/module-federation-examples/tree/feature/example-react-refresh/basic-host-remote

Changing the innertext of the button in the “Button.js” component in “app2” does not apply the changes live, only after reload.

With the old react-hot-loader it seems to work.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:7
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
ruanylcommented, Aug 19, 2022

For anyone who runs into this issue, the solution from @ije and @danieloprado in https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/516 works perfectly for me.

I end up with pnpm patch to patch the package, you can also do it with yarn patch if you’re using yarn.

@pmmmwh would you reconsider applying the changes suggested by @ije and @danieloprado?

4reactions
rainecommented, Apr 11, 2022

Does anyone have an example how react-refresh etc. should be loaded on the page in order for hot reload to work?

In my module federation setup, hot reload works occasionally, which suggests there’s some indeterminism going on in the order that scripts are loading on the page.

The suggestion of bundling react-refresh separately, placing it in window and then making it external in MF libs does not seem to work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Component modifications are not applied in module federation -
I'm having an issue getting react refresh working on a project with module fedration. The ws connection is working, also in the console...
Read more >
Webpack module federation is not working with eager shared ...
I used dynamic load technique for my remote library and it seems shared modules are not being fetched again and again now.
Read more >
Module Federation - webpack
Changes to the components library can be separately deployed without the need to re-deploy all applications. The application automatically uses the up-to-date ...
Read more >
Getting Out of Version-Mismatch-Hell with Module Federation
The reason is that dynamic remotes are not known at program start, and hence Module Federation cannot draw their versions into consideration ...
Read more >
How We Implemented Webpack Module Federation in Ares
Thus, the dependency between our applications will be minimized and we will not need to export every component we add to remote applications...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found