Skip to content

fix(modern-js): set optimization target from ssr config - #4900

Merged
2heal1 merged 3 commits into
mainfrom
codex/modernjs-optimization-target
Jul 15, 2026
Merged

2heal1 merged 3 commits into
mainfrom
codex/modernjs-optimization-target

Conversation

@2heal1

@2heal1 2heal1 commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

Description

Update the Modern.js and Modern.js v3 integrations to automatically select the federation optimization target based on the application configuration.

  • Default to web for browser builds and projects without SSR.
  • Default to node for Node builds when SSR is enabled.
  • Preserve an explicitly configured optimization target.
  • Add the autoOptimization plugin option, which defaults to true.
  • Allow automatic target selection to be disabled with autoOptimization: false.

Related Issue

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

@changeset-bot

changeset-bot Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e360568

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

This PR includes changesets to release 47 packages
Name Type
@module-federation/modern-js Patch
@module-federation/modern-js-v3 Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
@module-federation/runtime Patch
@module-federation/enhanced Patch
@module-federation/rspack Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/sdk Patch
@module-federation/runtime-tools Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/dts-plugin Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/devtools Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/retry-plugin Patch
@module-federation/rsbuild-plugin Patch
@module-federation/error-codes Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/runtime-core Patch
create-module-federation Patch
@module-federation/cli Patch
@module-federation/rspress-plugin Patch
@module-federation/treeshake-server Patch
@module-federation/treeshake-frontend Patch
@module-federation/metro Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rock Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/esbuild Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/observability-plugin Patch
@module-federation/playground Patch
website-new Patch
@module-federation/storybook-addon Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
@module-federation/utilities Patch
remote5 Patch
remote6 Patch
node-dynamic-remote-new-version Patch
node-dynamic-remote 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

@pkg-pr-new

pkg-pr-new Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@module-federation/devtools

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

@module-federation/cli

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

create-module-federation

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

@module-federation/dts-plugin

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

@module-federation/enhanced

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

@module-federation/error-codes

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

@module-federation/esbuild

pnpm add https://pkg.pr.new/@module-federation/esbuild@e360568

@module-federation/managers

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

@module-federation/manifest

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

@module-federation/metro

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

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

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

@module-federation/metro-plugin-rnef

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

@module-federation/metro-plugin-rock

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rock@e360568

@module-federation/modern-js

pnpm add https://pkg.pr.new/@module-federation/modern-js@e360568

@module-federation/modern-js-v3

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

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/@module-federation/native-federation-tests@e360568

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/@module-federation/native-federation-typescript@e360568

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/@module-federation/nextjs-mf@e360568

@module-federation/node

pnpm add https://pkg.pr.new/@module-federation/node@e360568

@module-federation/observability-plugin

pnpm add https://pkg.pr.new/@module-federation/observability-plugin@e360568

@module-federation/playground

pnpm add https://pkg.pr.new/@module-federation/playground@e360568

@module-federation/retry-plugin

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

@module-federation/rsbuild-plugin

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

@module-federation/rspack

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

@module-federation/rspress-plugin

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

@module-federation/runtime

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

@module-federation/runtime-core

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

@module-federation/runtime-tools

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

@module-federation/sdk

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

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/@module-federation/storybook-addon@e360568

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

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

@module-federation/treeshake-frontend

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

@module-federation/treeshake-server

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

@module-federation/typescript

pnpm add https://pkg.pr.new/@module-federation/typescript@e360568

@module-federation/utilities

pnpm add https://pkg.pr.new/@module-federation/utilities@e360568

@module-federation/webpack-bundler-runtime

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

@module-federation/bridge-react

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

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

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

@module-federation/bridge-shared

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

@module-federation/bridge-vue3

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

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

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

commit: e360568

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Report

8 package(s) changed, 34 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/modern-js 200.6 kB +2.9 kB (+1.5%) 1.2 kB no change
@module-federation/modern-js-v3 193.9 kB +2.9 kB (+1.5%) 876 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/cli 2.3 kB -2 B (-0.1%) 2.4 kB -34 B (-1.4%)
@module-federation/core 1.0 kB -2 B (-0.2%) 1.0 kB -35 B (-3.2%)
@module-federation/devtools 30.3 kB -1 B (-0.0%) 30.3 kB -25 B (-0.1%)
@module-federation/enhanced 2.7 kB +10 B (+0.4%) 2.8 kB -46 B (-1.6%)
@module-federation/metro-plugin-rnc-cli 416 B -1 B (-0.2%) 435 B -28 B (-6.0%)
@module-federation/modern-js 5.1 kB +94 B (+1.8%) 5.1 kB +94 B (+1.8%)
@module-federation/modern-js-v3 5.0 kB +94 B (+1.9%) 5.0 kB +94 B (+1.9%)
@module-federation/node 9.2 kB +3 B (+0.0%) 9.2 kB -31 B (-0.3%)

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 21.4 kB -18 B (-0.1%) 23.0 kB -19 B (-0.1%) +1.6 kB -1 B

Total dist (raw): 35.67 MB (+5.8 kB (+0.0%))
Total ESM gzip: 102.2 kB (no change)
Total web bundle (gzip): 230.1 kB (+195 B (+0.1%))
Total node bundle (gzip): 232.7 kB (-11 B (-0.0%))
Tracked ./bundler entry gzip: 556 B (no change)
Tracked ./bundler web bundle (gzip): 4.7 kB (no change)
Tracked ./bundler node bundle (gzip): 4.7 kB (no change)

Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as ./bundler are measured separately so ENV_TARGET-driven tree-shaking is visible. Bare imports are externalized to keep package-level sizes consistent, and assets are emitted as resources.

@2heal1
2heal1 merged commit f796458 into main Jul 15, 2026
24 checks passed
@2heal1
2heal1 deleted the codex/modernjs-optimization-target branch July 15, 2026 03:21
@2heal1 2heal1 mentioned this pull request Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant