[codex] modernjs-v3 RSC+MF SSR support adjustments#4437
Draft
ScriptedAlchemy wants to merge 10 commits intomainfrom
Draft
[codex] modernjs-v3 RSC+MF SSR support adjustments#4437ScriptedAlchemy wants to merge 10 commits intomainfrom
ScriptedAlchemy wants to merge 10 commits intomainfrom
Conversation
|
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
Bundle Size Report1 package(s) changed, 40 unchanged.
Total dist: 6.89 MB (+1.5 kB (+0.0%)) |
@module-federation/devtools
@module-federation/cli
create-module-federation
@module-federation/data-prefetch
@module-federation/dts-plugin
@module-federation/enhanced
@module-federation/error-codes
@module-federation/managers
@module-federation/manifest
@module-federation/metro
@module-federation/metro-plugin-rnc-cli
@module-federation/metro-plugin-rnef
@module-federation/modern-js-v3
@module-federation/retry-plugin
@module-federation/rsbuild-plugin
@module-federation/rspack
@module-federation/rspress-plugin
@module-federation/runtime
@module-federation/runtime-core
@module-federation/runtime-tools
@module-federation/sdk
@module-federation/third-party-dts-extractor
@module-federation/treeshake-frontend
@module-federation/treeshake-server
@module-federation/webpack-bundler-runtime
@module-federation/bridge-react
@module-federation/bridge-react-webpack-plugin
@module-federation/bridge-shared
@module-federation/bridge-vue3
@module-federation/inject-external-runtime-core-plugin
commit: |
…f-support # Conflicts: # .github/workflows/pkg-pr-new.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This patch aligns
@module-federation/modern-js-v3behavior 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:
source.enableAsyncEntrydefaulted totruefor RSC apps leads to unresolved server-bundle expectations (Cannot find server bundle-style failures in matrix runs).ssr.distOutputDirin RSC mode can conflict with RSC server output assumptions and contributes to mismatched server artifact lookup.Root Cause
modernjs-v3plugin defaults and SSR pathing were not conditioned onserver.rscfor key MF+SSR points:react-servercondition resolution.truewhen not explicitly configured by users.distOutputDirauto-assignment always ran when SSR was enabled.Fix
1) Preserve RSC server resolution when using
async-nodeIn
packages/modernjs-v3/src/cli/ssrPlugin.ts:enableRscfrommodernjsConfig?.server?.rscchain.target('async-node')for server MFchain.resolve.conditionNames.add('react-server')when RSC is enabled2) Default
enableAsyncEntrytofalsefor RSC appsIn
packages/modernjs-v3/src/cli/configPlugin.ts:enableRscmodernjsConfig.source?.enableAsyncEntry ?? !enableRscThis preserves explicit user config while making RSC-safe behavior the default.
3) Skip forced
ssr.distOutputDirin RSC modeIn
packages/modernjs-v3/src/cli/configPlugin.ts: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.tsResult: