feat(route-modules): install route-module behavior with createRouteModuleRouter #8845
Open
schiller-manuel(GitHub profile, opens in a new tab)wants to merge 1 commit into
monorepo fromroute-modules-router-factory·opened Showing 51 changed files with 5 additions and 5 deletions (loading 48).
x
@@ -5,4 +5,4 @@
-Experimental: Add route modules: workspace packages that own a subtree of file-based routes and are mounted into applications or other modules. The generated host route tree mounts a module root under a host route and type-checks the mount: a static mount path, no required search params above the module, the router context the module requires, and serializable lifecycle results in server-rendered applications. Module routes, links, navigation, redirects and hooks come from the module's generated route scope and take module-local paths and qualified route ids wherever the module is mounted; `getRouteApi` and route-bound hooks resolve the nearest installation. A module mounted under path params keeps the params of the current location in its own links, and `HostedRouter` types the links of code that mounts it. A module installed several times gets one copy of its routes per installation, with ids `<package>#<as>:/…`; module-local ids, destinations, redirects and not-found errors resolve to the installation of the route that uses them, and `InstallationRoutesById` types an installation's routes. Matches of module routes carry `localRouteId`, the installation-independent id, and the generated `isScopedMatch` guard narrows whole-router matches to the routes of a scope. Applications without route modules are unaffected.
+Experimental: Add route modules: workspace packages that own a subtree of file-based routes and are mounted into applications or other modules. Applications that mount modules create their router with `createRouteModuleRouter`, which takes the options of `createRouter` and installs the route-module behavior of the router and its links; in development, `createRouter` rejects route trees with mounted modules and options from generated module APIs. The generated host route tree mounts a module root under a host route and type-checks the mount: a static mount path, no required search params above the module, the router context the module requires, and serializable lifecycle results in server-rendered applications. Module routes, links, navigation, redirects and hooks come from the module's generated route scope and take module-local paths and qualified route ids wherever the module is mounted; `getRouteApi` and route-bound hooks resolve the nearest installation. A module mounted under path params keeps the params of the current location in its own links, and `HostedRouter` types the links of code that mounts it. A module installed several times gets one copy of its routes per installation, with ids `<package>#<as>:/…`; module-local ids, destinations, redirects and not-found errors resolve to the installation of the route that uses them, and `InstallationRoutesById` types an installation's routes. Matches of module routes carry `localRouteId`, the installation-independent id, and the generated `isScopedMatch` guard narrows whole-router matches to the routes of a scope. Applications without route modules are unaffected.
2 additions and 2 deletions+2-2benchmarks/bundle-size/scenarios/react-router-route-modules/src/main.tsxModifiedView file
@@ -1,8 +1,8 @@
-import { RouterProvider, createRouter } from '@tanstack/react-router'
+import { RouterProvider, createRouteModuleRouter } from '@tanstack/react-router'
-const router = createRouter({ routeTree })
+const router = createRouteModuleRouter({ routeTree })
2 additions and 2 deletions+2-2benchmarks/bundle-size/scenarios/react-start-route-modules/src/router.tsxModifiedView file
@@ -1,8 +1,8 @@
-import { createRouter } from '@tanstack/react-router'
+import { createRouteModuleRouter } from '@tanstack/react-router'
- return createRouter({
+ return createRouteModuleRouter({