-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
External modules not shared #2739
Comments
You can / should use a runtime plugin to handle this. Use the resolveShare hook and you can replace args.resolver on the hook then just make the resolver return window.react etc. |
At-least for the moment, we are actually locked into the builtin package that comes with webpack. Can't yet switch to the independent
|
No fix that i know of. Im not sure what side effects tapping the hook twice will have. It might repeat code in your runtime If it works, then run with it till it doesn't. |
Describe the bug
Background
My module federation setup has a single host and few remotes. Host loads the commonly used vendor packages like
react, react-dom, react-router-dom etc..
from my CDN. For this reason, all these common vendor codes are extenalized in the build process of the host via webpack config optionexternals
.Expectation
The host is supposed to share these packages with remotes, since we have enabled sharing via module federation config.
Reality
But, upon loading the remotes, what I can see is that remotes are bringing its own set of vendor packages or in other words the host's vendor packages are not shared with remote. There is no version conflict warnings from module federation and all these are marked as singletons too.
RCA
Upon digging into module federation source code, I saw that we are iterating over modules from
normalModuleFactory
inside the ProvideSharedPlugin [here] and this will cause all the externalized packages to get filtered out sincenormalModuleFactory
will not have them and this is why sharing of the externalized packages is not working with module federation.Currently, I am patching this by executing the below piece of code forcefully for extenalized modules too
Ask
Sharing of extenalized modules should be handled within module federation plugin itself
Reproduction
Used Package Manager
npm
System Info
Validations
The text was updated successfully, but these errors were encountered: