Skip to content

Conversation

@ScriptedAlchemy
Copy link
Contributor

ScriptedAlchemy and others added 30 commits September 26, 2025 15:39
Enhanced server plugin to traverse MF container entries
and added manifest fallback for serverReferencesMap

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
…proxy

Implement comprehensive RSC module federation support with remote manifest
handling, server action proxying, and improved integration between hosts
and remotes.

Key changes:
- Add remote RSC manifest plugin for fetching and merging
  client/server/server-references manifests from remotes
- Implement RSC manifest merger runtime plugin for client-side manifest
  consolidation
- Patch RSC server plugins to allow server actions outside react-server layer
- Add manifest-based remote entry resolution with SSR fallback
- Implement shared config patching to unshare RSC-critical packages
  (react, react-dom, server-only)
- Add container entry module build error patch to gracefully handle missing
  exposes in dev
- Enhance test suites for both CSR and SSR MF hosts with mf-exposes patterns
- Add MF test utilities and debug tooling

Technical improvements:
- Server actions can now be imported from client components by removing
  layer restriction
- Manifest URLs automatically resolve to correct remoteEntry.js or
  bundles/static/remoteEntry.js for SSR
- Remote origins tracked for future server action proxy middleware
- Node chain now treated as RSC server when server.rsc is enabled

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Add remotes property to PluginOptions interface
- Fix server plugin registration to use actual plugin functions instead of path references
- Remove invalid 'path' property from plugin definitions

This resolves TypeScript errors while maintaining build compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Fix syntax error where SWC parser doesn't support multi-line `as typeof import()` syntax.
Keep type assertion on single line with biome-ignore comment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Treat Node chain as RSC server when server.rsc is enabled (index.ts, rsbuild RSC plugin)
- Add early server middleware to proxy x-rsc-action to owning remote (remoteRscManifestPlugin)
- Harden RSC client plugin against child-compiler (HtmlWebpackPlugin) and missing sharedData
- rsc-client-loader: add fallback to dist/server and dist/bundles manifests for server-references
- Make MF stats/manifest patch non-fatal; fix import('webpack') parsing edge
- Register server plugins by name and use correct namespace for server plugin id
- Use server-safe expose wrappers for CSR remote
- Skip processing when normalModuleFactory is undefined (HtmlWebpackPlugin child compilers)
- Initialize clientReferencesMap and styles with safe defaults if sharedData is unavailable
- Prevents "Cannot read properties of undefined" errors during HtmlWebpackPlugin compilation

This resolves the HtmlWebpackPlugin child compiler crashes that blocked MF remote builds.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Enhanced RSC server plugins (both webpack and rspack) to ensure server
module IDs are populated in sharedData before the client build accesses
them. This addresses a race condition where the web compiler's
rsc-client-loader couldn't find moduleIds that the Node compiler assigns.

Changes:
- rsc-server-plugin.ts: Changed done hook to tapPromise for async
  hydration from chunkGraph and manifest file readback
- rspack-rsc-server-plugin.ts: Added same hydration logic
- rsc-client-loader.ts: Enhanced fallback manifest reading with
  comprehensive debug logging

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Documented all completed fixes and remaining issues:
- ✓ Fixed server module ID race condition (manifest hydration)
- ✓ Fixed HtmlWebpackPlugin child compiler crashes
- ✓ Fixed TypeScript type errors and SWC parser issues
- ✓ CSR and SSR remote builds passing
- ✗ CSR host tests failing due to empty client manifest

The critical remaining issue is that the RSC client plugin isn't
detecting and registering 'use client' components in host apps,
resulting in an empty react-client-manifest.json.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…ts are discovered; fix empty react-client-manifest in hosts
…st hydration retries to reduce race with server build
Status Summary:
✅ CSR Remote build: PASSING
✅ SSR Remote build: PASSING
⚠️  CSR Host build: Builds OK but client manifest empty
❌ CSR Host tests: 8/8 failed (server won't start)

Detailed Analysis:
- Remote builds working perfectly with AST-based export derivation
- Manifest hydration functioning correctly
- Host client manifest detection not working - ClientRoot.tsx not registered
- Empty client manifest prevents host server startup

Next Steps:
- Debug why ClientRoot.tsx isn't detected in host
- Verify entry layer propagation chain
- Consider alternative client component discovery mechanism

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…haredData so Node build includes them and assigns moduleIds
… 'use client' modules under src even when issuer is not in react-server layer (fix host client manifest empty)
…odule fallback in client plugins (webpack/rspack); minor loader merge fix
…ict react-server condition to server RSC layer and app code; prevent client code from resolving under react-server.\n- mf server (dev): add redirect-once CSR fallback for HTML GET; keep HEAD 200 for readiness.\n- tests(host): minor readiness pauses and harness tweaks for CSR/SSR suites.\n\nNote: further patches pending for server client-stub, moduleId hydration, and runtime federatedRef resolution.
Investigation findings:
- CSR+RSC is broken for BOTH MF and non-MF versions
- Issue exists in v2 branch as well (not introduced by MF work)
- Root cause: serverManifest.renderBundles is empty for CSR apps
- getServerManifest() only populates renderBundles from routes with bundle property
- CSR routes don't have bundle paths configured
- This causes csrRscRender to return "Cannot find server bundle for RSC" error

Changes in this checkpoint:
- Added done hook to RscClientPlugin to fix empty manifest timing issue
- Added server-entry.ts files to CSR MF test apps
- Modified layer assignment logic in rsbuild-rsc-plugin
- Various MF integration improvements

Next steps:
- Test v2 branch integration tests to confirm baseline behavior
- Identify proper fix for CSR+RSC renderBundles issue

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
… baseline

Critical fix: Our modified RSC plugins and WASM binary were breaking non-MF RSC apps.
Reverting to v2 versions restores CSR+RSC functionality.

All rsc-csr-app tests now pass (8/8).

Next: Merge v2 into mfp branch to bring in latest changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…t detect-only pass; populate manifest deterministically\n\n- rsc-server-loader: add detectOnly to publish :client-refs without transforming code (client compiler)\n- rsbuild-rsc-plugin: add client-side rsc-client-detect oneOf for webpack builds (includes src/**, exclude node_modules)\n- rsc-client-plugin (webpack): attach client refs during parser (v2 parity); remove late addEntry; processAssets derives from sharedData keys; pre-scan src for 'use client' to seed entry blocks\n- Result: react-client-manifest.json now populated for non-MF webpack (Counter visible); follow-ups: server actions + hydration in tests\n
- Guard MF + RSC to Webpack (block Rspack in rsbuild-rsc-plugin).

- rsc-server-loader: publish :client-refs early; keep source in SSR bundles.

- rsc-client-plugin (webpack): hydrate from sharedData ':client-refs'.

- rsc-client-plugin: safer logging; remove stray code; biome formatting.

- rsc-server-plugin: watch mode downgrades 'Module not added' to warning.

- modernjs-mf-custom: better artifact preload/merge; fetch logging; minor config.

- MF fixtures: align federation config for Webpack-only usage.

Notes:

- No new top-level demo alias; examples already force webpack via scripts.

- Types: add guards for sharedData scans.
@changeset-bot
Copy link

changeset-bot bot commented Nov 12, 2025

🦋 Changeset detected

Latest commit: c5a70f5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 297 packages
Name Type
@modern-js/runtime Patch
@module-federation/modern-js-rsc Patch
@modern-js/plugin-bff Patch
@modern-js/plugin-tailwindcss Patch
@modern-js/devtools-client Patch
@modern-js/plugin-devtools Patch
@modern-js/plugin-garfish Patch
@modern-js/plugin-router-v5 Patch
@modern-js/plugin-router-v7 Patch
@modern-js/plugin-state Patch
@modern-js/plugin-testing Patch
@modern-js/storybook-builder Patch
@integration-test/alias-set Patch
app-document Patch
async-entry-test Patch
babel-object-config-test Patch
tmp Patch
bff-api-app Patch
bff-client-app Patch
bff-indep-client-app Patch
bff-hono Patch
integration-clean-dist-path Patch
integration-compatibility Patch
integration-custom-dist-path Patch
custom-file-system-entry Patch
integration-custom-render Patch
integration-custom-template Patch
deploy Patch
deploy-server Patch
dev-server Patch
integration-disable-html Patch
app-custom-bootstrap Patch
app-custom-entries Patch
app-custom-routes-runtime Patch
app-custom Patch
app-entry Patch
app-route Patch
app-entry-server Patch
app-garfish-dashboard Patch
app-garfish-master Patch
app-garfish-table Patch
@integration-test/image-component Patch
main-entry-name Patch
nonce Patch
pure-esm-project Patch
routes-match Patch
routes Patch
app-rsbuild-hooks Patch
rsc-csr-app Patch
rsc-csr-mf-host Patch
rsc-csr-mf Patch
rsc-csr-routes Patch
rsc-ssr-app Patch
rsc-ssr-mf-host Patch
rsc-ssr-mf Patch
rsc-ssr-routes Patch
runtime-custom-plugin Patch
runtime-custom-config-plugin Patch
file-based-router Patch
use-loader Patch
select-mul-entry-test Patch
select-one-entry-test Patch
server-config-v2 Patch
server-config Patch
server-middleware Patch
server-new-middleware Patch
server-hook-reqeust Patch
server-hook-response Patch
server-hook-router Patch
@integration-test/server-hook-reqeust Patch
server-json-script Patch
server-monitors Patch
server-prod Patch
server-routes Patch
@source-code-build/app-ts-loader Patch
@source-code-build/app Patch
ssg-fixtures-mega-list-routes Patch
ssg-fixtures-nested-routes Patch
ssg-fixtures-simple Patch
ssg-fixtures-web-server Patch
ssr-base-async-entry-test Patch
ssr-base-json-test Patch
ssr-base-test Patch
ssr-base-fallback-test Patch
init Patch
ssr-inline Patch
ssr-partial-test Patch
ssr-script-loading Patch
ssr-streaming-inline-test Patch
ssr-streaming-test Patch
swc-config-function Patch
swc-minify-css Patch
swc-minify-js Patch
transform-fail Patch
integration-tailwindcss-v2 Patch
integration-tailwindcss-v3-js-config-with-postcss-config Patch
integration-tailwindcss-v3-js-config Patch
integration-tailwindcss-v3-merge-config Patch
integration-tailwindcss-v3-ts-config Patch
integration-tailwindcss-v3 Patch
integration-tailwindcss-without-plugin Patch
twin-macro-v2 Patch
twin-macro-v3 Patch
tmp-dir Patch
transform-import-type-test Patch
transform-import-type-lodash Patch
write-to-dist Patch
@e2e/garfish-dashboard-router-v6 Patch
@e2e/garfish-dashboard Patch
@e2e/garfish-main-router-v6 Patch
@e2e/garfish-main Patch
@e2e/garfish-table Patch
@modern-js/storybook Patch
integration-tests-storybook Patch
@modern-js/tsconfig Patch
@modern-js/babel-preset Patch
@modern-js/core Patch
@modern-js/flight-server-transform-plugin Patch
@modern-js/plugin-changeset Patch
@modern-js/plugin-data-loader Patch
@modern-js/plugin-i18n Patch
@modern-js/plugin-proxy Patch
@modern-js/plugin-ssg Patch
@modern-js/plugin-swc Patch
@modern-js/rsbuild-plugin-esbuild Patch
@modern-js/uni-builder Patch
@modern-js/main-doc Patch
@modern-js/module-tools-docs Patch
@modern-js/devtools-kit Patch
@modern-js/image Patch
@modern-js/render Patch
@modern-js/new-action Patch
@modern-js/sandpack-react Patch
@modern-js/babel-plugin-module-resolver Patch
@modern-js/bff-core Patch
@modern-js/bff-runtime Patch
@modern-js/server-core Patch
@modern-js/create-request Patch
@modern-js/plugin-express Patch
@modern-js/plugin-koa Patch
@modern-js/plugin-polyfill Patch
@modern-js/plugin-server Patch
@modern-js/plugin-worker Patch
@modern-js/prod-server Patch
@modern-js/server-runtime Patch
@modern-js/server Patch
@modern-js/server-utils Patch
@modern-js/plugin-module-babel Patch
@modern-js/plugin-module-banner Patch
@modern-js/plugin-module-import Patch
@modern-js/plugin-module-node-polyfill Patch
@modern-js/plugin-module-polyfill Patch
@modern-js/plugin-module-vue Patch
@modern-js/app-tools Patch
@modern-js/module-tools Patch
@modern-js/monorepo-tools Patch
@modern-js/create Patch
@modern-js/e2e Patch
@modern-js/node-bundle-require Patch
@modern-js/plugin-v2 Patch
@modern-js/plugin Patch
@modern-js/runtime-utils Patch
@modern-js/types Patch
@modern-js/upgrade Patch
@modern-js/utils Patch
@modern-js/babel-compiler Patch
@scripts/build Patch
@scripts/check-changeset Patch
@scripts/jest-config Patch
@scripts/lint-package-json Patch
@scripts/prebundle Patch
@scripts/release-versin Patch
@scripts/update-codesmith Patch
@scripts/vitest-config Patch
tests Patch
integration-asset-prefix Patch
integration-builder-plugins Patch
integration-copy-assets Patch
entries-app-builder-index Patch
entries-app-builder Patch
entries-integration Patch
integration-config-async-config-test Patch
integration-basic-local-config Patch
integration-config-function-params Patch
integration-local-config-function Patch
integration-load-config Patch
alias-js-test Patch
alias-module-id-test Patch
alias-ts-test Patch
asset-limit-test Patch
asset-name-test Patch
asset-path-test Patch
asset-publicPath-test Patch
svgr-test Patch
auto-extension-commonjs-test Patch
auto-extension-type-module-test Patch
auto-external-test Patch
banner-footer-test Patch
build-type-test Patch
copy-test Patch
decorator-test Patch
global-vars-js-test Patch
global-vars-ts-test Patch
dts-composite Patch
dts-test Patch
esbuild-options-test Patch
external-test Patch
format-cjs-test Patch
format-esm-test Patch
format-iife-test Patch
format-umd-test Patch
hook-test Patch
entry-test Patch
jsx-test Patch
loader-esbuild-test Patch
loader-swc-test Patch
metafile-test Patch
minify-test Patch
platform-test Patch
redirect-test Patch
resolve-alias-error Patch
resolve-alias-test Patch
data-url-test Patch
browser-false Patch
resolve-false Patch
ndoe-protocol-test Patch
lib1 Patch
lib2 Patch
lib3 Patch
condition-exports-test Patch
js-extensions-test Patch
main-fields-test Patch
shims-test Patch
module-tools-side-effects-test Patch
source-dir-test Patch
sourcemap-test Patch
splitting-test Patch
css-test Patch
less-test Patch
style-test Patch
postcss-test Patch
sass-test Patch
scss-test Patch
tailwindcss-test Patch
target-test Patch
transform-import Patch
transform-lodash Patch
tsconfig-test Patch
tsconfig-extends-test Patch
umdGlobals-test Patch
get-module-id-test Patch
dev-test Patch
build-platform-test Patch
build-preset-error-test Patch
build-preset-function-test Patch
build-preset-test Patch
build-preset-string-test Patch
integration-module-tools Patch
plugin-babel Patch
module-hooks-test Patch
plugin-node-polyfill Patch
plugin-polyfill Patch
plugin-vue Patch
runtime Patch
entry Patch
@source-code-build/common Patch
@source-code-build/components Patch
@source-code-build/utils Patch
ssg Patch
ssr Patch
swc-test-decorator-legacy Patch
swc-test-decorator Patch
swc-integration Patch
tailwindcss-integration-test Patch
@e2e/webpack-builder-import-antd-v4 Patch
@e2e/webpack-builder-import-antd-v5 Patch
@e2e/webpack-builder-import-arco Patch
@e2e/webpack-builder-test-moment Patch
@e2e/builder-remove-prop-types Patch
@e2e/webpack-builder-source-map Patch
@e2e/builder Patch
@e2e/garfish Patch
@modern-js/generator-common Patch
@modern-js/generator-utils Patch
@modern-js/bff-generator Patch
@modern-js/dependence-generator Patch
@modern-js/entry-generator Patch
@modern-js/mwa-generator Patch
@modern-js/router-v5-generator Patch
@modern-js/ssg-generator Patch
@modern-js/storybook-next-generator Patch
@modern-js/upgrade-generator Patch
@modern-js/generator-cases Patch
@modern-js/base-generator Patch
@modern-js/packages-generator Patch
@modern-js/server-generator Patch
@modern-js/tailwindcss-generator Patch

Not sure what this means? Click here to learn what changesets are.

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

@ScriptedAlchemy ScriptedAlchemy changed the base branch from main to v2 November 12, 2025 07:50
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