Skip to content

Fix/rsbuild static chunk availability - #8780

Open
LadyBluenotes wants to merge 3 commits into
mainfrom
fix/rsbuild-static-chunk-availability
Open

LadyBluenotes wants to merge 3 commits into
mainfrom
fix/rsbuild-static-chunk-availability

Conversation

@LadyBluenotes

@LadyBluenotes LadyBluenotes commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

🎯 Changes

Follow-up to #8695 (#8415, #8511). computeStaticDependencyChunks() treated a chunk as available if any group of the importing chunk, or any ancestor, contained it. A shared chunk in sibling route groups therefore got import edges to each route's copy of a duplicated module, and the manifest gave route A route C's CSS and preloads.

Rspack and webpack combine availability across parents with intersection (intersect_with in code_splitter.rs; minAvailableModules &= availableModules in buildChunkGraph.js). This PR does the same per chunk group: own chunks plus the intersection of the parents' availability. It iterates to a fixed point that only shrinks, so cyclic async graphs terminate and give the same result in any order. A chunk's availability is the intersection across its groups.

New Rspack-fixture tests: sibling duplication, a two-parent lazy group, a dependency available on every path, and a ping/pong cycle in both orders.

AI disclosure: drafted with an AI assistant; reviewed and verified by me.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.

Summary by CodeRabbit

  • Bug Fixes

    • Improved static chunk loading for applications built with Rsbuild.
    • Prevented shared chunks from incorrectly including CSS and preload links from sibling routes.
    • Preserved route-specific links to split chunks used by shared code.
    • Improved dependency ordering for JavaScript imports, dynamic imports, CSS, and preload resources across nested and cyclic routes.
  • Tests

    • Added coverage for shared chunks, lazy routes, route-specific dependencies, CSS ordering, preloads, and cyclic route scenarios.

@changeset-bot

changeset-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3e09e47

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

This PR includes changesets to release 5 packages
Name Type
@tanstack/start-plugin-core Patch
@tanstack/react-start-rsc Patch
@tanstack/react-start Patch
@tanstack/solid-start Patch
@tanstack/vue-start 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

@nx-cloud

nx-cloud Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 3e09e47

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ❌ Failed 6m 48s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 4s View ↗

☁️ Nx Cloud last updated this comment at 2026-10-21 19:32:02 UTC

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository: TanStack/router/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2a0e759c-8225-45be-8c58-de8c35013071
📥 Commits

Reviewing files that changed from the base of the PR and between 96b2c48 and 3e09e47.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: TanStack/router/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: de6a7326-3189-4bbb-85c8-547c2f7e7262
📥 Commits

Reviewing files that changed from the base of the PR and between 08a419c and 96b2c48.

📒 Files selected for processing: 3
  • .changeset/rsbuild-static-chunk-availability.md
  • packages/start-plugin-core/src/rsbuild/normalized-client-build.ts
  • packages/start-plugin-core/tests/rsbuild/normalized-client-build.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The Rsbuild client-build normalizer now filters static chunk dependencies by availability across chunk groups. It resolves dependency closures for JavaScript imports and CSS-only dependencies. New tests cover shared chunks, lazy groups, and cyclic routes.

Changes: Rsbuild static chunk resolution

Layer / File(s) Summary
Calculate chunk availability
packages/start-plugin-core/src/rsbuild/normalized-client-build.ts
The normalizer computes chunk-group availability by intersecting parent-group availability. It collects static dependency candidates before filtering them by group membership.
Resolve and apply static dependencies
packages/start-plugin-core/src/rsbuild/normalized-client-build.ts, packages/start-plugin-core/tests/rsbuild/normalized-client-build.test.ts, .changeset/rsbuild-static-chunk-availability.md
The resolver filters candidates by availability and orders recursive dependencies. Client-build normalization uses its methods for JavaScript and CSS-only dependencies. Tests cover shared chunks, lazy groups, cyclic routes, imports, CSS ordering, and preloads. A patch changeset records the release.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ClientBuildNormalization
  participant StaticDependencyResolver
  participant RspackChunkGroups
  ClientBuildNormalization->>StaticDependencyResolver: Create resolver for compilation
  StaticDependencyResolver->>RspackChunkGroups: Read loading-group availability
  RspackChunkGroups-->>StaticDependencyResolver: Return group and chunk availability
  ClientBuildNormalization->>StaticDependencyResolver: Request recursive JavaScript dependencies
  StaticDependencyResolver-->>ClientBuildNormalization: Return ordered dependency closure
  ClientBuildNormalization->>StaticDependencyResolver: Request CSS-only dependencies
  StaticDependencyResolver-->>ClientBuildNormalization: Return filtered static dependencies
Loading

Suggested reviewers: schiller-manuel

Merge Risk: ⚪ Minimal · up to 96b2c

This change corrects which shared chunks Rsbuild links as static imports, CSS and preloads across sibling routes. No concrete merge-blocking risk was found, and tests cover the main scenarios.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the primary change: fixing Rsbuild static chunk availability.
Description check Passed The description explains the issue, implementation, tests, AI assistance, checklist status, and release impact. It includes all required template sections.
Docstring Coverage Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 2 files. (1 skipped: 1 u…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 2 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

11 package(s) bumped directly, 12 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/react-router 1.170.45 → 1.170.46 Changeset
@tanstack/react-start 1.169.3 → 1.169.4 Changeset
@tanstack/router-core 1.171.38 → 1.171.39 Changeset
@tanstack/router-plugin 1.168.47 → 1.168.48 Changeset
@tanstack/solid-router 1.170.42 → 1.170.43 Changeset
@tanstack/solid-start 1.169.3 → 1.169.4 Changeset
@tanstack/start-client-core 1.170.38 → 1.170.39 Changeset
@tanstack/start-plugin-core 1.171.54 → 1.171.55 Changeset
@tanstack/start-server-core 1.169.44 → 1.169.45 Changeset
@tanstack/vue-router 1.170.41 → 1.170.42 Changeset
@tanstack/vue-start 1.169.3 → 1.169.4 Changeset
@tanstack/react-start-client 1.168.43 → 1.168.44 Dependent
@tanstack/react-start-rsc 0.1.64 → 0.1.65 Dependent
@tanstack/react-start-server 1.167.51 → 1.167.52 Dependent
@tanstack/router-cli 1.167.45 → 1.167.46 Dependent
@tanstack/router-generator 1.167.45 → 1.167.46 Dependent
@tanstack/router-vite-plugin 1.167.47 → 1.167.48 Dependent
@tanstack/solid-start-client 1.168.41 → 1.168.42 Dependent
@tanstack/solid-start-server 1.167.49 → 1.167.50 Dependent
@tanstack/start-static-server-functions 1.167.43 → 1.167.44 Dependent
@tanstack/start-storage-context 1.167.40 → 1.167.41 Dependent
@tanstack/vue-start-client 1.167.44 → 1.167.45 Dependent
@tanstack/vue-start-server 1.167.49 → 1.167.50 Dependent

@codspeed

codspeed Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 3%

2 warnings

⚠️ 58 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 193 untouched benchmarks
⏩ 3 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Memory mem client interrupted-navigations (vue) 97 KB 94.2 KB +3%

Tip

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


Comparing fix/rsbuild-static-chunk-availability (3e09e47) with main (08a419c)

Open in CodSpeed

Footnotes

  1. 3 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. ↩

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

This pull request does not affect bundle size in any measured scenario.

@pkg-pr-new

pkg-pr-new Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@8780

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8780

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8780

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@8780

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@8780

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@8780

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8780

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@8780

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@8780

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@8780

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@8780

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@8780

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@8780

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@8780

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@8780

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@8780

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@8780

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8780

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@8780

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8780

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@8780

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8780

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8780

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@8780

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@8780

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@8780

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@8780

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8780

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@8780

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@8780

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8780

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@8780

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@8780

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8780

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@8780

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8780

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8780

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@8780

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@8780

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@8780

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@8780

commit: 3e09e47

Sarah Gerrard and others added 3 commits October 21, 2026 12:23
…cross loading paths

A shared chunk recorded static imports to every chunk in the union of its groups and their ancestors, so it pointed at each sibling route's copy of a duplicated module. Compute availability per chunk group as its own chunks plus the intersection of its parents, iterate to a shrinking fixed point for cyclic async graphs, and intersect across the chunk's groups.
@LadyBluenotes
LadyBluenotes force-pushed the fix/rsbuild-static-chunk-availability branch from 96b2c48 to 3e09e47 Compare October 21, 2026 19:23

This branch has not been deployed

No deployments
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