Skip to content

Comments

[codex] modernjs-v3 RSC+MF SSR support adjustments#4437

Draft
ScriptedAlchemy wants to merge 10 commits intomainfrom
fix/modernjs-v3-rsc-mf-support
Draft

[codex] modernjs-v3 RSC+MF SSR support adjustments#4437
ScriptedAlchemy wants to merge 10 commits intomainfrom
fix/modernjs-v3-rsc-mf-support

Conversation

@ScriptedAlchemy
Copy link
Member

Summary

This patch aligns @module-federation/modern-js-v3 behavior with RSC + Module Federation SSR requirements by adding targeted guards in the Modern.js v3 CLI plugins.

For apps running with server.rsc: true, the current defaults and SSR wiring can produce unstable server-bundle/runtime behavior in strict MF+RSC runs. The changes in this PR are intentionally small and scoped to RSC mode to avoid broad behavioral drift for non-RSC applications.

Problem

In strict RSC+MF integration scenarios:

  • Forcing server target behavior without preserving RSC resolution conditions can cause server package resolution/runtime failures.
  • Keeping source.enableAsyncEntry defaulted to true for RSC apps leads to unresolved server-bundle expectations (Cannot find server bundle-style failures in matrix runs).
  • Forcing ssr.distOutputDir in RSC mode can conflict with RSC server output assumptions and contributes to mismatched server artifact lookup.

Root Cause

modernjs-v3 plugin defaults and SSR pathing were not conditioned on server.rsc for key MF+SSR points:

  • Server chain target coercion did not also preserve react-server condition resolution.
  • Async entry default remained globally true when not explicitly configured by users.
  • SSR distOutputDir auto-assignment always ran when SSR was enabled.

Fix

1) Preserve RSC server resolution when using async-node

In packages/modernjs-v3/src/cli/ssrPlugin.ts:

  • detect enableRsc from modernjsConfig?.server?.rsc
  • keep chain.target('async-node') for server MF
  • add chain.resolve.conditionNames.add('react-server') when RSC is enabled

2) Default enableAsyncEntry to false for RSC apps

In packages/modernjs-v3/src/cli/configPlugin.ts:

  • detect enableRsc
  • change source default to:
    • modernjsConfig.source?.enableAsyncEntry ?? !enableRsc

This preserves explicit user config while making RSC-safe behavior the default.

3) Skip forced ssr.distOutputDir in RSC mode

In packages/modernjs-v3/src/cli/configPlugin.ts:

  • gate SSR dist output injection to non-RSC mode:
    • else if (enableSSR && !enableRsc)

User Impact

For RSC+MF users, this reduces server runtime/bundle resolution instability and aligns defaults with strict RSC expectations. Non-RSC behavior remains unchanged.

Validation

Executed:

  • pnpm -C packages/modernjs-v3 exec vitest run src/cli/configPlugin.spec.ts src/server/fileCache.spec.ts src/server/staticMiddleware.spec.ts

Result:

  • 3 test files passed
  • 15 tests passed

@changeset-bot
Copy link

changeset-bot bot commented Feb 13, 2026

⚠️ No Changeset found

Latest commit: ce703a7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Feb 13, 2026

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit ce703a7
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/699690427b26920008018e97
😎 Deploy Preview https://deploy-preview-4437--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

Bundle Size Report

1 package(s) changed, 40 unchanged.

Package Total dist Delta ESM gzip Delta
modern-js-plugin-v3 187.7 kB +1.5 kB (+0.8%) 900 B no change

Total dist: 6.89 MB (+1.5 kB (+0.0%))
Total ESM gzip: 138.6 kB (no change)

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 13, 2026

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/devtools@ce703a7

@module-federation/cli

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/cli@ce703a7

create-module-federation

pnpm add https://pkg.pr.new/module-federation/core/create-module-federation@ce703a7

@module-federation/data-prefetch

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/data-prefetch@ce703a7

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/dts-plugin@ce703a7

@module-federation/enhanced

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/enhanced@ce703a7

@module-federation/error-codes

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/error-codes@ce703a7

@module-federation/managers

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/managers@ce703a7

@module-federation/manifest

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/manifest@ce703a7

@module-federation/metro

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro@ce703a7

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro-plugin-rnc-cli@ce703a7

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro-plugin-rnef@ce703a7

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/modern-js-v3@ce703a7

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/retry-plugin@ce703a7

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rsbuild-plugin@ce703a7

@module-federation/rspack

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rspack@ce703a7

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rspress-plugin@ce703a7

@module-federation/runtime

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime@ce703a7

@module-federation/runtime-core

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime-core@ce703a7

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime-tools@ce703a7

@module-federation/sdk

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/sdk@ce703a7

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/third-party-dts-extractor@ce703a7

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/treeshake-frontend@ce703a7

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/treeshake-server@ce703a7

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/webpack-bundler-runtime@ce703a7

@module-federation/bridge-react

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-react@ce703a7

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-react-webpack-plugin@ce703a7

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-shared@ce703a7

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-vue3@ce703a7

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/inject-external-runtime-core-plugin@ce703a7

commit: ce703a7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant