Skip to content
Source
Sign inSign up
TanStack/router

perf(start-plugin-core): avoid repeated work in Rsbuild compilation scans #8799

Openmattcosta7(GitHub profile, opens in a new tab)wants to merge 5 commits intomain fromrefs/pull/8799/headopened

🎯 Changes

Two passes that run on every Rsbuild compilation did avoidable work.

Client build normalization scanned each chunk's modules twice, once for tsr-split and once for tss-hydrate, calling the native identifier() each time. It now reads both in one scan. The literal-key guards stay separate, so encoded keys and first-value semantics are unchanged; new tests cover repeated, empty, +-encoded and percent-encoded keys, lookalike keys, and concatenation on and off.

Server function metadata replay (finishMake, stage -20) ran serverFnBuildInfoSchema.safeParse on every module's buildInfo, although almost no modules have the field. It now returns early when the field is absent, which was already the result.

MeasurementBeforeAfter
Metadata replay, 1,665-module dev compilation5.7 ms1.0 ms
Normalization, 128 routes, with hydration metadata—~4% lower
Normalization, 128 routes, route split only—within noise

Normalization numbers are from the new tests/rsbuild/normalized-client-build.bench.ts (real Rspack compilations, 8 and 128 routes, concatenation on and off), same fixture before and after. Client bundle output is unchanged.

Overlap with open PRs

Both halves overlap older open PRs, and I'd rather those land:

  • #8305 contains the same readServerFnBuildInfo early return. Prefer #8305: it's older and covers Zod work beyond this one function. If it merges first, I'll drop the start-compiler-host.ts change from this PR. If this merges first, #8305's rebase drops its identical hunk.
  • #8588 goes further on normalization: it finds route and hydration chunks with one pass over all modules, reads modules only from those chunks, and caches chunk-graph reads (2.5–4.4× on 760–3,245-chunk apps per its description). Prefer #8588, but it predates #8695 and needs porting to the new static-dependency code. If it merges first, I'll rebase this onto it and keep the single scan only if it still measures faster inside the chunks #8588 reads; otherwise I'll close this. If this merges first, #8588 can call getChunkMetadataFromModules in place of its two extractors.

So this PR is the small, low-risk fallback if those stay stalled; happy to close it once they move.

Written with an AI coding assistant.

✅ 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

  • Bug Fixes
    • Improved Rsbuild compilation handling for modules without server function metadata. Existing metadata continues to be validated, and invalid metadata is still rejected.
    1. 🦋 Changeset detected

      Latest commit: d262370b803c2df5ee794b866072d2406fd9b9b0

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

      This PR includes changesets to release 5 packages
      NameType
      @tanstack/start-plugin-corePatch
      @tanstack/react-start-rscPatch
      @tanstack/react-startPatch
      @tanstack/solid-startPatch
      @tanstack/vue-startPatch

      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

    2. Review in Change Stack →

      Important

      Review skipped

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

      Run configuration
      Commits

      Reviewing files that changed from the base of the PR and between b277e7b242909a6b23fbf8fd01e8f7ddccc42dbf and d262370b803c2df5ee794b866072d2406fd9b9b0.

      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
      Commits

      Reviewing files that changed from the base of the PR and between da2adec76dbe6c0da6d6a0d5640f7b9388217f45 and b277e7b242909a6b23fbf8fd01e8f7ddccc42dbf.

      Files selected for processing: 2
      • .changeset/rsbuild-cheaper-compilation-scans.md
      • packages/start-plugin-core/src/rsbuild/start-compiler-host.ts

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

      Walkthrough

      readServerFnBuildInfo now returns null before schema validation when server function metadata is absent. Present metadata continues to use the existing schema validation. A changeset requests a patch release for @tanstack/start-plugin-core.

      Changes: Rsbuild metadata handling

      Layer / File(s)Summary
      Skip validation when metadata is absent
      packages/start-plugin-core/src/rsbuild/start-compiler-host.ts, .changeset/rsbuild-cheaper-compilation-scans.md
      readServerFnBuildInfo checks for undefined metadata before schema validation. The changeset requests a patch release and describes this update.

      Estimated code review effort: 2 (Simple) | ~8 minutes

      Change: Refactor

      Possibly related issues

      • TanStack/router issue 8810 — It tracks build-time speed work that includes skipping schema parsing for modules without server-function metadata.

      Suggested labels: package: start-plugin-core

      Suggested reviewers: schiller-manuel

      Merge Risk: Minimal · previous review b277e

      No actionable merge-blocking risk is identified in the supplied changes.

      Pre-merge checks: Passed 4 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Docstring CoverageWarningDocstring coverage is 0.00% 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. Documentat…Write docstrings for the functions missing them to satisfy the coverage threshold.
      Passed Passed checks: 4 passed
      Check nameStatusExplanation
      Title checkPassedThe title clearly identifies an Rsbuild performance change. It is broad because the current summary mainly covers avoiding unnecessary server-function metadata validation, but it remains related to th…
      Description checkPassedThe description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, implementation, measurements, overlap with other pull requests, testing, AI assistanc…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Title check

      Explanation

      The title clearly identifies an Rsbuild performance change. It is broad because the current summary mainly covers avoiding unnecessary server-function metadata validation, but it remains related to the pull request objective.

      Full details: Description check

      Explanation

      The description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, implementation, measurements, overlap with other pull requests, testing, AI assistance, and changeset. One understanding-code checklist item remains unchecked, but the description is otherwise complete.

      Full details: Docstring Coverage

      Explanation

      Docstring coverage is 0.00% 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 1 functions across 1 files. (1 skipped: 1 unsupported.)

      Resolution

      Write docstrings for the functions missing them to satisfy the coverage threshold.

      Finishing Touches
      🧪 Generate unit tests (beta)
      • 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

Sign in to join this conversation.