diff --git a/.changeset/bundler-peer-floors.md b/.changeset/bundler-peer-floors.md deleted file mode 100644 index 59706fc0d0..0000000000 --- a/.changeset/bundler-peer-floors.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -'@tanstack/start-plugin-core': minor -'@tanstack/react-start': minor -'@tanstack/solid-start': minor -'@tanstack/vue-start': minor -'@tanstack/react-start-rsc': minor ---- - -Raise Start's bundler peer ranges to the lowest versions the compiler's test suites pass on: `vite` `>=8.1.0` (8.0.x fails Start's dev and build suites), `@rsbuild/core` `^2.2.13`, the first Rsbuild that requires Rspack 2.2.9 (earlier Rspack 2 releases leave dev builds stuck after a rebuild and fail RSC builds), and `@rspack/core` `>=2.2.9` for `@tanstack/react-start-rsc`. The router plugin's ranges are unchanged: it still supports Rsbuild 1. diff --git a/.changeset/compiler-checkout-shadow-index.md b/.changeset/compiler-checkout-shadow-index.md deleted file mode 100644 index 4e8ae78dd9..0000000000 --- a/.changeset/compiler-checkout-shadow-index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-utils': patch ---- - -Dev servers: a branch switch that rewrites thousands of files the app never loaded no longer stalls the dev server for about a second per 3,000 files: the imports a created file may take over (`./x` found `x/index.ts`, and `x.ts` appears) are looked up by directory and name instead of scanning every import of every compiled module. A repeated event of a `package.json` or tsconfig (the same save through a second environment, a touch) no longer resets the resolution cache. diff --git a/.changeset/compiler-copy-guard.md b/.changeset/compiler-copy-guard.md deleted file mode 100644 index 2bd3955611..0000000000 --- a/.changeset/compiler-copy-guard.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-utils': patch ---- - -The compiler now fails the compile with an internal compiler error, positioned at the change it would lose, when it would copy part of a module into an output without a change it planned there (a compiler bug: such a copy could ship code the change replaces, such as a server implementation in a client chunk). Before, the output was emitted without that change and no message was printed. diff --git a/.changeset/compiler-core-yuku.md b/.changeset/compiler-core-yuku.md deleted file mode 100644 index e6c6f4b69d..0000000000 --- a/.changeset/compiler-core-yuku.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -'@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. Each compile records its resolutions in its dependency ledger, and validation asks the bundler's resolver again once a file appeared or disappeared; while the file set is unchanged, the bundler is asked once per environment for each (importer, specifier) pair, so the `export *` chain of a barrel that a thousand modules import from is resolved once, not a thousand times. Emitted outputs are not cached: they 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`, `registry`, `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. diff --git a/.changeset/compiler-file-back-as-change.md b/.changeset/compiler-file-back-as-change.md deleted file mode 100644 index 3e9de93640..0000000000 --- a/.changeset/compiler-file-back-as-change.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/start-plugin-core': patch -'@tanstack/router-plugin': patch ---- - -Dev servers: a file removed and created again within a moment (a stash and pop, a checkout and back) is no longer missed by the modules compiled while it was gone. The watcher may report its return as a change (chokidar folds a removal and a re-creation into one change; Rspack lists a file another environment still had as modified): every file event now asks the imports that did not resolve again (about 30 µs per such import per environment and event; most apps have none: a relative import of a types-only `.d.ts` is one), and a change of a file the compiler knew nothing of counts as its creation. A compile in progress that met such an import goes on unless the event makes it resolve. A file created empty and then saved in place (truncated, then written) has its first save seen: an event that finds a file empty waits for its text unless it repeats an event that already found the file so (the same modification time; a time of whole seconds, as on HFS+, FAT or some network shares, counts as unknown). diff --git a/.changeset/compiler-freshness-step6.md b/.changeset/compiler-freshness-step6.md deleted file mode 100644 index a3d26a2f9c..0000000000 --- a/.changeset/compiler-freshness-step6.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -Dev servers: a module compiled while one of its imports was missing no longer keeps "not found" for that import once the file is back, also when the module had been compiled before with another import that never resolves (a types-only `./types`), and when the resolver answered from before the file came back. A file removed and created again within one watcher event (a branch switch, a stash and pop) re-plans every module that found another file of its name meanwhile (`x/index.ts` beside `x.ts`), also one compiling at that moment or compiled later from an answer the dev server had cached: every file event drops the resolver answers the compiler keeps, and a module compiled after it asks its imports again. A Vite hot update no longer compiles a route in every environment when none of its split chunks were loaded: rewriting or editing 750 routes at once (a checkout) settles in about 0.2 s instead of 0.9 s on a 3,000-module app. diff --git a/.changeset/compiler-in-place-saves.md b/.changeset/compiler-in-place-saves.md deleted file mode 100644 index d22bfc29ae..0000000000 --- a/.changeset/compiler-in-place-saves.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-utils': patch ---- - -Dev servers no longer compile a module's importers as if it had no exports when an editor saves it in place (truncates the file, then writes it) and the file watcher reports the save while the file is still empty: the compiler reads the file again for a moment, as Vite does for its own hot updates. A file that still reads empty after that moment is an empty module (one emptied on purpose stops reporting the marker or exports it had). In a Start app, a server fn whose builder comes from another module could otherwise ship its handler's imports to the dev client. diff --git a/.changeset/compiler-invalidation-compares.md b/.changeset/compiler-invalidation-compares.md deleted file mode 100644 index 4fa3fbf868..0000000000 --- a/.changeset/compiler-invalidation-compares.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-utils': minor ---- - -The compiler's file-event invalidation compares the file with what its caches read: a save that leaves a file as it was (a touch, an echo of the same event through a second hook) re-plans nothing, a repeated call waits for the first and changes nothing, and an event delivered late is judged by the file as it is. The modules each environment's bundler must build again (stale dependents, a registry change's file, a compile that kept being overtaken) are kept per environment until the host takes them. diff --git a/.changeset/compiler-one-placement.md b/.changeset/compiler-one-placement.md deleted file mode 100644 index 41f0ddc452..0000000000 --- a/.changeset/compiler-one-placement.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -Internal: the compiler places every module with one placement, and the analyses only the earlier engine read are gone; compiles are about 9 to 11 % faster per module. A `` boundary inside a top-level statement (`Tabs.Panel = function Panel() { return … }`, `register('p', () => …)`) no longer fails the compiler's own output checks in its test runs. A function-level class only erased code reads goes like any other declaration, with the server-only import only it read. diff --git a/.changeset/compiler-per-export-fingerprints.md b/.changeset/compiler-per-export-fingerprints.md deleted file mode 100644 index 8631c0fa76..0000000000 --- a/.changeset/compiler-per-export-fingerprints.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-utils': patch ---- - -Dev: a plan depends on the exports it reads of another module, not on that module's whole export list. Adding an export to a widely imported module (or changing one an importer doesn't use) no longer re-plans and re-transforms every importer: on a 1,500-route app, appending an export to a module every route imports went from about 6.7 s to 32 ms until the update. diff --git a/.changeset/compiler-raw-loaders.md b/.changeset/compiler-raw-loaders.md deleted file mode 100644 index 3839e8058d..0000000000 --- a/.changeset/compiler-raw-loaders.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch -'@tanstack/router-utils': patch ---- - -The router plugin's webpack/Rspack loader and Start's Rsbuild loader are raw loaders: a module they do not compile goes on to the bundler as the bytes it came as. A binary file with a JavaScript extension imported as an asset (an MPEG transport stream segment named `.ts`, with `type: 'asset/resource'`) was decoded as UTF-8 and emitted corrupted (752 bytes in, 1,502 out); it is now emitted unchanged, and a file the loaders pass through keeps its byte order mark. diff --git a/.changeset/compiler-region-tree.md b/.changeset/compiler-region-tree.md deleted file mode 100644 index af471023b1..0000000000 --- a/.changeset/compiler-region-tree.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -Compiling a module with many server functions, or many other changes the compiler makes, no longer takes time that grows with the square of their number, whether their handlers stay in place or are hoisted: a module of 1,600 server functions took about 10 times as long as one of 400, and now takes about 4 times as long. Outputs are unchanged. diff --git a/.changeset/compiler-router-webpack-restored-plans.md b/.changeset/compiler-router-webpack-restored-plans.md deleted file mode 100644 index e51838575c..0000000000 --- a/.changeset/compiler-router-webpack-restored-plans.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-plugin': patch ---- - -Router plugin on webpack and Rspack with the bundler's persistent cache (webpack's `filesystem` cache, Rspack's `persistent` cache, Rsbuild's `buildCache`): a route module restored from the cache is built again when its route changed since (a virtual route config that mounts the file elsewhere while no dev server or build ran), and a route-list change right after a start from the cache rebuilds the route module, as it does after a cold start. Route modules carry their plan in the cache for this; a start from the cache with nothing changed builds no route module again. diff --git a/.changeset/compiler-router-webpack-stale-drain.md b/.changeset/compiler-router-webpack-stale-drain.md deleted file mode 100644 index cb417fe6c3..0000000000 --- a/.changeset/compiler-router-webpack-stale-drain.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-plugin': patch -'@tanstack/router-utils': patch ---- - -Router plugin on webpack and Rspack, in dev: a route whose registry entry changed without its file changing (a virtual route config that mounts the file elsewhere, or makes it a route) is built again in the compilation that follows, also on webpack, where it used to keep the code split decided for its old route id until the file was saved. The plugin's loader rule now matches every JavaScript module outside `node_modules` (the loader leaves modules that are no routes as they are), so a file stays one module when it becomes a route or stops being one. A route file under `node_modules` (a routes package resolved without following symlinks, a `physical()` mount of an installed package) is therefore not code-split on webpack and Rspack; the build warns once per such file, naming it. Because the loader is now part of every app module's request, webpack's and Rspack's deterministic module ids of the modules that are no routes change with this release, and under pnpm (or any install whose paths hold the package version, such as Yarn Plug'n'Play) with each later update of the plugin too, since the loader's path is part of every request; with npm's `node_modules` layout they change once. The code does not change. diff --git a/.changeset/compiler-rsbuild-stale-drain.md b/.changeset/compiler-rsbuild-stale-drain.md deleted file mode 100644 index f2ea76d8b9..0000000000 --- a/.changeset/compiler-rsbuild-stale-drain.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/start-plugin-core': patch ---- - -Rsbuild dev: each environment compiler forwards its own file events to the compiler's invalidation and builds the modules it found stale at `finishMake`, in the compilation of the event. A checkout that writes a module while the compilation of its dependency starts no longer leaves that module's importers compiled against its old text, and the importers of a created file or of a route whose id changed are built in one compilation instead of two. An add, or a removal of a file that is back, with the text the compiler read still asks again what looked for the file meanwhile; a save to a text without a plan (empty, unparsable, not the compiler's) keeps no plan of the old text. An edit that marks an imported module reports the import at its importer once, as before. diff --git a/.changeset/compiler-statement-start-guard.md b/.changeset/compiler-statement-start-guard.md deleted file mode 100644 index 7081ed01f2..0000000000 --- a/.changeset/compiler-statement-start-guard.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -The compiler checks whether rewritten code needs a `;` before it more cheaply: a module with a `` boundary in the client build, or `` in the server build, no longer pays for a pass over its whole top-level statement. A comment the compiler keeps or inserts before a rewritten statement no longer gets an extra `;` in front of it. Outputs are otherwise unchanged. diff --git a/.changeset/compiler-stats-retain-nothing.md b/.changeset/compiler-stats-retain-nothing.md deleted file mode 100644 index fa87616a23..0000000000 --- a/.changeset/compiler-stats-retain-nothing.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -With `TSR_COMPILER_STATS=1`, the stats registry no longer keeps every session it reads alive: a finished build's or closed dev server's compiler state is released as without the knob. diff --git a/.changeset/compiler-strips-type-only-exports.md b/.changeset/compiler-strips-type-only-exports.md deleted file mode 100644 index 31657bf768..0000000000 --- a/.changeset/compiler-strips-type-only-exports.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -Route splitting and Start's removal of server-only code no longer leave a type-only export behind for a type whose import they removed (`import { db, type Row } from './db'` with `export type { Row }`). A Babel plugin running after TanStack's (React Compiler through `@rolldown/plugin-babel` or `@vitejs/plugin-react`) failed the build with "Export 'Row' is not defined". Type-only exports have no runtime meaning, so the compiler removes them from every module it emits, as it did before the compiler rewrite: `export type { X }`, `export type { X } from '…'`, `export type * from '…'` and the `type X` specifiers of an `export { … }`, keeping the value specifiers next to them. Type declarations (`export type X = …`, `export interface X`) stay as written. diff --git a/.changeset/compiler-text-and-place.md b/.changeset/compiler-text-and-place.md deleted file mode 100644 index 8438690f0a..0000000000 --- a/.changeset/compiler-text-and-place.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -With React Server Components, a server function whose handler is itself a `createClientOnlyFn(…)` or `createIsomorphicFn()…` call now runs it compiled for the server: the client-only function throws, the isomorphic one runs its `.server()` implementation, and the provider no longer holds the client implementation. Before, the RSC provider ran the handler as written (the client-only function ran on the server). In the RSC environment's module, a server function nested in another value no longer keeps imports that only a client-only function in its validator or middleware read. diff --git a/.changeset/compiler-virtual-modules-and-cache-key.md b/.changeset/compiler-virtual-modules-and-cache-key.md deleted file mode 100644 index 9010938448..0000000000 --- a/.changeset/compiler-virtual-modules-and-cache-key.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch -'@tanstack/router-plugin': patch -'@tanstack/router-utils': patch ---- - -An Rsbuild persistent cache no longer restores the output of another version of the compiler. A type namespace named like a route or its options variable no longer stops the route being read. A server function nested in code that moves out of a route module links on Rsbuild with RSC. diff --git a/.changeset/compiler-vite-stale-sets.md b/.changeset/compiler-vite-stale-sets.md deleted file mode 100644 index 7173694d1e..0000000000 --- a/.changeset/compiler-vite-stale-sets.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch -'@tanstack/router-plugin': patch -'@tanstack/router-utils': patch ---- - -Vite dev: the modules a file change makes out of date (an export of a shared module that becomes a server function, for example) are part of that change's hot update in every environment, without the dev server compiling each of them first: on a large app such an edit reached the browser in about 0.1 s instead of 2 to 4 s. A route whose registry entry changes is rebuilt in every environment, also right after a dev server restart. A module compiled while the files it reads kept changing no longer prints "Save the file again if the page looks wrong": it is rebuilt with the next file change (at once on Rsbuild and webpack). diff --git a/.changeset/compiler-watch-hooks-never-reject.md b/.changeset/compiler-watch-hooks-never-reject.md deleted file mode 100644 index 13ff0125b1..0000000000 --- a/.changeset/compiler-watch-hooks-never-reject.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch -'@tanstack/router-utils': patch ---- - -Router plugin on webpack and Rspack, and Start on Rsbuild, in dev and watch builds: a failure inside one of the plugins' own hooks (for example an app plugin that fails a module's build while the router builds an out-of-date route again, or an `importProtection.onViolation` callback that throws) now fails that one compilation with an error that names it, and watching goes on: the next change is built and served. It used to end the bundler's watcher, so the dev server stopped answering (and Rspack 2.3.1 could abort the process at the next compilation). A one-shot build still fails on it. diff --git a/.changeset/coverage-review-fixes.md b/.changeset/coverage-review-fixes.md deleted file mode 100644 index 03d86bff55..0000000000 --- a/.changeset/coverage-review-fixes.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -With RSC, a `` written in a server function's handler keeps its children: the environment that renders server components sends them in the Flight payload, and the browser renders them after hydration. A server fn's `.handler(…)` called with more than one argument (with a cast) loses all of them on the client, not only the first. A server fn only another server fn's handler and a split component call moves into the component's chunk, as on main. A split option's lazy import is written in its route option when one option reads it, so a minifier can inline a declaration the route options spread. A `` capture named `children` keeps its name. Vite dev: renaming or deleting a route file sends no update for the removed file before the reload, so the page no longer logs a failed request and "Failed to reload". diff --git a/.changeset/dev-cold-start-and-invalidate-index.md b/.changeset/dev-cold-start-and-invalidate-index.md deleted file mode 100644 index 993dbbd27a..0000000000 --- a/.changeset/dev-cold-start-and-invalidate-index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch -'@tanstack/router-utils': patch ---- - -Vite dev: Start no longer pre-bundles `@tanstack/-router/hmr` on its own (the router package is excluded from optimization, so the subpath is served from source with it); pre-bundling it made a cold-start re-optimization strand the first page load (504 "Outdated Optimize Dep", no hydration, no reload). The compiler's plan cache finds a changed file's plans through a path index instead of scanning every plan on every hot update. diff --git a/.changeset/dev-hmr-stable-updates.md b/.changeset/dev-hmr-stable-updates.md deleted file mode 100644 index f65e35f86f..0000000000 --- a/.changeset/dev-hmr-stable-updates.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -Dev HMR: a route file that stops parsing keeps its last facts, so its importers (the route tree) no longer hot-update into a full reload onto the dev server's error page; a dependent whose compiled output did not change is not hot-propagated (a route file gaining an export no longer reloads the page); derived modules a file no longer produces (an extracted export after the export went, a split chunk after `codeSplitGroupings: []`) are dropped from the file's hot update instead of dead-ending into a reload; and a React route component moved between its chunk, the route module and its extracted-export module is swapped in (its React Refresh family changed) instead of kept stale. diff --git a/.changeset/erasure-keeps-top-level-statements.md b/.changeset/erasure-keeps-top-level-statements.md deleted file mode 100644 index 44a7796b45..0000000000 --- a/.changeset/erasure-keeps-top-level-statements.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -When Start removes code meant for the other environment (a server function's handler on the client, `createServerOnlyFn`/`createClientOnlyFn`/`createIsomorphicFn` implementations, `.server()` middleware, a stripped `` fallback, a `deleteNodes` route option), a top-level statement that writes a binding only that code read (`flags.newUi = true`, `list.push(register())`, `db = connect()`, `state.title = 'x'`) now stays and runs, as it did before the compiler rewrite. It used to be removed with the binding, silently dropping changes it made elsewhere: to another module's object, to the document, through a setter or a method of your own, or a call in the written value. Declarations only removed code reads are still removed. - -A statement that fills a container only server code reads (`handlers.set('a', serverThing)`) therefore keeps its import on the client. To leave it out, build the container in its declaration (`new Map([['a', serverThing]])`) or move it to a `.server` file. diff --git a/.changeset/esbuild-route-generation.md b/.changeset/esbuild-route-generation.md deleted file mode 100644 index 09c7c0e796..0000000000 --- a/.changeset/esbuild-route-generation.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-plugin': patch ---- - -The esbuild entry (`@tanstack/router-plugin/esbuild`) generates the route tree: at the start of every build and rebuild. It never ran the generator before, so an app without a committed route tree failed to build. Esbuild watches only the files of the bundle, so a route file created in watch mode joins the tree at the next rebuild (or run `tsr watch` next to it). diff --git a/.changeset/external-resolutions-answers.md b/.changeset/external-resolutions-answers.md deleted file mode 100644 index 261eabbe82..0000000000 --- a/.changeset/external-resolutions-answers.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/start-plugin-core': patch ---- - -`vite build --watch`: an import the resolver marks external (a server build's packages) is remembered as an answer, so a file appearing or disappearing no longer asks the resolver again about every package import of every module; a `package.json` or `tsconfig` change still does. diff --git a/.changeset/function-local-orphans-go.md b/.changeset/function-local-orphans-go.md deleted file mode 100644 index e6ca05479c..0000000000 --- a/.changeset/function-local-orphans-go.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/start-plugin-core': patch ---- - -A declaration inside a function that only removed server code reads now leaves with its initialiser, as before the rewrite: in `function dbMiddleware() { const sql = connect(); return createMiddleware().server(() => … sql …) }`, the client no longer calls `connect()`, and the helper and the server-only package it imports are not in the client bundle. A hook call (`useX(…)`) read only by removed code still runs, so the hook order is the same on the server and the client. diff --git a/.changeset/hydrate-refusals.md b/.changeset/hydrate-refusals.md deleted file mode 100644 index 88934dd269..0000000000 --- a/.changeset/hydrate-refusals.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch -'@tanstack/router-utils': patch ---- - -`` fixes and refusals: - -- Solid: a split handler of several statements without semicolons whose statements start with a call of a component local (`setCount(…)` then `setOpen(true)`) no longer runs as one call chain. -- Solid: `ref={el!}`, `ref={el as T}` and `ref={(el)}` in split children assign the component's `let`, as `ref={el}` does. -- React: a function in split children that reads a `let` the component reassigns now fails the build at the read, naming the variable: the split children receive its value when the boundary renders, so the function would not see later assignments. Keep the value in a ref (`useRef`), or use `split={false}`. Solid reads such a variable through a getter and is unaffected. -- The deferred hydration guide now lists every pattern that fails the build. Two of them built before and miscompiled silently: assigning a local of the component inside the boundary, and assigning a module-level variable other code of the module also uses (the split code would write its own copy, or a binding it imports). Also refused: `await`/`yield` directly in the children, `new.target`, and (Solid) a nested boundary assigning an outer local through `ref`. diff --git a/.changeset/hydrate-through-app-reexports.md b/.changeset/hydrate-through-app-reexports.md deleted file mode 100644 index e20ef3c342..0000000000 --- a/.changeset/hydrate-through-app-reexports.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch -'@tanstack/router-utils': patch ---- - -`` imported through the app's own modules re-exporting it (`export { Hydrate } from '@tanstack/react-start'`, an imported `Hydrate` exported again, `export *`, a namespace import, chains of these) now splits its children like a direct import, in React and Solid, Vite and Rsbuild. Before, it deferred hydration but its children's code loaded with the page. A re-export under another name, or one from an installed package, is still not followed. diff --git a/.changeset/import-protection-allow-import.md b/.changeset/import-protection-allow-import.md deleted file mode 100644 index 38775b2bd8..0000000000 --- a/.changeset/import-protection-allow-import.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -'@tanstack/start-plugin-core': minor -'@tanstack/react-start': minor -'@tanstack/solid-start': minor -'@tanstack/vue-start': minor ---- - -Import protection: new `allowImport(info)` option, and `onViolation` only reports. - -- `allowImport` runs during the build, before an import is replaced by its mock, in dev and in builds, once per import. Returning `true` gives the import the real module: it is not a violation, nothing is reported, and `onViolation` is not called. `false` or nothing is the normal outcome under `behavior`. It also sees imports tree-shaking removes later, so use it to decide, not to report, and give stable answers. Its `info` is `onViolation`'s without `trace` and `snippet`: the graph is not finished, and a snippet is rendered for reports. -- `onViolation` runs after the build for imports that survive tree-shaking and were not allowed, and returns nothing. **If you returned `false` to allow an import, move that decision to `allowImport` and return `true`:** returning `false` now does nothing but print a message saying so. -- A build no longer runs an environment a second time, which fixes `build --watch` writing no client and `rsbuild build` never exiting under RSC when an import was allowed. With RSC, a `'use client'` file allowed from `rsc` is the real module in `ssr` too. -- A build no longer reports a dead re-export of a denied module for its graph being larger than 256 modules, or for importing a platform builtin, the framework's server runtime or a package declaring `sideEffects: false`. A real effect at any depth is still reported. -- A denied file importing a package this environment cannot resolve (only `node` exports, on the client) gives the normal denial on Vite, not `Errored while resolving`. -- Awaiting a mock no longer freezes the tab or the server: `await mock` gives a mock, and `mock.foo().then(cb)` runs `cb`. diff --git a/.changeset/import-protection-asset-queries.md b/.changeset/import-protection-asset-queries.md deleted file mode 100644 index 0227580b9d..0000000000 --- a/.changeset/import-protection-asset-queries.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Import protection covers asset queries: `?raw`, `?url`, `?inline`, `?worker` and `?sharedworker` of a denied file or of a file with a `server-only` marker give the client the mock, never the file's text, in a plain import or through a pattern (`import.meta.glob`, a template-literal `import()`, `import.meta.webpackContext`), on Vite and Rsbuild. On the client, a denied file is judged wherever it lives, also outside `srcDirectory`, when a pattern reaches it, and a non-code denied file is judged through a plain glob (Vite) or `new URL` (Rsbuild). Still not covered, as on main: a marked file the compiler can't read its marker from (a language it doesn't know, or one that does not parse) with an asset query, what a clean `?worker` imports, and `new URL` of a denied file on Vite. A Vite dev server records no import of the mock on the denied file itself (only watch builds and bundled dev declare the file to Rolldown). diff --git a/.changeset/import-protection-builder-chains.md b/.changeset/import-protection-builder-chains.md deleted file mode 100644 index edd39b98fa..0000000000 --- a/.changeset/import-protection-builder-chains.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch -'@tanstack/router-utils': patch ---- - -Import protection: a dead re-export of a denied module whose top level holds Start builder chains (`createServerFn().handler(…)`, middleware, isomorphic and env-only fns) with pure arguments is no longer reported. An argument the environment's compile erases (a validator such as `.validator(z.object({ … }))`, a handler or a server implementation on the client; a client implementation on the server) does not count there, and neither does what only such an argument reads (a module only a handler imports, a schema const only a validator reads). A real effect, an unknown method, top-level `await` and live imports are still reported. The compiler no longer recognises the removed `.inputValidator()`: a call of it fails the client compile at the call. diff --git a/.changeset/import-protection-bundler-witness.md b/.changeset/import-protection-bundler-witness.md deleted file mode 100644 index d43cfdf287..0000000000 --- a/.changeset/import-protection-bundler-witness.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Import protection no longer reads tsconfig to guess whether TypeScript erases an import whose bindings are only used as types: the bundler decides. Such an import of a denied module is reported (and mocked) exactly when Vite's or Rsbuild's TypeScript transform keeps it, in dev and in builds. This fixes the stock Vite template (a solution-style `tsconfig.json` with `verbatimModuleSyntax` in `tsconfig.app.json`), whose builds bundled the real server module unreported, and Rsbuild dev, which reported imports SWC erases. diff --git a/.changeset/import-protection-importers-disagree.md b/.changeset/import-protection-importers-disagree.md deleted file mode 100644 index 380ccb2e11..0000000000 --- a/.changeset/import-protection-importers-disagree.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Import protection: when one importer needs a denied file as it is (an exempt plain importer, or an import `allowImport` allows) and a checked module reaches the file itself (a pattern import such as `import.meta.glob`, or an import another plugin added), the build now fails on Vite and Rsbuild under both behaviors, whatever order the bundler compiled them in: one file can't be both its mock and itself. The error names the file, each importer and why, and the two fixes (leave the file out of the pattern, or narrow the exemption or `allowImport`). Dev servers print the same error and keep serving the file until it is fixed. - -An importer the app no longer imports, a removed split-out route component, or a removed import `allowImport` allowed no longer keeps a denied file as it is in `build --watch` and the Rsbuild dev server: the next compilation serves its mock. Warnings about an exempt pattern importer now say where its pattern import is. diff --git a/.changeset/import-protection-lazy-locations.md b/.changeset/import-protection-lazy-locations.md deleted file mode 100644 index 6d7b6e035e..0000000000 --- a/.changeset/import-protection-lazy-locations.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/start-plugin-core': patch ---- - -Faster Start builds: import protection locates an import through the bundler's source map only when it reports a violation (every checked module used to combine its input map), a dependency module an app imports is read but no longer parsed and summarised unless its text names something the compiler recognises or re-exports another module, and the compiler asks less of the parser per module. A violation's trace still locates each step in the user's files; a step through a module another plugin rewrote (React Compiler, MDX) is named without a line. diff --git a/.changeset/import-protection-messages.md b/.changeset/import-protection-messages.md deleted file mode 100644 index e6518fbdda..0000000000 --- a/.changeset/import-protection-messages.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch -'@tanstack/router-utils': patch ---- - -Import protection reports say where a violation is and give a fix that works: a browser-only component rendered on the server suggests `` (from how the import is used, also in Solid; Vue SFCs get the `defineAsyncComponent(createClientOnlyFn(() => import(...)))` form), a pattern import names the matching `import.meta.glob` call and suggests a negative pattern, traces start at the app's own files, a marker conflict points at the second marker, Vite builds report every violation, and Rsbuild dev failures are located without the loader's stack. The mock runtime reports each mocked import once. diff --git a/.changeset/import-protection-pattern-imports.md b/.changeset/import-protection-pattern-imports.md deleted file mode 100644 index 39070b6014..0000000000 --- a/.changeset/import-protection-pattern-imports.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Import protection checks the imports a bundler expands from a pattern too: a denied file reached only through `import.meta.glob`, a template literal `import()` or `import.meta.webpackContext` is replaced by its mock and reported, in dev and in builds, on Vite and Rsbuild (a build names each module importing it, a dev server the denied file). Rsbuild builds with the `error` behaviour now fail on such an import, and Vite and Rsbuild dev servers report it (they used to mock it silently). diff --git a/.changeset/import-protection-rsbuild-rsc-conditions.md b/.changeset/import-protection-rsbuild-rsc-conditions.md deleted file mode 100644 index 4c0865afb5..0000000000 --- a/.changeset/import-protection-rsbuild-rsc-conditions.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Rsbuild with RSC: import protection judges the file an import resolves to in the RSC layer, where Rspack resolves with the `react-server` condition. A package or `package.json` `imports` entry whose `react-server` and default conditions name different files was judged by the default file: a client-only file only the default condition names failed the build (or was mocked in dev), and a denied file only `react-server` names was reported as an import another plugin added. diff --git a/.changeset/import-protection-served-verdict-vite.md b/.changeset/import-protection-served-verdict-vite.md deleted file mode 100644 index 682799ad72..0000000000 --- a/.changeset/import-protection-served-verdict-vite.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Import protection on Vite: the dev server builds a denied file again when what it was served no longer matches its importers, as Rsbuild does: an exempt importer (or an import `allowImport` allows) read after a pattern import made the file a mock gets the real module (the page reloads), and an edit that removes the exempt import serves the mock without a restart. A Vite build compiles each module once, so when it compiled the denied file for a pattern import before it read the import that needs the file as it is, every importer gets the mock, and the build now says so under `behavior` (an error with `'error'`, a warning with `'mock'`), naming the file, the importer that needs it and the pattern to fix. A `vite build --watch` rebuild that kept a denied file as it is after its exempt import was removed says so the same way. diff --git a/.changeset/import-protection-served-verdict.md b/.changeset/import-protection-served-verdict.md deleted file mode 100644 index c309b948c6..0000000000 --- a/.changeset/import-protection-served-verdict.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Import protection: a denied file compiled under its own id is real or mocked for every importer at once, and that choice now depends on its static importers only (real when an exempt importer imports it), not on the order the bundler compiles them in. What was served is recorded when it is served, and every report reads that record: a file an exempt importer gets for real is no longer reported as "mocked" (nor fails an `error` build) when a pattern import (`import.meta.glob`, `import.meta.webpackContext`) also reaches it, and the warning about a denied file whose every importer is unchecked prints whenever that file was served its mock. Rsbuild builds the file again in the same compilation when what it was served no longer matches its importers: an exempt importer compiled after the file gets the real module, a persistent cache no longer restores the real module after its exempt import was removed, a dev edit that removes the exempt import serves the mock without a restart, and a warm build with `allowImport` builds again only the modules whose answer changed. diff --git a/.changeset/import-protection-unchecked-importers.md b/.changeset/import-protection-unchecked-importers.md deleted file mode 100644 index 44b2d06249..0000000000 --- a/.changeset/import-protection-unchecked-importers.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Import protection: a build warns once about each denied file it mocks whose every importer is exempt (`exclude`, `ignoreImporters`) or outside the scope (`include`, `srcDirectory`), naming the file, what denies it (its pattern, or its marker import), its importers and the fix (import the file statically from an exempt module inside the scope). The warning is not a violation: `onViolation` is not called, and the `error` behavior does not fail the build. diff --git a/.changeset/import-protection-vite-exempt-order.md b/.changeset/import-protection-vite-exempt-order.md deleted file mode 100644 index cb4ddf02f5..0000000000 --- a/.changeset/import-protection-vite-exempt-order.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Import protection on Vite builds: a denied file that an exempt module imports plainly and an exempt pattern import (such as `import.meta.glob`) also reaches is now reported under `behavior` whichever way the build served it (it compiles the file once, for whichever import comes first), so the build's outcome no longer depends on the order. Rsbuild serves the file as it is to both, with no report. diff --git a/.changeset/import-protection-worker-imports.md b/.changeset/import-protection-worker-imports.md deleted file mode 100644 index 3679da3ed2..0000000000 --- a/.changeset/import-protection-worker-imports.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Rsbuild: a denied import in a module that a worker or service-worker plugin builds (a child compiler of the client build) fails the build with an import-protection error at the import, naming the importer and the denied file, and is reported to `onViolation`, instead of a build failure that printed nothing. A child compiler cannot load the mock, so this happens whatever the `behavior`. diff --git a/.changeset/input-validator-removed-message.md b/.changeset/input-validator-removed-message.md deleted file mode 100644 index ee91f78d43..0000000000 --- a/.changeset/input-validator-removed-message.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -A client build that reaches `.inputValidator()` on a server function or middleware builder now reports that the method was renamed to `.validator()` (#7566) and removed (#8694), instead of the generic "call the methods of a builder directly" error. diff --git a/.changeset/loader-index-input-maps.md b/.changeset/loader-index-input-maps.md deleted file mode 100644 index f71d840ba8..0000000000 --- a/.changeset/loader-index-input-maps.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -webpack, Rspack and Rsbuild: a loader before the compiler's that passes an index source map (a map of `sections`) no longer fails the module; the map is composed like any other. diff --git a/.changeset/no-cache-plans-dependents.md b/.changeset/no-cache-plans-dependents.md deleted file mode 100644 index 5882187930..0000000000 --- a/.changeset/no-cache-plans-dependents.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-utils': patch ---- - -With `TSR_COMPILER_NO_CACHE=plans` (or `all`), an edit of a module still updates the modules that read it: plans are no longer reused, but their dependencies are kept. diff --git a/.changeset/one-placement-handlers.md b/.changeset/one-placement-handlers.md deleted file mode 100644 index 004e5ab4f1..0000000000 --- a/.changeset/one-placement-handlers.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -An `enum` or `namespace` that only removed code reads (a split route option, a server function's handler on the client) is now removed from the module like any other declaration, with the imports only it read. diff --git a/.changeset/overtaken-compile-tracked.md b/.changeset/overtaken-compile-tracked.md deleted file mode 100644 index e5c539dd86..0000000000 --- a/.changeset/overtaken-compile-tracked.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/start-plugin-core': patch -'@tanstack/router-plugin': patch ---- - -Dev: a module whose compile was overtaken by changes of its dependencies three times in a row (the "compile-overtaken" warning, in a burst of file changes) is tracked again: a later change of what it read reloads it, instead of leaving its output stale until the module itself is saved. diff --git a/.changeset/react-route-hmr-after-refresh.md b/.changeset/react-route-hmr-after-refresh.md deleted file mode 100644 index 37ea5b9464..0000000000 --- a/.changeset/react-route-hmr-after-refresh.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-core': patch -'@tanstack/react-router': patch ---- - -React route HMR always shows an edit: after a route file edit the router takes the new component once React Refresh ran its refresh pass (or after 200 ms when no pass comes), and React Refresh alone decides whether the mounted component keeps its state. A component React Refresh can't patch (a conditional behind a `const`, a factory's result, an unexported class, a layout imported through a barrel that switches module) used to keep showing the old code until a reload. A route update of an unsplit React route lands one refresh pass later than before (about 17 ms on Vite, 31 ms on Rsbuild). diff --git a/.changeset/react-route-hmr-cast-hoist.md b/.changeset/react-route-hmr-cast-hoist.md deleted file mode 100644 index 915d15bb97..0000000000 --- a/.changeset/react-route-hmr-cast-hoist.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-plugin': patch ---- - -React development: an inline higher-order component whose argument is a cast (`component: memo(Page as any)`) in a route module is hoisted like `memo(Page)`, so it keeps its state on Rsbuild. Vite's React Refresh transform registers no component for that spelling yet; it still remounts there. diff --git a/.changeset/react-route-hmr-no-markers.md b/.changeset/react-route-hmr-no-markers.md deleted file mode 100644 index e18f30c199..0000000000 --- a/.changeset/react-route-hmr-no-markers.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -React development output no longer predicts which components React Refresh keeps: split chunks and Hydrate chunks lose their `$$tsrRefreshId` statement, and React route modules lose the `unsplit` entry of their route HMR call (the runtime takes the new component after React Refresh's pass). Production output is unchanged. diff --git a/.changeset/react-start-rsc-compiler.md b/.changeset/react-start-rsc-compiler.md deleted file mode 100644 index 81b4cb6b40..0000000000 --- a/.changeset/react-start-rsc-compiler.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@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/release-finished-environment-plans.md b/.changeset/release-finished-environment-plans.md deleted file mode 100644 index 279a58bb22..0000000000 --- a/.changeset/release-finished-environment-plans.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch -'@tanstack/router-plugin': patch -'@tanstack/router-utils': patch ---- - -Production builds release an environment's compiler state as soon as that environment is built, instead of keeping every finished environment's state until the whole build ends. A build of several environments (client, SSR, then a server or RSC environment) no longer grows its heap with each one (#8794). diff --git a/.changeset/round2-message-findings.md b/.changeset/round2-message-findings.md deleted file mode 100644 index 38e6745875..0000000000 --- a/.changeset/round2-message-findings.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/router-generator': patch -'@tanstack/start-plugin-core': patch ---- - -Three diagnostics now state their true cause and position: - -- Import protection: a `require()` of a denied file is reported at the call (`Imported by: src/entry.ts:3:27, through require("./db.server")`), with a code frame and the fixes of a plain import, instead of as "an import another plugin's transform added". `import.meta.glob`, `import.meta.webpackContext` and `require.context` written through a TypeScript assertion (`(import.meta as any).webpackContext(…)`) are named as the pattern imports they are. -- Import protection: an importer in a Vue single-file component is reported at its line and column in the SFC, with the SFC in the code frame and in `onViolation`'s `importerLoc`, also in a production build without source maps (it reported the compiled script's coordinates). -- Route generation: when the generator repairs a route's constructor (`createLazyFileRoute` in a route file) whose id is not a string literal, the id warning is printed once, at its position in the repaired file (a Vite build printed it twice, the first time at the column from before the repair). diff --git a/.changeset/route-chunk-copy-statements.md b/.changeset/route-chunk-copy-statements.md deleted file mode 100644 index 9d2849e283..0000000000 --- a/.changeset/route-chunk-copy-statements.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch ---- - -Route code splitting: a split chunk that copies a binding of the route file also runs an `export default ` that reads or writes it, as on `main` (`let ready = false; export default (ready = true)` reads `true` in the chunk, not `false`); the chunk runs the expression as a statement and exports no default. A declaration a chunk copies keeps its comments, so an annotation written before `export` (`/* #__NO_SIDE_EFFECTS__ */ export function f`) still lets the bundler drop an unused call in the chunk. diff --git a/.changeset/route-factory-reexport-report.md b/.changeset/route-factory-reexport-report.md deleted file mode 100644 index 59554ee6c5..0000000000 --- a/.changeset/route-factory-reexport-report.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-plugin': patch ---- - -A route file whose `createFileRoute` (or another route factory) is imported from a module of the app that re-exports the router's is now reported, naming the file and the fix (`import { createFileRoute } from '@tanstack/react-router'`): only the router's own export is recognised, so such a route is not code-split or hot-updated. Under TanStack Start the client build fails instead, since the route's `server`, `ssr` and `headers` options could not be removed from it. diff --git a/.changeset/route-generator-dev-memory.md b/.changeset/route-generator-dev-memory.md deleted file mode 100644 index c3ecb44f9f..0000000000 --- a/.changeset/route-generator-dev-memory.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-generator': patch ---- - -A long-running dev server or `tsr watch` keeps a digest of each route file instead of its text (about 2.4 KB less per route file), and an edit that leaves the route tree unchanged no longer goes over every route file. diff --git a/.changeset/route-generator-failed-batch.md b/.changeset/route-generator-failed-batch.md deleted file mode 100644 index 956d2e1cd4..0000000000 --- a/.changeset/route-generator-failed-batch.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-generator': patch ---- - -Dev: when a batch of route file changes fails because one file can't be read (permissions, a directory in its place), the other files' changes still reach the route tree with the next batch, instead of the tree keeping a route a file no longer exports until a file is added or removed. diff --git a/.changeset/route-generator-tmp-dir.md b/.changeset/route-generator-tmp-dir.md deleted file mode 100644 index 963706ec6a..0000000000 --- a/.changeset/route-generator-tmp-dir.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-generator': patch ---- - -A dev server or `tsr watch` keeps writing the route tree after its temporary directory (`.tanstack/tmp` by default) is deleted under it, for example by `git stash -u` or `git clean -fd` in a repository that doesn't ignore `.tanstack/`; until now, every later route change failed until restart. diff --git a/.changeset/route-generator-virtual-missing-file.md b/.changeset/route-generator-virtual-missing-file.md deleted file mode 100644 index 4a358627c9..0000000000 --- a/.changeset/route-generator-virtual-missing-file.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-generator': patch ---- - -A route file named by a virtual route config (`virtualRouteConfig` or a `__virtual.ts` subtree) that does not exist fails the run naming the file, as before the rewrite, instead of dropping the route and moving its children to the root. In dev and watch mode the error is printed and the last good route tree is kept. A batch that fails while writing route files or the route tree no longer leaves the generator's tree model (which Start's client route tree is printed from) ahead of the published tree. diff --git a/.changeset/route-generator-yuku.md b/.changeset/route-generator-yuku.md deleted file mode 100644 index 312106cc1b..0000000000 --- a/.changeset/route-generator-yuku.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -'@tanstack/router-generator': minor -'@tanstack/router-cli': patch ---- - -Rebuild the route generator without Babel. - -**`routeTree.gen.ts` formatting changes.** 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 if your formatter ignores the file, as the installation guides recommend. If a formatter runs over it, ignore the file or set `enableRouteTreeFormatting: true`: otherwise the generator and the formatter rewrite each other's output on every run. 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 (``createFileRoute(`/posts`)``) that doesn't match the file is rewritten to a string literal in your `quoteStyle`; a computed path (`${…}`, a variable) 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. -- A route file that does not parse fails `tsr generate` and builds, naming the file, the root route file included (main read the root without parsing it, so only the bundler failed on it); a build fails on it even when the plugin instance built or watched before. A dev server or watch session keeps the file's last good route and reports it. -- `disableLogging` silences the generator's warnings about route files too (a file without a `Route` export, a route id it reports instead of fixing, a file an edit broke in a running dev server); a run that fails still throws. -- 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. diff --git a/.changeset/route-hmr-exported-destructuring.md b/.changeset/route-hmr-exported-destructuring.md deleted file mode 100644 index 0d6afa2df1..0000000000 --- a/.changeset/route-hmr-exported-destructuring.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch ---- - -React route HMR: a lowercase route component exported in a destructuring (`export const { component, meta } = makeViews()`) no longer exports the component under the other names of the declaration, and a declaration listing it beside a destructuring (`export const component = …, { a, b } = parts`) no longer fails with a duplicate export. Each export keeps its own binding. diff --git a/.changeset/route-hmr-kept-readers.md b/.changeset/route-hmr-kept-readers.md deleted file mode 100644 index f49f6569db..0000000000 --- a/.changeset/route-hmr-kept-readers.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/router-core': patch -'@tanstack/react-router': patch -'@tanstack/solid-router': patch -'@tanstack/vue-router': patch ---- - -Route HMR on Rsbuild and webpack: an edit of a route file reaches the split chunks (and `` chunks) that read a binding the route module keeps; they used to go on showing the binding's first value until a reload. The route module's evaluation invalidates them and refreshes the route once the update is applied. diff --git a/.changeset/route-hmr-lazy-files.md b/.changeset/route-hmr-lazy-files.md deleted file mode 100644 index a1666ec4d8..0000000000 --- a/.changeset/route-hmr-lazy-files.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-plugin': patch -'@tanstack/router-core': patch ---- - -Dev: an edit of a lazy route file (`createLazyFileRoute`, `*.lazy.tsx`) updates the route in place instead of reloading the page, on Vite and Rsbuild, for React, Solid and Vue; a React component keeps its state when React Refresh can patch it, as in a route file. diff --git a/.changeset/route-hmr-runtime.md b/.changeset/route-hmr-runtime.md deleted file mode 100644 index 79a90e06b3..0000000000 --- a/.changeset/route-hmr-runtime.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -'@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. In development, once a router error boundary has shown a render error, later route edits reload the page, as without route HMR, so the edit that fixes the error shows (Solid and Vue: any router error boundary; React: only the global boundary, since React Refresh recovers route boundaries in place). A loader or `beforeLoad` error is no render error: route edits after it update in place, except once Vue's global boundary has replaced a document shell, which Vue cannot render again in place. Nothing of it reaches production bundles. diff --git a/.changeset/route-hmr-same-name-swap.md b/.changeset/route-hmr-same-name-swap.md deleted file mode 100644 index c7935e5385..0000000000 --- a/.changeset/route-hmr-same-name-swap.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-plugin': patch ---- - -Route HMR shows a component option that an edit points at another component under the same name: switching `import { Shell } from '../layouts/classic'` to `'../layouts/modern'` in an unsplit or root route (React and Solid), or flipping `component: wide ? Wide : Narrow` (React). Such values were kept as if React Refresh or solid-refresh would patch them. In React development, a split component whose value cannot hold the route HMR marker (a frozen object) no longer throws when its chunk loads. diff --git a/.changeset/route-options-used-elsewhere.md b/.changeset/route-options-used-elsewhere.md deleted file mode 100644 index 8cc1d2be7f..0000000000 --- a/.changeset/route-options-used-elsewhere.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-plugin': patch ---- - -Route options named through a `const` that other code in the route file also uses (`const z = options; z.server = …`, `export const defaults = options`) are no longer code-split or stripped of `deleteNodes` options: the build warns, as it does for options written to after their declaration. Before, a write through another name of the object (`z.server = …`) was not seen: the literal's `server` was removed, the write's stayed in the client output, and nothing was reported. diff --git a/.changeset/route-recogniser-closing.md b/.changeset/route-recogniser-closing.md deleted file mode 100644 index 58a3bed6fc..0000000000 --- a/.changeset/route-recogniser-closing.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -'@tanstack/router-generator': patch -'@tanstack/router-plugin': patch -'@tanstack/router-utils': patch -'@tanstack/start-plugin-core': patch ---- - -The route generator now gives a route file the constructor of its kind (`createFileRoute`, `createLazyFileRoute`) also when its route id is not a string literal; it still reports the id. Before, the code splitter waited for that repair, and a Start build shipped the route's `server` code to the client. - -While route generation has never succeeded (a dev server started with a route file that does not parse), a module that exports a `Route` fails to compile with the generator's error, as the route tree does, instead of being served as written with its `server` code. Once generation succeeds, it is compiled as a route again. - -The warning for a route file whose `Route` is not the router's own call now names its cause: the options call missing, a constructor imported as a type only, a root constructor called the wrong way (with `createRootRouteWithContext()({ … })` for the context form), or a call wrapped, made in a function of the file or stored in another const, with the call of the file's kind to write (`createLazyFileRoute` in a lazy file). A route made by the app's own helper (imported from another module) is no longer reported, whatever else the file imports from the router package, and the generator tells whether a call is the router's constructor by its import, not its name. Route options in a reassigned `let` are reported as such. - -An object-form loader with only a `handler` whose object is written to later (`a.staleReloadMode = …`) is no longer split down to its handler, which dropped the option written later; it stays in the route module, with a warning. diff --git a/.changeset/route-recogniser-one-verdict.md b/.changeset/route-recogniser-one-verdict.md deleted file mode 100644 index f83c31626e..0000000000 --- a/.changeset/route-recogniser-one-verdict.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -'@tanstack/router-generator': patch -'@tanstack/router-plugin': patch -'@tanstack/router-utils': patch ---- - -The route generator and the code splitter now agree on which files are routes. The code splitter splits a file only when the generator lists it and its `Route` is the router's own `createFileRoute`, `createLazyFileRoute`, `createRootRoute` or `createRootRouteWithContext` call for that kind of file, imported from the router package of the configured framework. A file the generator does not list is served as written, also under Start: it is not split and its `server`, `ssr` and `headers` options are not removed. A route made with another framework's router package or a subpath of the router package is left as written too. - -The generator now repairs a root constructor in a route file to `createFileRoute(path)`, and `createFileRoute` or `createLazyFileRoute` in `__root` to `createRootRoute`, as it already repairs `createLazyFileRoute` in a route file. It also reads the root route file, and it no longer warns about a route made by the app's own helper. - -A route whose `createFileRoute` comes from an app module that re-exports the router's no longer warns or fails the build under Start. Neither does a route factory call other than the route's own. What those calls hold is not code-split, and under Start their server options ship to the client. The warning for a route file whose `Route` is not the router's call now says, under `deleteNodes`, that the listed options are not removed. - -Route options, a spread in them and an object-form loader can now be named through several `const`s (`const options = base`) or a cast (`const options = base as any`). They are split and their server options removed as when written inline. An object-form loader named through two consts is no longer exported as the object itself, which the lazy loader then called. diff --git a/.changeset/route-recognition-round1.md b/.changeset/route-recognition-round1.md deleted file mode 100644 index c48942d756..0000000000 --- a/.changeset/route-recognition-round1.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-generator': patch -'@tanstack/router-plugin': patch ---- - -Route files the generator lists are reported when the code splitter can't read their `Route`, in two more shapes: a route made with `createRoute` (the constructor of code-based routes), and a `Route` declared by a destructuring pattern (`export const { Route } = …`, `export const [Route] = …`). Like the other unrecognised shapes, they build and warn that the route is not code-split and, under TanStack Start, that its `server`, `headers` and `ssr` options ship to the client; the message offers the `createFileRoute('/x')({ … })` call to write. A route id in parentheses or a TypeScript assertion (`createFileRoute(('/x'))`, `'/x' as const`) is a string literal the generator keeps in sync, instead of being reported as "not a string literal". A Vite build given the router plugins inline (the same objects for every config resolution) prints each generator warning once instead of once per resolution; the `Generator` takes an optional `logger`. diff --git a/.changeset/route-splitting-as-main.md b/.changeset/route-splitting-as-main.md deleted file mode 100644 index e53b4051ec..0000000000 --- a/.changeset/route-splitting-as-main.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -'@tanstack/router-plugin': minor -'@tanstack/router-utils': minor -'@tanstack/start-plugin-core': patch ---- - -Route code splitting keeps the rules of the Babel splitter: - -- **The same options are split.** `component`, `errorComponent`, `pendingComponent`, `notFoundComponent` and `loader`, as your groupings say. An option whose value the route file exports (`export function PostsComponent`) stays in the route module, and the build warns once, naming the file and the exports, as before. Root routes are not split. -- **Code only one split option uses moves into its chunk**, its initialiser included; what several options read (a staying one included) is one shared module, as before, unless it reads `Route`: then each chunk has its own copy. Assigning is not reading: a `let` one option only assigns and a split option reads is two variables, as before. -- **Only what splitting made unused leaves the route module.** A declaration or import that only moved code used (a use in a type counts) is removed when nothing left reads it. Top-level statements stay, and so does code that was already unused: `const unused = register('x')` stays in the route module only and runs once (the Babel splitter's chunks each ran it again); an import nothing uses (`import './polyfill'`, a CSS file) runs with the route file at the same point, once (in the shared module when there is one). React's classic JSX runtime is not supported with code splitting. -- **Values the Babel splitter could not move into a chunk keep working.** A member access (`pages.Home`), `satisfies`, a class, a namespace member, an array-pattern binding, a sequence, an object-form loader, a call holding JSX or TypeScript syntax (`memo(() =>

)`), and an option whose chunk would assign a variable it shares with the route module or another chunk stay in the route module, where they work, instead of failing the build. diff --git a/.changeset/router-generator-once-per-vite-build.md b/.changeset/router-generator-once-per-vite-build.md deleted file mode 100644 index 1b0a492ae5..0000000000 --- a/.changeset/router-generator-once-per-vite-build.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-plugin': patch ---- - -A Vite build whose environments share the app's plugins (`builder.sharedPlugins`, as TanStack Start sets it) generates the route tree once instead of once per config resolution (the top level's and each environment's): two of three generator runs less in a Start build, and a generator plugin's `onRouteTreeChanged` runs once. Plugins passed inline to `createBuilder` are given to every resolution and generate in each, as before. diff --git a/.changeset/router-generator-vite-watch-build.md b/.changeset/router-generator-vite-watch-build.md deleted file mode 100644 index 04b3c2024c..0000000000 --- a/.changeset/router-generator-vite-watch-build.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-plugin': patch ---- - -`vite build --watch` follows route files created while it watches: the route generator watches the route directories itself, as it does under `rspack`/`webpack` watch, and the route tree it writes makes the build compile again with the new route. Before, Vite's watcher reported only files of the bundle, so a new route file never joined the route tree or the output, not even at a later rebuild. This applies whether `build.watch` is set at the top level or per environment, and the generator stops watching when the build's watchers close. diff --git a/.changeset/router-messages-accurate.md b/.changeset/router-messages-accurate.md deleted file mode 100644 index 4f0e8add7a..0000000000 --- a/.changeset/router-messages-accurate.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/router-generator': patch -'@tanstack/start-plugin-core': patch ---- - -Route compiler and generator messages fire only when there is something to fix, and say how: - -- Every message names files relative to the project root and carries one position on every host: line and column counted from 1 in Vite builds (which printed none), Rsbuild, Rspack and webpack; the Vite dev server keeps its own `File:` line, mapped to the file as written. Rsbuild no longer prints the path three times, and a custom server function id error is reported once, not once per environment. -- Invalid split groupings fail the module at the value, naming the option; invalid plugin options fail with one readable error instead of a raw schema dump. -- A route tree the generator cannot build (two files for one route, conflicting paths, a missing root route) now fails `tsr generate` and builds, naming the files, instead of building with the tree on disk. Dev and watch mode print the error and keep the last good tree. diff --git a/.changeset/router-plugin-library-build-externals.md b/.changeset/router-plugin-library-build-externals.md deleted file mode 100644 index 0945a25576..0000000000 --- a/.changeset/router-plugin-library-build-externals.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@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 deleted file mode 100644 index 42f42e205e..0000000000 --- a/.changeset/router-plugin-order-check-splitting-only.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@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 deleted file mode 100644 index 3a9b699d8c..0000000000 --- a/.changeset/router-plugin-yuku.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -'@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:** - -- **Routes the compiler cannot read statically stay unsplit**: route options built by a helper call (`createFileRoute('/x')(makeOptions())`), imported from another module or written to after their declaration. What a spread or a computed key holds isn't split either (the options written next to it still are). -- **With `deleteNodes` set (as in every TanStack Start client build), options the compiler can't read build and warn**, naming the file: a listed option they hold isn't removed, so the code it reads stays in the output. A listed option written next to a spread is still removed. -- **`codeSplittingOptions.deleteNodes` applies with `autoCodeSplitting: false` too**: the listed options are removed from the route files in dev and builds. Before, only the code splitter read `deleteNodes`, so it did nothing without `autoCodeSplitting`. -- **A route module that does not parse fails a build** naming the file; a dev server warns and leaves the module as it is. -- **`routeTree.gen.ts` formatting changes** (`enableRouteTreeFormatting` now defaults to `false`): once if your formatter ignores the file, as the installation guides recommend; see the route generator's changeset otherwise. - -- Route code splitting keeps the Babel splitter's rules (see the route-splitting changeset). -- **Options removed by `codeSplittingOptions.deleteNodes`** (in every TanStack Start client build: `server`, `ssr`, `headers`) take what only they read out of every output of the route file, split chunks included: a default value in a destructuring declaration that a split component also reads (`const { title, secret = readSecret() } = …`, `secret` read only by a server handler) no longer brings its server-only import into a client chunk, nor does it next to a rest element (`const { secret = readSecret(), ...rest } = …` keeps `secret` without its default, so the key stays out of `rest`); main kept them in the route's shared chunk. -- `createFileRoute` & co. are recognised by their import binding. -- Route HMR keeps split components' lazy wrappers across updates in React, Solid and Vue and refreshes edits of split loaders and other non-component options on Rspack and webpack. -- Production output is decided by the bundler's mode and is identical with `addHmr: false`. -- Rspack and webpack use the plugin's own loader: project paths with `'`, `#` or spaces work (#7754). Rspack/webpack no longer rebuild every environment once after the first watch build. -- Removed: the `@babel/*` dependencies and the direct `chokidar` dependency (the route generator's watcher brings it). `@babel/core` no longer comes with the plugin: if your app runs Babel itself (for example for the React Compiler), declare `@babel/core` in your own `devDependencies`. New entry `@tanstack/router-plugin/planners` exposes the route planners to TanStack Start. diff --git a/.changeset/router-vite-run-sessions.md b/.changeset/router-vite-run-sessions.md deleted file mode 100644 index a92a91adf7..0000000000 --- a/.changeset/router-vite-run-sessions.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-plugin': patch -'@tanstack/router-utils': patch -'@tanstack/start-plugin-core': patch ---- - -The router plugin's Vite host keeps its compiler state per build run or dev server, as Start's plugins do: a dev server with inline plugins that restarts (`server.restart()`, or Vite's own restart on an `.env` edit) keeps re-planning route modules when the route tree changes, where it used to stop after the old server closed. The route listener of a dev server in middleware mode now also ends when the server closes. diff --git a/.changeset/router-webpack-diagnostic-locations.md b/.changeset/router-webpack-diagnostic-locations.md deleted file mode 100644 index 018c2b888f..0000000000 --- a/.changeset/router-webpack-diagnostic-locations.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-plugin': patch -'@tanstack/router-utils': patch ---- - -Rspack, webpack and Rsbuild: a router compile error or warning names its position as the compilation's own location, so the bundler's output points at it (`File: ./src/routes/index.tsx:2:22`, `WARNING in ./src/routes/index.tsx 2:22`) instead of `:1:1` or no position. diff --git a/.changeset/router-webpack-listener-shutdown.md b/.changeset/router-webpack-listener-shutdown.md deleted file mode 100644 index a10567caf6..0000000000 --- a/.changeset/router-webpack-listener-shutdown.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-plugin': patch ---- - -webpack and Rspack: the router plugin's route listener ends when the compiler shuts down (`compiler.close()`), not only when it stops watching. A one-shot build with the generator and code splitter as separate plugins no longer keeps its compiler state alive for the rest of the process. diff --git a/.changeset/rsbuild-manifest-module-chunks-once.md b/.changeset/rsbuild-manifest-module-chunks-once.md new file mode 100644 index 0000000000..02febd9d84 --- /dev/null +++ b/.changeset/rsbuild-manifest-module-chunks-once.md @@ -0,0 +1,5 @@ +--- +'@tanstack/start-plugin-core': patch +--- + +Rsbuild: the Start manifest pass that runs after every client compilation (builds and each dev update) reads an imported module's chunks once per compilation and counts the module once per importing chunk, instead of once per import connection. The manifest is unchanged; the pass takes about 40 % less time (on a 333-route app, tens of milliseconds less per HMR update). diff --git a/.changeset/rsbuild-watched-directory-edits.md b/.changeset/rsbuild-watched-directory-edits.md deleted file mode 100644 index 1dfe706b31..0000000000 --- a/.changeset/rsbuild-watched-directory-edits.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch -'@tanstack/router-utils': patch ---- - -Rsbuild dev: a directory a plugin watches (Tailwind CSS adds the ones it scans) is no longer taken for a created file when Rspack reports it modified, and a created file asks again only the resolutions it may take. Under Yarn PnP the first route edit of such an app rebuilt a module of `@tanstack/start-client-core`, which Rspack then failed to resolve, breaking every later compile. diff --git a/.changeset/rsc-provider-hoist-order.md b/.changeset/rsc-provider-hoist-order.md deleted file mode 100644 index 97c9a43613..0000000000 --- a/.changeset/rsc-provider-hoist-order.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/start-plugin-core': patch ---- - -RSC: a server function nested in the statement right after a declaration it reads outside its handler (`const auth = createMiddleware(…)…` then `registry.add(createServerFn().middleware([auth]).handler(…))`) no longer makes the server-function provider throw `Cannot access … before initialization` when it loads (Rsbuild): code the compiler places after a statement now comes before the next one in every output it renders in, as it already did in the route module. diff --git a/.changeset/server-code-check-recognition.md b/.changeset/server-code-check-recognition.md deleted file mode 100644 index f71815410b..0000000000 --- a/.changeset/server-code-check-recognition.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -The server-code check of client builds now takes what is server-only from the compiler's recognition of the code (every server function's handler and validator, middleware's server implementation and validator, isomorphic function's server implementation, `createServerOnlyFn` body, and route option in `deleteNodes`) instead of from what the compiler removed, so a compiler bug that skipped one of them also fails the build instead of shipping it. diff --git a/.changeset/server-code-check-route-options.md b/.changeset/server-code-check-route-options.md deleted file mode 100644 index 51b0c4c6f5..0000000000 --- a/.changeset/server-code-check-route-options.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-plugin': patch ---- - -The server-code check of Start's client builds also covers the route options Start removes from the client (`server`, `headers`, `ssr`): if a compiler bug ever kept one in a client module, the build fails with an internal compiler error instead of shipping it. diff --git a/.changeset/server-code-check.md b/.changeset/server-code-check.md deleted file mode 100644 index 247038f688..0000000000 --- a/.changeset/server-code-check.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/start-plugin-core': patch ---- - -Start's client builds now check that no client module holds server code: a server function's handler, a validator, a middleware's or an isomorphic function's server implementation, or a `createServerOnlyFn` body. The compiler removes these from the client already; if a compiler bug ever kept one, the build (or, in development, the module) fails with an internal compiler error naming the file, the position of the server code and the client module that held it, instead of shipping it. diff --git a/.changeset/server-fn-registry-follows-edits.md b/.changeset/server-fn-registry-follows-edits.md deleted file mode 100644 index b9c49d96e6..0000000000 --- a/.changeset/server-fn-registry-follows-edits.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -On the Vite dev server, a server function an edit removes is no longer registered: calling it by its old id fails like any unknown id instead of reaching a module that no longer exports it. diff --git a/.changeset/serverfn-handler-one-instance.md b/.changeset/serverfn-handler-one-instance.md deleted file mode 100644 index a148303c90..0000000000 --- a/.changeset/serverfn-handler-one-instance.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/start-plugin-core': patch ---- - -With the SSR environment as the server-function provider, a server function's handler shares its module's state and classes with the rest of the module: a class the handler instantiates passes `instanceof` in server code, and state the module or a validator writes is what the handler reads (#8656). Handlers still load lazily, on the first call. diff --git a/.changeset/serverfn-lazy-module.md b/.changeset/serverfn-lazy-module.md deleted file mode 100644 index 0202d6fca5..0000000000 --- a/.changeset/serverfn-lazy-module.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -With the SSR environment as the server-function provider, a server function that only a route's split component (or other code the module does not keep) calls no longer loads its validator and handler imports when the server starts: it lives in the module's lazy server module with its chain, whatever builder, factory or options the chain starts from. The split component's copy is a caller, as in the browser: the chain with its middleware, without its validator, calling the one server function through the server-function registry. The server-function registry always imports the lazy server module, so an HTTP call loads a handler's imports before its middleware runs, as before the compiler rewrite. A declaration only a handler reads no longer lands in a route's eagerly loaded shared module. diff --git a/.changeset/solid-route-hmr-identity.md b/.changeset/solid-route-hmr-identity.md deleted file mode 100644 index 977b6930a2..0000000000 --- a/.changeset/solid-route-hmr-identity.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -'@tanstack/router-core': patch -'@tanstack/solid-router': patch -'@tanstack/vue-router': patch -'@tanstack/router-plugin': patch ---- - -Solid route HMR (development only): an edit always shows. The router keeps the component it holds only when solid-refresh patches it in place: both values are solid-refresh proxies of the same component name and file. A layout imported through a barrel that switches module is no longer kept as the old module's component. On Rsbuild and webpack, every Solid split chunk hands its exports to the route's lazy component when it evaluates again on its own, so a component option whose value changed (`const Page = flag ? Wide : Narrow`) shows its new value. A split chunk holding components carries the route file's leading `@refresh` pragmas (`// @refresh granular`), so solid-refresh keeps a split component's state where it keeps an unsplit one's. Route modules no longer carry the compile-time component identities (`unsplit`) in their development HMR block. diff --git a/.changeset/solid-split-chunk-newest-import.md b/.changeset/solid-split-chunk-newest-import.md deleted file mode 100644 index 66b64517d3..0000000000 --- a/.changeset/solid-split-chunk-newest-import.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/router-core': patch -'@tanstack/solid-router': patch -'@tanstack/router-plugin': patch ---- - -Solid route HMR on Rsbuild, Rspack and webpack (development only): a split chunk imported again answers its newest evaluation. An edit of a loader grouped with the route component (`codeSplittingOptions.defaultBehavior: [['component', 'loader']]`) now shows, as does a route module edit after a conditional component switched (`const Page = flag ? Wide : Narrow`, then `staleTime`). This is a temporary workaround of Rspack's lazy compilation (web-infra-dev/rspack#16594): a later `import()` of a module that accepts its own updates, as solid-refresh makes every Solid chunk, answers its first namespace. A component the chunk handed over is kept when solid-refresh patched it, so such edits remount nothing more. diff --git a/.changeset/spelling-variant-fixes.md b/.changeset/spelling-variant-fixes.md deleted file mode 100644 index 8ea30ff7e6..0000000000 --- a/.changeset/spelling-variant-fixes.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch -'@tanstack/start-plugin-core': patch ---- - -The compilers read a few more spellings the same way: - -- An isomorphic, server-only or client-only implementation in a type wrapper, called where it is written (`createIsomorphicFn().server(impl as any)()`, `createServerOnlyFn(impl as any)()`), compiles to code that parses in its environment. -- A route callback reading `this` stays in the route module with a warning (`not-split:this-reference`) wherever it is declared: in a `const` the option names, through `const`s naming each other, as a function declaration, or as the `handler` of a loader object a `const` holds. It was split, and the lazy wrapper called it without `this`. -- `codeSplitGroupings` is read through `const`s naming each other (`const chosen = groupings`), not only through one. -- Production source maps of Vite builds (Rollup and Rolldown) name every output of a route file by its path: a split chunk, a shared module or a server function's module no longer names its source `route.tsx?tsr-split=…`, so devtools show one file, breakpoints set in it bind, and error trackers group by it. Queries the compiler does not own stay, and an app's own `sourcemapPathTransform` still runs. diff --git a/.changeset/split-methods-this.md b/.changeset/split-methods-this.md deleted file mode 100644 index 98362ca4fa..0000000000 --- a/.changeset/split-methods-this.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-plugin': patch ---- - -Route options written as methods are code-split: `component() { … }`, `loader() { … }` and `async loader() { … }` split as `component: function () { … }` does (#8623). A function or method that uses its own `this` or `super` is not split: it stays in the route file as written, because splitting can change what `this` refers to, and the build warns at the option: use an arrow function or avoid `this` to split it (#8688). diff --git a/.changeset/split-wrapped-values-env-compile.md b/.changeset/split-wrapped-values-env-compile.md deleted file mode 100644 index 74df665b3d..0000000000 --- a/.changeset/split-wrapped-values-env-compile.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/router-plugin': patch ---- - -A split route option whose value sits in an `as` cast now carries the value into its chunk as each build compiled it. Before, a value Start compiles per environment (`loader: createIsomorphicFn().server(…).client(…) as any`, `createServerOnlyFn(…) as any`) reached the client chunk as written: the client build succeeded, shipped the server implementation and read an undeclared name. The same holds in development for a component route HMR keeps in the route module. diff --git a/.changeset/ssr-serverfn-one-instance.md b/.changeset/ssr-serverfn-one-instance.md deleted file mode 100644 index 7e2a2727c0..0000000000 --- a/.changeset/ssr-serverfn-one-instance.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@tanstack/router-utils': patch -'@tanstack/start-plugin-core': patch ---- - -On the server, each server function has one executing instance (its validator, middleware and module state), as before the compiler rewrite: a server function's handler module imports it from its file instead of copying it, and a split route chunk's copy of it is a caller, as in the browser, that reaches that instance through the server-function registry. diff --git a/.changeset/start-builder-escape-fixes.md b/.changeset/start-builder-escape-fixes.md deleted file mode 100644 index 386f1bb8f0..0000000000 --- a/.changeset/start-builder-escape-fixes.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Reading a server function or middleware builder's options by name (`base.options.method`, `const { method } = base.options`) no longer fails the client build; the options object passed on, written to, or its `middleware` list read still does, and now says to read options by name. Refusals give a fix that works for more shapes: a middleware kept in an object is told to stay in its own `const` and get its `.server()` there; an `.mdx` (or other non-JavaScript) module re-exporting a builder is told to import it from its own module, at the re-export's position also when the loader makes no source map; a factory returned from a getter or method is named. A Vue SFC statement that a later transform reprints over several lines is reported at its line and column in the SFC. diff --git a/.changeset/start-builder-escapes.md b/.changeset/start-builder-escapes.md deleted file mode 100644 index d6b22e1096..0000000000 --- a/.changeset/start-builder-escapes.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -'@tanstack/start-plugin-core': minor -'@tanstack/router-utils': patch -'@tanstack/router-plugin': patch ---- - -Start never ships server code to the client through a builder it cannot follow: each use of a Start builder or factory (`createServerFn`, `createMiddleware`, `createIsomorphicFn`, `createServerOnlyFn`, `createStart` and what they return) is either compiled or fails the client build with an error at that use. - -- **Newly compiled:** a Start namespace or start instance destructured (`const { createServerFn } = Start`, `const { createMiddleware } = createStart(…)`), `(0, createServerFn)()`, a builder chosen by `?:`, `??`, `||` or `&&` between two builders of the same kind, a factory with statements before its single `return`, a project namespace re-exported (`export * as ns`, `export { ns }`, `export default ns`) and read by member, a `let` builder reassigned with a builder of the same kind, a `const` list of middleware passed to `.middleware(list)`, `createServerFn.call(thisArg, options)`, a method called on a finished server fn, a builder merged with a type of the same name, and the JavaScript of `.mdx`, `.vue`, `.svelte`, `.astro` and `.marko` modules (their server functions are compiled in place; exporting an open builder from one is an error). -- **Now a client build error, at the use:** a builder or factory passed to a function, stored in an object, an array or a class field, assigned to a variable (`const b = a` is followed), awaited or rendered as a JSX prop; a method read off a builder (`const h = createServerFn().handler`, `.call`, `.bind`); a builder returned from a function with control flow, from an async function, a method or a getter; a `let` holding a builder reassigned with anything else; a builder destructured; a project namespace object passed around, when its module exports a builder; a builder in a TS `namespace`; a client-only `createIsomorphicFn().client(fn)` or `createMiddleware().client(fn)` passed to other code (use `createClientOnlyFn(fn)`); `renderServerComponent` or `createCompositeComponent` outside a server function; a route factory call other than the one bound to `Route` carrying `server`, `ssr` or `headers`. -- **A function parameter that reaches server code:** passed directly as the server code (`(fn) => createServerOnlyFn(fn)`, `({ handler }) => createMiddleware().server(handler)`, an isomorphic `.server(fn)`, `.validator(schema)`), it is a client build error at that use, since its argument is server code and every call keeps it on the client. Only read inside the server code (`(role) => createMiddleware().server(() => check(role))`), it gets one warning at its definition: the arguments of its calls still ship to the client, so do not pass secrets or server code through it. -- **Also fixed:** any import of a `server-only` or `client-only` marker marks the module, as does a top-level `import()` of it; a re-export cycle through `export *` resolves; on Rsbuild the compiler resolves imports with their `exports` conditions; a `name:` specifier behind an alias or a plugin is read. -- **Route options the compiler can't read build and warn:** a spread, options from a call or an import or written to after their declaration, and a computed key. What they hold isn't split or removed, so any server code in them ships to the client; the warning says what to write instead. A `server`, `ssr` or `headers` written next to a spread is still removed. An edit of a route whose whole options can't be read reloads the page. -- **Vue single-file components:** the script block (` - - -` - -// The configs import the harness plugin through a relative path so the app -// stays free of extra dependencies. The plugin is inert unless the harness -// sets COMPILER_PERF_HOOKS_OUT. -const startViteConfig = `import path from 'node:path' -import { defineConfig } from 'vite' -import viteReact from '@vitejs/plugin-react' -import { tanstackStart } from '@tanstack/react-start/plugin/vite' -import { hookTimingPlugin } from '../../scripts/hook-timing.mjs' - -export default defineConfig({ - cacheDir: path.resolve(import.meta.dirname, '.vite-cache'), - logLevel: 'warn', - clearScreen: false, - build: { outDir: process.env.COMPILER_PERF_OUT_DIR ?? 'dist' }, - plugins: [tanstackStart(), viteReact(), hookTimingPlugin()], -}) -` - -// tanstack.com's vite.config: a Rollup-style `manualChunks` function grouping -// Start's client runtime, which Rolldown merges into the entry -const startDepsViteConfig = startViteConfig.replace( - " build: { outDir: process.env.COMPILER_PERF_OUT_DIR ?? 'dist' },", - ` build: { - outDir: process.env.COMPILER_PERF_OUT_DIR ?? 'dist', - rollupOptions: { - output: { - manualChunks: (id: string) => - id.includes('/node_modules/@tanstack/react-start') || - id.includes('/node_modules/@tanstack/start-') - ? 'tanstack-start' - : undefined, - }, - }, - },`, -) - -/** - * The generated dependency graph of `react-start-deps`, written under the - * app's own node_modules: `@bench/icons` (a barrel of DEP_ICONS components, - * side-effect free, like an icon package), `@bench/utils` (a chain of - * DEP_UTILS modules each importing the next two) and `@bench/start-lib` (a - * Start library: a server function, a `` wrapper, a 2 MB `?url` - * asset, the utils chain). - */ -function dependencyFiles(rng) { - const files = new Map() - const pkg = (name, extra = {}) => - JSON.stringify( - { - name, - version: '1.0.0', - type: 'module', - exports: { '.': './index.js' }, - ...extra, - }, - null, - 2, - ) + '\n' - files.set( - 'node_modules/@bench/icons/package.json', - pkg('@bench/icons', { sideEffects: false }), - ) - const barrel = [] - for (let n = 0; n < DEP_ICONS; n++) { - const id = pad4(n) - barrel.push(`export { Icon${id} } from './icons/Icon${id}.js'`) - files.set( - `node_modules/@bench/icons/icons/Icon${id}.js`, - `import { jsx } from 'react/jsx-runtime' -export function Icon${id}(props) { - return jsx('svg', { 'data-icon': '${id}', viewBox: '0 0 ${rng.int(8, 64)} 16', ...props }) -} -`, - ) - } - files.set('node_modules/@bench/icons/index.js', barrel.join('\n') + '\n') - files.set('node_modules/@bench/utils/package.json', pkg('@bench/utils')) - files.set( - 'node_modules/@bench/utils/index.js', - `export { u0000 as util } from './u0000.js'\n`, - ) - for (let n = 0; n < DEP_UTILS; n++) { - const id = pad4(n) - const next = [(n + 1) % DEP_UTILS, (n + 2) % DEP_UTILS].map(pad4) - files.set( - `node_modules/@bench/utils/u${id}.js`, - `import { u${next[0]} } from './u${next[0]}.js' -import { u${next[1]} } from './u${next[1]}.js' -export function u${id}(depth) { - return depth <= 0 ? ${rng.int(1, 999)} : u${next[0]}(depth - 1) + u${next[1]}(depth - 2) -} -`, - ) - } - files.set( - 'node_modules/@bench/start-lib/package.json', - pkg('@bench/start-lib'), - ) - // a binary asset a bundler serves by URL: never code, never read as text - let blob = '' - for (let i = 0; i < 2 * 1024 * 1024; i++) { - blob += String.fromCharCode(rng.int(1, 255)) - } - files.set('node_modules/@bench/start-lib/engine.wasm', blob) - files.set( - 'node_modules/@bench/start-lib/index.js', - `import { jsx } from 'react/jsx-runtime' -import { createServerFn } from '@tanstack/react-start' -import { ClientOnly } from '@tanstack/react-router' -import { util } from '@bench/utils' -import engineUrl from './engine.wasm?url' - -export const libStats = createServerFn({ method: 'GET' }).handler(async () => { - return { engine: engineUrl.length, depth: util(6) } -}) - -export function LibBadge({ label }) { - return jsx(ClientOnly, { - fallback: null, - children: jsx('span', { 'data-lib': engineUrl, children: label + util(3) }), - }) -} -`, - ) - return files -} - -const routerViteConfig = `import path from 'node:path' -import { defineConfig } from 'vite' -import viteReact from '@vitejs/plugin-react' -import { tanstackRouter } from '@tanstack/router-plugin/vite' -import { hookTimingPlugin } from '../../scripts/hook-timing.mjs' - -export default defineConfig({ - cacheDir: path.resolve(import.meta.dirname, '.vite-cache'), - logLevel: 'warn', - clearScreen: false, - build: { outDir: process.env.COMPILER_PERF_OUT_DIR ?? 'dist' }, - plugins: [ - tanstackRouter({ target: 'react', autoCodeSplitting: true }), - viteReact(), - hookTimingPlugin(), - ], -}) -` - -const startRsbuildConfig = `import { defineConfig } from '@rsbuild/core' -import { pluginReact } from '@rsbuild/plugin-react' -import { tanstackStart } from '@tanstack/react-start/plugin/rsbuild' - -export default defineConfig({ - logLevel: 'warn', - plugins: [pluginReact(), tanstackStart()], - output: { - distPath: { root: process.env.COMPILER_PERF_OUT_DIR ?? 'dist-rsbuild' }, - cleanDistPath: true, - }, - performance: { printFileSize: false }, -}) -` - -const solidHydratedMarker = ` onMount(() => { - ;(window as any).__PERF_HYDRATED__ = performance.timeOrigin + performance.now() - })` - -const solidStartRootSource = `import { onMount } from 'solid-js' -import type { JSX } from 'solid-js' -import { HydrationScript } from 'solid-js/web' -import { HeadContent, Outlet, Scripts, createRootRoute } from '@tanstack/solid-router' -import { Nav } from '../components/Nav' - -export const Route = createRootRoute({ - head: () => ({ - meta: [{ charSet: 'utf-8' }, { title: 'Compiler perf app' }], - }), - component: RootComponent, - notFoundComponent: () =>

Not found

, -}) - -function RootComponent() { - return ( - - - - ) -} - -function RootDocument(props: { children: JSX.Element }) { -${solidHydratedMarker} - return ( - - - - - - -