Skip to content
Source
Sign inSign up
TanStack/router

perf(start-plugin-core): speed up rsbuild client build normalization #8588

Openguru-irl(GitHub profile, opens in a new tab)wants to merge 10 commits intomain fromrefs/pull/8588/headopened

🎯 Changes

normalizeRspackClientBuild converts the Rspack client compilation into the data used to build the Start manifest. It runs on every Rsbuild build and on every dev rebuild. This PR makes it faster for builds with many chunks. The output does not change.

  • Chunk and chunk group properties (files, auxiliaryFiles, groupsIterable, chunks, childrenIterable) are now read once per call. Rspack builds a new collection on every read, and the previous code read them many times per chunk.
  • Modules are now read only from chunks that contain a route-split or hydration module. The previous code called getChunkModules for every chunk.

Benchmarks

Median of 21 runs of normalizeRspackClientBuild on generated apps, Rspack 2.2.3, production unless noted:

AppChunksChunk groupsmainThis PRSpeedup
Routes and shared vendor chunks76048161.1 ms14.3 ms4.3x
Large2,456901131.8 ms36.5 ms3.6x
Large (development)2,456901138.6 ms37.3 ms3.7x
Shared modules in route chunks1,39790197.0 ms39.4 ms2.5x
Many non-route async chunks3,2453,101235.1 ms53.4 ms4.4x

For each app, the output was compared with main on Rspack 2.0.0, 2.1.1 and 2.2.3 and was identical.

Tests

  • New unit tests in normalized-client-build.test.ts use a small fake chunk graph. They check that:
    • imports and dynamic imports are listed in the same order as before (this test also passes on main);
    • modules are read only from chunks with a route-split or hydration module;
    • each chunk and chunk group property is read at most once.
  • @tanstack/start-plugin-core test:unit, test:types and test:eslint pass.
  • These Rsbuild e2e suites pass:
    • react-start rsbuild, rsc-rsbuild and hmr
    • deferred-hydration (production and dev)
    • solid-start deferred-hydration
    • css-inline, with and without transform assets

✅ 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.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Performance
    • Start manifest generation is faster for Rsbuild client builds containing many chunks, reducing build-time overhead in larger applications. This improvement preserves the generated manifest’s route and hydration information.
    1. Review in Change Stack →

      Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

      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: 0d724f22-7a12-413d-af3d-13243beba842

      📥 Commits

      Reviewing files that changed from the base of the PR and between 1f0f20a3206a28365d74fd2485b9a8eedbf74dd0 and aa5c89c783adb51c14cd622e0861e3ed639fa34b.

      📒 Files selected for processing (3)
      • .changeset/rsbuild-client-build-capture.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

      Walkthrough

      Rsbuild client build normalization now memoizes chunk and group graph reads and limits route and hydration metadata extraction to relevant chunks. Tests cover normalized metadata and graph-read limits.

      Changes

      Rsbuild Client Build Normalization

      Layer / File(s)Summary
      Chunk graph reader and metadata selection
      packages/start-plugin-core/src/rsbuild/normalized-client-build.ts
      A per-build reader memoizes chunk and group data, plus derived JavaScript file lists. Route and hydration metadata extraction targets chunks containing those modules.
      Normalization integration and regression coverage
      packages/start-plugin-core/src/rsbuild/normalized-client-build.ts, packages/start-plugin-core/tests/rsbuild/normalized-client-build.test.ts, .changeset/rsbuild-client-build-capture.md
      Entrypoint, asset, import, and RSC CSS collection use cached graph accessors. Tests cover normalized output, selective module reads, and graph-property read counts. The changeset describes faster manifest generation for Rsbuild client builds with many chunks.

      Priority: ➖ Normal

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

      Change: Refactor

      Merge Risk: ⚪ Minimal · up to aa5c8

      No merge-blocking issue was established for this normalization change; it is ready to merge after normal checks.

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 2 files. (1 skipped: …Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Title check✅ PassedThe title clearly and concisely describes the primary change: improving the performance of Rsbuild client build normalization in start-plugin-core.
      Description check✅ PassedThe description follows the required template, explains the changes and motivation, includes benchmarks and test results, and completes the checklist and release-impact sections.
      Full details: Docstring Coverage

      Explanation

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

      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Autopilot is currently an internal CodeRabbit preview.


      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.
    2. View your CI Pipeline Execution ↗ for commit aa5c89c783adb51c14cd622e0861e3ed639fa34b

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded23mView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded2m 9sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-10-02 08:56:50 UTC

    3. More templates

      @tanstack/arktype-adapter

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

      @tanstack/eslint-plugin-router

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

      @tanstack/eslint-plugin-start

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

      @tanstack/history

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

      @tanstack/nitro-v2-vite-plugin

      npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@8588

      @tanstack/react-router

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

      @tanstack/react-router-devtools

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

      @tanstack/react-router-ssr-query

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

      @tanstack/react-start

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

      @tanstack/react-start-client

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

      @tanstack/react-start-rsc

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

      @tanstack/react-start-server

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

      @tanstack/router-cli

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

      @tanstack/router-core

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

      @tanstack/router-devtools

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

      @tanstack/router-devtools-core

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

      @tanstack/router-generator

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

      @tanstack/router-plugin

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

      @tanstack/router-ssr-query-core

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

      @tanstack/router-utils

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

      @tanstack/router-vite-plugin

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

      @tanstack/solid-router

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

      @tanstack/solid-router-devtools

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

      @tanstack/solid-router-ssr-query

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

      @tanstack/solid-start

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

      @tanstack/solid-start-client

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

      @tanstack/solid-start-server

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

      @tanstack/start-client-core

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

      @tanstack/start-fn-stubs

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

      @tanstack/start-plugin-core

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

      @tanstack/start-server-core

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

      @tanstack/start-static-server-functions

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

      @tanstack/start-storage-context

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

      @tanstack/valibot-adapter

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

      @tanstack/virtual-file-routes

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

      @tanstack/vue-router

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

      @tanstack/vue-router-devtools

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

      @tanstack/vue-router-ssr-query

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

      @tanstack/vue-start

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

      @tanstack/vue-start-client

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

      @tanstack/vue-start-server

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

      @tanstack/zod-adapter

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

      commit: aa5c89c

    4. Merging this PR will degrade performance by 14.02%

      :warning: 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 regressed benchmark ✅ 190 untouched benchmarks ⏩ 3 skipped benchmarks1

      Warning

      Please fix the performance issues or acknowledge them on CodSpeed.

      Performance Changes

      ModeBenchmarkBASEHEADEfficiency
      ❌Simulationhydrate restored route state and mixed Links (react)213.4 ms248.2 ms-14.02%

      Tip

      Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


      Comparing guru-irl:perf/rsbuild-client-build-capture (aa5c89c) with main (1f0f20a) 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. ↩

    5. Screenshot 2026-10-02 at 16 29 38

      The performance benchmark was executed on 2 different machine configs. The other 2 checks are failing with 403s

    6. @schiller-manuel can I get a review? This cuts hot reloads by ~30% in large applications

Sign in to join this conversation.