-
Notifications
You must be signed in to change notification settings - Fork 139
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
[Bug]: ModuleFederation needs globalThis but polyfill chunks executed later #3593
Comments
Hello @nanianlisao. Please provide a reproduction repository or online demo. For background, see Why reproductions are required. Thanks ❤️ |
You can find the The default |
@chenjiahan You need to run it under chrome 70, and then the following error will appear. The problem is that the polyfill does not take effect, not the splitChunk rule. |
Any new progress? @chenjiahan |
Any reproduction? |
Sorry, my description is wrong, in fact the problem is that mf requires globalThis. However, after rsbuild turns on mf, corejs will be additionally divided into chunks and executed later, thus causing an error.
https://github.com/nanianlisao/rsbuild-repro/tree/main pnpm run dev Open it in chrome 70 and you'll find the error |
Get, I have reproduced this problem. The MF runtime runs earlier than core-js, so the core-js globalThis polyfill cannot work as expected. I will discuss with MF members how to fix this. |
A workaround is to use export default defineConfig({
plugins: [
pluginReact({
fastRefresh: false,
}),
],
moduleFederation: {
options: {},
},
output: {
polyfill: "usage",
overrideBrowserslist: ["chrome 70"],
},
}); |
Yes, it works. But I would like to inject polyfill via entry, for example for compatibility with some third-party packages, and it works fine in webpack. |
Do you mean webpack's Module Federation v1 plugin or Module Federation enhanced? Module Federation v1 does not use |
I have discussed this with @2heal1 and MF will consider adding a minimal |
Try |
Version
Details
The minimum configuration is as follows:
At this time, corejs injection does not take effect.
In addition, this seems to be a problem with rspack, webpack is ok
Reproduce link
no
Reproduce Steps
no
The text was updated successfully, but these errors were encountered: