-
Notifications
You must be signed in to change notification settings - Fork 2.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
Library changes are not hot-reloaded when using ModuleFederation #14127
Comments
Same here. Any progress on this ? |
Same issue. |
This is the expected behavior. |
@deefactorial please read the issue description again. It has not much in common with the fragment of the video from your comment. |
But that doesn’t make it the right behaviour. The library abstraction erodes the great experience hot-reloading brings to developers. |
same issue here |
This is the same issue as #11615, where the workspace library is being served by a static remove rather than the host or the dev remote. The workaround is outlined here: #11615 (comment) If you know which libraries are problematic, you can exclude them from being shared. // module-federation.config.js
module.exports = {
shared: (libName, libConfigFromNx) => {
return libName === '@react-module-federation/shared-components'
? false
: libConfigFromNx
},
// ...
}; This will not work for libraries that require shared state (e.g. redux), which have to be singletons. You can also include the last alphabetical remote always in your We're still investigating if there is something we can do on our end, and webpack's |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
When using
nx serve
to serve my app, changes made to the library used by both of the microfrontends (remotes) which the app contains of are not visible in the browser, unless all apps which use this library are launched in the dev mode. If the host app is served (nx serve host
) or host with one remote (nx serve host --devRemotes=cart
) changes made to the library are not visible in the browser. If the host app is launched along with both (all) remotes (nx serve host --devRemotes=cart,shop
) , the changes made to the library are visible in the browser instantly.This scales to more remotes which was discovered on the original (private) repository with 5 remotes. All 5 remotes and the host have to be served in the dev mode to allow seeing library changes in the browser.
Expected Behavior
Changes made to the library are visible in the browser in every app (host or remote) which is launched in the dev mode, regardless if other apps are also launched in the dev mode or built/served statically.
Github Repo
https://github.com/parostatkiem/nx-microfrontends-problem
Steps to Reproduce
npm ci
to install dependenciesnx serve host --devRemotes=cart --open
Cart
route using the list. You should see the text "Welcome to Mylib!" appearing twice because you're seeing the host and the cart apps at the same time.libs/mylib/src/lib/mylib.tsx
file in the editor, change the Mylib component content to something else, let's sayinto
nx serve
process.nx serve host --devRemotes=cart,shop --open
Cart
route using the list. You should see the text "Welcome to Mylib and see the changes!" appearing twice because you're seeing the host and the cart apps at the same time.libs/mylib/src/lib/mylib.tsx
file in the editor, change the Mylib component content to something else, let's sayinto
Nx Report
Failure Logs
No response
Additional Information
The repository was setup with the commands from the official docs of Nx, which are (with
npm install
commands skipped):npx create-nx-workspace nx-problem --preset=empty
nx g @nrwl/react:host host --remotes=shop,cart
nx generate library mylib
(chose React generator, no compiler and no test runner)Then I removed the
Nx-welocome
component from all the apps to keep the website content simple.The text was updated successfully, but these errors were encountered: