Skip to content

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

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

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

Conversation

@ScriptedAlchemy
Copy link
Contributor

@ScriptedAlchemy ScriptedAlchemy commented Feb 7, 2026

Summary

  • Add layer support for Module Federation shared modules across provide and consume flows
  • Add layer metadata support for exposed modules so expose entries can participate in layered builds
  • Keep the runtime aligned with Module Federation core, only adding the minimal layer-specific glue needed for layered sharing
  • Align the Rspack layer test cases with the Module Federation core layer fixtures

What This Changes

  • Thread layer / issuerLayer metadata through shared module configuration and runtime registration
  • Preserve layer information in federation manifest and shared-entry generation paths
  • Support layered exposed modules in the enhanced Module Federation path
  • Validate the behavior with the container-1-5 layer serial cases and the matching sharing/tree-shaking cases

Why This PR Exists

Rspack already supports share scopes as arrays from earlier work. This PR is not re-adding generic array share-scope support.

The purpose of this PR is to add layer-aware federation behavior so layered shared modules and layered exposed modules work the same way as they do in Module Federation core.

Stack

Current stack, bottom to top:

  • #12977 feat(mf): layer-aware sharing and runtime scope-array support <- this PR
  • #13203 feat(mf): emit RSC metadata in federation manifests
  • #13204 feat(rsbuild): add RSC federation host/remote example
  • #13208 feat(rsbuild): add RSC federation module patterns
  • #13215 feat(rsc): register federation manifest data at runtime

@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, 0 projects with changes.

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

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

📦 Binary Size-limit

Comparing dbf3131 to chore(deps): update dependency terser-webpack-plugin to ^5.4.0 (#13354) by renovate[bot]

❌ Size increased by 40.75KB from 49.04MB to 49.08MB (⬆️0.08%)

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 7, 2026

Merging this PR will not alter performance

✅ 16 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing feat/mf-layers (dbf3131) with main (16982dc)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@ScriptedAlchemy ScriptedAlchemy changed the title feat/mf layers feat(mf): layer-aware sharing and runtime scope-array support Feb 7, 2026
ScriptedAlchemy and others added 2 commits February 8, 2026 23:37
test: retry native watcher watch steps

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 28, 2026

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

Latest commit: 492d8a4
Status: ✅  Deploy successful!
Preview URL: https://0a3b86f4.rspack-v2.pages.dev
Branch Preview URL: https://feat-mf-layers.rspack-v2.pages.dev

View logs

Preserve string versus array share scope semantics while restoring the enhanced consume and remote runtime wiring needed for layer-aware federation. Fold the unrelated watch helper change back to main so this worktree stays focused on the MF runtime fix.

Made-with: Cursor
Keep this MF layer/share-scope branch focused on the enhanced runtime fix by removing the stale module graph stats guard, which is not required for build:cli:dev or the container-1-5 serial cases.

Made-with: Cursor
Keep the manifest path aligned with the original stats-driven parsing flow by deriving consumed shared package data from module identifiers instead of downcasting consume shared modules.

Made-with: Cursor
Capture expose layer information in emitted MF stats and manifest output, and add a manifest-layers regression case to verify layered shared and expose metadata stays correct.

Made-with: Cursor
Hydrate consume handler mappings from consumes loading data so bundler-runtime keeps layer-aware share metadata in the enhanced path. Also validate multi-entry share scopes unless enhanced mode is enabled, and emit remote external metadata alongside remote runtime records.
Keep provide shared runtime entries in their original shareScope shape and mark enhanced initializeSharingData as already updated so bundler-runtime does not rebuild downgraded shared registrations from the legacy structure.
Emit consume-shared source data for shared consumers and let the runtime module reuse it when serializing consume metadata. This keeps module-output consume entries callable so layered federation consumers can initialize sharing before resolving shared react.

Made-with: Cursor
Wait for consume share scopes to finish initializing before delegating to the bundler runtime so layered shared modules resolve consistently. Remove the temporary federation debug instrumentation that was added while tracing the runtime flow.

Made-with: Cursor
Drop the temporary discovery document now that the parity investigation is captured elsewhere.

Made-with: Cursor
Reinstate legacy share-scope validation and restore the enhanced runtime metadata paths needed for layered consume and module remote resolution.

Made-with: Cursor
Preserve layer-aware shared metadata across manifest generation, used-exports optimization, and module remote runtime wiring so layered federation outputs stay correct and covered.

Made-with: Cursor
Keep layered consume scope initialization in the enhanced runtime while preserving legacy consume version-check behavior and rust lint parity.

Made-with: Cursor
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.

2 participants