fix(rsbuild-plugin): support app SSR node target with custom environment#4427
fix(rsbuild-plugin): support app SSR node target with custom environment#4427ScriptedAlchemy wants to merge 23 commits intomainfrom
Conversation
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🦋 Changeset detectedLatest commit: 7f039bb The changes in this PR will be included in the next version bump. This PR includes changesets to release 43 packages
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb2b405e83
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ( | ||
| !isMFFormat(bundlerConfig) && | ||
| !isRspress && | ||
| !isNodeTargetEnvironmentConfig | ||
| ) { |
There was a problem hiding this comment.
Restrict node-target flow to the selected environment
This condition still allows any MF-format bundler config to enter the node-target processing path even when its name does not match the configured environment, so target: 'node' can still affect extra environments. In builds with multiple MF-format environments, if the selected env is processed first, patchNodeMFConfig(moduleFederationOptions) mutates shared options and later non-selected environments receive node runtime/library settings, which can break client/web outputs; this is reproducible with environment: 'ssr' and an env order like ssr then client.
Useful? React with 👍 / 👎.
Bundle Size Report3 package(s) changed, 38 unchanged.
Total dist: 6.89 MB (+7.7 kB (+0.1%)) |
@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: |
Android Release APK for all devicesNote: if the download link expires, please re-run the workflow to generate a new build. Generated at 2026-02-15T21:46:23.410Z UTC |
iOS Release APP for simulatorsNote: if the download link expires, please re-run the workflow to generate a new build. Generated at 2026-02-15T21:51:57.206Z UTC |
…p-ssr-node-env # Conflicts: # apps/metro-example-host/e2e/flows/core.yaml
Summary
This PR makes
@module-federation/rsbuild-pluginsupport plugin-only SSR for Rsbuild app mode when usingtarget: 'node'with a customenvironment(for examplessr) without introducing breaking behavior.Problem
Using
pluginModuleFederation(..., { target: 'node', environment: 'ssr' })in app-mode SSR was not reliable:config.environments['mf']isMFFormatgating, which could leavemf_remote/*unresolvedRoot Cause
pluginModuleFederationused a hardcoded env key (mf) instead of the configuredenvironmentoption.onBeforeCreateCompilerreturned early for non-MF-format configs before considering thattarget: 'node'needs to run for the selected environment even when output is commonjs-like.target === 'node' && isMFFormat(...)) rather than constrained to the selected environment.Changes
config.environments[environment].target: 'node'env is missing, including available environment names.environmentbehavior ('mf') unchanged for backward compatibility.target: 'dual'restrictions/behavior intact (no app-modedualenablement in this PR).Tests
Added
/packages/rsbuild-plugin/src/cli/node-target.spec.tscovering:environment: 'ssr') without requiringmftarget: 'dual'restriction remains unchanged for non-Rslib/non-Rspress callersmfenvironment behavior still worksVerification
pnpm -s nx run rsbuild-plugin:testpnpm -s nx run rsbuild-plugin:buildBoth pass.
Docs and Release Notes
packages/rsbuild-plugin/README.mdwith app-mode node target example.apps/website-new/docs/en/guide/build-plugins/plugins-rsbuild.mdxapps/website-new/docs/zh/guide/build-plugins/plugins-rsbuild.mdx.changeset/quick-forks-wonder.md