Skip to content

fix(mf): use dynamic exports type for MF modules#12841

Merged
ahabhgk merged 1 commit intomainfrom
fix-strict-esm-with-mf
Jan 26, 2026
Merged

fix(mf): use dynamic exports type for MF modules#12841
ahabhgk merged 1 commit intomainfrom
fix-strict-esm-with-mf

Conversation

@ahabhgk
Copy link
Copy Markdown
Contributor

@ahabhgk ahabhgk commented Jan 26, 2026

Summary

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.

Related links

fix #8043

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

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.
Copilot AI review requested due to automatic review settings January 26, 2026 08:32
@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Jan 26, 2026
@ahabhgk ahabhgk enabled auto-merge (squash) January 26, 2026 08:33
@ahabhgk ahabhgk requested a review from LingyuCoder January 26, 2026 08:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_type for ConsumeSharedModule and RemoteModule, returning ExportsType::Dynamic.
  • Add a regression config case that validates default + named imports from a shared ESM .js module when consumed from a .mjs file.
  • Remove an E2E test workaround that forced javascript/auto for .js files.

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.

@github-actions
Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
rome 985.9 KB 0
react-5k 2.7 MB 0
ui-components 2.3 MB 0
react-1k 825.5 KB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing d02781f to chore(test): exclude flaky native watch test case (#12837) by pshu

❌ Size increased by 256bytes from 48.33MB to 48.33MB (⬆️0.00%)

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

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

View logs

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jan 26, 2026

Merging this PR will not alter performance

✅ 16 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing fix-strict-esm-with-mf (d02781f) with main (d9c06e1)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@ahabhgk ahabhgk merged commit 419edec into main Jan 26, 2026
83 of 86 checks passed
@ahabhgk ahabhgk deleted the fix-strict-esm-with-mf branch January 26, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: esm default import with shared does not properly access the default function

3 participants