Fix/rsbuild static chunk availability #8780
main fromfix/rsbuild-static-chunk-availability·opened 🎯 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 including CSS and preload links intended for sibling routes.
- Preserved route-specific links to split chunks used by shared code.
- Improved resource ordering and delivery across nested, lazy, and cyclic routes, including deferred styles for root boundaries.
Tests
- Expanded coverage for shared chunks, route-specific resources, CSS ordering, preloads, and deferred hydration.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-plugin-core
View your CI Pipeline Execution ↗ for commit 454207874a24bcefa104f8748e9ccc71f6375913
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...❌ Failed 16m 38s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 1m 26s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-29 19:24:16UTCNo actionable comments were generated in the recent review.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: TanStack/router
- Branch: fix/rsbuild-static-chunk-availability
- File: .coderabbit.yaml
- Commit: 4542078
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f93eda0a-8312-40e7-b9e4-6501169eb579
Commits-
Reviewing files that changed from the base of the PR and between 8bb4af824e47dfedb22d3fcef7a1de04d6131c23 and 454207874a24bcefa104f8748e9ccc71f6375913.
Files selected for processing: 8-
e2e/react-start/deferred-hydration/src/routes/__root.tsxe2e/react-start/deferred-hydration/src/shared/root-deferred.module.csse2e/react-start/deferred-hydration/tests/hydration.spec.tspackages/start-plugin-core/src/rsbuild/normalized-client-build.tspackages/start-plugin-core/src/start-manifest-plugin/manifestBuilder.tspackages/start-plugin-core/src/types.tspackages/start-plugin-core/src/vite/start-manifest-plugin/normalized-client-build.tspackages/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 groups entry and route assets based on chunk-group availability. The manifest builder uses those groups to create route resources. Tests cover shared chunks, route-specific assets, hydration CSS, and asset ordering.
Changes: Rsbuild route-scoped client assets
Priority:Layer / File(s) Summary Asset contract and normalization
packages/start-plugin-core/src/types.ts,packages/start-plugin-core/src/rsbuild/normalized-client-build.ts,packages/start-plugin-core/src/vite/start-manifest-plugin/normalized-client-build.tsThe client build types now distinguish chunk builds from grouped builds. Rsbuild normalization maps route origins to route asset groups and collects entry, preload, and CSS assets. The Vite normalizer continues to return the chunk-build type. Manifest route resources
packages/start-plugin-core/src/start-manifest-plugin/manifestBuilder.tsThe manifest builder selects the grouped-build path when route assets are present. It maps route preloads and CSS to manifest resources, merges entry assets into the root, and emits entry scripts. Asset behavior validation
packages/start-plugin-core/tests/rsbuild/normalized-client-build.test.ts,e2e/react-start/deferred-hydration/src/routes/__root.tsx,e2e/react-start/deferred-hydration/src/shared/root-deferred.module.css,e2e/react-start/deferred-hydration/tests/hydration.spec.ts,.changeset/rsbuild-static-chunk-availability.mdTests cover shared chunks, lazy-group dependencies, route assets, asset ordering, and Windows paths. The deferred-hydration example and test cover CSS in a root hydration boundary. A changeset records a patch release. NormalEstimated code review effort: 4 (Complex) | ~45 minutes
Change: Bug fix
Sequence Diagram(s)#
sequenceDiagram participant RspackCompilation participant normalizeRspackClientBuild participant buildStartManifest RspackCompilation->>normalizeRspackClientBuild: Provide entrypoint and chunk groups normalizeRspackClientBuild->>buildStartManifest: Return entry and route assets buildStartManifest->>buildStartManifest: Map route preloads and CSS to manifest resourcesPossibly related issues
- TanStack/router#8810: The tracking issue describes the shared-chunk route asset behavior and the parent-availability rule covered by this change.
Possibly related PRs
- TanStack/router#8800: It caches the normalized build and fingerprints chunk groups used by this PR’s group-based normalization.
Suggested reviewers:
schiller-manuel,czearing
Merge Risk:
Minimal · up to45420-
The change makes Rsbuild static chunk availability follow chunk-group parent paths, which should stop sibling route assets from leaking into the manifest. No actionable merge-blocking risk was found, and tests cover the main cases, including shared chunks, two-parent groups and cycles.
Pre-merge checks:
4 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Docstring Coverage Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold. Passed checks: 4 passed-
Check name Status Explanation Title check The title "Fix/rsbuild static chunk availability" names the main change: the fix to static dependency chunk availability for Rsbuild (computeStaticDependencyChunks now intersects parent availability p… Description check The description follows the template: it has a Changes section explaining the bug (shared chunks in sibling route groups linking another route's CSS and preloads), the fix (per-group intersection of p… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Title check
-
Explanation
The title "Fix/rsbuild static chunk availability" names the main change: the fix to static dependency chunk availability for Rsbuild (computeStaticDependencyChunks now intersects parent availability per chunk group). It is concise and specific. The branch-style prefix "Fix/" is a minor style issue but does not affect relevance.
Full details: Description check
-
Explanation
The description follows the template: it has a Changes section explaining the bug (shared chunks in sibling route groups linking another route's CSS and preloads), the fix (per-group intersection of parent availability with a fixed-point iteration), and the tests added. It includes the checklist with the items checked and the release impact section with the changeset box checked. The AI disclosure is present. The description does not mention the changeset file by name, and it does not state the scope of the e2e deferred-hydration changes, but these gaps are non-critical.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 13 functions across 7 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 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.
Comment `@coderabbitai help` to get the list of available commands.-
🚀 Changeset Version Preview#
1 package(s) bumped directly, 4 bumped as dependents.
🟩 Patch bumps#
Package Version Reason @tanstack/start-plugin-core1.171.55 → 1.171.56 Changeset @tanstack/react-start1.169.4 → 1.169.5 Dependent @tanstack/react-start-rsc0.1.65 → 0.1.66 Dependent @tanstack/solid-start1.169.4 → 1.169.5 Dependent @tanstack/vue-start1.169.4 → 1.169.5 Dependent Merging this PR will improve performance by 3.42%#
2 warnings
:warning: 51 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.
:warning: 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.
⚡ 2improved benchmarks✅ 192untouched benchmarks⏩ 3skipped benchmarks1Performance Changes#
Mode Benchmark BASEHEADEfficiency ⚡ Memory mem client navigation-churn (solid)109.7 KB 105.7 KB +3.8% ⚡ Memory mem client unique-location-churn (vue)82.8 KB 80.3 KB +3.03% Tip
Curious why performance improved? Comment
@codspeedbot explain why performance improvedon this PR, or directly use the CodSpeed MCP with your agent.
Comparingfix/rsbuild-static-chunk-availability(4542078) withmain(da2adec)Footnotes#
-
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. ↩
-
Bundle Size Benchmarks#
This pull request does not affect bundle size in any measured scenario.
More templates
- tanstack-router-vue-example-basic-jsx
- tanstack-router-vue-example-basic-file-based-jsx
- tanstack-router-vue-example-basic-file-based-sfc
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-router-react-example-basic-authjs
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-rsbuild
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-example-next-migration
- tanstack-start-example-rscs
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
- tanstack-router-solid-example-authenticated-routes
- tanstack-router-solid-example-authenticated-routes-firebase
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-default-search-params
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-basic-virtual-file-based
- tanstack-router-solid-example-basic-virtual-inside-file-based
- tanstack-router-solid-example-deferred-data
- tanstack-router-solid-i18n-paraglide
- tanstack-router-solid-example-kitchen-sink
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-large-file-based
- tanstack-router-solid-example-location-masking
- tanstack-router-solid-example-navigation-blocking
- tanstack-router-solid-example-quickstart
- tanstack-router-solid-example-quickstart-esbuild-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-router-solid-example-quickstart-rspack-file-based
- tanstack-router-solid-example-quickstart-webpack-file-based
- @tanstack/router-solid-mono-simple
- router-solid-mono-simple-lazy
- router-solid-monorepo-solid-query
- tanstack-router-solid-example-scroll-restoration
- tanstack-solid-router-search-validator-adapters
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-authjs
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-bun-hosting
- tanstack-solid-start-example-convex-better-auth
- tanstack-solid-start-example-counter
- tanstack-solid-start-i18n-paraglide
- tanstack-solid-start-example-large
- tanstack-solid-start-streaming-data-from-server-functions
- tanstack-solid-start-example-supabase-basic
- tanstack-solid-start-tailwind-v4
- tanstack-router-solid-example-view-transitions
- tanstack-router-solid-example-with-framer-motion
- tanstack-router-solid-example-with-trpc
@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@8780commit:
4542078@LadyBluenotes I think we could simplify this by collecting assets per route’s chunk group, rather than reconstructing a global
chunk.importsgraph from module dependencies.A shared chunk can belong to several loading contexts, and its dependencies may be provided by different chunks in each context. Flattening those relationships into a single imports list loses that distinction and can pull sibling route assets into the manifest.
My suggestion is:
- Iterate over
compilation.chunkGroupsand usegroup.originsto identify the?tsr-split=...imports. - Resolve those requests to route file paths and build a route → chunk groups mapping. We need to preserve multiple groups per route and handle relative requests and aliases.
- Collect assets directly from each group’s chunks, plus chunks guaranteed to be available through every parent path. Keep the parent intersection and cycle handling, without expanding a shared chunk into its other groups.
- Pass the resulting per-route JS/CSS assets to the manifest builder directly, instead of converting them back into chunk import edges.
I implemented a prototype here. The regression scenarios from this PR pass after adapting the assertions to the final route manifest, along with the Rsbuild CSS, deferred hydration, and HMR integration tests.
- Iterate over
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 454207874a24bcefa104f8748e9ccc71f6375913
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 5 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