Skip to content

feat(mf): layer-aware sharing and runtime scope-array support#12977

Draft
ScriptedAlchemy wants to merge 13 commits intomainfrom
feat/mf-layers
Draft

feat(mf): layer-aware sharing and runtime scope-array support#12977
ScriptedAlchemy wants to merge 13 commits intomainfrom
feat/mf-layers

Conversation

@ScriptedAlchemy
Copy link
Contributor

@ScriptedAlchemy ScriptedAlchemy commented Feb 7, 2026

Summary

This PR adds first-class layer-aware Module Federation behavior in Rspack and ports a comprehensive layer test matrix under serialCases/container-1-5.

Motivation

Layered MF usage (default, ssr, rsc, and custom layers) needs consistent share resolution and runtime behavior across container, reference, consume, and provide paths. This PR aligns those paths and adds regression coverage.

What Changed

  • Runtime and plugin behavior:
  • Updated MF container/reference/share runtime handling in Rust and JS implementations.
  • Added/updated layer-aware scope resolution, including scope-array style handling in relevant runtime/plugin paths.
  • Updated sharing internals (collect, consume, provide, and runtime modules) to preserve layer context.
  • Bindings and type surface:
  • Updated MF raw options/binding plumbing (crates/rspack_binding_api/.../raw_mf.rs).
  • Updated Node binding type declarations (crates/node_binding/napi-binding.d.ts).
  • Updated API extractor snapshot (packages/rspack/etc/core.api.md).
  • Test coverage:
  • Added serial layer suites:
  • tests/rspack-test/serialCases/container-1-5/1-layers-full
  • tests/rspack-test/serialCases/container-1-5/2-layers-full
  • tests/rspack-test/serialCases/container-1-5/3-layers-full
  • tests/rspack-test/serialCases/container-1-5/4-layers-full
  • tests/rspack-test/serialCases/container-1-5/5-layers-full
  • tests/rspack-test/serialCases/container-1-5/6-layers-full
  • tests/rspack-test/serialCases/container-1-5/7-layers-full
  • tests/rspack-test/serialCases/container-1-5/8-layers-full
  • Updated sharing tree-shaking config case to align with layered sharing behavior.
  • Docs and design notes:
  • Added MF.md and RSC.md design/context documents used during this implementation.

Diff Snapshot

  • 103 files changed
  • ~2889 insertions / 244 deletions
  • Major touch areas:
  • crates/rspack_plugin_mf/**
  • packages/rspack/src/container/**
  • packages/rspack/src/sharing/**
  • tests/rspack-test/serialCases/container-1-5/**

Compatibility

  • Non-layered MF configs should continue to behave as before.
  • Layered configs now resolve shared entries and runtime scope data with explicit layer semantics.

Validation

  • CI is running on this PR branch after rustfmt fixes.
  • Previous Rust check failure was rustfmt-only and has been fixed (fix(mf): format rust files for CI).

@github-actions github-actions bot added the release: feature release: feature related release(mr only) label Feb 7, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 5 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB -
react-1k 825.4 KB -
react-5k 2.7 MB -
rome 984.2 KB -
ui-components 2.2 MB -
📋 Detailed Reports (Click to expand)

📁 react-10k

Path: ../build-tools-performance/cases/react-10k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 5.7 MB - -
📄 JavaScript 5.7 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 825.4 KB - -
📄 JavaScript 825.4 KB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 react-5k

Path: ../build-tools-performance/cases/react-5k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 2.7 MB - -
📄 JavaScript 2.7 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 rome

Path: ../build-tools-performance/cases/rome/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 984.2 KB - -
📄 JavaScript 984.2 KB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 2.2 MB - -
📄 JavaScript 2.0 MB - -
🎨 CSS 267.8 KB - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

📦 Binary Size-limit

Comparing 75af9c2 to feat: add support for readonly persistent cache (#12902) by Cole Ellison

❌ Size increased by 27.88KB from 48.59MB to 48.62MB (⬆️0.06%)

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 7, 2026

Merging this PR will not alter performance

✅ 16 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing feat/mf-layers (75af9c2) with main (649b67e)2

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.

  2. No successful run was found on main (cc3efa6) during the generation of this report, so 649b67e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@ScriptedAlchemy ScriptedAlchemy changed the title feat/mf layers feat(mf): layer-aware sharing and runtime scope-array support Feb 7, 2026
test: retry native watcher watch steps

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant