HMR broken with module federation

See original GitHub issue

After having a video call with @ScriptedAlchemy yesterday evening, he asked me to open an issue for HMR being broken with module federation.

  • This is a bug

  • Operating System: Windows 10

  • Node Version: 12.16.2

  • NPM Version: 6.14.4

  • webpack Version: 5.0.0-beta.22

  • webpack-dev-server Version: 3.11.0

  • Browser: Chrome 84.0.4147.105, Firefox 79.0, Edge 84.0.522.48

Code

https://github.com/codepunkt/react-microfrontend-eval

Expected Behavior

Changes in a react component will show in the browser without a refresh.

Actual Behavior

Changes in a react component will not show in the browser without a refresh.

For Bugs; How can we reproduce the behavior?

  1. clone repository
  2. checkout commit b53e2a249226d96525b96213db7f1b6e43309e8b
  3. run yarn on project root
  4. go into federation directory
  5. run yarn start in federation directory
  6. open localhost:3001 in the browser
  7. open federation/remote-a/src/components/Content/Content.tsx in an editor of choice, make changes to the react component in this file and save
  8. browser will not show changes and throw 2 errors like these:
    • jsonp chunk loading:86 Uncaught TypeError: Cannot read property ‘push’ of undefined at window.webpackHotUpdate_federation_remote_a (jsonp chunk loading:86) at main.6fa816d24a2d1d5749e3.hot-update.js:1
    • Uncaught TypeError: Cannot set property ‘./src/components/Content/Content.tsx’ of undefined at window.webpackHotUpdate_federation_remote_a (jsonp chunk loading:82) at src_bootstrap_tsx-webpack_sharing_consume_default_react_react.6fa816d24a2d1d5749e3.hot-update.js:1

Related

Issue at webpack-dev-server: https://github.com/webpack/webpack-dev-server/issues/2688

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
yuzhanglongcommented, Aug 30, 2021

same problem happened to me, did you fix it?

0reactions
clyfishcommented, Aug 26, 2022

Is there any temporary solution to solve this issue? It works just when I remove module federation plugin from webpack, otherwise, It doesn’t work 😕

@rzkhosroshahi , try this: https://github.com/webpack/webpack-dev-server/issues/3038#issuecomment-1220867385

Read more comments on GitHub >

github_iconTop Results From Across the Web

HMR broken with module federation · Issue #2688 - GitHub
After having a video call with @ScriptedAlchemy yesterday evening, he asked me to open an issue for HMR being broken with module federation....
Read more >
Enabling Live Reload in Module Federated CRA - Raj Rajhans
The issue is that currently HMR doesn't work with module federation. See this and this issue on webpack repos to understand why.
Read more >
nx react module federation hot reload - Stack Overflow
It's not working with HMR. Well never got to make it work. But using live reload witht following config its working fine.
Read more >
HMR / Hot Module Replacement problem with Vue.js 3 ...
HMR / Hot Module Replacement problem with Vue. · Vue async component not working with Webpack hot module replacement · Vue 3 CLI...
Read more >
Hot Module Replacement - webpack
This guide extends on code examples found in the Development guide. Hot Module Replacement (or HMR) is one of the most useful features...
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