module federation HMR on host
See original GitHub issueCurrent Behavior
host app HMR is not working and I need to reload the page by myself. but remote app HMR is working as expected (inside the host app).
Expected Behavior
when changing the code in the host app, it should reload the app.
Steps to Reproduce
just look at my configurations:
for the host project.json
(I’m using nx server):
"serve": {
"executor": "@nrwl/react:module-federation-dev-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "client:build",
"hmr": true,
"port": 4200
},
"configurations": {
"development": {
"buildTarget": "client:build:development",
"open": true,
"watch": true,
"liveReload": true
},
"production": {
"buildTarget": "client:build:production",
"hmr": false
}
}
}
and this is in the remote project.json
"serve": {
"executor": "@nrwl/react:module-federation-dev-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "assets:build",
"hmr": true,
"port": 4201
},
"configurations": {
"development": {
"buildTarget": "assets:build:development"
},
"production": {
"buildTarget": "assets:build:production",
"hmr": false
}
}
}
Failure Logs
I see this warning in the console. I’m not sure if its related
(missing: http://localhost:4200/polyfills.2c951a6de4399979.hot-update.mjs)
at http://localhost:4200/polyfills.js:21576:25
at new Promise (<anonymous>)
at loadUpdateChunk (http://localhost:4200/polyfills.js:21571:19)
at http://localhost:4200/polyfills.js:22031:28
at Array.forEach (<anonymous>)
at __webpack_require__.hmrC.jsonp (http://localhost:4200/polyfills.js:22026:21)
at http://localhost:4200/polyfills.js:21054:46
at Array.reduce (<anonymous>)
at http://localhost:4200/polyfills.js:21050:54
Environment
Node : 17.3.0
OS : darwin x64
npm : 8.3.0
nx : 14.4.2
@nrwl/angular : Not Found
@nrwl/cypress : 14.4.2
@nrwl/detox : Not Found
@nrwl/devkit : 14.4.2
@nrwl/eslint-plugin-nx : 14.4.2
@nrwl/express : Not Found
@nrwl/jest : 14.4.2
@nrwl/js : 14.4.2
@nrwl/linter : 14.4.2
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : 14.4.2
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : 14.4.2
@nrwl/web : 14.4.2
@nrwl/workspace : 14.4.2
typescript : 4.7.4
---------------------------------------
Community plugins:
Issue Analytics
- State:
- Created a year ago
- Comments:13
Top Results From Across the Web
Federated Module Reloading. - Medium
We're passionate about making Module Federation easier and more enjoyable to use. Based on user feedback, we knew FMR was the perfect place...
Read more >Enabling Live Reload in Module Federated CRA - Raj Rajhans
Recently I had work on getting hot reload to work in a module ... The issue is that currently HMR doesn't work with...
Read more >nx react module federation hot reload - Stack Overflow
I'm using module federation with nx and want to enable HMR. I applied the hmr: true option in both project.json files. (for the...
Read more >Hot Module Replacement - webpack
HMR is not intended for use in production, meaning it should only be used in development. See the building for production guide for...
Read more >Module federation - Notes
Module federation is about managing different physical parts of the application(s) in runtime. We already looked at this problem in code splitting chapter....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What ended up fixing it for me was also removing the “styles” attribute from the project.json as well. I made two separate build processes, one for local and one for prod, the local one removes polyfills and styles, the prod one keeps them.
@usyyy I moved the
polyfills
in thehost
appsproject.json
into theproduction
configuration. e.g.