Skip to content
Source
Sign inSign up
TanStack/router

perf(compiler): edit the analyzed module instead of copying it for each output #8675

OpenSheraff(GitHub profile, opens in a new tab)wants to merge 6 commits intocodex/yuku-evaluation fromperf/copy-free-outputsopened

🎯 Changes

Stacked on #8504.

Since #8504 stopped caching route analyses, each transform analyzes its own file and produces one output. So the copy each output made (cloneModuleAst: structuredClone plus two walks pairing copied and original nodes) is no longer needed. The code-splitter outputs, the Hydrate virtual module load and the import-protection rewrite now edit module.ast directly.

Contract: one analysis, one output; read-only passes first. Anything read from the tree's structure is read before the first edit: the declaration graph, the file pragmas (filePragmas), the cleanup's initial liveness (prepareBindingCleanup), the source statements' references. Yuku 0.19's semantic queries are keyed by node identity, so they keep describing the source after edits: bindingOf, referenceOf, scopeOf, parentOf/ancestors, lookup, the binding/reference/import/export records, comments. Nodes the compiler creates are unknown to them, so a source node is one with a parent. walk, findAll and nodeAt see the edits. ARCHITECTURE-CODE-SPLITTING.md describes this.

The Start compiler keeps its copy: its module cache holds source nodes that resolving other modules reads later.

Emitted code is byte-identical: 2,928 code-splitter outputs (code and source maps), plus the server-functions, deferred-hydration and import-protection production builds with Vite and Rsbuild.

Build (vs #8504, 10 alternating pairs, measured alone)TimePeak RSS
Code-splitter corpus (one analysis per output)−31.4%within ±3.4%
250 routes−15.5%within ±3.4%
750 routes−17.4%within ±3.4%
Start server-functions−3.4%within ±3.4%
Start deferred-hydration−5.8%within ±3.4%

Written with Claude Code (AI-assisted).

✅ 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).

🤖 Generated with Claude Code

    1. 🦋 Changeset detected

      Latest commit: 5242532e0e15ad3363abc575f583b4d192a58eb7

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

      This PR includes changesets to release 10 packages
      NameType
      @tanstack/router-utilsPatch
      @tanstack/router-pluginPatch
      @tanstack/start-plugin-corePatch
      @tanstack/react-start-rscPatch
      @tanstack/react-startPatch
      @tanstack/router-generatorPatch
      @tanstack/solid-startPatch
      @tanstack/vue-startPatch
      @tanstack/router-vite-pluginPatch
      @tanstack/router-cliPatch

      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. Important

      Review skipped

      Auto reviews are disabled on base/target branches other than the default branch.

      Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration
      • Configuration used: Repository: TanStack/router/.coderabbit.yaml
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: eb2dd780-b404-4e43-8ba5-ea46e1cb297e

      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
      • 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.
    3. View your CI Pipeline Execution ↗ for commit 5242532e0e15ad3363abc575f583b4d192a58eb7

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

      ☁️ Nx Cloud last updated this comment at 2026-10-11 15:22:07 UTC

    4. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-plugin

    5. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-utils

    6. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-plugin-core

    7. 🚀 Changeset Version Preview

      7 package(s) bumped directly, 3 bumped as dependents.

      🟨 Minor bumps

      PackageVersionReason
      @tanstack/router-cli1.167.41 → 1.168.0Changeset
      @tanstack/router-generator1.167.41 → 1.168.0Changeset
      @tanstack/router-plugin1.168.43 → 1.169.0Changeset
      @tanstack/router-utils1.162.3 → 1.163.0Changeset
      @tanstack/router-vite-plugin1.167.43 → 1.168.0Changeset
      @tanstack/start-plugin-core1.171.50 → 1.172.0Changeset

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/react-start-rsc0.1.60 → 0.1.61Changeset
      @tanstack/react-start1.168.61 → 1.168.62Dependent
      @tanstack/solid-start1.168.58 → 1.168.59Dependent
      @tanstack/vue-start1.168.57 → 1.168.58Dependent
    8. Bundle Size Benchmarks

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

    9. More templates

      @tanstack/arktype-adapter

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

      @tanstack/eslint-plugin-router

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

      @tanstack/eslint-plugin-start

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

      @tanstack/history

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

      @tanstack/nitro-v2-vite-plugin

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

      @tanstack/react-router

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

      @tanstack/react-router-devtools

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

      @tanstack/react-router-ssr-query

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

      @tanstack/react-start

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

      @tanstack/react-start-client

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

      @tanstack/react-start-rsc

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

      @tanstack/react-start-server

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

      @tanstack/router-cli

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

      @tanstack/router-core

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

      @tanstack/router-devtools

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

      @tanstack/router-devtools-core

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

      @tanstack/router-generator

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

      @tanstack/router-plugin

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

      @tanstack/router-ssr-query-core

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

      @tanstack/router-utils

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

      @tanstack/router-vite-plugin

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

      @tanstack/solid-router

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

      @tanstack/solid-router-devtools

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

      @tanstack/solid-router-ssr-query

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

      @tanstack/solid-start

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

      @tanstack/solid-start-client

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

      @tanstack/solid-start-server

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

      @tanstack/start-client-core

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

      @tanstack/start-fn-stubs

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

      @tanstack/start-plugin-core

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

      @tanstack/start-server-core

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

      @tanstack/start-static-server-functions

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

      @tanstack/start-storage-context

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

      @tanstack/valibot-adapter

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

      @tanstack/virtual-file-routes

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

      @tanstack/vue-router

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

      @tanstack/vue-router-devtools

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

      @tanstack/vue-router-ssr-query

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

      @tanstack/vue-start

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

      @tanstack/vue-start-client

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

      @tanstack/vue-start-server

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

      @tanstack/zod-adapter

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

      commit: 5242532

    10. Merging this PR will not alter performance

      :information_source: 99 benchmarks have no flame graph

      The flamegraph could not be generated because too much time was spent in runtime internals, making the visualization not useful for performance analysis.

      ✅ 194 untouched benchmarks ⏩ 3 skipped benchmarks1


      Comparing perf/copy-free-outputs (5242532) with codex/yuku-evaluation (47bbc0e)[^unexpected-base] 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. ↩

Sign in to join this conversation.