diff --git a/.changeset/compiler-core-yuku.md b/.changeset/compiler-core-yuku.md new file mode 100644 index 0000000000..d013d83c9c --- /dev/null +++ b/.changeset/compiler-core-yuku.md @@ -0,0 +1,11 @@ +--- +'@tanstack/router-utils': minor +--- + +Add the compiler core shared by the router plugin and TanStack Start, built on Yuku (`@tanstack/router-utils/compiler`): one parse and one plan per module and environment, with every output (the module, its split chunks, Hydrate chunks, server function providers) emitted from the original source with exact source maps. + +The dev caches stay bounded by the live modules: deleted, renamed or no longer imported files leave no plans, raw facts or dependency-index rows behind, and publishing a plan updates only that plan's dependency rows. Resolutions and emitted outputs are not cached: each compile records its resolutions in its dependency ledger, validation asks the bundler's resolver again once a file appeared or disappeared, and outputs are emitted from the frozen plan on request. `TSR_COMPILER_STATS=1` exposes the cache sizes (`compilerStats()`) of the compiler core, the router plugin and the route generator, and `TSR_COMPILER_NO_CACHE` (`plans`, `facts`, `targets`, `all`) disables caches for measurements. + +Removed the Babel helpers (`parseAst`, `generateFromAst`, `deadCodeElimination`, `findReferencedIdentifiers`, `stripTypeExports` and the binding helpers of `compiler-helpers`) and the `@babel/*` and `babel-dead-code-elimination` dependencies. Also removed the unused `logDiff`, `createIdentifier` and `decodeIdentifier` exports and the `ansis` and `diff` dependencies. + +The package requires Node `^20.19.0 || >=22.12.0`: its CommonJS build loads the ESM-only parser through `require(esm)`. diff --git a/.changeset/react-start-rsc-compiler.md b/.changeset/react-start-rsc-compiler.md new file mode 100644 index 0000000000..81b4cb6b40 --- /dev/null +++ b/.changeset/react-start-rsc-compiler.md @@ -0,0 +1,7 @@ +--- +'@tanstack/react-start-rsc': minor +--- + +RSC CSS injection runs in Start's compiler. Server functions that only a `'use client'` component imports are in the production manifest (#7943). With RSC, server function provider modules load only what their handlers reach, so a route module's client-only code no longer runs under `react-server`. + +Removed `@tanstack/react-start-rsc/plugin/rscCssTransform` (the Babel transform). diff --git a/.changeset/route-generator-yuku.md b/.changeset/route-generator-yuku.md new file mode 100644 index 0000000000..c235d63b99 --- /dev/null +++ b/.changeset/route-generator-yuku.md @@ -0,0 +1,17 @@ +--- +'@tanstack/router-generator': minor +'@tanstack/router-cli': patch +--- + +Rebuild the route generator without Babel. + +**`routeTree.gen.ts` formatting changes once.** The route tree is printed directly in your `quoteStyle` and `semicolons`, and `enableRouteTreeFormatting` now defaults to `false`: Prettier is loaded only when you set it to `true`. A committed `routeTree.gen.ts` shows a one-time formatting diff after upgrading. Custom scaffolding templates are inserted as written. + +- Route files are recognised by binding: an aliased `createFileRoute` import gets its id fixed; a `createFileRoute` the app declares itself is left alone; a plain template literal path is reported, not rewritten (#7216). +- The tree is rebuilt from the files on every change: deleting a layout keeps its children, a deleted `routeTree.gen.ts` is written again, edits of the virtual route config and of `__virtual.ts` files are picked up, and a moved route gets its new id without a content change. +- Empty `.ts` route files get a scaffold without JSX (#8480); `.lazy.vue` files and `route.component.vue` pieces belong to their route; `importRoutesUsingAbsolutePaths` applies to lazy imports; unusual file names give valid trees. +- A route file used for two routes, and two routes with one id, are errors naming the files. +- Writes are atomic per write (also when `tmpDir` is on another filesystem); the generator's own writes no longer regenerate. +- `tsr watch` and the Rspack/webpack plugins watch every route root, including `physical()` mounts. +- `GeneratorPlugin.onRouteTreeChanged` receives the tree model (`{ model }`). The internal helpers `format`, `inferFullPath`, `checkRouteFullPathUniqueness` and `writeIfDifferent` are no longer exported. +- `@tanstack/router-generator` and `@tanstack/router-cli` require Node `^20.19.0 || >=22.12.0`: the CommonJS build and the `tsr` binary load the ESM-only parser through `require(esm)`. diff --git a/.changeset/route-hmr-runtime.md b/.changeset/route-hmr-runtime.md new file mode 100644 index 0000000000..8ad5149152 --- /dev/null +++ b/.changeset/route-hmr-runtime.md @@ -0,0 +1,8 @@ +--- +'@tanstack/router-core': patch +'@tanstack/react-router': patch +'@tanstack/solid-router': patch +'@tanstack/vue-router': patch +--- + +Add the development-only route HMR runtime used by the router plugin's output, on new `/hmr` subpaths (`@tanstack/router-core/hmr`, `@tanstack/{react,solid,vue}-router/hmr`). It updates the live route in place, keeps each split component's lazy wrapper across updates, and with Vite's bundled dev falls back to the original importer when Rolldown throws `MissingFactoryError`. An update patches only the route its module exported, so another router in the same window (module federation) is left alone (#7921). After the route tree is regenerated (a route added or renamed), updates keep reaching the route the rebuilt tree holds. Nothing of it reaches production bundles. diff --git a/.changeset/router-plugin-library-build-externals.md b/.changeset/router-plugin-library-build-externals.md new file mode 100644 index 0000000000..0945a25576 --- /dev/null +++ b/.changeset/router-plugin-library-build-externals.md @@ -0,0 +1,5 @@ +--- +'@tanstack/router-plugin': patch +--- + +Fix the Vite plugin failing a library build (`build.lib` with `external` dependencies) at the end of the build: the report of split exports that an entry chunk still holds walked the entry's imports, which also name the external packages, and read a chunk that does not exist (`Cannot read properties of undefined (reading 'modules')`). diff --git a/.changeset/router-plugin-order-check-splitting-only.md b/.changeset/router-plugin-order-check-splitting-only.md new file mode 100644 index 0000000000..42f42e205e --- /dev/null +++ b/.changeset/router-plugin-order-check-splitting-only.md @@ -0,0 +1,5 @@ +--- +'@tanstack/router-plugin': patch +--- + +Check the Vite plugin order (the router plugin before the framework's JSX plugin) only when `autoCodeSplitting` is on, as before: without splitting, route HMR works whatever the order, so a config listing `react()` or `solid()` first is not an error. diff --git a/.changeset/router-plugin-yuku.md b/.changeset/router-plugin-yuku.md new file mode 100644 index 0000000000..41052d98cb --- /dev/null +++ b/.changeset/router-plugin-yuku.md @@ -0,0 +1,23 @@ +--- +'@tanstack/router-plugin': minor +--- + +Route code splitting and route HMR run on the new compiler core instead of Babel: faster dev startup, HMR and builds, with the same production output shape. + +**What changes for your app when you upgrade:** + +- **Vite 6 or later is required** (the `vite` peer range is now `>=6`): the plugin is tested on Vite 6, 7 and 8; Vite 5 is no longer supported. +- **esbuild refuses `autoCodeSplitting: true`** with a clear error (route generation still works there); use Vite, Rspack or webpack for code splitting. +- **CommonJS consumers need Node 20.19+ or 22.12+** (`engines`): a `webpack.config.js` / `rspack.config.js` that `require()`s the plugin loads the ESM-only parser through `require(esm)`, which Node 22.0–22.11 and 21 do not support. +- **Routes the compiler cannot read statically stay unsplit with one warning per file per build** naming the file: route options built by a helper call (`createFileRoute('/x')(makeOptions())`), options that spread or compute, methods that read `this`, and route modules the compiler cannot parse. Main split some of these silently or crashed. +- **`routeTree.gen.ts` formatting changes once** (`enableRouteTreeFormatting` now defaults to `false`; see the route generator's changeset). +- **Removed:** `codeSplittingOptions.compilerPlugins` (the experimental Babel hook). + +- Any route option value splits: identifiers, inline functions, method shorthands (#8623), object-form loaders (#8753), casts, `satisfies`, calls such as `memo(Page)`, and options held in a module-level constant. Module state the route module and its chunks share exists once (#8754, #8505). Root routes split their `errorComponent` and `notFoundComponent`. +- `createFileRoute` & co. are recognised by their import binding. Routes whose options cannot be read statically, and methods or function expressions that read `this` (#8688), stay in the route module with one warning naming the file. +- A route's CSS import loads with its split component chunks when every component option the route defines is split; otherwise it stays in the route module. +- Route HMR keeps split components' lazy wrappers across updates in React, Solid and Vue, refreshes edits of split loaders and other non-component options on Rspack and webpack, and needs no framework plugin for `.ts` route modules. +- Production output is decided by the bundler's mode and is identical with `addHmr: false`. +- Rspack and webpack use the plugin's own loader: source maps compose with earlier loaders and name the route file (#6667, #3828); project paths with `'`, `#` or spaces work (#7754). Rspack/webpack no longer rebuild every environment once after the first watch build. +- esbuild refuses `autoCodeSplitting` with a clear error; the route generator keeps working there. +- Removed: `codeSplittingOptions.compilerPlugins` (the experimental Babel hook), the `@babel/*` dependencies and the direct `chokidar` dependency (the route generator's watcher brings it). New entry `@tanstack/router-plugin/planners` exposes the route planners to TanStack Start. diff --git a/.changeset/start-compiler-yuku.md b/.changeset/start-compiler-yuku.md new file mode 100644 index 0000000000..89e30a5585 --- /dev/null +++ b/.changeset/start-compiler-yuku.md @@ -0,0 +1,52 @@ +--- +'@tanstack/start-plugin-core': minor +'@tanstack/router-core': minor +'@tanstack/start-client-core': patch +'@tanstack/react-start': patch +'@tanstack/solid-start': patch +'@tanstack/vue-start': patch +--- + +Start's Vite and Rsbuild plugins run on the new compiler core instead of Babel: each module compiles once per environment, with server functions, environment separation, ``, RSC CSS, route code splitting and HMR, and import protection in one pass. Builds and dev startup are 2–4× faster on a 340-route benchmark app. + +**What changes for your app when you upgrade:** + +- **Every server function id changes** (a shorter hash of the file and the function's name). Update CDN rules, WAF allowlists, analytics keyed by id and native clients that call `/_serverFn/` directly. Browser tabs loaded before a deploy fail their next server-function call after it: plan a reload or a blue/green window. +- **`serverFns.generateFunctionId` receives the function's stable name** (`greetUser`) as `functionName`, not the generated handler name (`greetUser_createServerFn_handler`). Custom generators keyed on the old names must be updated. +- **Production builds answer HTTP calls only for server functions that some client module imports.** A function only server code calls, or one returned to the client as data, gets a 404 over HTTP. The dev server still answers and warns once per function, so this shows up only after deploying: check the dev warnings before you ship. +- **A module the compiler cannot parse fails the client build** with an error naming the file, instead of shipping untransformed (its server code included). +- **`routeTree.gen.ts` formatting changes once**: `enableRouteTreeFormatting` now defaults to `false` and the tree is printed in your `quoteStyle` and `semicolons`; commit the one-time diff. +- **Removed (experimental, Babel-typed):** the `compilerTransforms` and `serverFnProviderModuleDirectives` options and the `StartCompilerPlugin`, `StartCompilerImportTransform`, `StartCompilerTransformContext` and `StartCompilerTransformCandidate` types. RSC integrations pass `rsc: { loadCssExpression, providerDirective }` instead. + +**Server functions** + +- **Production builds answer HTTP calls only for server functions that client code imports.** A function only server code calls (another server function, a server route), or one returned to the client as data, is refused when called over HTTP. The dev server still answers such a call and warns once per function. +- `serverFns.generateFunctionId` receives the server function's stable key (its export or variable name, e.g. `greetUser`) as `functionName`, instead of the generated handler name (`greetUser_createServerFn_handler`). Custom generators keyed on the old names must be updated. +- Default production ids are shorter (22 characters). +- Server functions are recognised by binding through re-exports, namespaces, aliases, user factories and stored builders, whatever the code formatting (#7280). With SSR as the provider the handler stays in its module (one instance) and server-side callers call it directly (#7213, #8731). `createServerOnlyFn(...)` passed to `.handler()` works (#8446). Nested server functions are hoisted on the server when safe. +- Client middleware sees only the server function's id during SSR, as in the browser. +- Vite `bundledDev`: lazy dependencies load, edits no longer crash the hot update, and SSR reflects edits (#8407, #8062, #7535). + +**Import protection** + +- A denied import is replaced by a mock module of its own that exports the target's names. Build violations are decided after tree-shaking; when `onViolation` returns `false` the import gets the real module and the build reruns until no new import is allowed. +- Exempt importers (`ignoreImporters`, `exclude`, `include`) get the real module; dependencies that mark themselves server-only follow `excludeFiles`; `.vue` and `.mdx` importers are checked on their compiled output; a client entry marked server-only fails the build. +- Reports show the import in the original source with a code frame, and traces follow the bundler graph. In dev, a denied import added by an edit is reported. +- Rsbuild: works with Rspack's persistent cache (`performance.buildCache`). + +**Rsbuild** + +- Server-only routes are pruned from the client route tree (#8545); the client manifest lists only the chunks a route loads (#8780). +- Dev answers the SPA shell with `spa.enabled` (#8543) and no longer forces `server.compress: false` (#8544). +- The server environment shares async chunks instead of duplicating the route modules the server function resolver imports. + +**Other** + +- Dev compiler state stays bounded by the live modules (Vite and Rsbuild): deleted, renamed or no longer imported files leave no plans, raw facts or import-protection records behind. +- Editing the imports of a route module no longer fully reloads the page. +- Generator plugins given as `router.plugins` run next to Start's (#7768); Start's route tree footer follows `quoteStyle` and `semicolons`. +- Solid Start server environments split route components like the client, so hydration keys agree. +- Require `exsolve` `^1.1.3`, so memory no longer grows across builds in one process. Entry lookups bypass its process-wide cache, so an entry file created after a dev server restart is found. +- The plugins load the router-core helpers they need from the new `@tanstack/router-core/tooling` entry instead of the router runtime. + +**Removed (experimental, Babel-typed):** the `compilerTransforms` and `serverFnProviderModuleDirectives` options and the `StartCompilerPlugin`, `StartCompilerImportTransform`, `StartCompilerTransformContext` and `StartCompilerTransformCandidate` types. RSC integrations pass `rsc: { loadCssExpression, providerDirective }` instead. diff --git a/.github/workflows/compiler-platforms.yml b/.github/workflows/compiler-platforms.yml index 84afc2c837..349bbce3f8 100644 --- a/.github/workflows/compiler-platforms.yml +++ b/.github/workflows/compiler-platforms.yml @@ -2,8 +2,17 @@ name: Compiler Platforms # The main PR workflow only runs on Linux x64 (glibc). The compilers load a # native Yuku binary per platform and handle platform-specific paths, so run -# their unit tests and a Vite and Rsbuild production build on the other -# platforms we ship to. +# their fast test tier (test:unit, the compiler core's included; its client +# checks run in pages of a headless Chromium), a small integration smoke set +# (test:integration:smoke: real Vite, Rspack, webpack and Rsbuild builds, +# including apps under paths with `#`, `%`, spaces and non-ASCII characters, +# and modules the compiler cannot parse) and a Vite and Rsbuild production +# build on the other platforms we ship to. The rest of the slow tier +# (test:integration) runs on Linux x64 in the main PR workflow. +# +# Chromium: Playwright's own build on the glibc platforms; Alpine (musl) has +# no Playwright build, so the job installs the distribution's Chromium and +# names it to the test browser helper (TANSTACK_COMPILER_TESTS_CHROMIUM). on: pull_request: @@ -12,6 +21,8 @@ on: - 'packages/router-generator/**' - 'packages/router-plugin/**' - 'packages/start-plugin-core/**' + - 'packages/compiler-test-utils/**' + - 'packages/react-start-rsc/**' - 'pnpm-lock.yaml' - '.github/workflows/compiler-platforms.yml' schedule: @@ -57,7 +68,9 @@ jobs: - name: Install system packages if: ${{ matrix.container }} shell: sh - run: apk add --no-cache bash git + # Chromium and its fonts for the browser-backed tests (Playwright has + # no musl build; the helper launches this executable instead) + run: apk add --no-cache bash git chromium font-noto - name: Keep LF line endings # Snapshots are stored with LF. Windows runners check out CRLF by default, # and with `* text=auto` disabling autocrlf alone still uses the native eol @@ -81,6 +94,8 @@ jobs: if: ${{ matrix.container }} run: npm install --global "$(node -p "require('./package.json').packageManager")" - name: Install dependencies + # The compiler packages, what their tests build (the start-plugin-core + # tiers depend on the React, Solid and Vue Start builds) and the e2e app run: >- pnpm install --frozen-lockfile --filter . @@ -88,12 +103,39 @@ jobs: --filter "@tanstack/router-generator..." --filter "@tanstack/router-plugin..." --filter "@tanstack/start-plugin-core..." + --filter "@tanstack/react-start-rsc..." + --filter "@tanstack/react-start..." + --filter "@tanstack/solid-start..." + --filter "@tanstack/vue-start..." --filter "tanstack-react-start-e2e-basic..." - - name: Unit tests + - name: Install Chromium (Playwright) + if: ${{ !matrix.container }} + # `--with-deps` installs the shared libraries Chromium needs on Linux + # (a no-op where they are present); the macOS and Windows images need none + run: | + if [ "$RUNNER_OS" = Linux ]; then + pnpm exec playwright install --with-deps chromium + else + pnpm exec playwright install chromium + fi + - name: Use the system Chromium (container) + if: ${{ matrix.container }} + run: echo "TANSTACK_COMPILER_TESTS_CHROMIUM=$(command -v chromium-browser || command -v chromium)" >> "$GITHUB_ENV" + - name: Unit tests (fast tier) run: >- pnpm nx run-many --targets=test:unit --projects=@tanstack/router-utils,@tanstack/router-generator,@tanstack/router-plugin,@tanstack/start-plugin-core --skip-nx-cache --outputStyle=static + - name: Noncompiler tests (runtime and build plumbing) + run: >- + pnpm nx run-many --targets=test:noncompiler + --projects=@tanstack/start-plugin-core,@tanstack/react-start-rsc + --skip-nx-cache --outputStyle=static + - name: Integration smoke (no browser) + run: >- + pnpm nx run-many --targets=test:integration:smoke + --projects=@tanstack/router-plugin,@tanstack/start-plugin-core + --skip-nx-cache --outputStyle=static - name: Production builds run: >- pnpm nx run-many --targets=build:vite:ssr,build:rsbuild:ssr diff --git a/AGENTS.md b/AGENTS.md index f47b5103e1..eb0757cacd 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -24,7 +24,7 @@ CI=1 NX_DAEMON=false pnpm nx run-many -p -t --skipRemoteCache ``` - Run one Nx command at a time. For a ~20-second startup/graph stall, stop, run `pnpm nx reset`, and retry once, then escalate. Do not apply that timeout to running tests. -- For code changes, run affected packages' `test:unit`, `test:types`, and `test:eslint` where available, including affected consumers; use `test:e2e` for browser/app behavior and `test:build` for exports/build changes. Root `pnpm test` includes the full e2e suite. Published-code changes require `pnpm changeset`. +- For code changes, run affected packages' `test:unit`, `test:integration`, `test:noncompiler`, `test:types`, and `test:eslint` where available, including affected consumers; use `test:e2e` for browser/app behavior and `test:build` for exports/build changes. Root `pnpm test` includes the full e2e suite. Published-code changes require `pnpm changeset`. ## Runtime rules diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4b6e808af1..12ba6656d1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,6 +65,7 @@ Run the checks relevant to your changes while developing: - `pnpm test:eslint` checks linting for affected packages. - `pnpm test:types` checks types for affected packages. - `pnpm test:unit` runs unit tests for affected packages. +- `pnpm test:integration` runs the slow tier of the compiler packages (`router-plugin`, `start-plugin-core`, `compiler-test-utils`): tests that start real builds, dev servers or browsers. - `pnpm test:build` checks builds for affected packages. - `pnpm test:e2e` runs end-to-end tests and requires the Playwright browsers. diff --git a/benchmarks/AGENTS.md b/benchmarks/AGENTS.md index 9d56a2411a..c8af3dba2e 100644 --- a/benchmarks/AGENTS.md +++ b/benchmarks/AGENTS.md @@ -2,11 +2,12 @@ Read the relevant README before running benchmarks. Compare baseline and candidate with the same workload and production builds; add a focused case when existing scenarios miss the changed mechanism. Keep workloads and benchmark names stable for historical comparisons. -| Changed behavior | Guide | Nx project | -| ------------------------------------------ | ---------------------------------- | -------------------------------------------------------- | -| Standalone Router navigation/rendering CPU | [client-nav](client-nav/README.md) | `@benchmarks/client-nav` | -| Start request/SSR CPU | [ssr](ssr/README.md) | `@benchmarks/ssr` | -| Client/server retention and allocations | [memory](memory/README.md) | `@benchmarks/memory-client`, `@benchmarks/memory-server` | +| Changed behavior | Guide | Nx project | +| ------------------------------------------ | ---------------------------------------- | ------------------------------------------------------------ | +| Standalone Router navigation/rendering CPU | [client-nav](client-nav/README.md) | `@benchmarks/client-nav` | +| Start request/SSR CPU | [ssr](ssr/README.md) | `@benchmarks/ssr` | +| Client/server retention and allocations | [memory](memory/README.md) | `@benchmarks/memory-client`, `@benchmarks/memory-server` | +| Compiler/plugin dev, HMR and build time | [compiler-perf](compiler-perf/README.md) | `@benchmarks/compiler-perf` (run `scripts/run.mjs` directly) | Use `test:perf:` through Nx. Plain memory runs only smoke-test; memory metrics require CodSpeed. Client navigation benchmarks do not cover Start hydration or client server-function calls. diff --git a/benchmarks/bundle-size/.gitignore b/benchmarks/bundle-size/.gitignore index bd05a98cee..57d925bd7c 100644 --- a/benchmarks/bundle-size/.gitignore +++ b/benchmarks/bundle-size/.gitignore @@ -9,3 +9,5 @@ results/*.js results/*.log results/runs/ !results/.gitkeep +dist-server +dist-server-maps diff --git a/benchmarks/bundle-size/README.md b/benchmarks/bundle-size/README.md index 2185d6b43f..8d0b8dbb9f 100644 --- a/benchmarks/bundle-size/README.md +++ b/benchmarks/bundle-size/README.md @@ -170,3 +170,20 @@ The measurement script supports optional interfaces for historical backfilling: These are intended for one-off scripts that replay historical commits and append results to the same history dataset shape used for chart generation. If `--append-history` points at a `data.js` file, output is written as `window.BENCHMARK_DATA = ...` for direct GitHub Pages compatibility. + +## Server Output + +`scripts/benchmarks/bundle-size/server.mjs` builds the Start scenarios with +their server environment (`measure.mjs` builds the client only) and reports +server bytes (total, entry chunk), the chunks and modules loaded for a first +request to `/`, and cold start time (process spawn → first SSR response): + +```bash +node scripts/benchmarks/bundle-size/server.mjs --repo-root . \ + --dist-dir benchmarks/bundle-size/dist-server --build \ + --maps-dist-dir benchmarks/bundle-size/dist-server-maps --build-maps \ + --out server.json [--baseline ] +``` + +To compare checkouts, run it with `--repo-root ` and dist +directories inside that checkout (chunks resolve their externals from there). diff --git a/benchmarks/compiler-perf/.gitignore b/benchmarks/compiler-perf/.gitignore new file mode 100644 index 0000000000..4cd272dd4f --- /dev/null +++ b/benchmarks/compiler-perf/.gitignore @@ -0,0 +1,2 @@ +apps/ +results/ diff --git a/benchmarks/compiler-perf/README.md b/benchmarks/compiler-perf/README.md new file mode 100644 index 0000000000..64835d8869 --- /dev/null +++ b/benchmarks/compiler-perf/README.md @@ -0,0 +1,267 @@ +# Compiler performance harness + +Measures, on large generated apps, how the TanStack compiler (route generator, +code splitting, HMR injection, Start server-function and environment +transforms, `` handling, import protection) affects what users wait for: + +1. **Dev startup**: process start → server listening → first page hydrated in + Chromium, plus a "compile everything" variant that isolates transform + throughput. +2. **HMR**: file save → updated DOM, per kind of edit. +3. **Production build**: wall-clock of `vite build` (client + SSR) and + `rsbuild build`. + +and attributes main-thread time to our plugins (CPU profiles plus per-plugin +hook timing). Optional scenarios measure the **floor** (the same scenarios +with the compiler's outputs replayed, i.e. what they would cost with a +zero-cost compiler) and **memory** (peak RSS, heap after GC, HMR leak check). + +## Workloads + +`scripts/generate.mjs` writes deterministic (seeded) apps into `apps/` (git-ignored): + +| variant | contents | +| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `react-start` | TanStack Start (Vite and Rsbuild configs): 338 route files (10 sections × 3 groups, nested layouts, pathless/group/splat/param routes, 5 server routes), loaders, `validateSearch`/`loaderDeps`, `beforeLoad`, pending/error/notFound components, 106 server functions (20 files + inline, validators, middleware), `createIsomorphicFn`/`createServerOnlyFn`/`createClientOnlyFn`, `ClientOnly`, 10 `` boundaries, `*.server.ts` modules, 40 shared components | +| `react-router` | the same route tree as a client-only Router app with `autoCodeSplitting`, no Start features | +| `solid-start` | `react-start` written for Solid (signals, ``/``, `class`, accessor router hooks); Vite only (`vite-plugin-solid`; no Rsbuild config, which would need `@rsbuild/plugin-babel` + `@rsbuild/plugin-solid`). Same route tree, server functions and probes | +| `solid-router` | `react-router` written for Solid | + +Every result records a hash of the generated sources (`workloads..hash`); +`compare.mjs` warns when baseline and candidate inputs differ. Apps resolve +dependencies through this package, which links the built workspace packages. + +## Running + +From the repository root of any checkout that contains this directory: + +```sh +CI=1 pnpm install --frozen-lockfile +# Builds @tanstack/react-start, router-plugin, react-router through Nx, then runs everything. +node benchmarks/compiler-perf/scripts/run.mjs --label --out +``` + +Results: `/results.json` (all samples + stats), `/summary.md`, +`/run.log`, and `/profiles/` (CPU profiles + hook timings). +Without `--out`, results go to `benchmarks/compiler-perf/results/