diff --git a/.changeset/compiler-core-yuku.md b/.changeset/compiler-core-yuku.md index bf666d1c7f..9685f705c1 100644 --- a/.changeset/compiler-core-yuku.md +++ b/.changeset/compiler-core-yuku.md @@ -7,3 +7,5 @@ Add the compiler core shared by the router plugin and TanStack Start, built on Y 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. `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` 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/route-generator-yuku.md b/.changeset/route-generator-yuku.md index c75c2a155d..c235d63b99 100644 --- a/.changeset/route-generator-yuku.md +++ b/.changeset/route-generator-yuku.md @@ -14,3 +14,4 @@ Rebuild the route generator without Babel. - 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/router-plugin-yuku.md b/.changeset/router-plugin-yuku.md index 7145dc36a3..f0d2e9f945 100644 --- a/.changeset/router-plugin-yuku.md +++ b/.changeset/router-plugin-yuku.md @@ -4,6 +4,14 @@ 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:** + +- **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. diff --git a/.changeset/start-compiler-yuku.md b/.changeset/start-compiler-yuku.md index 04e6e396c7..89e30a5585 100644 --- a/.changeset/start-compiler-yuku.md +++ b/.changeset/start-compiler-yuku.md @@ -9,6 +9,15 @@ 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. diff --git a/packages/router-cli/package.json b/packages/router-cli/package.json index 2eebdcd9ae..ba4ceb2534 100644 --- a/packages/router-cli/package.json +++ b/packages/router-cli/package.json @@ -63,7 +63,7 @@ "bin/**" ], "engines": { - "node": ">=20.19" + "node": "^20.19.0 || >=22.12.0" }, "dependencies": { "@tanstack/router-generator": "workspace:*", diff --git a/packages/router-generator/package.json b/packages/router-generator/package.json index 9aa2937b4f..6ee8eea151 100644 --- a/packages/router-generator/package.json +++ b/packages/router-generator/package.json @@ -63,7 +63,7 @@ "src" ], "engines": { - "node": ">=20.19" + "node": "^20.19.0 || >=22.12.0" }, "dependencies": { "@tanstack/router-core": "workspace:*", diff --git a/packages/router-plugin/package.json b/packages/router-plugin/package.json index 35e1f7d4a5..920a6aba7c 100644 --- a/packages/router-plugin/package.json +++ b/packages/router-plugin/package.json @@ -127,7 +127,7 @@ "!skills/_artifacts" ], "engines": { - "node": ">=20.19" + "node": "^20.19.0 || >=22.12.0" }, "dependencies": { "@jridgewell/remapping": "^2.3.5", diff --git a/packages/router-utils/package.json b/packages/router-utils/package.json index 8e22dab3d0..4567ecbc68 100644 --- a/packages/router-utils/package.json +++ b/packages/router-utils/package.json @@ -70,7 +70,7 @@ "src" ], "engines": { - "node": ">=20.19" + "node": "^20.19.0 || >=22.12.0" }, "dependencies": { "pathe": "catalog:",