Skip to content

fix(modernjs): quiet valid stream SSR splitChunks config#4851

Open
BleedingDev wants to merge 7 commits into
module-federation:mainfrom
BleedingDev:codex/fix-modernjs-splitchunks-warning
Open

fix(modernjs): quiet valid stream SSR splitChunks config#4851
BleedingDev wants to merge 7 commits into
module-federation:mainfrom
BleedingDev:codex/fix-modernjs-splitchunks-warning

Conversation

@BleedingDev

Copy link
Copy Markdown
Contributor

Summary

  • keep stream SSR splitChunks normalization to async
  • skip the warning when splitChunks.chunks is already async
  • cover both Modern.js adapters with unit tests

Validation

  • pnpm --filter @module-federation/modern-js-v3 run test
  • pnpm --filter @module-federation/modern-js run test
  • pnpm exec prettier --check packages/modernjs-v3/src/cli/configPlugin.ts packages/modernjs-v3/src/cli/configPlugin.spec.ts packages/modernjs/src/cli/configPlugin.ts packages/modernjs/src/cli/configPlugin.spec.ts .changeset/quiet-stream-ssr-splitchunks.md
  • pnpm exec turbo run build --filter=@module-federation/modern-js... --filter=@module-federation/modern-js-v3... --concurrency=4

@changeset-bot

changeset-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7d46c22

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

@netlify

netlify Bot commented Jun 27, 2026

Copy link
Copy Markdown

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 7d46c22
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/6a4b1eba00058c0008b38c5c
😎 Deploy Preview https://deploy-preview-4851--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cfbb0f58ab

ℹ️ 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".

Comment thread packages/bridge/bridge-react/src/router/v8-dom.tsx Outdated
Comment thread packages/bridge/bridge-react/src/router/v8.tsx Outdated
@BleedingDev
BleedingDev force-pushed the codex/fix-modernjs-splitchunks-warning branch from cfbb0f5 to d7001da Compare June 27, 2026 09:10
@BleedingDev
BleedingDev force-pushed the codex/fix-modernjs-splitchunks-warning branch from d7001da to 4ae9519 Compare June 27, 2026 09:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ae9519251

ℹ️ 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".

Comment on lines +342 to +344
const currentChunks = splitChunkConfig.chunks;
splitChunkConfig.chunks = 'async';
logger.warn(
`splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"`,
);
if (currentChunks !== 'async') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Warn for cacheGroup chunk overrides

When a user's config has top-level splitChunks.chunks: 'async' but any cache group sets its own chunks: 'all'/'initial', this guard suppresses the stream-SSR warning even though cache-group chunks overrides the top-level setting. This code only rewrites splitChunkConfig.chunks and leaves those cache-group overrides untouched, so the incompatible split remains silently (same mirror in modernjs-v3). Please include cache-group chunk overrides in the check or normalize them before skipping the warning.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 948dc693d4

ℹ️ 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".

`splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"`,
);

for (const cacheGroup of Object.values(splitChunkConfig.cacheGroups)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include fallback cache groups in SSR normalization

When stream SSR uses top-level splitChunks.chunks: 'async' but splitChunks.fallbackCacheGroup.chunks is set to 'all' or 'initial', this new pass only scans cacheGroups, so shouldWarn can stay false while the fallback cache group still overrides chunk selection. Webpack documents fallbackCacheGroup.chunks as part of split-chunk chunk selection (https://webpack.js.org/plugins/split-chunks-plugin/#splitchunkschunks), so this can silently leave the same incompatible initial/all split in place; the mirrored loop in packages/modernjs-v3/src/cli/configPlugin.ts needs the same handling.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d9e7b963c

ℹ️ 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".

splitChunkConfig.cacheGroups
typeof splitChunkConfig === 'object'
) {
let shouldWarn = splitChunkConfig.chunks !== 'async';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat omitted splitChunks.chunks as async

When a stream-SSR client build leaves optimization.splitChunks.chunks unset, the bundler default is already async, but this initializer treats the resulting undefined as a change-worthy value and emits the warning anyway. That makes otherwise valid default splitChunks configs noisy again; the mirrored logic in packages/modernjs-v3/src/cli/configPlugin.ts needs the same default-as-async handling.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 299cb93fef

ℹ️ 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".

Comment on lines +354 to +357
'chunks' in cacheGroup &&
cacheGroup.chunks !== 'async'
) {
cacheGroup.chunks = 'async';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve function-valued cache group filters

When an SSR client config uses a function-valued cacheGroups.foo.chunks that already limits the group to async chunks, this condition treats the function as incompatible and replaces it with 'async'. That broadens the cache group to every async chunk and drops the user's chunk-splitting logic; elsewhere in the repo (ContainerPlugin.patchChunkSplit) function filters are explicitly supported. Please wrap or preserve function filters instead of overwriting them, and make the same adjustment in the modernjs-v3 mirror.

Useful? React with 👍 / 👎.

@pkg-pr-new

pkg-pr-new Bot commented Jul 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@module-federation/devtools

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

@module-federation/cli

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

create-module-federation

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

@module-federation/dts-plugin

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

@module-federation/enhanced

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

@module-federation/error-codes

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

@module-federation/esbuild

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

@module-federation/managers

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

@module-federation/manifest

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

@module-federation/metro

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

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

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

@module-federation/metro-plugin-rnef

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

@module-federation/metro-plugin-rock

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

@module-federation/modern-js

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

@module-federation/modern-js-v3

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

@module-federation/native-federation-tests

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

@module-federation/native-federation-typescript

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

@module-federation/nextjs-mf

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

@module-federation/node

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

@module-federation/observability-plugin

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

@module-federation/playground

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

@module-federation/retry-plugin

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

@module-federation/rsbuild-plugin

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

@module-federation/rspack

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

@module-federation/rspress-plugin

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

@module-federation/runtime

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

@module-federation/runtime-core

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

@module-federation/runtime-tools

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

@module-federation/sdk

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

@module-federation/storybook-addon

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

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

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

@module-federation/treeshake-frontend

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

@module-federation/treeshake-server

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

@module-federation/typescript

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

@module-federation/utilities

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

@module-federation/webpack-bundler-runtime

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

@module-federation/bridge-react

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

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

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

@module-federation/bridge-shared

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

@module-federation/bridge-vue3

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

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

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

commit: 7d46c22

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c454fc3670

ℹ️ 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".

Comment on lines +342 to +343
let shouldWarn =
typeof splitChunksValue === 'string' && splitChunksValue !== 'async';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Constrain function chunk filters to async

When stream SSR is enabled and a user supplies a top-level function filter such as splitChunks.chunks = () => true, this new string-only guard neither rewrites nor warns, so initial chunks can still be split even though this plugin is trying to force async-only splitting. Fresh evidence is the new typeof ... === 'string' check, which skips top-level predicates that the previous implementation normalized when cache groups existed; the repo also treats a predicate returning true as equivalent to all in ContainerPlugin.patchChunkSplit. Please wrap function filters with the async-only constraint, or reject/warn for functions that cannot be proven async, and mirror the fix in the Modern.js v3 copy.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Report

12 package(s) changed, 30 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/cli 26.3 kB no change 786 B no change
@module-federation/core 39.1 kB no change 173 B no change
@module-federation/devtools 665.5 kB no change 4.0 kB no change
@module-federation/enhanced 810.0 kB no change 672 B no change
@module-federation/managers 70.0 kB no change 334 B no change
@module-federation/manifest 136.1 kB no change 182 B no change
@module-federation/metro-plugin-rnc-cli 0 B no change 314 B no change
@module-federation/modern-js 198.0 kB +3.5 kB (+1.8%) 1.2 kB no change
@module-federation/modern-js-v3 191.3 kB +3.5 kB (+1.9%) 875 B no change
@module-federation/node 193.4 kB no change 217 B no change
@module-federation/storybook-addon 79.2 kB no change 100 B no change
@module-federation/utilities 110.6 kB no change 328 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/cli 2.3 kB -28 B (-1.2%) 2.3 kB -28 B (-1.2%)
@module-federation/core 1.1 kB -29 B (-2.6%) 1.0 kB -28 B (-2.6%)
@module-federation/devtools 30.3 kB -23 B (-0.1%) 30.3 kB -23 B (-0.1%)
@module-federation/enhanced 2.6 kB -40 B (-1.5%) 2.6 kB -40 B (-1.5%)
@module-federation/managers 2.4 kB -24 B (-1.0%) 2.4 kB -24 B (-1.0%)
@module-federation/manifest 6.1 kB -37 B (-0.6%) 6.1 kB -37 B (-0.6%)
@module-federation/metro-plugin-rnc-cli 411 B -23 B (-5.3%) 411 B -23 B (-5.3%)
@module-federation/modern-js 5.1 kB +167 B (+3.3%) 5.1 kB +167 B (+3.3%)
@module-federation/modern-js-v3 4.9 kB +160 B (+3.3%) 4.9 kB +160 B (+3.3%)
@module-federation/node 9.2 kB -24 B (-0.3%) 9.2 kB -24 B (-0.3%)
@module-federation/storybook-addon 1.9 kB -22 B (-1.1%) 1.7 kB -21 B (-1.2%)
@module-federation/utilities 2.6 kB -28 B (-1.1%) 2.6 kB -28 B (-1.1%)

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.1 kB -11 B (-0.0%) +1.7 kB +7 B

Total dist (raw): 35.70 MB (+7.0 kB (+0.0%))
Total ESM gzip: 131.2 kB (no change)
Total web bundle (gzip): 255.7 kB (+49 B (+0.0%))
Total node bundle (gzip): 257.9 kB (+51 B (+0.0%))
Tracked ./bundler entry gzip: 556 B (no change)
Tracked ./bundler web bundle (gzip): 4.8 kB (no change)
Tracked ./bundler node bundle (gzip): 4.8 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 commented Jul 6, 2026

Copy link
Copy Markdown
Member

I found one issue that should be fixed before merging.

The stream SSR splitChunks normalization now only handles string values. If a user provides a function filter, such as splitChunks.chunks = () => true, the function is preserved without warning. In webpack, chunks: 'async' excludes initial chunks, while a custom function can still allow them. That means stream SSR can still split initial chunks even though this plugin is trying to force async-only splitting.

This affects both Modern.js adapters:

  • packages/modernjs/src/cli/configPlugin.ts
  • packages/modernjs-v3/src/cli/configPlugin.ts

The new tests also lock in this behavior by expecting function filters to be preserved. Please wrap function filters with an async-only guard, or warn/reject them if they cannot be safely constrained, and mirror the change in both adapters.

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.

2 participants