[codex] modernjs-v3 RSC+MF SSR support adjustments#4437
[codex] modernjs-v3 RSC+MF SSR support adjustments#4437ScriptedAlchemy wants to merge 17 commits into
Conversation
|
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Bundle Size Report1 package(s) changed, 40 unchanged.
Total dist: 6.88 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/esbuild
@module-federation/managers
@module-federation/manifest
@module-federation/metro
@module-federation/metro-plugin-rnc-cli
@module-federation/metro-plugin-rnef
@module-federation/modern-js
@module-federation/modern-js-v3
@module-federation/native-federation-tests
@module-federation/native-federation-typescript
@module-federation/nextjs-mf
@module-federation/node
@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/storybook-addon
@module-federation/third-party-dts-extractor
@module-federation/treeshake-frontend
@module-federation/treeshake-server
@module-federation/typescript
@module-federation/utilities
@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
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: