Skip to content

fix(rsc): group client chunks by server-entry ownership#13880

Merged
SyMind merged 12 commits into
mainfrom
rsc-client-component-code-splitting
May 18, 2026
Merged

fix(rsc): group client chunks by server-entry ownership#13880
SyMind merged 12 commits into
mainfrom
rsc-client-component-code-splitting

Conversation

@SyMind

@SyMind SyMind commented Apr 29, 2026

Copy link
Copy Markdown
Member

Summary

  • Group use client modules by RSC ownership instead of always creating one async chunk per client boundary.
  • Put client modules owned by a single use server-entry subtree into the same chunk group as that server-entry's CSS.
  • Keep client modules shared by multiple server-entry/root owners isolated so each client manifest entry still maps to one emitted client asset.
  • Group root-only client modules into one root client chunk for the RSC entry.

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions github-actions Bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Apr 29, 2026
@codspeed-hq

codspeed-hq Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 3.26%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 33 untouched benchmarks
⏩ 25 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation rust@create_full_hash 6.2 ms 6 ms +3.26%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing rsc-client-component-code-splitting (2563cf5) with main (896b9ce)

Open in CodSpeed

Footnotes

  1. 25 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@SyMind SyMind force-pushed the rsc-client-component-code-splitting branch from e681001 to ad89228 Compare May 12, 2026 10:46
@github-actions

github-actions Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 2563cf5 to perf(deps): unify duplicate Rust dependencies to reduce binary size (#14012) by AsyncIter

❌ Size increased by 31.88KB from 61.96MB to 61.99MB (⬆️0.05%)

@github-actions

github-actions Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

⚠️ Note: The latest commit (896b9cee6e) does not have baseline artifacts. Using commit 93237d032a for baseline comparison instead. If this seems incorrect, please wait a few minutes and try rerunning the workflow.

Found 6 projects in monorepo, 2 projects with changes.

📊 Quick Summary
Project Total Size Change
popular-libs 1.7 MB +220.0 B (0.0%)
react-10k 5.7 MB 0
react-1k 826.3 KB 0
rome 1.6 MB 0
react-5k 2.7 MB 0
ui-components 4.8 MB +9.0 B (0.0%)
📋 Detailed Reports (Click to expand)

📁 popular-libs

Path: ../build-tools-performance/cases/popular-libs/dist/rsdoctor-data.json

📌 Baseline Commit: 93237d032a | PR: #14067

Metric Current Baseline Change
📊 Total Size 1.7 MB 1.7 MB +220.0 B (0.0%)
📄 JavaScript 1.7 MB 1.7 MB +220.0 B (0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 289.0 B 289.0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: popular-libs Bundle Diff

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

📌 Baseline Commit: 93237d032a | PR: #14067

Metric Current Baseline Change
📊 Total Size 4.8 MB 4.8 MB +9.0 B (0.0%)
📄 JavaScript 4.7 MB 4.7 MB +9.0 B (0.0%)
🎨 CSS 107.0 KB 107.0 KB 0
🌐 HTML 328.0 B 328.0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: ui-components Bundle Diff

Generated by Rsdoctor GitHub Action

@SyMind

SyMind commented May 15, 2026

Copy link
Copy Markdown
Member Author

@codex review

@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: 007cffa1a0

ℹ️ 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 crates/rspack_plugin_rsc/src/rsc_entry_module.rs Outdated
@SyMind

SyMind commented May 15, 2026

Copy link
Copy Markdown
Member Author

@codex review

@SyMind SyMind marked this pull request as ready for review May 15, 2026 09:33
Copilot AI review requested due to automatic review settings May 15, 2026 09:33
ahabhgk
ahabhgk previously approved these changes May 15, 2026

@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: 34d0cdf0a6

ℹ️ 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 crates/rspack_plugin_rsc/src/server_plugin.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the RSC plugin to group client component chunks by root/server-entry ownership instead of always emitting one async chunk per client boundary, and expands fixtures/snapshots to cover the new grouping behavior.

Changes:

  • Tracks root-owned and server-entry-owned client imports during RSC graph traversal.
  • Injects grouped RSC entry async blocks for root and per-server-entry client modules, with updated debug comments.
  • Adds a comprehensive client-chunk-grouping config case and updates the debug-comments fixture.

Reviewed changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/rspack_plugin_rsc/src/component_info.rs Tracks client imports by root and server-entry ownership.
crates/rspack_plugin_rsc/src/server_plugin.rs Groups collected client imports into root, server-entry, and ungrouped buckets.
crates/rspack_plugin_rsc/src/client_plugin.rs Injects grouped RSC client entry dependencies.
crates/rspack_plugin_rsc/src/rsc_entry_module.rs Builds grouped async blocks and updates debug comment rendering.
crates/rspack_plugin_rsc/src/rsc_entry_dependency.rs Carries grouped client module data through the dependency.
crates/rspack_plugin_rsc/src/rsc_entry_module_factory.rs Passes grouped dependency data into RscEntryModule.
crates/rspack_plugin_rsc/src/plugin_state.rs Stores grouped client entry state.
crates/rspack_plugin_rsc/src/utils.rs Reuses precomputed module resources for CSS detection.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/rspack.config.js Adds manifest and emitted-CSS assertions for grouping.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/test.config.js Configures the new config case bundle.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/Root.js Adds root RSC fixture.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/framework/entry.client.js Adds client compiler fixture entry.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/framework/entry.rsc.js Adds RSC render/test entry.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/framework/entry.ssr.js Adds SSR fixture entry.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/pages/PageOne.js Adds first server-entry page fixture.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/pages/PageOne.css Adds first page server CSS marker.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/pages/PageTwo.js Adds second server-entry page fixture.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/pages/PageTwo.css Adds second page server CSS marker.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/PageOneClientA.js Adds page-one-owned client fixture.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/PageOneClientA.css Adds CSS marker for page-one client A.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/PageOneClientB.js Adds page-one-owned client fixture.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/PageOneClientB.css Adds CSS marker for page-one client B.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/PageTwoClient.js Adds page-two-owned client fixture.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/PageTwoClient.css Adds CSS marker for page-two client.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/RootOnlyA.js Adds root-only client fixture.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/RootOnlyA.css Adds CSS marker for root client A.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/RootOnlyB.js Adds root-only client fixture.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/RootOnlyB.css Adds CSS marker for root client B.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/SharedAcrossPages.js Adds multi-server-entry shared client fixture.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/SharedAcrossPages.css Adds CSS marker for page-shared client.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/SharedRootAndPage.js Adds root/server-entry shared client fixture.
tests/rspack-test/configCases/rsc-plugin/client-chunk-grouping/src/clients/SharedRootAndPage.css Adds CSS marker for root/page-shared client.
tests/rspack-test/configCases/rsc-plugin/rsc-entry-debug-comments/src/App.js Updates debug fixture root to exercise ownership groups.
tests/rspack-test/configCases/rsc-plugin/rsc-entry-debug-comments/src/Client.js Removes old single-client fixture.
tests/rspack-test/configCases/rsc-plugin/rsc-entry-debug-comments/src/clients/PageOneClient.js Adds page-one client fixture.
tests/rspack-test/configCases/rsc-plugin/rsc-entry-debug-comments/src/clients/PageTwoClient.js Adds page-two client fixture.
tests/rspack-test/configCases/rsc-plugin/rsc-entry-debug-comments/src/clients/RootClient.js Adds root client fixture.
tests/rspack-test/configCases/rsc-plugin/rsc-entry-debug-comments/src/clients/SharedAcrossPages.js Adds shared-across-pages client fixture.
tests/rspack-test/configCases/rsc-plugin/rsc-entry-debug-comments/src/clients/SharedRootAndPage.js Adds root/page shared client fixture.
tests/rspack-test/configCases/rsc-plugin/rsc-entry-debug-comments/src/pages/PageOne.js Adds first server-entry debug fixture page.
tests/rspack-test/configCases/rsc-plugin/rsc-entry-debug-comments/src/pages/PageOne.css Updates CSS selector for page-one fixture.
tests/rspack-test/configCases/rsc-plugin/rsc-entry-debug-comments/src/pages/PageTwo.js Adds second server-entry debug fixture page.
tests/rspack-test/configCases/rsc-plugin/rsc-entry-debug-comments/src/pages/PageTwo.css Adds page-two CSS fixture.
tests/rspack-test/configCases/rsc-plugin/rsc-entry-debug-comments/__snapshot__/rsc-entry-debug-comments.txt Updates expected grouped debug comments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/rspack_plugin_rsc/src/server_plugin.rs
@SyMind

SyMind commented May 15, 2026

Copy link
Copy Markdown
Member Author

@codex review

@github-actions

github-actions Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

📝 Rspack Ecosystem CI: Open

suite result
rslib ✅ success
devserver ✅ success
rstest ✅ success
rsdoctor ❌ failure
rsbuild ✅ success
rsbuild-rsc-plugin ❌ failure
lynx-stack ❌ failure
modernjs ✅ success
rspress ✅ success
plugin ✅ success
examples ✅ success

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

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

@SyMind SyMind marked this pull request as draft May 15, 2026 10:50
@github-actions

github-actions Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

📝 Rspack Ecosystem CI: Open

suite result
modernjs ✅ success
devserver ❌ failure
rstest ✅ success
rsbuild ✅ success
rsdoctor ✅ success
plugin ❌ failure
examples ✅ success
lynx-stack ❌ failure
rspress ✅ success
rslib ✅ success
rsbuild-rsc-plugin ❌ failure

@SyMind SyMind marked this pull request as ready for review May 18, 2026 06:16
@github-actions

github-actions Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

📝 Rspack Ecosystem CI: Open

suite result
rsdoctor ✅ success
modernjs ✅ success
rsbuild ✅ success
examples ✅ success
plugin ❌ failure
rslib ✅ success
devserver ❌ failure
rstest ✅ success
rspress ✅ success
rsbuild-rsc-plugin ❌ failure
lynx-stack ❌ failure

@SyMind

SyMind commented May 18, 2026

Copy link
Copy Markdown
Member Author

@codex review

@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: 68434fed5a

ℹ️ 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 crates/rspack_plugin_rsc/src/component_info.rs
@SyMind

SyMind commented May 18, 2026

Copy link
Copy Markdown
Member Author

@codex review

@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: 930fe2aa73

ℹ️ 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 crates/rspack_plugin_rsc/src/server_plugin.rs
@SyMind

SyMind commented May 18, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

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

@SyMind SyMind merged commit 77524ed into main May 18, 2026
35 checks passed
@SyMind SyMind deleted the rsc-client-component-code-splitting branch May 18, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants