fix(mf): use dynamic exports type for MF modules#12841
Conversation
This implements `get_exports_type` for `RemoteModule` and `ConsumeSharedModule`. This fixes default imports when consuming shared modules in `.mjs` files and removes the need for `javascript/auto` workarounds.
There was a problem hiding this comment.
Pull request overview
Updates Module Federation module metadata so shared/remote modules report a dynamic exports shape, fixing ESM default-import interop (notably in .mjs consumers) and allowing removal of prior javascript/auto workarounds.
Changes:
- Implement
get_exports_typeforConsumeSharedModuleandRemoteModule, returningExportsType::Dynamic. - Add a regression config case that validates default + named imports from a shared ESM
.jsmodule when consumed from a.mjsfile. - Remove an E2E test workaround that forced
javascript/autofor.jsfiles.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/rspack-test/configCases/container-1-0/consume-module-mjs-default-export/shared-esm-pkg/package.json | Declares a local fixture package as ESM via "type": "module". |
| tests/rspack-test/configCases/container-1-0/consume-module-mjs-default-export/shared-esm-pkg/index.js | Adds default + named exports for the shared-module interop regression test. |
| tests/rspack-test/configCases/container-1-0/consume-module-mjs-default-export/rspack.config.js | Configures MF sharing for the fixture module to exercise ConsumeSharedModule. |
| tests/rspack-test/configCases/container-1-0/consume-module-mjs-default-export/pure-esm-consumer.mjs | ESM consumer that default-imports from a shared module to reproduce the bug. |
| tests/rspack-test/configCases/container-1-0/consume-module-mjs-default-export/index.js | Asserts runtime behavior for default and named imports in the .mjs consumer. |
| tests/e2e/cases/module-federation/async-startup-self-remote-runtimechunk-single/rspack.config.js | Removes the no-longer-needed javascript/auto workaround rule. |
| crates/rspack_plugin_mf/src/sharing/consume_shared_module.rs | Forces MF “consume shared” modules to report ExportsType::Dynamic. |
| crates/rspack_plugin_mf/src/container/remote_module.rs | Forces MF “remote” modules to report ExportsType::Dynamic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
❌ Size increased by 256bytes from 48.33MB to 48.33MB (⬆️0.00%) |
Deploying rspack with
|
| Latest commit: |
d02781f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b129c51c.rspack-v2.pages.dev |
| Branch Preview URL: | https://fix-strict-esm-with-mf.rspack-v2.pages.dev |
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
This implements
get_exports_typeforRemoteModuleandConsumeSharedModule. This fixes default imports when consuming shared modules in.mjsfiles and removes the need forjavascript/autoworkarounds.Related links
fix #8043
Checklist