-
-
Notifications
You must be signed in to change notification settings - Fork 268
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
rspack module federation not firing onLoad and other hooks when exposed modules from other remotes are loaded #2537
Comments
I may not understand what you mean, do you mean that the resource is loaded repeatedly when the following dependencies: host -> remote-a -> remote-b, should not be added to the remote-b resource when loading remote-a @MadaraUchiha-314 |
Yes, that's one of the issue. the other issue is that rspack internally doesn't use |
@MadaraUchiha-314 hoe are you configuring the remote? Rspack seems to be inlining the external url for import from. Can you share the Rspack build config |
Here's the rspack bui.d config: https://github.com/MadaraUchiha-314/rollup-plugin-module-federation/blob/main/packages/examples/project-a/rspack.config.mjs |
@MadaraUchiha-314 does webpack handle the same? It seems that bundler will use esm http external imports for remoteType |
Webpack also handles it the same way that rspack does. Direct import like: import*as __WEBPACK_EXTERNAL_MODULE_http_localhost_8080_packages_examples_project_b_dist_webpack_esm_my_remote_entry_js_46592bd8__ from "http://localhost:8080/packages/examples/project-b/dist/webpack/esm/my-remote-entry.js"; |
@ScriptedAlchemy Another bug that's happening due to this raw import is that when I use the mf-manifest.json to refer to a remote entry rather than the direct url, the import is something like: import * as __WEBPACK_EXTERNAL_MODULE_webpack_container_reference_project_b__ from "http://localhost:8080/packages/examples/project-b/dist/rspack/esm/mf-manifest.json"; and I am getting the error:
Reproducible URL: https://rollup-plugin-module-federation.netlify.app/packages/examples/project-a/dist/rspack/esm/ This means that federation 2.0 in rspack using ESM and mf-manifest.json just doesn't work!! I think having these raw HTTP imports to externals is not the right design. In my rollup federation, I convert these to |
Use remotetype: 'script' in the plugin Also why use esm outputs vs normal js? |
Stale issue message |
IMO both of these issues are still existing.
@ScriptedAlchemy LMK if this issue can be prioritized. This is blocking adoption of rspack + ESM (for SSR purposes) in our enterprise. |
It requires the creation of new module types. Currently, both depend on ExternalModule. I'll have to either update the external module and everything related to externals, or I need to make a new module type. Either way, this requires core changes that will have to be implemented into webpack, then rspack. The best alternative is to treat remoteType as a script and use a runtime plugin to handle loading the entry via esm or some custom runtime. |
Stale issue message |
Workarounds exist. Treating the remote as type script still and using a runtime plugin to use import() on loadEntry should suffice |
Describe the bug
rspack rewrites the import for an exposed module from a remote to a static import rather than a dynamic import using
loadRemote
This is causing 2 issues:
Example:
I have 2 remotes:
project-a imports the button (which is an exposed module) from project-b.
rspack converts it to this:
My rollup plugin rollup-plugin-module-federation converts it to:
My implementation fixes both the bugs I mentioned above.
loadRemote
it fires all the hooksWorking example:
Just click on the buttons from left to right and check the console logs and the network tabs.
Reproduction
Provided above.
Used Package Manager
npm
System Info
Validations
The text was updated successfully, but these errors were encountered: