-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add example with HMR #358
Comments
I have faced this problem as well on one of my latest POCs. Still haven't figured out a working config. I hope someone else would bring some light in the tunnel. 👍 |
working on it, its extremely complex. We will eventually roll support for it into webpack 5 but its a monster to achieve |
Cross container hmr will be releases in 5.1 or 5.2. Live reload works for the client side. Server side prod hmr is harder but there's a few easy patterns once might be able to leverage. |
@ScriptedAlchemy I'm guessing this is still unavailable (ref: https://webpack.js.org/blog/2020-12-08-roadmap-2021/#hot-module-replacement-for-module-federation) but curious if any progress has been made here? |
@ScriptedAlchemy Do you happen to have a solution/example for single-container hmr right now? I experience the same issue as the OP with a single one. This seems to suggest it's possible. |
Same issue here. Any updates? |
In my case, I noticed that in If I configured Is that |
@ruanyl If you don't "expose" anything in the ModuleFederationPlugin config then HMR works - I believe because that remoteEntry.js isn't generated. So host-only modules are hmr friendly. |
@zedford My point is when the container has Because if I only inject |
yes you dont need to inject a hosts own remote unless you depend on the pattern - typically I only consume the hosts own remote in prod builds for advanced things like worker threads and MF Excluding the remote chunk from HTML will / should solve it - you can vote for HMR on MF at webpack https://webpack.js.org/vote/ I have a number of points and have already traded a lot of influencer points to bump it up the list |
Module-federation/fmr plugin released |
Hi @ScriptedAlchemy that's awesome. I'm sorry but could you provide some more details on the post above or a link? I don't see an example added on the homepage or any docs that say HMR has been added to webpack. |
It's on npm, plug-in myself and the federation group wrote. Search module-federation/fmr and it should come up. Official support still unavailable from webpack. |
I see thanks so much for doing this! Is this compatible with react fast refresh? In other words, is there any way we could use the plugin you made and this fast refresh plugin together? |
Hi @wdfinch, did you find a way to do this? |
Not yet. I haven't tried though. It's not urgent for me since it's just a dev convenience.  |
We could track the current host and maybe enable it for the host. But there is no hot reloading for MF. So closest we can get is live reloading the page when you update a federated module |
I'm seeing the same issue with a host and one remote. Two webpack runtimes are being loaded. One in the host
It is calling the second It seems that the In the example i see that it is called Code that appends here: https://github.com/webpack/webpack/blob/f43047c4c2aa4b0a315328e4c34a319dc2662254/lib/config/defaults.js#L778-L782 I resolved the host error by simply adding Answer was actually in the FAQ here: https://webpack.js.org/concepts/module-federation/#collision-between-modules-from-different-remotes But now I am faced with the error when running my remote that has an
So the exact setting to name the Just need to rename this when generating our
This was the fix! |
Encountered same issue on React 18. Use chunks main as mentioned abov. For the other error with createRoot error that comes after i followed https://github.com/pmmmwh/react-refresh-webpack-plugin according to React Team they have some version of HMR built in. This works for custom webpack configs. |
Hi, I met the same problem, how did you solve this problem with createRoot? |
It depends on your setup. I don't remember exactly but i think i was using webpack-hot-middleware. example in "using webpack-hot-middleware example" |
Why this is closed?? |
Hi,
I have spend quite some time trying to configure module federation to work with HMR, however, with no success. No matter what kind of configuration I try the results is always the same:
remoteEntry.js:989 Uncaught TypeError: Cannot read property 'push' of undefined
at self.webpackHotUpdateplatform (remoteEntry.js:989)
at main.52ee0b798cefc4bb4013.hot-update.js:9
self.webpackHotUpdateplatform @ remoteEntry.js:989
(anonymous) @ main.52ee0b798cefc4bb4013.hot-update.js:9
Update failed: ChunkLoadError: Loading hot update chunk main failed.
(missing: http://localhost:3001/main.52ee0b798cefc4bb4013.hot-update.js)
at http://localhost:3001/main.js:1829:26
at new Promise ()
at loadUpdateChunk (http://localhost:3001/main.js:1824:20)
at http://localhost:3001/main.js:2253:29
at Array.forEach ()
at Object.webpack_require.hmrC.jsonp (http://localhost:3001/main.js:2248:22)
at http://localhost:3001/main.js:1416:45
at Array.reduce ()
at http://localhost:3001/main.js:1412:53
remoteEntry.js:985 Uncaught TypeError: Cannot set property './src/pages/CMS.tsx' of undefined
at self.webpackHotUpdateplatform (remoteEntry.js:985)
at src_pages_CMS_tsx-webpack_sharing_consume_default_react_react-webpack_sharing_consume_default-843145.52ee0b798cefc4bb4013.hot-update.js:9
A simple example how to do it will be much appreciated.
Thank you!
The text was updated successfully, but these errors were encountered: