Merging the lockfiles of main and the route-modules commits left it
inconsistent. Regenerate it with pnpm 12 from the pre-rebase lockfile,
so every importer, including the route-modules fixtures, keeps one Vite
with the Start packages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A mask is built in the scope of its destination. Start requirements cannot be
certified by `any` or `never` fields, a route's `server.middleware` list is
not validated against them, and a module's own fragment context is not
protected against later modules.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The large example's modules and the benchmark's modules use other modules;
their declaration builds now include `.tanstack/route-types-stubs.d.ts` as
documented, so they need no order among the modules. The example ignores the
generated namespace files and client views.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The react-start fixture's team module uses settings but built its
declarations against the real contract, relying on publish order. Its
declaration build now includes the generated stand-ins like the react-router
fixture, so the probe for a used module's local paths moved to the source
check, which reads the real contract.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The tree-shaking check listed six APIs that have no binder and never asserted
that the names it looks for exist; it now lists the bound APIs and requires
the Link binder in the Link bundle. The validation alias type tests pass the
foreign value to the alias instead of a mismatching literal. The header
variants assert the generated headers. Two assertions that could not fail
are gone. The suites share their check and emit expectations, content hashes
come from the workspace, and the declaration build against the real contracts
is one helper.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The mask-scope check hoisted a read of the options' scope above the binding
condition, which kept 27 bytes of it in every application bundle. Both reads
sit inside the conditions again, so applications without route modules drop
them.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The React, Solid and Vue Start packages ran the same 370-line fixture with
six differing constants; the fixture now lives in start-plugin-core's tests
and each package defines it for its own plugins.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Applications that register no route-module requirement no longer walk their
local middleware chains at every `.server()` and `.handler()`; the installed
ids of a module list are computed once instead of once per required module;
the consumer id and middleware-owner unions are spelled once.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The context validation rejected a whole `any` context but accepted a required
field typed `any` or `never`, since both are assignable to the requirement.
Such fields are now reported, at the application and before a local consumer.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A scoped `MatchRoute` can receive options whose scope is resolved later, an
object rather than a module id; the prop no longer warns about it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The eight id-based binders (`getRouteApi`, `useMatch`, `useLoaderData`,
`useLoaderDeps`, `useSearch`, `useParams`, `useRouteContext`, `notFound`) were
spelled out in each framework; they now delegate to one core helper that maps
module-local ids to the installation. The unused `FileRoutesByPathEntry` type
is dropped.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Scoped `Link`, `createLink`, `Navigate` and `MatchRoute` spread their props
proxy to add the module scope. Solid resolves such a spread in one memo, so
every prop, children included, depended on every other: a params change
re-created the children and replaced the element. The scope is now merged as
a lazy getter over the props, as the scoped `useLinkProps` already did, with
the core's scope resolution exported for it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The id is set once the options or their mask carry a scope, which the
preceding check establishes; the build did not see that.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The generator's pruning and Start's client tree each spelled out when a
route has only a `server` option; the generator now exports the predicate.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The Vite client plugin resolved every relative import a second time to look
for a mounted module's route tree, and the Rspack replacement hook ran for
every module; both now return early while no module has a client view. The
Rspack transform resolves the generated route tree path once.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The webpack adapter read the id of the uninitialized replacement Route first:
a module root (and a file route before its parent is assigned) reads as a root,
so the hot update patched the application root with the module root's options.
The generated id now comes first, hot data second, as in the Vite adapter.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A route module's root is created with `createModuleRoot()({ ... })` from the
module's generated scope. The code splitter's file filter and its root-route
list did not know the factory, so module roots never got an HMR statement, and
Start client builds kept their `ssr`, `server` and `headers` options with their
server-only imports.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`bindRouteScopeOptions` returns the options unchanged when they already carry
the scope they are bound to, instead of copying them on every scoped link
build.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Addressing a module by its id when its only installation is named said the
module was installed several times. The development message now lists the
installation names.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The client not-found boundary resolved the module-local target id inside
`findIndex`, once per match; it now resolves it once like the server lane.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A module-scoped mask on an application destination (`settings.linkOptions`
as the `mask` of an application `Link`) type-checks but was resolved as an
application path. It is now rejected in development like a mask from another
module on a module destination, through the same scope resolution, which no
longer allocates an options copy for the check.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A module is installed once, or several times under names. Mounting the same
root unnamed and then named reinitialized the unnamed installation against
the template host, so its routes no longer matched; the reverse order made
module-local ids resolve to the unnamed copy. `mountRouteModule` now rejects
the mix the way the generator does, while mounting the same installation
again, as hot updates do, stays allowed.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The core keeps the route-module behavior (module-root id, id resolution,
location scoping, navigation scope) in one never-assigned `routeModules`
binding instead of four; every read site branches on that one binding, so
applications without route modules still drop it entirely. Module roots and
mounts install it: the module-root factory of a generated scope installs the
core behavior and the framework's link options when the root is created, and
`mountRouteModule` installs the core behavior. Binding a scope API or building
options installs nothing anymore, so every generated `/* @__PURE__ */` binder
call is pure. A module option built without any installed module is named in
development; production keeps no check.
Adopts the binding and binder parts of TanStack/router#8845 without the
`createRouteModuleRouter` factory.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The stand-in include of the declaration build, `uses` through namespaces in
both directions, the generated files table and the Nx and Turborepo task
wiring for used modules.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
products uses account and storefront, account uses products, through peer
dependencies and explicit Nx task dependencies; the declaration builds
include the generated stand-ins. The suite generates and emits in every
order, checks that stand-ins and real contracts emit identical declarations
and asserts the leak boundary of a type imported from a used module.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The mount path row already shows a module's root; its route list no longer
repeats it. The panel's matches are memoized, and the tests cover a module
installed several times.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A route module links into the modules it uses through generated namespaces;
its declaration build compiles against stand-ins for their contracts, so a
type imported from a used module would be emitted with the stand-in's types.
The rule now reports every import from a module listed in `uses` (values,
types, re-exports and dynamic imports) and covers `useLinkProps`,
`useBlocker`, `notFound` and `createMiddleware`. Package declarations are
read once per package.json and revalidated by mtime.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`uses` is a contract relation: generation reads only the used package's
package.json (dependencies, devDependencies or peerDependencies), never its
manifest, so two modules can use each other and a module can use the module
that includes it. The declaration build compiles against generated stand-ins
for the used contracts (`.tanstack/route-types-stubs.d.ts`); the contract
(`routeContract.gen.ts`) now declares the module's register and router and
reaches only the module's own files, the framework and the contracts of
included modules. Include cycles are rejected with a diagnostic.
Generated files are kept in sync: files that are not generated anymore are
removed, also when a package stops being a route module, and a generated
file deleted or edited in watch mode is regenerated. Every generated file is
written atomically through the generator's file system. Generated namespaces
and contracts import only what they use, so `noUnusedLocals` passes on them.
Diagnostics name a single named installation instead of "several times".
The route-module context no longer carries derivable state (installations,
manifests, watch-file lists); mount placement is resolved once per build.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Its declaration referenced the namespace type through import('.'),
which Node16 ESM resolution rejects.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`Link` and `useNavigate` added the nearest route to every navigation,
read the match context and listed the route-module options, although
only the route-module translation reads them. They now do so only when
route-module code installed that translation, which it does before an
application renders, and the framework links learn the internal scope
options (`_module`, `_fromRoute`) from route-module code. Without route
modules the branches fold away, as do the not-found boundary's module
resolution and `buildLocation`'s options alias.
With Vite, react-router.minimal, react-start.minimal and the minimal
Solid scenarios now match main byte for byte. Rsbuild does not fold the
never-assigned hooks and keeps the module branches.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`routeScopeNamespaceFiles` places the generated namespace files of a
route scope: 'indexed' (default, `routeScope.gen.namespace<N>.ts`),
'named' (`routeScope.gen.<namespace>.ts`), 'folder'
(`routeScope.gen/<namespace>.ts`) or a function returning the path
relative to the route tree's directory.
Namespace files import the route tree from their own location. Paths
must stay inside the generated directory and outside the routes
directory, and differ in more than letter case. Changing the layout
removes the files of the previous one, which the previous scope file
lists.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add `react-router.route-modules` and `react-start.route-modules`: the
minimal application with a small workspace route module mounted at
`/feature`, linked through its namespace and reading the router through
the module's scope. Each scenario generates the module before building.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Applications without route modules still bundled the module branches of
the core and the framework route APIs: `buildLocation`'s module-local
translation, `getRouteNavigationScope` in every route's `redirect`,
`useNavigate` and `Link`, and the module-root id in route init.
- router-core: route-module code installs these as hooks
(`route-module-hooks.ts`) from `mountRouteModule`, module roots and
scoped options. They are never assigned without route modules, so
bundlers drop every branch that reads them. The per-module check of
the translation reports a module that is used but not installed.
- useNavigate passes its route-module defaults through without naming
them; Link no longer lists the constant `_fromRoute` as a dependency.
- router-generator: scopes export the framework's own APIs where the
scope binds nothing (`useMatches`, `useLocation`, `useRouterState`,
`useBlocker`, ... and the id-based APIs outside one installation of a
module installed several times) instead of calling a binder.
react-router.minimal: -87 B gzip, react-start.minimal: -122 B gzip
against the previous head.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The workspace-wide `pnpm dedupe` also upgraded unrelated tooling: Rsbuild
and Rspack for the bundle-size benchmark, and @typescript-eslint/utils
apart from its rule tester, which broke the eslint plugin's build.
Restore the previous resolution and give Vite's optional sass peer one
version from the workspace root, the one the Start plugins already used,
so every application shares their Vite instance.
Also look up mounted module route files by their forward-slash keys in
the remaining generator tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Move the route-module bundler tests out of start-plugin-core into
react-start, solid-start and vue-start, which test their own public
Vite and Rsbuild plugins against their build. Upstream packages no
longer need downstream builds.
- Move the Start namespace alias test from router-generator into the
React Start route-modules fixture, which publishes real Start modules.
- Generate into each temporary workspace's own tmpDir: renaming from the
cwd-relative default failed across devices on CI.
- React Router route-modules fixture: declare that the web build needs
the modules' generate and emit-types tasks, and depend on the web
package so its tools are built before the fixture's tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- start-plugin-core: the client route tree plugin sent a full reload on
every route tree change, so adding or removing a route option such as
`loader` or `beforeLoad` discarded client state instead of hot updating.
Reload only when the routes the client keeps change: the application's
pruned tree, the provider tree mapping or a provider's client tree.
- router-generator: key mounted module route files with forward slashes
like the package's own route files. The router plugin looks them up by
normalized module id, so on Windows module routes missed HMR and code
splitting.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The route-modules importers resolved Vite with a different optional
sass peer than the Start plugins, so the dev server got a second Vite
instance, failed the RunnableDevEnvironment check and never installed
the SSR middleware: every page answered "Cannot GET". Dedupe the
lockfile so all importers share one Vite, keeping prettier and
tinyglobby at their previous versions.
Also import the route-modules config with its extension, which Vite's
native config loader requires.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Group the profile page's API probes into labeled Match, Links and
Navigation sections and give them spacing. Point the framework Link
probes and the React deferred members link at orgs the fixtures
actually use instead of arbitrary ids, and style the installation
switcher in the React fixture.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Route modules are workspace packages that own a subtree of file-based routes and are mounted into applications or other modules. A package declares `tanstack.router.module` in its package.json. The generator gives it qualified route ids (`<pkg>:<path>`), a generated route scope (`routeScope.gen.ts` plus one namespace file per included or used module), a public contract (`routeContract.gen.ts`, exported as `./route-types` after the package's own declaration build), a runtime entry (`routeModule.gen.ts`, exported as `./route-module`) and a topology manifest (`.tanstack/route-module.json`). Includers mount modules with the `routeModules` option: `includes` chooses the host route and mount path, optionally under path params, `uses` references modules mounted elsewhere, and an application installs a module several times by including it once per installation named with `as`, each with its own namespace and route ids (`<pkg>#<as>:<path>`). Matches of module routes carry `localRouteId`, and the generated `isScopedMatch` guard narrows whole-router matches by module id prefix.
Runtime: the generated host tree mounts module roots with the internal `mountRouteModule`; module-local ids, destinations, redirects and not-found errors resolve to the installation of the route that uses them; `HostedRouter` types the links of code that mounts modules under path params. Type composition is contract-based through `./route-types`; the framework packages augment `@tanstack/router-core/extensions` and export `RouteCore`.
Start: modules get `createServerFn`, `createMiddleware` and `createStartModule` in their scope, declare required context by augmenting `StartModuleRequirements`, and contribute fragments that applications install with `createStart(() => ({ extends: startModules }))`; `startModules.gen.ts` type-checks installation and requirements. The Start plugin lists module routes in the routes manifest, selects the providers' client tree views, discovers prerenderable module pages and extends import protection to module packages.
Build and tooling: the host bundler compiles, code-splits and hot-updates module routes, including every installation; `tsr generate` and `tsr watch` are the only commands and packages own their declaration builds; the devtools show modules; the `route-module-imports` ESLint rule enforces scope imports. Fixtures cover React, Solid, Vue and Start with Vite and Rsbuild, and a large example measures builds.
* chore(pnpm): upgrade to pnpm 12
* ci: use native pnpm 12 bootstrap for compiler jobs
* fix(benchmarks): invoke the Nx CLI directly
* refactor(benchmarks): run Nx through pnpm exec
#8889 wrote the Rsbuild dev manifest with the eager `paths.manifest`.
#8868, merged after it, replaced `paths` with the lazy `pathsOf()`, which
builds the virtual paths from the resolved root on first use. Neither PR
saw the other, so main fails to type-check with "Cannot find name 'paths'".
Read the manifest path through `pathsOf()`, like every other use.
`updateManifest` runs after a client compile, so the root is resolved by
then, and the path is the same one `manifestPath` returns for the RSC
manifest rebuild.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A chunk counted as a static dependency of a shared chunk when any one of
the shared chunk's groups had it. When two routes share a module in a
chunk of its own and a module that module imports is duplicated into each
route's chunk, the shared chunk depended on both route chunks, so each
route's manifest entry preloaded the other route's chunk and linked its
stylesheet. A chunk now counts as available only when every group of the
shared chunk (or one of its ancestors) has it.
Taken from #8817.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(start-plugin-core): write Rsbuild virtual modules under the app's root
The Rsbuild plugin read `resolvedStartConfig.root || process.cwd()` at
setup, before `modifyRsbuildConfig` resolves the root, so Start's virtual
modules always went under `<cwd>/node_modules/.virtual`. Run from another
directory (`rsbuild build --root <app>` from a monorepo root), the packages
those modules import did not resolve there: an RSC app failed with "Module
not found" on its serialization adapters. The virtual paths are now built
from the resolved root when the first Rspack config is built.
From #8817.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(start-plugin-core): resolve a relative Rsbuild root before building virtual paths
Rsbuild accepts a relative `root` (resolved against its `cwd`) but passes
it to `modifyRsbuildConfig` as written. Start stored it as is, so the
virtual modules' paths were relative and resolved against each importer:
the build failed with "Module not found". Take Rsbuild's resolved
`api.context.rootPath` unless the root is already absolute.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(start-plugin-core): leave the temporary working directory before removing it
`onTestFinished` callbacks run last first, so the directory was removed
while it was still the working directory, which Windows refuses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(start-plugin-core): use a canonical Rsbuild root for the virtual modules' paths
Rsbuild keeps `root` as written, trailing separator included (`/app/`,
and `rootPath` of a relative `app/`), so the virtual paths had `//` while
Rspack's module identifiers have one separator: the dev rebuild of the
server-fn resolver (substring match) skipped it. Resolve the root.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(start-plugin-core): the relative-root Rsbuild app renders its index page
The test only checked that the build finished. Render `/` through the
built server's `fetch` handler, which also reads the server manifest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(start-plugin-core): derive server-fn ids from the stable key, with 22-character defaults
`serverFns.generateFunctionId` now receives the server function's
stable name (`greetUser`) as `functionName` instead of the generated
handler name (`greetUser_createServerFn_handler`). Repeats of the same
variable name in one file get `#1`, `#2`, ...
Default production ids are the first 22 base64url characters of the
SHA256 of `<file>#<stable key>` instead of the full 64-character hex
digest.
Split out of #8817, which derives ids the same way.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(start-plugin-core): keep generateFunctionId's handler-name input, reject custom ids that aren't one URL path segment
Follows #8817's current id contract:
- `generateFunctionId` receives the generated handler name again
(`greetUser_createServerFn_handler`, `_1`, `_2`… for repeats), with
characters outside `[A-Za-z0-9_$]` as `_`. The handler export keeps its
name.
- The default id stays 22 base64url characters of
`sha256("<root-relative file>#<variable name>")`, `#n` for repeats.
- A custom id outside RFC 3986's unreserved characters and `$` (or `.`,
`..`, empty) fails the build, naming the file, the function and the id.
- The e2e id maps return to main's keys.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(start-plugin-core): a repeated server function name loses leading and doubled underscores
The generator's `functionName` for a repeated name goes through the old
increment rule, which strips leading underscores and collapses runs of
underscores (a second `_x` gets `x_createServerFn_handler_1`). Say so,
and pin it with `_x` twice and `café` then `caf_`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(start-plugin-core): names that become equal after the `_` replacement get suffixes too
`café` and `caf_` both give `caf__createServerFn_handler`, so the later
one gets `caf_createServerFn_handler_1`, like a repeated variable name.
Describe the replacement first, then the suffix rule for any resulting
duplicate.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(start-plugin-core): keep main's server-fn ids; refuse custom ids that never worked over HTTP
#8817 now prints main's default ids and passes main's functionName to
generateFunctionId, so this reverts the shorter default ids, the
generator-name split and the empty-id failure. What stays is #8817's
custom-id check: an id the URL never carries whole fails the build, one
with other characters outside the unreserved set and $ builds with a
deprecation warning, and the resolver manifest escapes a `'` in an id.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>