diff --git a/.github/labeler.yml b/.github/labeler.yml index 16ac3b06ef..fe89bd8c8d 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -14,26 +14,12 @@ - 'packages/react-router-with-query/**/*' 'package: react-start': - 'packages/react-start/**/*' -'package: start-api-routes': - - 'packages/start-api-routes/**/*' 'package: react-start-client': - 'packages/react-start-client/**/*' -'package: react-start-config': - - 'packages/react-start-config/**/*' 'package: react-start-plugin': - 'packages/react-start-plugin/**/*' -'package: react-start-router-manifest': - - 'packages/react-start-router-manifest/**/*' 'package: react-start-server': - 'packages/react-start-server/**/*' -'package: start-server-functions-client': - - 'packages/start-server-functions-client/**/*' -'package: start-server-functions-fetcher': - - 'packages/start-server-functions-fetcher/**/*' -'package: start-server-functions-handler': - - 'packages/start-server-functions-handler/**/*' -'package: start-server-functions-ssr': - - 'packages/start-server-functions-ssr/**/*' 'package: router-cli': - 'packages/router-cli/**/*' 'package: router-core': @@ -60,18 +46,20 @@ - 'packages/solid-start/**/*' 'package: solid-start-client': - 'packages/solid-start-client/**/*' -'package: solid-start-config': - - 'packages/solid-start-config/**/*' 'package: solid-start-plugin': - 'packages/solid-start-plugin/**/*' -'package: solid-start-router-manifest': - - 'packages/solid-start-router-manifest/**/*' 'package: solid-start-server': - 'packages/solid-start-server/**/*' -'package: start': - - 'packages/start/**/*' -'package: start-config': - - 'packages/start-config/**/*' +'package: start-client-core': + - 'packages/start-client-core/**/*' +'package: start-plugin-core': + - 'packages/start-plugin-core/**/*' +'package: start-server-core': + - 'packages/start-server-core/**/*' +'package: start-server-functions-client': + - 'packages/start-server-functions-client/**/*' +'package: start-server-functions-fetcher': + - 'packages/start-server-functions-fetcher/**/*' 'package: start-server-functions-server': - 'packages/start-server-functions-server/**/*' 'package: valibot-adapter': diff --git a/.gitignore b/.gitignore index 5cc3e94113..d2b926625e 100644 --- a/.gitignore +++ b/.gitignore @@ -61,12 +61,14 @@ nx-cloud.env gpt/db.json app.config.timestamp-* +vite.config.timestamp-* vite.config.js.timestamp-* vite.config.ts.timestamp-* app.config.js.timestamp-* app.config.ts.timestamp-* app.config.timestamp_* +vite.config.timestamp_* vite.config.js.timestamp_* vite.config.ts.timestamp_* app.config.js.timestamp_* @@ -76,4 +78,5 @@ app.config.ts.timestamp_* # Handling VSCode settings /.vscode/ -!/examples/react/**/.vscode/settings.json \ No newline at end of file +!/examples/react/**/.vscode/settings.json +**/.tanstack-start/build \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index d285f8937d..25c93015ed 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,7 +7,6 @@ pnpm-lock.yaml **/snapshots **/.vercel -**/.vinxi **/.output **/node_modules node_modules diff --git a/docs/router/api/file-based-routing.md b/docs/router/api/file-based-routing.md index 0e165665c0..777d9f3116 100644 --- a/docs/router/api/file-based-routing.md +++ b/docs/router/api/file-based-routing.md @@ -132,19 +132,6 @@ By default, this value is set to `false`. > [!TIP] > You should ignore the path of your generated route tree file from your linter and formatter to avoid conflicts. -### `apiBase` - -As a framework, [TanStack Start](/start) supports the concept of API routes. This option configures the base path for API routes. - -By default, this value is set to `/api`. - -This means that all API routes will be prefixed with `/api`. - -This configuration value is only useful if you are using TanStack Start. - -> [!IMPORTANT] -> This default value may conflict with your own project's routing if you planned on having a normal route with the same base path. You can change this value to avoid conflicts. - ### `autoCodeSplitting` This feature is only available is you are using the TanStack Router Bundler Plugin. diff --git a/docs/router/eslint/create-route-property-order.md b/docs/router/eslint/create-route-property-order.md index 3ce5102013..c0fee218d2 100644 --- a/docs/router/eslint/create-route-property-order.md +++ b/docs/router/eslint/create-route-property-order.md @@ -29,7 +29,7 @@ Examples of **incorrect** code for this rule: /* eslint "@tanstack/router/create-route-property-order": "warn" */ import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/foo/bar/$id')({ +export const Route = createFileRoute({ loader: async ({context}) => { await context.queryClient.ensureQueryData(getQueryOptions(context.hello)), }, @@ -43,7 +43,7 @@ Examples of **correct** code for this rule: /* eslint "@tanstack/router/create-route-property-order": "warn" */ import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/foo/bar/$id')({ +export const Route = createFileRoute({ beforeLoad: () => ({hello: 'world'}), loader: async ({context}) => { await context.queryClient.ensureQueryData(getQueryOptions(context.hello)), diff --git a/docs/router/framework/react/api/router/createFileRouteFunction.md b/docs/router/framework/react/api/router/createFileRouteFunction.md index 945e713075..0986d6ccff 100644 --- a/docs/router/framework/react/api/router/createFileRouteFunction.md +++ b/docs/router/framework/react/api/router/createFileRouteFunction.md @@ -26,7 +26,7 @@ A new function that accepts a single argument of type [`RouteOptions`](./RouteOp ```tsx import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ loader: () => { return 'Hello World' }, diff --git a/docs/router/framework/react/api/router/retainSearchParamsFunction.md b/docs/router/framework/react/api/router/retainSearchParamsFunction.md index 97e411b29c..d4bc185203 100644 --- a/docs/router/framework/react/api/router/retainSearchParamsFunction.md +++ b/docs/router/framework/react/api/router/retainSearchParamsFunction.md @@ -39,7 +39,7 @@ const searchSchema = z.object({ two: z.string().optional(), }) -export const Route = createFileRoute('/hello')({ +export const Route = createFileRoute({ validateSearch: zodValidator(searchSchema), search: { middlewares: [retainSearchParams(true)], diff --git a/docs/router/framework/react/api/router/stripSearchParamsFunction.md b/docs/router/framework/react/api/router/stripSearchParamsFunction.md index 05b9b02e7f..439a1796d2 100644 --- a/docs/router/framework/react/api/router/stripSearchParamsFunction.md +++ b/docs/router/framework/react/api/router/stripSearchParamsFunction.md @@ -30,7 +30,7 @@ const searchSchema = z.object({ two: z.string().default(defaultValues.two), }) -export const Route = createFileRoute('/hello')({ +export const Route = createFileRoute({ validateSearch: zodValidator(searchSchema), search: { // strip default values @@ -68,7 +68,7 @@ const searchSchema = z.object({ two: z.string().default('xyz'), }) -export const Route = createFileRoute('/hello')({ +export const Route = createFileRoute({ validateSearch: zodValidator(searchSchema), search: { // remove all search params diff --git a/docs/router/framework/react/decisions-on-dx.md b/docs/router/framework/react/decisions-on-dx.md index 405db4c6eb..a38716f624 100644 --- a/docs/router/framework/react/decisions-on-dx.md +++ b/docs/router/framework/react/decisions-on-dx.md @@ -225,7 +225,7 @@ Let's take a look at how the route configuration for the previous example would // src/routes/posts/index.ts import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: () => 'Posts index component goes here!!!', }) ``` diff --git a/docs/router/framework/react/guide/external-data-loading.md b/docs/router/framework/react/guide/external-data-loading.md index e2d0e1eb53..2b1ebf78f1 100644 --- a/docs/router/framework/react/guide/external-data-loading.md +++ b/docs/router/framework/react/guide/external-data-loading.md @@ -48,7 +48,7 @@ Here is a naive illustration (don't do this) of using a Route's `loader` option // src/routes/posts.tsx let postsCache = [] -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: async () => { postsCache = await fetchPosts() }, @@ -80,7 +80,7 @@ const postsQueryOptions = queryOptions({ queryFn: () => fetchPosts(), }) -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ // Use the `loader` option to ensure that the data is loaded loader: () => queryClient.ensureQueryData(postsQueryOptions), component: () => { @@ -105,7 +105,7 @@ export const Route = createFileRoute('/posts')({ When an error occurs while using `suspense` with `Tanstack Query`, you'll need to let queries know that you want to try again when re-rendering. This can be done by using the `reset` function provided by the `useQueryErrorResetBoundary` hook. We can invoke this function in an effect as soon as the error component mounts. This will make sure that the query is reset and will try to fetch data again when the route component is rendered again. This will also cover cases where users navigate away from our route instead of clicking the `retry` button. ```tsx -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: () => queryClient.ensureQueryData(postsQueryOptions), errorComponent: ({ error, reset }) => { const router = useRouter() diff --git a/docs/router/framework/react/guide/router-context.md b/docs/router/framework/react/guide/router-context.md index 561b1e2f00..f54e7a7b23 100644 --- a/docs/router/framework/react/guide/router-context.md +++ b/docs/router/framework/react/guide/router-context.md @@ -92,7 +92,7 @@ Once you have defined the router context type, you can use it in your route defi ```tsx // src/routes/todos.tsx -export const Route = createFileRoute('/todos')({ +export const Route = createFileRoute({ component: Todos, loader: ({ context }) => fetchTodosByUserId(context.user.id), }) @@ -122,7 +122,7 @@ Then, in your route: ```tsx // src/routes/todos.tsx -export const Route = createFileRoute('/todos')({ +export const Route = createFileRoute({ component: Todos, loader: ({ context }) => context.fetchTodosByUserId(context.userId), }) @@ -158,7 +158,7 @@ Then, in your route: ```tsx // src/routes/todos.tsx -export const Route = createFileRoute('/todos')({ +export const Route = createFileRoute({ component: Todos, loader: async ({ context }) => { await context.queryClient.ensureQueryData({ @@ -234,7 +234,7 @@ So, now in our route's `loader` function, we can access the `networkStrength` ho ```tsx import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ component: Posts, loader: ({ context }) => { if (context.networkStrength === 'STRONG') { @@ -282,7 +282,7 @@ const router = createRouter({ ```tsx import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/todos')({ +export const Route = createFileRoute({ component: Todos, beforeLoad: () => { return { diff --git a/docs/router/framework/react/guide/tanstack-start.md b/docs/router/framework/react/guide/tanstack-start.md index 9704d721c4..a56a204e28 100644 --- a/docs/router/framework/react/guide/tanstack-start.md +++ b/docs/router/framework/react/guide/tanstack-start.md @@ -47,15 +47,12 @@ TanStack Start is powered by the following packages and need to be installed as - [@tanstack/start](https://github.com/tanstack/start) - [@tanstack/react-router](https://tanstack.com/router) -- [Vinxi](https://vinxi.vercel.app/) - -> [!NOTE] -> Vinxi is a temporary dependency that will be replaced by a simple vite plugin or a dedicated Start CLI. +- [Vite](https://vite.dev/) To install them, run: ```shell -npm i @tanstack/react-start @tanstack/react-router vinxi +npm i @tanstack/react-start @tanstack/react-router vite ``` You'll also need React and the Vite React plugin, so install their dependencies as well: @@ -72,16 +69,16 @@ npm i -D typescript @types/react @types/react-dom # Update Configuration Files -We'll then update our `package.json` to use Vinxi's CLI and set `"type": "module"`: +We'll then update our `package.json` to use Vite's CLI and set `"type": "module"`: ```jsonc { // ... "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start", + "dev": "vite dev", + "build": "vite build", + "start": "vite start", }, } ``` @@ -97,12 +94,10 @@ export default defineConfig({}) # Add the Basic Templating -There are four required files for TanStack Start usage: +There are 2 required files for TanStack Start usage: 1. The router configuration -2. The server entry point -3. The client entry point -4. The root of your application +2. The root of your application Once configuration is done, we'll have a file tree that looks like the following: @@ -111,10 +106,8 @@ Once configuration is done, we'll have a file tree that looks like the following ├── app/ │ ├── routes/ │ │ └── `__root.tsx` -│ ├── `client.tsx` │ ├── `router.tsx` │ ├── `routeTree.gen.ts` -│ └── `ssr.tsx` ├── `.gitignore` ├── `app.config.ts` ├── `package.json` @@ -123,7 +116,7 @@ Once configuration is done, we'll have a file tree that looks like the following ## The Router Configuration -This is the file that will dictate the behavior of TanStack Router used within Start. Here, you can configure everything +This is the file that will dictate the behavior of TanStack Router used within Start for both the server and the client. Here, you can configure everything from the default [preloading functionality](./preloading.md) to [caching staleness](./data-loading.md). ```tsx @@ -149,52 +142,9 @@ declare module '@tanstack/react-router' { > `routeTree.gen.ts` is not a file you're expected to have at this point. > It will be generated when you run TanStack Start (via `npm run dev` or `npm run start`) for the first time. -## The Server Entry Point - -As TanStack Start is an [SSR](https://unicorn-utterances.com/posts/what-is-ssr-and-ssg) framework, we need to pipe this router -information to our server entry point: - -```tsx -// app/ssr.tsx -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) -``` - -This allows us to know what routes and loaders we need to execute when the user hits a given route. - -## The Client Entry Point - -Now we need a way to hydrate our client-side JavaScript once the route resolves to the client. We do this by piping the same -router information to our client entry point: - -```tsx -// app/client.tsx -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter({ - scrollRestoration: true, -}) - -hydrateRoot(document!, ) -``` - -This enables us to kick off client-side routing once the user's initial server request has fulfilled. - ## The Root of Your Application -Finally, we need to create the root of our application. This is the entry point for all other routes. The code in this file will wrap all other routes in the application. +Finally, we need to create the root of our application. This is the entry point for all application routes. The code in this file will wrap all other routes in the application. ```tsx // app/routes/__root.tsx diff --git a/docs/router/framework/react/migrate-from-react-location.md b/docs/router/framework/react/migrate-from-react-location.md index 100d614cae..fc04391c61 100644 --- a/docs/router/framework/react/migrate-from-react-location.md +++ b/docs/router/framework/react/migrate-from-react-location.md @@ -112,7 +112,7 @@ export const Route = createRootRoute({ // src/routes/index.tsx import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Index, }) ``` @@ -125,7 +125,7 @@ export const Route = createFileRoute('/')({ // src/routes/posts.tsx import { createFileRoute, Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ component: Posts, loader: async () => { const posts = await fetchPosts() @@ -164,7 +164,7 @@ function Posts() { // src/routes/posts.index.tsx import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndex, }) ``` @@ -177,7 +177,7 @@ export const Route = createFileRoute('/posts/')({ // src/routes/posts.$postId.tsx import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ component: PostsId, loader: async ({ params: { postId } }) => { const post = await fetchPost(postId) diff --git a/docs/router/framework/react/overview.md b/docs/router/framework/react/overview.md index be83513a79..9e064cf0a1 100644 --- a/docs/router/framework/react/overview.md +++ b/docs/router/framework/react/overview.md @@ -42,7 +42,7 @@ It's probably no surprise at this point that picking a router is so important th **Does this mean that TanStack Router is a framework?** -TanStack Router itself is not a "framework" in the traditional sense, since it doesn't address a few other common full-stack concerns. However TanStack Router has been designed to be upgradable to a full-stack framework when used in conjunction with other tools that address bundling, deployments, and server-side-specific functionality. This is why we are currently developing [TanStack Start](https://tanstack.com/start), a full-stack framework that is built on top of TanStack Router and tools like Nitro, and Vite. +TanStack Router itself is not a "framework" in the traditional sense, since it doesn't address a few other common full-stack concerns. However TanStack Router has been designed to be upgradable to a full-stack framework when used in conjunction with other tools that address bundling, deployments, and server-side-specific functionality. This is why we are currently developing [TanStack Start](https://tanstack.com/start), a full-stack framework that is built on top of TanStack Router and Vite. For a deeper dive on the history of TanStack Router, feel free to read [TanStack Router's History](./decisions-on-dx.md#tanstack-routers-origin-story). diff --git a/docs/router/framework/react/routing/routing-concepts.md b/docs/router/framework/react/routing/routing-concepts.md index 38d9ae5cd9..8ba6969379 100644 --- a/docs/router/framework/react/routing/routing-concepts.md +++ b/docs/router/framework/react/routing/routing-concepts.md @@ -13,7 +13,7 @@ All other routes, other than the [Root Route](#the-root-route), are configured u ```tsx import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ component: PostsComponent, }) ``` @@ -71,7 +71,7 @@ Let's take a look at an `/about` route: // about.tsx import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/about')({ +export const Route = createFileRoute({ component: AboutComponent, }) @@ -93,7 +93,7 @@ Let's take a look at an index route for a `/posts` URL: import { createFileRoute } from '@tanstack/react-router' // Note the trailing slash, which is used to target index routes -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) @@ -113,7 +113,7 @@ These params are then usable in your route's configuration and components! Let's ```tsx import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ // In a loader loader: ({ params }) => fetchPost(params.postId), // Or in a component @@ -172,7 +172,7 @@ This tree structure is used to wrap the child routes with a layout component: ```tsx import { Outlet, createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/app')({ +export const Route = createFileRoute({ component: AppLayoutComponent, }) @@ -243,7 +243,7 @@ The `_pathlessLayout.tsx` route is used to wrap the child routes with a Pathless ```tsx import { Outlet, createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: PathlessLayoutComponent, }) diff --git a/docs/start/config.json b/docs/start/config.json index 76cae14ab8..49ae01b516 100644 --- a/docs/start/config.json +++ b/docs/start/config.json @@ -46,8 +46,8 @@ "to": "framework/react/middleware" }, { - "label": "API Routes", - "to": "framework/react/api-routes" + "label": "Server Routes", + "to": "framework/react/server-routes" }, { "label": "SSR", diff --git a/docs/start/framework/react/api-routes.md b/docs/start/framework/react/api-routes.md deleted file mode 100644 index 87032c5bcd..0000000000 --- a/docs/start/framework/react/api-routes.md +++ /dev/null @@ -1,292 +0,0 @@ ---- -id: api-routes -title: API Routes ---- - -API Routes are a powerful feature of TanStack Start that allow you to create server-side endpoints in your application without the need for a separate server. API Routes are useful for handling form submissions, user authentication, and more. - -By default, API Routes are defined in your `./app/routes/api` directory of your project and are automatically handled by the TanStack Start server. - -> 🧠 This means that by default, your API Routes will be prefixed with `/api` and will be served from the same server as your application. You can customize this base path by changing the `tsr.apiBase` in your TanStack Start config. - -## File Route Conventions - -API Routes in TanStack Start, follow the same file-based routing conventions as TanStack Router. This means that each file in your `routes` directory that is prefixed with `api` (which can be configured) will be treated as an API route. Here are a few examples: - -- `routes/api.users.ts` will create an API route at `/api/users` -- `routes/api/users.ts` will **also** create an API route at `/api/users` -- `routes/api/users.index.ts` will **also** create an API route at `/api/users` -- `routes/api/users/$id.ts` will create an API route at `/api/users/$id` -- `routes/api/users/$id/posts.ts` will create an API route at `/api/users/$id/posts` -- `routes/api.users.$id.posts.ts` will **also** create an API route at `/api/users/$id/posts` -- `routes/api/file/$.ts` will create an API route at `/api/file/$` - -Your route files that are prefixed with `api`, can be thought of as the handlers for the given API route path. - -It's important to remember that each route can only have a single handler file associated with it. So, if you have a file named `routes/api/users.ts` which'd equal the request path of `/api/users`, you cannot have other files that'd also resolve to the same route, like: - -- `routes/api/users.index.ts` -- `routes/api.users.ts`. -- `routes/api.users.index.ts`. - -❗ One more thing, API Routes do not have the concept of pathless layout routes or parallel routes. So, a file named: - -- `routes/api/_pathlessLayout/users.ts` would resolve to `/api/_pathlessLayout/users` and **NOT** `/api/users`. - -## Nested Directories vs File-names - -In the examples above, you may have noticed that the file naming conventions are flexible and allow you to mix and match directories and file names. This is intentional and allows you to organize your API Routes in a way that makes sense for your application. You can read more about this in the [TanStack Router File-based Routing Guide](/router/latest/docs/framework/react/routing/file-based-routing#s-or-s). - -## Setting up the entry handler - -Before you can create your API routes, you need to set up the entry handler for your TanStack Start project. This entry handler, similar to `client` and `ssr`, handles the API incoming requests and routes them to the appropriate API route handler. The API entry handler is defined in the `app/api.ts` file in your project. - -Here's an example implementation: - -```ts -// app/api.ts -import { - createStartAPIHandler, - defaultAPIFileRouteHandler, -} from '@tanstack/react-start/api' - -export default createStartAPIHandler(defaultAPIFileRouteHandler) -``` - -This file is responsible for creating the API handler that will be used to route incoming requests to the appropriate API route handler. The `defaultAPIFileRouteHandler` is a helper function that will automatically load and execute the appropriate API route handler based on the incoming request. - -## Defining an API Route - -API Routes export an APIRoute instance by calling the `createAPIFileRoute` function. Similar to other file-based routes in TanStack Router, the first argument to this function is the path of the route. The function returned is called again with an object that defines the route handlers for each HTTP method. - -> [!TIP] -> If you've already got the dev server running, when you create a new API route, it'll automatically have the initial handler set up for you. From there on, you can customize the handler as needed. - -> [!NOTE] -> The export variable must be named `APIRoute` or the resulting response will be a `404 not found`. - -```ts -// routes/api/hello.ts -import { createAPIFileRoute } from '@tanstack/react-start/api' - -export const APIRoute = createAPIFileRoute('/api/hello')({ - GET: async ({ request }) => { - return new Response('Hello, World! from ' + request.url) - }, -}) -``` - -Each HTTP method handler receives an object with the following properties: - -- `request`: The incoming request object. You can read more about the `Request` object in the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/Request). -- `params`: An object containing the dynamic path parameters of the route. For example, if the route path is `/users/$id`, and the request is made to `/users/123`, then `params` will be `{ id: '123' }`. We'll cover dynamic path parameters and wildcard parameters later in this guide. - -Once you've processed the request, you need to return a `Response` object or `Promise`. This can be done by creating a new `Response` object and returning it from the handler. You can read more about the `Response` object in the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/Response). - -## Dynamic Path Params - -API Routes support dynamic path parameters, which are denoted by a `$` followed by the parameter name. For example, a file named `routes/api/users/$id.ts` will create an API route at `/api/users/$id` that accepts a dynamic `id` parameter. - -```ts -// routes/api/users/$id.ts -import { createAPIFileRoute } from '@tanstack/react-start/api' - -export const APIRoute = createAPIFileRoute('/users/$id')({ - GET: async ({ params }) => { - const { id } = params - return new Response(`User ID: ${id}`) - }, -}) - -// Visit /api/users/123 to see the response -// User ID: 123 -``` - -You can also have multiple dynamic path parameters in a single route. For example, a file named `routes/api/users/$id/posts/$postId.ts` will create an API route at `/api/users/$id/posts/$postId` that accepts two dynamic parameters. - -```ts -// routes/api/users/$id/posts/$postId.ts -import { createAPIFileRoute } from '@tanstack/react-start/api' - -export const APIRoute = createAPIFileRoute('/users/$id/posts/$postId')({ - GET: async ({ params }) => { - const { id, postId } = params - return new Response(`User ID: ${id}, Post ID: ${postId}`) - }, -}) - -// Visit /api/users/123/posts/456 to see the response -// User ID: 123, Post ID: 456 -``` - -## Wildcard/Splat Param - -API Routes also support wildcard parameters at the end of the path, which are denoted by a `$` followed by nothing. For example, a file named `routes/api/file/$.ts` will create an API route at `/api/file/$` that accepts a wildcard parameter. - -```ts -// routes/api/file/$.ts -import { createAPIFileRoute } from '@tanstack/react-start/api' - -export const APIRoute = createAPIFileRoute('/file/$')({ - GET: async ({ params }) => { - const { _splat } = params - return new Response(`File: ${_splat}`) - }, -}) - -// Visit /api/file/hello.txt to see the response -// File: hello.txt -``` - -## Handling requests with a body - -To handle POST requests,you can add a `POST` handler to the route object. The handler will receive the request object as the first argument, and you can access the request body using the `request.json()` method. - -```ts -// routes/api/hello.ts -import { createAPIFileRoute } from '@tanstack/react-start/api' - -export const APIRoute = createAPIFileRoute('/api/hello')({ - POST: async ({ request }) => { - const body = await request.json() - return new Response(`Hello, ${body.name}!`) - }, -}) - -// Send a POST request to /api/hello with a JSON body like { "name": "Tanner" } -// Hello, Tanner! -``` - -This also applies to other HTTP methods like `PUT`, `PATCH`, and `DELETE`. You can add handlers for these methods in the route object and access the request body using the appropriate method. - -It's important to remember that the `request.json()` method returns a `Promise` that resolves to the parsed JSON body of the request. You need to `await` the result to access the body. - -This is a common pattern for handling POST requests in API Routes. You can also use other methods like `request.text()` or `request.formData()` to access the body of the request. - -## Responding with JSON - -When returning JSON using a Response object, this is a common pattern: - -```ts -// routes/api/hello.ts -import { createAPIFileRoute } from '@tanstack/react-start/api' - -export const APIRoute = createAPIFileRoute('/api/hello')({ - GET: async ({ request }) => { - return new Response(JSON.stringify({ message: 'Hello, World!' }), { - headers: { - 'Content-Type': 'application/json', - }, - }) - }, -}) - -// Visit /api/hello to see the response -// {"message":"Hello, World!"} -``` - -## Using the `json` helper function - -Or you can use the `json` helper function to automatically set the `Content-Type` header to `application/json` and serialize the JSON object for you. - -```ts -// routes/api/hello.ts -import { json } from '@tanstack/react-start' -import { createAPIFileRoute } from '@tanstack/react-start/api' - -export const APIRoute = createAPIFileRoute('/api/hello')({ - GET: async ({ request }) => { - return json({ message: 'Hello, World!' }) - }, -}) - -// Visit /api/hello to see the response -// {"message":"Hello, World!"} -``` - -## Responding with a status code - -You can set the status code of the response by either: - -- Passing it as a property of the second argument to the `Response` constructor - - ```ts - // routes/api/hello.ts - import { json } from '@tanstack/react-start' - import { createAPIFileRoute } from '@tanstack/react-start/api' - - export const APIRoute = createAPIFileRoute('/users/$id')({ - GET: async ({ request, params }) => { - const user = await findUser(params.id) - if (!user) { - return new Response('User not found', { - status: 404, - }) - } - return json(user) - }, - }) - ``` - -- Using the `setResponseStatus` helper function from `@tanstack/react-start/server` - - ```ts - // routes/api/hello.ts - import { json } from '@tanstack/react-start' - import { createAPIFileRoute } from '@tanstack/react-start/api' - import { setResponseStatus } from '@tanstack/react-start/server' - - export const APIRoute = createAPIFileRoute('/users/$id')({ - GET: async ({ request, params }) => { - const user = await findUser(params.id) - if (!user) { - setResponseStatus(404) - return new Response('User not found') - } - return json(user) - }, - }) - ``` - -In this example, we're returning a `404` status code if the user is not found. You can set any valid HTTP status code using this method. - -## Setting headers in the response - -Sometimes you may need to set headers in the response. You can do this by either: - -- Passing an object as the second argument to the `Response` constructor. - - ```ts - // routes/api/hello.ts - import { createAPIFileRoute } from '@tanstack/react-start/api' - - export const APIRoute = createAPIFileRoute('/api/hello')({ - GET: async ({ request }) => { - return new Response('Hello, World!', { - headers: { - 'Content-Type': 'text/plain', - }, - }) - }, - }) - - // Visit /api/hello to see the response - // Hello, World! - ``` - -- Or using the `setHeaders` helper function from `@tanstack/react-start/server`. - - ```ts - // routes/api/hello.ts - import { createAPIFileRoute } from '@tanstack/react-start/api' - import { setHeaders } from '@tanstack/react-start/server' - - export const APIRoute = createAPIFileRoute('/api/hello')({ - GET: async ({ request }) => { - setHeaders({ - 'Content-Type': 'text/plain', - }) - return new Response('Hello, World!') - }, - }) - ``` diff --git a/docs/start/framework/react/build-from-scratch.md b/docs/start/framework/react/build-from-scratch.md index 055526d7f8..b7e46b2990 100644 --- a/docs/start/framework/react/build-from-scratch.md +++ b/docs/start/framework/react/build-from-scratch.md @@ -4,7 +4,7 @@ title: Build a Project from Scratch --- > [!NOTE] -> If you chose to quick start with an example or cloned project, you can skip this guide and move on to the [Learn the Basics](../learn-the-basics) guide. +> If you chose to quick start with an example or cloned project, you can skip this guide and move on to the [Learn the Basics](./learn-the-basics.md) guide. _So you want to build a TanStack Start project from scratch?_ @@ -47,14 +47,12 @@ We highly recommend using TypeScript with TanStack Start. Create a `tsconfig.jso ## Install Dependencies -TanStack Start is (currently\*) powered by [Vinxi](https://vinxi.vercel.app/) and [TanStack Router](https://tanstack.com/router) and requires them as dependencies. - -> [!NOTE] > \*Vinxi will be removed before version 1.0.0 is released and TanStack will rely only on Vite and Nitro. The commands and APIs that use Vinxi will likely be replaced with a Vite plugin or dedicated TanStack Start CLI. +TanStack Start is (currently\*) powered by [Vite](https://vite.dev/) and [TanStack Router](https://tanstack.com/router) and requires them as dependencies. To install them, run: ```shell -npm i @tanstack/react-start @tanstack/react-router vinxi +npm i @tanstack/react-start @tanstack/react-router vite ``` You'll also need React and the Vite React plugin, so install them too: @@ -72,46 +70,42 @@ npm i -D typescript @types/react @types/react-dom ## Update Configuration Files -We'll then update our `package.json` to use Vinxi's CLI and set `"type": "module"`: +We'll then update our `package.json` to set `"type": "module"`: ```json { // ... "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" } } ``` -Then configure TanStack Start's `app.config.ts` file: +Then configure TanStack Start's `vite.config.ts` file: -```typescript -// app.config.ts -import { defineConfig } from '@tanstack/react-start/config' +```ts +// vite.config.ts +import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' export default defineConfig({ - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], + server: { + port: 3000, }, + plugins: [tsConfigPaths(), TanStackStartVitePlugin()], }) ``` ## Add the Basic Templating -There are four required files for TanStack Start usage: +There are 2 required files for TanStack Start usage: 1. The router configuration -2. The server entry point -3. The client entry point -4. The root of your application +2. The root of your application Once configuration is done, we'll have a file tree that looks like the following: @@ -120,10 +114,8 @@ Once configuration is done, we'll have a file tree that looks like the following ├── app/ │ ├── routes/ │ │ └── `__root.tsx` -│ ├── `client.tsx` │ ├── `router.tsx` │ ├── `routeTree.gen.ts` -│ └── `ssr.tsx` ├── `.gitignore` ├── `app.config.ts` ├── `package.json` @@ -159,48 +151,6 @@ declare module '@tanstack/react-router' { } ``` -## The Server Entry Point - -As TanStack Start is an [SSR](https://unicorn-utterances.com/posts/what-is-ssr-and-ssg) framework, we need to pipe this router -information to our server entry point: - -```tsx -// app/ssr.tsx -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) -``` - -This allows us to know what routes and loaders we need to execute when the user hits a given route. - -## The Client Entry Point - -Now we need a way to hydrate our client-side JavaScript once the route resolves to the client. We do this by piping the same -router information to our client entry point: - -```tsx -// app/client.tsx -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) -``` - -This enables us to kick off client-side routing once the user's initial server request has fulfilled. - ## The Root of Your Application Finally, we need to create the root of our application. This is the entry point for all other routes. The code in this file will wrap all other routes in the application. @@ -263,7 +213,7 @@ Now that we have the basic templating setup, we can write our first route. This ```tsx // app/routes/index.tsx import * as fs from 'node:fs' -import { createFileRoute, useRouter } from '@tanstack/react-router' +import { useRouter } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' const filePath = 'count.txt' @@ -287,7 +237,7 @@ const updateCount = createServerFn({ method: 'POST' }) await fs.promises.writeFile(filePath, `${count + data}`) }) -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, loader: async () => await getCount(), }) diff --git a/docs/start/framework/react/hosting.md b/docs/start/framework/react/hosting.md index 5241494e80..18cf42f713 100644 --- a/docs/start/framework/react/hosting.md +++ b/docs/start/framework/react/hosting.md @@ -3,7 +3,7 @@ id: hosting title: Hosting --- -Hosting is the process of deploying your application to the internet so that users can access it. This is a critical part of any web development project, ensuring your application is available to the world. TanStack Start is built on [Nitro](https://nitro.unjs.io/), a powerful server toolkit for deploying web applications anywhere. Nitro allows TanStack Start to provide a unified API for SSR, streaming, and hydration on any hosting provider. +Hosting is the process of deploying your application to the internet so that users can access it. This is a critical part of any web development project, ensuring your application is available to the world. TanStack Start is built on Vite, a powerful dev/build platform that allows us to make it possible to deploy your application to any hosting provider. ## What should I use? diff --git a/docs/start/framework/react/learn-the-basics.md b/docs/start/framework/react/learn-the-basics.md index cc00141883..dc4b55dcbc 100644 --- a/docs/start/framework/react/learn-the-basics.md +++ b/docs/start/framework/react/learn-the-basics.md @@ -7,13 +7,10 @@ This guide will help you learn the basics behind how TanStack Start works, regar ## Dependencies -TanStack Start is (currently\*) powered by [Vinxi](https://vinxi.vercel.app/), [Nitro](https://nitro.unjs.io/) and [TanStack Router](https://tanstack.com/router). +TanStack Start is powered by [Vite](https://vite.dev/) and [TanStack Router](https://tanstack.com/router). - **TanStack Router**: A router for building web applications. -- **Nitro**: A framework for building server applications. -- **Vinxi**: A server framework for building web applications. - -> [!NOTE] Vinxi will be removed before version 1.0.0 is released and TanStack will rely only on Vite and Nitro. The commands and APIs that use Vinxi will likely be replaced with a Vite plugin. +- **Vite**: A build tool for bundling your application. ## It all "Starts" with the Router @@ -47,14 +44,15 @@ declare module '@tanstack/react-router' { The `routeTree.gen.ts` file is generated when you run TanStack Start (via `npm run dev` or `npm run start`) for the first time. This file contains the generated route tree and a handful of TS utilities that make TanStack Start fully type-safe. -## The Server Entry Point +## The Server Entry Point (Optional) -Although TanStack Start is designed with client-first APIs, it is by and large, a full-stack framework. This means that all use cases, including both dynamic and static rely on a server or build-time entry to render our application's initial HTML payload. +> [!NOTE] +> The server entry point is **optional** out of the box. If not provided, TanStack Start will automatically handle the server entry point for you using the below as a default. -This is done via the `app/ssr.tsx` file: +This is done via the `src/server.tsx` file: ```tsx -// app/ssr.tsx +// src/server.tsx import { createStartHandler, defaultStreamHandler, @@ -69,13 +67,16 @@ export default createStartHandler({ })(defaultStreamHandler) ``` -Whether we are statically generating our app or serving it dynamically, the `ssr.tsx` file is the entry point for doing all SSR-related work. +Whether we are statically generating our app or serving it dynamically, the `server.tsx` file is the entry point for doing all SSR-related work. - It's important that a new router is created for each request. This ensures that any data handled by the router is unique to the request. - The `getRouterManifest` function is used to generate the router manifest, which is used to determine many aspects of asset management and preloading for our application. - The `defaultStreamHandler` function is used to render our application to a stream, allowing us to take advantage of streaming HTML to the client. (This is the default handler, but you can also use other handlers like `defaultRenderHandler`, or even build your own) -## The Client Entry Point +## The Client Entry Point (Optional) + +> [!NOTE] +> The client entry point is **optional** out of the box. If not provided, TanStack Start will automatically handle the client entry point for you using the below as a default. Getting our html to the client is only half the battle. Once there, we need to hydrate our client-side JavaScript once the route resolves to the client. We do this by hydrating the root of our application with the `StartClient` component: @@ -94,7 +95,7 @@ This enables us to kick off client-side routing once the user's initial server r ## The Root of Your Application -Other than the client entry point, the `__root` route of your application is the entry point for your application. The code in this file will wrap all other routes in the app, including your home page. It behaves like a pathless layout route for your whole application. +Other than the client entry point (which is optional by default), the `__root` route of your application is the entry point for your application. The code in this file will wrap all other routes in the app, including your home page. It behaves like a pathless layout route for your whole application. Because it is **always rendered**, it is the perfect place to construct your application shell and take care of any global logic. diff --git a/docs/start/framework/react/middleware.md b/docs/start/framework/react/middleware.md index 7eb75ba032..9877da95fd 100644 --- a/docs/start/framework/react/middleware.md +++ b/docs/start/framework/react/middleware.md @@ -24,12 +24,14 @@ Middleware is defined using the `createMiddleware` function. This function retur ```tsx import { createMiddleware } from '@tanstack/react-start' -const loggingMiddleware = createMiddleware().server(async ({ next, data }) => { - console.log('Request received:', data) - const result = await next() - console.log('Response processed:', result) - return result -}) +const loggingMiddleware = createMiddleware({ type: 'function' }).server( + async ({ next, data }) => { + console.log('Request received:', data) + const result = await next() + console.log('Response processed:', result) + return result + }, +) ``` ## Using Middleware in Your Server Functions @@ -63,7 +65,7 @@ The `middleware` method is used to dependency middleware to the chain that will ```tsx import { createMiddleware } from '@tanstack/react-start' -const loggingMiddleware = createMiddleware().middleware([ +const loggingMiddleware = createMiddleware({ type: 'function' }).middleware([ authMiddleware, loggingMiddleware, ]) @@ -84,7 +86,7 @@ const mySchema = z.object({ workspaceId: z.string(), }) -const workspaceMiddleware = createMiddleware() +const workspaceMiddleware = createMiddleware({ type: 'function' }) .validator(zodValidator(mySchema)) .server(({ next, data }) => { console.log('Workspace ID:', data.workspaceId) @@ -107,12 +109,14 @@ The `next` function is used to execute the next middleware in the chain. **You m ```tsx import { createMiddleware } from '@tanstack/react-start' -const loggingMiddleware = createMiddleware().server(async ({ next }) => { - console.log('Request received') - const result = await next() - console.log('Response processed') - return result -}) +const loggingMiddleware = createMiddleware({ type: 'function' }).server( + async ({ next }) => { + console.log('Request received') + const result = await next() + console.log('Response processed') + return result + }, +) ``` ## Providing context to the next middleware via `next` @@ -122,15 +126,17 @@ The `next` function can be optionally called with an object that has a `context` ```tsx import { createMiddleware } from '@tanstack/react-start' -const awesomeMiddleware = createMiddleware().server(({ next }) => { - return next({ - context: { - isAwesome: Math.random() > 0.5, - }, - }) -}) +const awesomeMiddleware = createMiddleware({ type: 'function' }).server( + ({ next }) => { + return next({ + context: { + isAwesome: Math.random() > 0.5, + }, + }) + }, +) -const loggingMiddleware = createMiddleware().server( +const loggingMiddleware = createMiddleware({ type: 'function' }).server( async ({ next, context }) => { console.log('Is awesome?', context.isAwesome) return next() @@ -180,12 +186,14 @@ Similar to the `server` function, it also receives an object with the following - `context`: An object that stores data from parent middleware. It can be extended with additional data that will be passed to child middleware. ```tsx -const loggingMiddleware = createMiddleware().client(async ({ next }) => { - console.log('Request sent') - const result = await next() - console.log('Response received') - return result -}) +const loggingMiddleware = createMiddleware({ type: 'function' }).client( + async ({ next }) => { + console.log('Request sent') + const result = await next() + console.log('Response received') + return result + }, +) ``` ## Sending client context to the server @@ -193,7 +201,7 @@ const loggingMiddleware = createMiddleware().client(async ({ next }) => { **Client context is NOT sent to the server by default since this could end up unintentionally sending large payloads to the server.** If you need to send client context to the server, you must call the `next` function with a `sendContext` property and object to transmit any data to the server. Any properties passed to `sendContext` will be merged, serialized and sent to the server along with the data and will be available on the normal context object of any nested server middleware. ```tsx -const requestLogger = createMiddleware() +const requestLogger = createMiddleware({ type: 'function' }) .client(async ({ next, context }) => { return next({ sendContext: { @@ -217,7 +225,7 @@ You may have noticed that in the example above that while client-sent context is import { zodValidator } from '@tanstack/zod-adapter' import { z } from 'zod' -const requestLogger = createMiddleware() +const requestLogger = createMiddleware({ type: 'function' }) .client(async ({ next, context }) => { return next({ sendContext: { @@ -241,16 +249,18 @@ Similar to sending client context to the server, you can also send server contex > The return type of `next` in `client` can only be inferred from middleware known in the current middleware chain. Therefore the most accurate return type of `next` is in middleware at the end of the middleware chain ```tsx -const serverTimer = createMiddleware().server(async ({ next }) => { - return next({ - sendContext: { - // Send the current time to the client - timeFromServer: new Date(), - }, - }) -}) +const serverTimer = createMiddleware({ type: 'function' }).server( + async ({ next }) => { + return next({ + sendContext: { + // Send the current time to the client + timeFromServer: new Date(), + }, + }) + }, +) -const requestLogger = createMiddleware() +const requestLogger = createMiddleware({ type: 'function' }) .middleware([serverTimer]) .client(async ({ next }) => { const result = await next() @@ -276,13 +286,15 @@ Here's an example of adding an `Authorization` header any request using this mid ```tsx import { getToken } from 'my-auth-library' -const authMiddleware = createMiddleware().client(async ({ next }) => { - return next({ - headers: { - Authorization: `Bearer ${getToken()}`, - }, - }) -}) +const authMiddleware = createMiddleware({ type: 'function' }).client( + async ({ next }) => { + return next({ + headers: { + Authorization: `Bearer ${getToken()}`, + }, + }) + }, +) ``` ## Using Middleware @@ -323,10 +335,12 @@ registerGlobalMiddleware({ ```tsx // authMiddleware.ts -const authMiddleware = createMiddleware().server(({ next, context }) => { - console.log(context.user) // <-- This will not be typed! - // ... -}) +const authMiddleware = createMiddleware({ type: 'function' }).server( + ({ next, context }) => { + console.log(context.user) // <-- This will not be typed! + // ... + }, +) ``` To solve this, add the global middleware you are trying to reference to the server function's middleware array. **The global middleware will be deduped to a single entry (the global instance), and your server function will receive the correct types.** @@ -356,40 +370,44 @@ Middleware is executed dependency-first, starting with global middleware, follow - `d` ```tsx -const globalMiddleware1 = createMiddleware().server(async ({ next }) => { - console.log('globalMiddleware1') - return next() -}) +const globalMiddleware1 = createMiddleware({ type: 'function' }).server( + async ({ next }) => { + console.log('globalMiddleware1') + return next() + }, +) -const globalMiddleware2 = createMiddleware().server(async ({ next }) => { - console.log('globalMiddleware2') - return next() -}) +const globalMiddleware2 = createMiddleware({ type: 'function' }).server( + async ({ next }) => { + console.log('globalMiddleware2') + return next() + }, +) registerGlobalMiddleware({ middleware: [globalMiddleware1, globalMiddleware2], }) -const a = createMiddleware().server(async ({ next }) => { +const a = createMiddleware({ type: 'function' }).server(async ({ next }) => { console.log('a') return next() }) -const b = createMiddleware() +const b = createMiddleware({ type: 'function' }) .middleware([a]) .server(async ({ next }) => { console.log('b') return next() }) -const c = createMiddleware() +const c = createMiddleware({ type: 'function' }) .middleware() .server(async ({ next }) => { console.log('c') return next() }) -const d = createMiddleware() +const d = createMiddleware({ type: 'function' }) .middleware([b, c]) .server(async () => { console.log('d') diff --git a/docs/start/framework/react/overview.md b/docs/start/framework/react/overview.md index ca4bbac835..5fa9088845 100644 --- a/docs/start/framework/react/overview.md +++ b/docs/start/framework/react/overview.md @@ -3,7 +3,7 @@ id: overview title: TanStack Start Overview --- -TanStack Start is a full-stack React framework powered by TanStack Router. It provides a full-document SSR, streaming, server functions, bundling, and more using tools like [Nitro](https://nitro.unjs.io/) and [Vite](https://vitejs.dev/). It is ready to deploy to your favorite hosting provider! +TanStack Start is a full-stack React framework powered by TanStack Router. It provides a full-document SSR, streaming, server functions, bundling, and more. Thanks to [Vite](https://vite.dev/), it's ready to develop and deploy to any hosting provider or runtime you want! ## Router or Start? @@ -39,7 +39,7 @@ What you get with TanStack Start: ## How does it work? -TanStack Start uses [Nitro](https://nitro.unjs.io/) and [Vite](https://vitejs.dev/) to bundle and deploy your application. In fact, these are the same tools that power Solid Start! With these tools, we can do a few things we couldn't do before: +TanStack Start uses [Vite](https://vitejs.dev/) to bundle and deploy your application and empowers amazing features like: - Provide a unified API for SSR, streaming, and hydration - Extract server-only code from your client-side code (e.g. server functions) diff --git a/docs/start/framework/react/server-routes.md b/docs/start/framework/react/server-routes.md new file mode 100644 index 0000000000..f712a29f8f --- /dev/null +++ b/docs/start/framework/react/server-routes.md @@ -0,0 +1,387 @@ +--- +id: server-routes +title: Server Routes +--- + +// TODO: Add redirect from api-routes to server-routes + +Server routes are a powerful feature of TanStack Start that allow you to create server-side endpoints in your application and are useful for handling raw HTTP requests, form submissions, user authentication, and much more. + +Server routes can be defined in your `./app/routes` directory of your project **right alongside your TanStack Router routes** and are automatically handled by the TanStack Start server. + +Here's what a simple server route looks like: + +```ts +// routes/hello.ts + +export const ServerRoute = createServerRoute({ + GET: async ({ request }) => { + return new Response('Hello, World!') + }, +}) +``` + +## Server Routes and App Routes + +Because server routes can be defined in the same directory as your app routes, you can even use the same file for both! + +```tsx +// routes/hello.ts + +export const ServerRoute = createServerRoute().methods({ + POST: async ({ request }) => { + const body = await request.json() + return new Response(JSON.stringify({ message: `Hello, ${body.name}!` })) + }, +}) + +export const Route = createFileRoute({ + component: HelloComponent, +}) + +function HelloComponent() { + const [reply, setReply] = useState('') + + return ( +
+ +
+ ) +} +``` + +## File Route Conventions + +Server routes in TanStack Start, follow the same file-based routing conventions as TanStack Router. This means that each file in your `routes` directory with a `ServerRoute` export will be treated as an API route. Here are a few examples: + +- `/routes/users.ts` will create an API route at `/users` +- `/routes/users.index.ts` will **also** create an API route at `/users` (but will error if duplicate methods are defined) +- `/routes/users/$id.ts` will create an API route at `/users/$id` +- `/routes/users/$id/posts.ts` will create an API route at `/users/$id/posts` +- `/routes/users.$id.posts.ts` will create an API route at `/users/$id/posts` +- `/routes/file/$.ts` will create an API route at `/api/file/$` +- `/routes/my-script[.]js.ts` will create an API route at `/my-script.js` + +## Unique Route Paths + +Each route can only have a single handler file associated with it. So, if you have a file named `routes/users.ts` which'd equal the request path of `/api/users`, you cannot have other files that'd also resolve to the same route. For example, the following files would all resolve to the same route and would error: + +- `/routes/users.index.ts` +- `/routes/users.ts` +- `/routes/users.index.ts` + +## Escaped Matching + +Just as with normal routes, server routes can match on escaped characters. For example, a file named `routes/users[.]ts` will create an API route at `/api/users[.]`. + +## Pathless Layout Routes and Break-out Routes + +Because of the unified routing system, pathless layout routes and break-out routes are supported for similar functionality around server route middleware. + +- Pathless layout routes can be used to add middleware to a group of routes +- Break-out routes can be used to "break out" of parent middleware + +## Nested Directories vs File-names + +In the examples above, you may have noticed that the file naming conventions are flexible and allow you to mix and match directories and file names. This is intentional and allows you to organize your Server routes in a way that makes sense for your application. You can read more about this in the [TanStack Router File-based Routing Guide](/router/latest/docs/framework/react/routing/file-based-routing#s-or-s). + +## Handling Server Route Requests + +Server route requests are handled by Start's `createStartHandler` in your `server.ts` entry file. + +```tsx +// server.ts +import { createStartHandler } from '@tanstack/react-start/server' + +export default createStartHandler({ + createRouter, + getRouterManifest, +})(defaultStreamHandler) +``` + +The start handler is responsible for matching an incoming request to a server route and executing the appropriate middleware, validators and handler. + +Remember, if you need to customize the server handler, you can do so by creating a custom handler and then passing the event to the start handler: + +```tsx +// server.ts +import { createStartHandler } from '@tanstack/react-start/server' + +export default defineHandler((event) => { + const startHandler = createStartHandler({ + createRouter, + getRouterManifest, + })(defaultStreamHandler) + + return startHandler(event) +}) +``` + +## Defining an Server Route + +Server routes are created by exporting a `ServerRoute` from a route file. The `ServerRoute` export should be created by calling the `createServerFileRoute` function. The resulting builder object can then be used to: + +- Add route-level middleware +- Define handlers for each HTTP method +- Add middleware and validators to specific HTTP methods + +```ts +// routes/hello.ts +export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ request }) => { + return new Response('Hello, World! from ' + request.url) + }, +}) +``` + +## Defining a Server Route Handler + +There are two ways to define a handler for a server route. + +- Provide a handler function directly to the method +- By calling the `handler` method on the method builder object for more advanced use cases + +### Providing a handler function directly to the method + +For simple use cases, you can provide a handler function directly to the method. + +```ts +// routes/hello.ts +export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ request }) => { + return new Response('Hello, World! from ' + request.url) + }, +}) +``` + +### Providing a handler function via the method builder object + +For more complex use cases, you can provide a handler function via the method builder object. This allows you to: + +- Add middleware to the method +- Add a validator to the method + +```tsx +// routes/hello.ts +export const ServerRoute = createServerFileRoute().methods((api) => ({ + GET: api + .middleware([loggerMiddleware]) + .validator(z.object({ name: z.string() })) + .handler(async ({ request }) => { + return new Response('Hello, World! from ' + request.url) + }), +})) +``` + +## Handler Context + +Each HTTP method handler receives an object with the following properties: + +- `request`: The incoming request object. You can read more about the `Request` object in the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/Request). +- `params`: An object containing the dynamic path parameters of the route. For example, if the route path is `/users/$id`, and the request is made to `/users/123`, then `params` will be `{ id: '123' }`. We'll cover dynamic path parameters and wildcard parameters later in this guide. +- `context`: An object containing the context of the request. This is useful for passing data between middleware. + +Once you've processed the request, you can return a `Response` object or `Promise` or even use any of the helpers from `@tanstack/react-start` to manipulate the response. + +## Dynamic Path Params + +Server routes support dynamic path parameters in the same way as TanStack Router. For example, a file named `routes/users/$id.ts` will create an API route at `/users/$id` that accepts a dynamic `id` parameter. + +```ts +// routes/users/$id.ts +export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ params }) => { + const { id } = params + return new Response(`User ID: ${id}`) + }, +}) + +// Visit /api/users/123 to see the response +// User ID: 123 +``` + +You can also have multiple dynamic path parameters in a single route. For example, a file named `routes/users/$id/posts/$postId.ts` will create an API route at `/api/users/$id/posts/$postId` that accepts two dynamic parameters. + +```ts +// routes/users/$id/posts/$postId.ts +export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ params }) => { + const { id, postId } = params + return new Response(`User ID: ${id}, Post ID: ${postId}`) + }, +}) + +// Visit /api/users/123/posts/456 to see the response +// User ID: 123, Post ID: 456 +``` + +## Wildcard/Splat Param + +Server routes also support wildcard parameters at the end of the path, which are denoted by a `$` followed by nothing. For example, a file named `routes/file/$.ts` will create an API route at `/api/file/$` that accepts a wildcard parameter. + +```ts +// routes/file/$.ts +export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ params }) => { + const { _splat } = params + return new Response(`File: ${_splat}`) + }, +}) + +// Visit /api/file/hello.txt to see the response +// File: hello.txt +``` + +## Handling requests with a body + +To handle POST requests,you can add a `POST` handler to the route object. The handler will receive the request object as the first argument, and you can access the request body using the `request.json()` method. + +```ts +// routes/hello.ts +export const ServerRoute = createServerFileRoute().methods({ + POST: async ({ request }) => { + const body = await request.json() + return new Response(`Hello, ${body.name}!`) + }, +}) + +// Send a POST request to /api/hello with a JSON body like { "name": "Tanner" } +// Hello, Tanner! +``` + +This also applies to other HTTP methods like `PUT`, `PATCH`, and `DELETE`. You can add handlers for these methods in the route object and access the request body using the appropriate method. + +It's important to remember that the `request.json()` method returns a `Promise` that resolves to the parsed JSON body of the request. You need to `await` the result to access the body. + +This is a common pattern for handling POST requests in Server routes/ You can also use other methods like `request.text()` or `request.formData()` to access the body of the request. + +## Responding with JSON + +When returning JSON using a Response object, this is a common pattern: + +```ts +// routes/hello.ts +export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ request }) => { + return new Response(JSON.stringify({ message: 'Hello, World!' }), { + headers: { + 'Content-Type': 'application/json', + }, + }) + }, +}) + +// Visit /api/hello to see the response +// {"message":"Hello, World!"} +``` + +## Using the `json` helper function + +Or you can use the `json` helper function to automatically set the `Content-Type` header to `application/json` and serialize the JSON object for you. + +```ts +// routes/hello.ts +import { json } from '@tanstack/react-start' + +export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ request }) => { + return json({ message: 'Hello, World!' }) + }, +}) + +// Visit /api/hello to see the response +// {"message":"Hello, World!"} +``` + +## Responding with a status code + +You can set the status code of the response by either: + +- Passing it as a property of the second argument to the `Response` constructor + + ```ts + // routes/hello.ts + import { json } from '@tanstack/react-start' + + export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ request, params }) => { + const user = await findUser(params.id) + if (!user) { + return new Response('User not found', { + status: 404, + }) + } + return json(user) + }, + }) + ``` + +- Using the `setResponseStatus` helper function from `@tanstack/react-start/server` + + ```ts + // routes/hello.ts + import { json } from '@tanstack/react-start' + import { setResponseStatus } from '@tanstack/react-start/server' + + export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ request, params }) => { + const user = await findUser(params.id) + if (!user) { + setResponseStatus(404) + return new Response('User not found') + } + return json(user) + }, + }) + ``` + +In this example, we're returning a `404` status code if the user is not found. You can set any valid HTTP status code using this method. + +## Setting headers in the response + +Sometimes you may need to set headers in the response. You can do this by either: + +- Passing an object as the second argument to the `Response` constructor. + + ```ts + // routes/hello.ts + export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ request }) => { + return new Response('Hello, World!', { + headers: { + 'Content-Type': 'text/plain', + }, + }) + }, + }) + + // Visit /api/hello to see the response + // Hello, World! + ``` + +- Or using the `setHeaders` helper function from `@tanstack/react-start/server`. + + ```ts + // routes/hello.ts + import { setHeaders } from '@tanstack/react-start/server' + + export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ request }) => { + setHeaders({ + 'Content-Type': 'text/plain', + }) + return new Response('Hello, World!') + }, + }) + ``` diff --git a/docs/start/framework/react/ssr.md b/docs/start/framework/react/ssr.md index f509d47f72..b932548555 100644 --- a/docs/start/framework/react/ssr.md +++ b/docs/start/framework/react/ssr.md @@ -7,10 +7,10 @@ Server-side rendering (SSR) is the process of rendering your application on the ## SSR Basics -TanStack Start supports server-side rendering out of the box. To enable server-side rendering, create an `app/ssr.tsx` file in your project: +TanStack Start supports server-side rendering out of the box. To enable server-side rendering, create an `src/server.tsx` file in your project: ```tsx -// app/ssr.tsx +// src/server.tsx import { createStartHandler, diff --git a/docs/start/framework/react/static-prerendering.md b/docs/start/framework/react/static-prerendering.md index 768e11d539..30111f24fb 100644 --- a/docs/start/framework/react/static-prerendering.md +++ b/docs/start/framework/react/static-prerendering.md @@ -3,13 +3,11 @@ id: static-prerendering title: Static Prerendering --- -> Static Prerendering is a feature of Nitro, and while it is available in TanStack Start, we are still exploring the best practices for using it. Tread lightly! - Static prerendering is the process of generating static HTML files for your application. This can be useful for either improving the performance of your application, as it allows you to serve pre-rendered HTML files to users without having to generate them on the fly or for deploying static sites to platforms that do not support server-side rendering. -## Prerendering, powered by Nitro +## Prerendering -TanStack Start is built on Nitro, which means we can take advantage of Nitro's prerendering capabilities. Nitro can prerender your application to static HTML files, which can then be served to users without having to generate them on the fly. To prerender your application, you can add the `server.prerender` option to your `app.config.js` file: +TanStack Start can prerender your application to static HTML files, which can then be served to users without having to generate them on the fly. To prerender your application, you can add the `server.prerender` option to your `app.config.js` file: ```js // app.config.js @@ -25,39 +23,3 @@ export default defineConfig({ }, }) ``` - -Many of the options available for prerendering are documented in the [Nitro config prerender documentation](https://nitro.unjs.io/config#prerender). - -## Prerendering dynamic routes with Nitro - -Nitro ships with some prebuilt hooks that let you customize the prerendering process among other things. One of these hooks is the `prerender:routes` hook. This hook allows you to fetch async data and add routes to a `Set` of routes to be prerendered. - -For this example, let's pretend we have a blog with a list of posts. We want to prerender each post page. Our post route looks like `/posts/$postId`. We can use the `prerender:routes` hook to fetch the all of our posts and add each post path to the routes set. - -```ts -// app.config.ts -import { defineConfig } from '@tanstack/react-start/config' - -export default defineConfig({ - server: { - hooks: { - 'prerender:routes': async (routes) => { - // fetch the pages you want to render - const posts = await fetch('https://api.example.com/posts') - const postsData = await posts.json() - - // add each post path to the routes set - postsData.forEach((post) => { - routes.add(`/posts/${post.id}`) - }) - }, - }, - prerender: { - routes: ['/'], - crawlLinks: true, - }, - }, -}) -``` - -As of writing, the [Nitro hooks documentation](https://nitro.build/config#hooks) does not include any information on the provided hooks. diff --git a/docs/start/framework/solid/build-from-scratch.md b/docs/start/framework/solid/build-from-scratch.md index c5fcdb3563..b854021ca8 100644 --- a/docs/start/framework/solid/build-from-scratch.md +++ b/docs/start/framework/solid/build-from-scratch.md @@ -4,7 +4,7 @@ title: Build a Project from Scratch --- > [!NOTE] -> If you chose to quick start with an example or cloned project, you can skip this guide and move on to the [Learn the Basics](../learn-the-basics) guide. +> If you chose to quick start with an example or cloned project, you can skip this guide and move on to the [Learn the Basics](./learn-the-basics.md) guide. _So you want to build a TanStack Start project from scratch?_ @@ -48,14 +48,16 @@ We highly recommend using TypeScript with TanStack Start. Create a `tsconfig.jso ## Install Dependencies -TanStack Start is (currently\*) powered by [Vinxi](https://vinxi.vercel.app/) and [TanStack Router](https://tanstack.com/router) and requires them as dependencies. +TanStack Start is powered by: -> [!NOTE] > \*Vinxi will be removed before version 1.0.0 is released and TanStack will rely only on Vite and Nitro. The commands and APIs that use Vinxi will likely be replaced with a Vite plugin or dedicated TanStack Start CLI. +- [**TanStack Router**](https://tanstack.com/router) - A router for building web applications. +- [**Vite**](https://vite.dev/) - A build tool for building web applications. +- [**Nitro**](https://nitro.unjs.io/) - A framework for building server applications. To install them, run: ```shell -npm i @tanstack/solid-start @tanstack/solid-router vinxi +npm i @tanstack/solid-start @tanstack/solid-router vite ``` You'll also need Solid and the Vite Solid plugin, so install them too: @@ -80,28 +82,26 @@ We'll then update our `package.json` to use Vinxi's CLI and set `"type": "module // ... "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" } } ``` -Then configure TanStack Start's `app.config.ts` file: +Then configure TanStack Start's Vite plugin in `vite.config.ts`: -```typescript -// app.config.ts -import { defineConfig } from '@tanstack/solid-start/config' +```ts +// vite.config.ts +import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' export default defineConfig({ - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], + server: { + port: 3000, }, + plugins: [tsConfigPaths(), TanStackStartVitePlugin()], }) ``` @@ -124,7 +124,6 @@ Once configuration is done, we'll have a file tree that looks like the following │ ├── `client.tsx` │ ├── `router.tsx` │ ├── `routeTree.gen.ts` -│ └── `ssr.tsx` ├── `.gitignore` ├── `app.config.ts` ├── `package.json` @@ -160,47 +159,8 @@ declare module '@tanstack/solid-router' { } ``` -## The Server Entry Point - -As TanStack Start is an [SSR](https://unicorn-utterances.com/posts/what-is-ssr-and-ssg) framework, we need to pipe this router -information to our server entry point: - -```tsx -// app/ssr.tsx -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/solid-start/server' -import { getRouterManifest } from '@tanstack/solid-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) -``` - -This allows us to know what routes and loaders we need to execute when the user hits a given route. - -## The Client Entry Point - -Now we need a way to hydrate our client-side JavaScript once the route resolves to the client. We do this by piping the same -router information to our client entry point: - -```tsx -// app/client.tsx -/// -import { hydrate } from 'solid-js/web' -import { StartClient } from '@tanstack/solid-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrate(() => , document.body) -``` - -This enables us to kick off client-side routing once the user's initial server request has fulfilled. +> [!NOTE] +> TanStack Start provides **default server and client entry points** to handle requests and client-entry + hydration. You can customize these entry points by adding a `server.ts` and/or `client.tsx` file in the root of your project, but for now, we'll use the defaults. ## The Root of Your Application @@ -245,7 +205,7 @@ Now that we have the basic templating setup, we can write our first route. This ```tsx // app/routes/index.tsx import * as fs from 'node:fs' -import { createFileRoute, useRouter } from '@tanstack/solid-router' +import { useRouter } from '@tanstack/solid-router' import { createServerFn } from '@tanstack/solid-start' const filePath = 'count.txt' @@ -269,7 +229,7 @@ const updateCount = createServerFn({ method: 'POST' }) await fs.promises.writeFile(filePath, `${count + data}`) }) -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, loader: async () => await getCount(), }) diff --git a/docs/start/framework/solid/learn-the-basics.md b/docs/start/framework/solid/learn-the-basics.md index 094b965623..863d62183b 100644 --- a/docs/start/framework/solid/learn-the-basics.md +++ b/docs/start/framework/solid/learn-the-basics.md @@ -7,13 +7,11 @@ This guide will help you learn the basics behind how TanStack Start works, regar ## Dependencies -TanStack Start is (currently\*) powered by [Vinxi](https://vinxi.vercel.app/), [Nitro](https://nitro.unjs.io/) and [TanStack Router](https://tanstack.com/router). +TanStack Start is powered by: -- **TanStack Router**: A router for building web applications. -- **Nitro**: A framework for building server applications. -- **Vinxi**: A server framework for building web applications. - -> [!NOTE] Vinxi will be removed before version 1.0.0 is released and TanStack will rely only on Vite and Nitro. The commands and APIs that use Vinxi will likely be replaced with a Vite plugin. +- [**TanStack Router**](https://tanstack.com/router): A router for building web applications. +- [**Vite**](https://vite.dev/): A build tool for building web applications. +- [**Nitro**](https://nitro.unjs.io/): A framework for building server applications. ## It all "Starts" with the Router diff --git a/e2e/create-start/.gitignore b/e2e/create-start/.gitignore deleted file mode 100644 index 8354e4d50d..0000000000 --- a/e2e/create-start/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -node_modules -.DS_Store -dist -dist-ssr -*.local - -/test-results/ -/playwright-report/ -/blob-report/ -/playwright/.cache/ \ No newline at end of file diff --git a/e2e/create-start/package.json b/e2e/create-start/package.json deleted file mode 100644 index 1c46410866..0000000000 --- a/e2e/create-start/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "create-start-e2e", - "private": true, - "type": "module", - "scripts": { - "test:e2e": "playwright test --project=chromium" - }, - "devDependencies": { - "@playwright/test": "^1.50.1", - "@tanstack/create-start": "workspace:^", - "get-port-please": "^3.1.2", - "tempy": "^3.1.0", - "terminate": "^2.8.0", - "wait-port": "^1.1.0" - } -} diff --git a/e2e/create-start/playwright.config.ts b/e2e/create-start/playwright.config.ts deleted file mode 100644 index b07c8b268b..0000000000 --- a/e2e/create-start/playwright.config.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { defineConfig, devices } from '@playwright/test' - -/** - * See https://playwright.dev/docs/test-configuration. - */ -export default defineConfig({ - testDir: './tests', - - reporter: [['line']], - timeout: 60000, - use: { - trace: 'on-first-retry', - }, - workers: 1, - - // use: { - // /* Base URL to use in actions like `await page.goto('/')`. */ - // baseURL: 'http://localhost:3001/', - // }, - - // webServer: { - // command: 'pnpm run dev', - // url: 'http://localhost:3001', - // reuseExistingServer: !process.env.CI, - // stdout: 'pipe', - // }, - - projects: [ - { - name: 'chromium', - use: { ...devices['Desktop Chrome'] }, - }, - ], -}) diff --git a/e2e/create-start/tests/templates/barebones.test.ts b/e2e/create-start/tests/templates/barebones.test.ts deleted file mode 100644 index 8778ef37d7..0000000000 --- a/e2e/create-start/tests/templates/barebones.test.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { temporaryDirectory } from 'tempy' -import { getRandomPort } from 'get-port-please' -import { unstable_scaffoldTemplate } from '@tanstack/create-start' -import { test } from '../../utils/setup' - -// Before running any tests - create the project in the temporary directory -const projectPath = temporaryDirectory() -await unstable_scaffoldTemplate({ - cfg: { - packageManager: { - installDeps: true, - packageManager: 'pnpm', - }, - git: { - setupGit: false, - }, - packageJson: { - type: 'new', - name: 'barebones-test', - }, - ide: { - ide: 'vscode', - }, - }, - targetPath: projectPath, - templateId: 'barebones', -}) - -const PORT = await getRandomPort() -test.use({ projectPath }) -test.use({ port: PORT }) -test.use({ baseURL: `http://localhost:${PORT}` }) - -test.describe('barebones template e2e', () => { - test('Navigating to index page', async ({ page }) => { - await page.goto('/') - }) -}) diff --git a/e2e/create-start/tsconfig.json b/e2e/create-start/tsconfig.json deleted file mode 100644 index 44c53edd67..0000000000 --- a/e2e/create-start/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "esModuleInterop": true, - "jsx": "react-jsx", - "target": "ESNext", - "moduleResolution": "Bundler", - "module": "ESNext", - "skipLibCheck": true - } -} diff --git a/e2e/create-start/utils/setup.ts b/e2e/create-start/utils/setup.ts deleted file mode 100644 index bfb4c1fd53..0000000000 --- a/e2e/create-start/utils/setup.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { exec, execSync } from 'node:child_process' -import { test as baseTest } from '@playwright/test' -import terminate from 'terminate/promise' -import waitPort from 'wait-port' - -async function _setup( - projectPath: string, - port: number, -): Promise<{ - PID: number - ADDR: string - killProcess: () => Promise - deleteTempDir: () => void -}> { - const ADDR = `http://localhost:${port}` - - const childProcess = exec( - `VITE_SERVER_PORT=${port} pnpm vinxi dev --port ${port}`, - { - cwd: projectPath, - }, - ) - - childProcess.stdout?.on('data', (data) => { - const message = data.toString() - console.log('Stdout:', message) - }) - - childProcess.stderr?.on('data', (data) => { - console.error('Stderr:', data.toString()) - }) - - try { - await waitPort({ port, timeout: 30000 }) // Added timeout - } catch (err) { - console.error('Failed to start server:', err) - throw err - } - - const PID = childProcess.pid! - const killProcess = async () => { - console.log('Killing process') - try { - await terminate(PID) - } catch (err) { - console.error('Failed to kill process:', err) - } - } - const deleteTempDir = () => execSync(`rm -rf ${projectPath}`) - - return { PID, ADDR, killProcess, deleteTempDir } -} - -type SetupApp = Awaited> - -export const test = baseTest.extend<{ - setupApp: SetupApp - projectPath: string - port: number - ensureServer: void -}>({ - projectPath: ['', { option: true }], - port: [0, { option: true }], - ensureServer: [ - async ({ projectPath, port }, use) => { - const setup = await _setup(projectPath, port) - await use() - await setup.killProcess() - }, - { auto: true }, - ], -}) diff --git a/e2e/react-router/basic-file-based-code-splitting/src/routeTree.gen.ts b/e2e/react-router/basic-file-based-code-splitting/src/routeTree.gen.ts index 12e3efedb5..d8f7bdfeb3 100644 --- a/e2e/react-router/basic-file-based-code-splitting/src/routeTree.gen.ts +++ b/e2e/react-router/basic-file-based-code-splitting/src/routeTree.gen.ts @@ -10,73 +10,74 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as WithoutLoaderImport } from './routes/without-loader' -import { Route as ViewportTestImport } from './routes/viewport-test' -import { Route as PostsImport } from './routes/posts' -import { Route as LayoutImport } from './routes/_layout' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as LayoutLayout2Import } from './routes/_layout/_layout-2' -import { Route as LayoutLayout2LayoutBImport } from './routes/_layout/_layout-2/layout-b' -import { Route as LayoutLayout2LayoutAImport } from './routes/_layout/_layout-2/layout-a' +import { Route as WithoutLoaderRouteImport } from './routes/without-loader' +import { Route as ViewportTestRouteImport } from './routes/viewport-test' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as LayoutRouteImport } from './routes/_layout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2' +import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b' +import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a' // Create/Update Routes -const WithoutLoaderRoute = WithoutLoaderImport.update({ +const WithoutLoaderRoute = WithoutLoaderRouteImport.update({ id: '/without-loader', path: '/without-loader', getParentRoute: () => rootRoute, } as any) -const ViewportTestRoute = ViewportTestImport.update({ +const ViewportTestRoute = ViewportTestRouteImport.update({ id: '/viewport-test', path: '/viewport-test', getParentRoute: () => rootRoute, } as any) -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const LayoutRoute = LayoutImport.update({ +const LayoutRoute = LayoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const LayoutLayout2Route = LayoutLayout2Import.update({ +const LayoutLayout2Route = LayoutLayout2RouteImport.update({ id: '/_layout-2', getParentRoute: () => LayoutRoute, } as any) -const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBImport.update({ +const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => LayoutLayout2Route, } as any) -const LayoutLayout2LayoutARoute = LayoutLayout2LayoutAImport.update({ +const LayoutLayout2LayoutARoute = LayoutLayout2LayoutARouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => LayoutLayout2Route, @@ -90,75 +91,168 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/viewport-test': { id: '/viewport-test' path: '/viewport-test' fullPath: '/viewport-test' - preLoaderRoute: typeof ViewportTestImport + preLoaderRoute: typeof ViewportTestRouteImport parentRoute: typeof rootRoute } '/without-loader': { id: '/without-loader' path: '/without-loader' fullPath: '/without-loader' - preLoaderRoute: typeof WithoutLoaderImport + preLoaderRoute: typeof WithoutLoaderRouteImport parentRoute: typeof rootRoute } '/_layout/_layout-2': { id: '/_layout/_layout-2' path: '' fullPath: '' - preLoaderRoute: typeof LayoutLayout2Import - parentRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutLayout2RouteImport + parentRoute: typeof LayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/_layout/_layout-2/layout-a': { id: '/_layout/_layout-2/layout-a' path: '/layout-a' fullPath: '/layout-a' - preLoaderRoute: typeof LayoutLayout2LayoutAImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutARouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/_layout/_layout-2/layout-b': { id: '/_layout/_layout-2/layout-b' path: '/layout-b' fullPath: '/layout-b' - preLoaderRoute: typeof LayoutLayout2LayoutBImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport + parentRoute: typeof LayoutLayout2RouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/viewport-test' { + const createFileRoute: CreateFileRoute< + '/viewport-test', + FileRoutesByPath['/viewport-test']['parentRoute'], + FileRoutesByPath['/viewport-test']['id'], + FileRoutesByPath['/viewport-test']['path'], + FileRoutesByPath['/viewport-test']['fullPath'] + > +} +declare module './routes/without-loader' { + const createFileRoute: CreateFileRoute< + '/without-loader', + FileRoutesByPath['/without-loader']['parentRoute'], + FileRoutesByPath['/without-loader']['id'], + FileRoutesByPath['/without-loader']['path'], + FileRoutesByPath['/without-loader']['fullPath'] + > +} +declare module './routes/_layout/_layout-2' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2', + FileRoutesByPath['/_layout/_layout-2']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2']['id'], + FileRoutesByPath['/_layout/_layout-2']['path'], + FileRoutesByPath['/_layout/_layout-2']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-a' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-a', + FileRoutesByPath['/_layout/_layout-2/layout-a']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-b' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-b', + FileRoutesByPath['/_layout/_layout-2/layout-b']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['fullPath'] + > +} + // Create and export the route tree interface LayoutLayout2RouteChildren { @@ -292,6 +386,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout.tsx b/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout.tsx index 02ddbb1cd9..5c4a461d8d 100644 --- a/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout.tsx +++ b/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2.tsx b/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2.tsx index 3b7dbf2903..483b910862 100644 --- a/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2.tsx +++ b/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout/_layout-2')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-a.tsx b/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-a.tsx index 61e19b4d9f..a190b24202 100644 --- a/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-a.tsx +++ b/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-b.tsx b/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-b.tsx index cceed1fb9a..505f8f6fbf 100644 --- a/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-b.tsx +++ b/e2e/react-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/react-router/basic-file-based-code-splitting/src/routes/index.tsx b/e2e/react-router/basic-file-based-code-splitting/src/routes/index.tsx index eac82a9174..b23956ae17 100644 --- a/e2e/react-router/basic-file-based-code-splitting/src/routes/index.tsx +++ b/e2e/react-router/basic-file-based-code-splitting/src/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.$postId.tsx b/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.$postId.tsx index 47d1148be2..805fa37ed3 100644 --- a/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.$postId.tsx +++ b/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.$postId.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import { fetchPost } from '../posts' import type { ErrorComponentProps } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent as any, notFoundComponent: () => { diff --git a/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.index.tsx b/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.index.tsx index 056433ca0a..fdbe5865e5 100644 --- a/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.index.tsx +++ b/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.tsx b/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.tsx index c7a09ed7f8..4469b2216a 100644 --- a/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.tsx +++ b/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsComponent, }) diff --git a/e2e/react-router/basic-file-based-code-splitting/src/routes/viewport-test.tsx b/e2e/react-router/basic-file-based-code-splitting/src/routes/viewport-test.tsx index d60bf062d3..b182feb7b1 100644 --- a/e2e/react-router/basic-file-based-code-splitting/src/routes/viewport-test.tsx +++ b/e2e/react-router/basic-file-based-code-splitting/src/routes/viewport-test.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/viewport-test')({ +export const Route = createFileRoute({ component: () =>
Hello /viewport-test!
, }) diff --git a/e2e/react-router/basic-file-based-code-splitting/src/routes/without-loader.tsx b/e2e/react-router/basic-file-based-code-splitting/src/routes/without-loader.tsx index 9dddcfe5f4..af692bdaca 100644 --- a/e2e/react-router/basic-file-based-code-splitting/src/routes/without-loader.tsx +++ b/e2e/react-router/basic-file-based-code-splitting/src/routes/without-loader.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/without-loader')({ +export const Route = createFileRoute({ component: () =>
Hello /without-loader!
, }) diff --git a/e2e/react-router/basic-file-based/src/routeTree.gen.ts b/e2e/react-router/basic-file-based/src/routeTree.gen.ts index 0cc7397492..46910315f9 100644 --- a/e2e/react-router/basic-file-based/src/routeTree.gen.ts +++ b/e2e/react-router/basic-file-based/src/routeTree.gen.ts @@ -12,118 +12,135 @@ import { createFileRoute } from '@tanstack/react-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostsImport } from './routes/posts' -import { Route as EditingBImport } from './routes/editing-b' -import { Route as EditingAImport } from './routes/editing-a' -import { Route as AnchorImport } from './routes/anchor' -import { Route as LayoutImport } from './routes/_layout' -import { Route as IndexImport } from './routes/index' -import { Route as RedirectIndexImport } from './routes/redirect/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as StructuralSharingEnabledImport } from './routes/structural-sharing.$enabled' -import { Route as RedirectTargetImport } from './routes/redirect/$target' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as LayoutLayout2Import } from './routes/_layout/_layout-2' -import { Route as groupLazyinsideImport } from './routes/(group)/lazyinside' -import { Route as groupInsideImport } from './routes/(group)/inside' -import { Route as groupLayoutImport } from './routes/(group)/_layout' -import { Route as anotherGroupOnlyrouteinsideImport } from './routes/(another-group)/onlyrouteinside' -import { Route as RedirectTargetIndexImport } from './routes/redirect/$target/index' -import { Route as RedirectPreloadThirdImport } from './routes/redirect/preload/third' -import { Route as RedirectPreloadSecondImport } from './routes/redirect/preload/second' -import { Route as RedirectPreloadFirstImport } from './routes/redirect/preload/first' -import { Route as RedirectTargetViaLoaderImport } from './routes/redirect/$target/via-loader' -import { Route as RedirectTargetViaBeforeLoadImport } from './routes/redirect/$target/via-beforeLoad' -import { Route as PostsPostIdEditImport } from './routes/posts_.$postId.edit' -import { Route as ParamsSingleValueImport } from './routes/params.single.$value' -import { Route as LayoutLayout2LayoutBImport } from './routes/_layout/_layout-2/layout-b' -import { Route as LayoutLayout2LayoutAImport } from './routes/_layout/_layout-2/layout-a' -import { Route as groupSubfolderInsideImport } from './routes/(group)/subfolder/inside' -import { Route as groupLayoutInsidelayoutImport } from './routes/(group)/_layout.insidelayout' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as EditingBRouteImport } from './routes/editing-b' +import { Route as EditingARouteImport } from './routes/editing-a' +import { Route as AnchorRouteImport } from './routes/anchor' +import { Route as LayoutRouteImport } from './routes/_layout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as RedirectIndexRouteImport } from './routes/redirect/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as ParamsPsIndexRouteImport } from './routes/params-ps/index' +import { Route as StructuralSharingEnabledRouteImport } from './routes/structural-sharing.$enabled' +import { Route as RedirectTargetRouteImport } from './routes/redirect/$target' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2' +import { Route as groupLazyinsideRouteImport } from './routes/(group)/lazyinside' +import { Route as groupInsideRouteImport } from './routes/(group)/inside' +import { Route as groupLayoutRouteImport } from './routes/(group)/_layout' +import { Route as anotherGroupOnlyrouteinsideRouteImport } from './routes/(another-group)/onlyrouteinside' +import { Route as RedirectTargetIndexRouteImport } from './routes/redirect/$target/index' +import { Route as ParamsPsWildcardIndexRouteImport } from './routes/params-ps/wildcard/index' +import { Route as ParamsPsNamedIndexRouteImport } from './routes/params-ps/named/index' +import { Route as RedirectPreloadThirdRouteImport } from './routes/redirect/preload/third' +import { Route as RedirectPreloadSecondRouteImport } from './routes/redirect/preload/second' +import { Route as RedirectPreloadFirstRouteImport } from './routes/redirect/preload/first' +import { Route as RedirectTargetViaLoaderRouteImport } from './routes/redirect/$target/via-loader' +import { Route as RedirectTargetViaBeforeLoadRouteImport } from './routes/redirect/$target/via-beforeLoad' +import { Route as PostsPostIdEditRouteImport } from './routes/posts_.$postId.edit' +import { Route as ParamsSingleValueRouteImport } from './routes/params.single.$value' +import { Route as ParamsPsWildcardChar123Char125suffixRouteImport } from './routes/params-ps/wildcard/{$}suffix' +import { Route as ParamsPsWildcardPrefixChar123Char125RouteImport } from './routes/params-ps/wildcard/prefix{$}' +import { Route as ParamsPsWildcardSplatRouteImport } from './routes/params-ps/wildcard/$' +import { Route as ParamsPsNamedChar123fooChar125suffixRouteImport } from './routes/params-ps/named/{$foo}suffix' +import { Route as ParamsPsNamedPrefixChar123fooChar125RouteImport } from './routes/params-ps/named/prefix{$foo}' +import { Route as ParamsPsNamedFooRouteImport } from './routes/params-ps/named/$foo' +import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b' +import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a' +import { Route as groupSubfolderInsideRouteImport } from './routes/(group)/subfolder/inside' +import { Route as groupLayoutInsidelayoutRouteImport } from './routes/(group)/_layout.insidelayout' // Create Virtual Routes -const groupImport = createFileRoute('/(group)')() +const groupRouteImport = createFileRoute('/(group)')() // Create/Update Routes -const groupRoute = groupImport.update({ +const groupRoute = groupRouteImport.update({ id: '/(group)', getParentRoute: () => rootRoute, } as any) -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const EditingBRoute = EditingBImport.update({ +const EditingBRoute = EditingBRouteImport.update({ id: '/editing-b', path: '/editing-b', getParentRoute: () => rootRoute, } as any) -const EditingARoute = EditingAImport.update({ +const EditingARoute = EditingARouteImport.update({ id: '/editing-a', path: '/editing-a', getParentRoute: () => rootRoute, } as any) -const AnchorRoute = AnchorImport.update({ +const AnchorRoute = AnchorRouteImport.update({ id: '/anchor', path: '/anchor', getParentRoute: () => rootRoute, } as any) -const LayoutRoute = LayoutImport.update({ +const LayoutRoute = LayoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const RedirectIndexRoute = RedirectIndexImport.update({ +const RedirectIndexRoute = RedirectIndexRouteImport.update({ id: '/redirect/', path: '/redirect/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const StructuralSharingEnabledRoute = StructuralSharingEnabledImport.update({ - id: '/structural-sharing/$enabled', - path: '/structural-sharing/$enabled', +const ParamsPsIndexRoute = ParamsPsIndexRouteImport.update({ + id: '/params-ps/', + path: '/params-ps/', getParentRoute: () => rootRoute, } as any) -const RedirectTargetRoute = RedirectTargetImport.update({ +const StructuralSharingEnabledRoute = + StructuralSharingEnabledRouteImport.update({ + id: '/structural-sharing/$enabled', + path: '/structural-sharing/$enabled', + getParentRoute: () => rootRoute, + } as any) + +const RedirectTargetRoute = RedirectTargetRouteImport.update({ id: '/redirect/$target', path: '/redirect/$target', getParentRoute: () => rootRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const LayoutLayout2Route = LayoutLayout2Import.update({ +const LayoutLayout2Route = LayoutLayout2RouteImport.update({ id: '/_layout-2', getParentRoute: () => LayoutRoute, } as any) -const groupLazyinsideRoute = groupLazyinsideImport +const groupLazyinsideRoute = groupLazyinsideRouteImport .update({ id: '/lazyinside', path: '/lazyinside', @@ -131,92 +148,144 @@ const groupLazyinsideRoute = groupLazyinsideImport } as any) .lazy(() => import('./routes/(group)/lazyinside.lazy').then((d) => d.Route)) -const groupInsideRoute = groupInsideImport.update({ +const groupInsideRoute = groupInsideRouteImport.update({ id: '/inside', path: '/inside', getParentRoute: () => groupRoute, } as any) -const groupLayoutRoute = groupLayoutImport.update({ +const groupLayoutRoute = groupLayoutRouteImport.update({ id: '/_layout', getParentRoute: () => groupRoute, } as any) const anotherGroupOnlyrouteinsideRoute = - anotherGroupOnlyrouteinsideImport.update({ + anotherGroupOnlyrouteinsideRouteImport.update({ id: '/(another-group)/onlyrouteinside', path: '/onlyrouteinside', getParentRoute: () => rootRoute, } as any) -const RedirectTargetIndexRoute = RedirectTargetIndexImport.update({ +const RedirectTargetIndexRoute = RedirectTargetIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => RedirectTargetRoute, } as any) -const RedirectPreloadThirdRoute = RedirectPreloadThirdImport.update({ +const ParamsPsWildcardIndexRoute = ParamsPsWildcardIndexRouteImport.update({ + id: '/params-ps/wildcard/', + path: '/params-ps/wildcard/', + getParentRoute: () => rootRoute, +} as any) + +const ParamsPsNamedIndexRoute = ParamsPsNamedIndexRouteImport.update({ + id: '/params-ps/named/', + path: '/params-ps/named/', + getParentRoute: () => rootRoute, +} as any) + +const RedirectPreloadThirdRoute = RedirectPreloadThirdRouteImport.update({ id: '/redirect/preload/third', path: '/redirect/preload/third', getParentRoute: () => rootRoute, } as any) -const RedirectPreloadSecondRoute = RedirectPreloadSecondImport.update({ +const RedirectPreloadSecondRoute = RedirectPreloadSecondRouteImport.update({ id: '/redirect/preload/second', path: '/redirect/preload/second', getParentRoute: () => rootRoute, } as any) -const RedirectPreloadFirstRoute = RedirectPreloadFirstImport.update({ +const RedirectPreloadFirstRoute = RedirectPreloadFirstRouteImport.update({ id: '/redirect/preload/first', path: '/redirect/preload/first', getParentRoute: () => rootRoute, } as any) -const RedirectTargetViaLoaderRoute = RedirectTargetViaLoaderImport.update({ +const RedirectTargetViaLoaderRoute = RedirectTargetViaLoaderRouteImport.update({ id: '/via-loader', path: '/via-loader', getParentRoute: () => RedirectTargetRoute, } as any) const RedirectTargetViaBeforeLoadRoute = - RedirectTargetViaBeforeLoadImport.update({ + RedirectTargetViaBeforeLoadRouteImport.update({ id: '/via-beforeLoad', path: '/via-beforeLoad', getParentRoute: () => RedirectTargetRoute, } as any) -const PostsPostIdEditRoute = PostsPostIdEditImport.update({ +const PostsPostIdEditRoute = PostsPostIdEditRouteImport.update({ id: '/posts_/$postId/edit', path: '/posts/$postId/edit', getParentRoute: () => rootRoute, } as any) -const ParamsSingleValueRoute = ParamsSingleValueImport.update({ +const ParamsSingleValueRoute = ParamsSingleValueRouteImport.update({ id: '/params/single/$value', path: '/params/single/$value', getParentRoute: () => rootRoute, } as any) -const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBImport.update({ +const ParamsPsWildcardChar123Char125suffixRoute = + ParamsPsWildcardChar123Char125suffixRouteImport.update({ + id: '/params-ps/wildcard/{$}suffix', + path: '/params-ps/wildcard/{$}suffix', + getParentRoute: () => rootRoute, + } as any) + +const ParamsPsWildcardPrefixChar123Char125Route = + ParamsPsWildcardPrefixChar123Char125RouteImport.update({ + id: '/params-ps/wildcard/prefix{$}', + path: '/params-ps/wildcard/prefix{$}', + getParentRoute: () => rootRoute, + } as any) + +const ParamsPsWildcardSplatRoute = ParamsPsWildcardSplatRouteImport.update({ + id: '/params-ps/wildcard/$', + path: '/params-ps/wildcard/$', + getParentRoute: () => rootRoute, +} as any) + +const ParamsPsNamedChar123fooChar125suffixRoute = + ParamsPsNamedChar123fooChar125suffixRouteImport.update({ + id: '/params-ps/named/{$foo}suffix', + path: '/params-ps/named/{$foo}suffix', + getParentRoute: () => rootRoute, + } as any) + +const ParamsPsNamedPrefixChar123fooChar125Route = + ParamsPsNamedPrefixChar123fooChar125RouteImport.update({ + id: '/params-ps/named/prefix{$foo}', + path: '/params-ps/named/prefix{$foo}', + getParentRoute: () => rootRoute, + } as any) + +const ParamsPsNamedFooRoute = ParamsPsNamedFooRouteImport.update({ + id: '/params-ps/named/$foo', + path: '/params-ps/named/$foo', + getParentRoute: () => rootRoute, +} as any) + +const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => LayoutLayout2Route, } as any) -const LayoutLayout2LayoutARoute = LayoutLayout2LayoutAImport.update({ +const LayoutLayout2LayoutARoute = LayoutLayout2LayoutARouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => LayoutLayout2Route, } as any) -const groupSubfolderInsideRoute = groupSubfolderInsideImport.update({ +const groupSubfolderInsideRoute = groupSubfolderInsideRouteImport.update({ id: '/subfolder/inside', path: '/subfolder/inside', getParentRoute: () => groupRoute, } as any) -const groupLayoutInsidelayoutRoute = groupLayoutInsidelayoutImport.update({ +const groupLayoutInsidelayoutRoute = groupLayoutInsidelayoutRouteImport.update({ id: '/insidelayout', path: '/insidelayout', getParentRoute: () => groupLayoutRoute, @@ -230,208 +299,625 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutRouteImport parentRoute: typeof rootRoute } '/anchor': { id: '/anchor' path: '/anchor' fullPath: '/anchor' - preLoaderRoute: typeof AnchorImport + preLoaderRoute: typeof AnchorRouteImport parentRoute: typeof rootRoute } '/editing-a': { id: '/editing-a' path: '/editing-a' fullPath: '/editing-a' - preLoaderRoute: typeof EditingAImport + preLoaderRoute: typeof EditingARouteImport parentRoute: typeof rootRoute } '/editing-b': { id: '/editing-b' path: '/editing-b' fullPath: '/editing-b' - preLoaderRoute: typeof EditingBImport + preLoaderRoute: typeof EditingBRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/(another-group)/onlyrouteinside': { id: '/(another-group)/onlyrouteinside' path: '/onlyrouteinside' fullPath: '/onlyrouteinside' - preLoaderRoute: typeof anotherGroupOnlyrouteinsideImport + preLoaderRoute: typeof anotherGroupOnlyrouteinsideRouteImport parentRoute: typeof rootRoute } '/(group)': { id: '/(group)' path: '/' fullPath: '/' - preLoaderRoute: typeof groupImport + preLoaderRoute: typeof groupRouteImport parentRoute: typeof rootRoute } '/(group)/_layout': { id: '/(group)/_layout' path: '/' fullPath: '/' - preLoaderRoute: typeof groupLayoutImport + preLoaderRoute: typeof groupLayoutRouteImport parentRoute: typeof groupRoute } '/(group)/inside': { id: '/(group)/inside' path: '/inside' fullPath: '/inside' - preLoaderRoute: typeof groupInsideImport - parentRoute: typeof groupImport + preLoaderRoute: typeof groupInsideRouteImport + parentRoute: typeof groupRouteImport } '/(group)/lazyinside': { id: '/(group)/lazyinside' path: '/lazyinside' fullPath: '/lazyinside' - preLoaderRoute: typeof groupLazyinsideImport - parentRoute: typeof groupImport + preLoaderRoute: typeof groupLazyinsideRouteImport + parentRoute: typeof groupRouteImport } '/_layout/_layout-2': { id: '/_layout/_layout-2' path: '' fullPath: '' - preLoaderRoute: typeof LayoutLayout2Import - parentRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutLayout2RouteImport + parentRoute: typeof LayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/redirect/$target': { id: '/redirect/$target' path: '/redirect/$target' fullPath: '/redirect/$target' - preLoaderRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetRouteImport parentRoute: typeof rootRoute } '/structural-sharing/$enabled': { id: '/structural-sharing/$enabled' path: '/structural-sharing/$enabled' fullPath: '/structural-sharing/$enabled' - preLoaderRoute: typeof StructuralSharingEnabledImport + preLoaderRoute: typeof StructuralSharingEnabledRouteImport + parentRoute: typeof rootRoute + } + '/params-ps/': { + id: '/params-ps/' + path: '/params-ps' + fullPath: '/params-ps' + preLoaderRoute: typeof ParamsPsIndexRouteImport parentRoute: typeof rootRoute } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/redirect/': { id: '/redirect/' path: '/redirect' fullPath: '/redirect' - preLoaderRoute: typeof RedirectIndexImport + preLoaderRoute: typeof RedirectIndexRouteImport parentRoute: typeof rootRoute } '/(group)/_layout/insidelayout': { id: '/(group)/_layout/insidelayout' path: '/insidelayout' fullPath: '/insidelayout' - preLoaderRoute: typeof groupLayoutInsidelayoutImport - parentRoute: typeof groupLayoutImport + preLoaderRoute: typeof groupLayoutInsidelayoutRouteImport + parentRoute: typeof groupLayoutRouteImport } '/(group)/subfolder/inside': { id: '/(group)/subfolder/inside' path: '/subfolder/inside' fullPath: '/subfolder/inside' - preLoaderRoute: typeof groupSubfolderInsideImport - parentRoute: typeof groupImport + preLoaderRoute: typeof groupSubfolderInsideRouteImport + parentRoute: typeof groupRouteImport } '/_layout/_layout-2/layout-a': { id: '/_layout/_layout-2/layout-a' path: '/layout-a' fullPath: '/layout-a' - preLoaderRoute: typeof LayoutLayout2LayoutAImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutARouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/_layout/_layout-2/layout-b': { id: '/_layout/_layout-2/layout-b' path: '/layout-b' fullPath: '/layout-b' - preLoaderRoute: typeof LayoutLayout2LayoutBImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport + parentRoute: typeof LayoutLayout2RouteImport + } + '/params-ps/named/$foo': { + id: '/params-ps/named/$foo' + path: '/params-ps/named/$foo' + fullPath: '/params-ps/named/$foo' + preLoaderRoute: typeof ParamsPsNamedFooRouteImport + parentRoute: typeof rootRoute + } + '/params-ps/named/prefix{$foo}': { + id: '/params-ps/named/prefix{$foo}' + path: '/params-ps/named/prefix{$foo}' + fullPath: '/params-ps/named/prefix{$foo}' + preLoaderRoute: typeof ParamsPsNamedPrefixChar123fooChar125RouteImport + parentRoute: typeof rootRoute + } + '/params-ps/named/{$foo}suffix': { + id: '/params-ps/named/{$foo}suffix' + path: '/params-ps/named/{$foo}suffix' + fullPath: '/params-ps/named/{$foo}suffix' + preLoaderRoute: typeof ParamsPsNamedChar123fooChar125suffixRouteImport + parentRoute: typeof rootRoute + } + '/params-ps/wildcard/$': { + id: '/params-ps/wildcard/$' + path: '/params-ps/wildcard/$' + fullPath: '/params-ps/wildcard/$' + preLoaderRoute: typeof ParamsPsWildcardSplatRouteImport + parentRoute: typeof rootRoute + } + '/params-ps/wildcard/prefix{$}': { + id: '/params-ps/wildcard/prefix{$}' + path: '/params-ps/wildcard/prefix{$}' + fullPath: '/params-ps/wildcard/prefix{$}' + preLoaderRoute: typeof ParamsPsWildcardPrefixChar123Char125RouteImport + parentRoute: typeof rootRoute + } + '/params-ps/wildcard/{$}suffix': { + id: '/params-ps/wildcard/{$}suffix' + path: '/params-ps/wildcard/{$}suffix' + fullPath: '/params-ps/wildcard/{$}suffix' + preLoaderRoute: typeof ParamsPsWildcardChar123Char125suffixRouteImport + parentRoute: typeof rootRoute } '/params/single/$value': { id: '/params/single/$value' path: '/params/single/$value' fullPath: '/params/single/$value' - preLoaderRoute: typeof ParamsSingleValueImport + preLoaderRoute: typeof ParamsSingleValueRouteImport parentRoute: typeof rootRoute } '/posts_/$postId/edit': { id: '/posts_/$postId/edit' path: '/posts/$postId/edit' fullPath: '/posts/$postId/edit' - preLoaderRoute: typeof PostsPostIdEditImport + preLoaderRoute: typeof PostsPostIdEditRouteImport parentRoute: typeof rootRoute } '/redirect/$target/via-beforeLoad': { id: '/redirect/$target/via-beforeLoad' path: '/via-beforeLoad' fullPath: '/redirect/$target/via-beforeLoad' - preLoaderRoute: typeof RedirectTargetViaBeforeLoadImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetViaBeforeLoadRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/via-loader': { id: '/redirect/$target/via-loader' path: '/via-loader' fullPath: '/redirect/$target/via-loader' - preLoaderRoute: typeof RedirectTargetViaLoaderImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetViaLoaderRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/preload/first': { id: '/redirect/preload/first' path: '/redirect/preload/first' fullPath: '/redirect/preload/first' - preLoaderRoute: typeof RedirectPreloadFirstImport + preLoaderRoute: typeof RedirectPreloadFirstRouteImport parentRoute: typeof rootRoute } '/redirect/preload/second': { id: '/redirect/preload/second' path: '/redirect/preload/second' fullPath: '/redirect/preload/second' - preLoaderRoute: typeof RedirectPreloadSecondImport + preLoaderRoute: typeof RedirectPreloadSecondRouteImport parentRoute: typeof rootRoute } '/redirect/preload/third': { id: '/redirect/preload/third' path: '/redirect/preload/third' fullPath: '/redirect/preload/third' - preLoaderRoute: typeof RedirectPreloadThirdImport + preLoaderRoute: typeof RedirectPreloadThirdRouteImport + parentRoute: typeof rootRoute + } + '/params-ps/named/': { + id: '/params-ps/named/' + path: '/params-ps/named' + fullPath: '/params-ps/named' + preLoaderRoute: typeof ParamsPsNamedIndexRouteImport + parentRoute: typeof rootRoute + } + '/params-ps/wildcard/': { + id: '/params-ps/wildcard/' + path: '/params-ps/wildcard' + fullPath: '/params-ps/wildcard' + preLoaderRoute: typeof ParamsPsWildcardIndexRouteImport parentRoute: typeof rootRoute } '/redirect/$target/': { id: '/redirect/$target/' path: '/' fullPath: '/redirect/$target/' - preLoaderRoute: typeof RedirectTargetIndexImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetIndexRouteImport + parentRoute: typeof RedirectTargetRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/anchor' { + const createFileRoute: CreateFileRoute< + '/anchor', + FileRoutesByPath['/anchor']['parentRoute'], + FileRoutesByPath['/anchor']['id'], + FileRoutesByPath['/anchor']['path'], + FileRoutesByPath['/anchor']['fullPath'] + > +} +declare module './routes/editing-a' { + const createFileRoute: CreateFileRoute< + '/editing-a', + FileRoutesByPath['/editing-a']['parentRoute'], + FileRoutesByPath['/editing-a']['id'], + FileRoutesByPath['/editing-a']['path'], + FileRoutesByPath['/editing-a']['fullPath'] + > +} +declare module './routes/editing-b' { + const createFileRoute: CreateFileRoute< + '/editing-b', + FileRoutesByPath['/editing-b']['parentRoute'], + FileRoutesByPath['/editing-b']['id'], + FileRoutesByPath['/editing-b']['path'], + FileRoutesByPath['/editing-b']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/(another-group)/onlyrouteinside' { + const createFileRoute: CreateFileRoute< + '/(another-group)/onlyrouteinside', + FileRoutesByPath['/(another-group)/onlyrouteinside']['parentRoute'], + FileRoutesByPath['/(another-group)/onlyrouteinside']['id'], + FileRoutesByPath['/(another-group)/onlyrouteinside']['path'], + FileRoutesByPath['/(another-group)/onlyrouteinside']['fullPath'] + > +} +declare module './routes/(group)' { + const createFileRoute: CreateFileRoute< + '/(group)', + FileRoutesByPath['/(group)']['parentRoute'], + FileRoutesByPath['/(group)']['id'], + FileRoutesByPath['/(group)']['path'], + FileRoutesByPath['/(group)']['fullPath'] + > +} +declare module './routes/(group)/_layout' { + const createFileRoute: CreateFileRoute< + '/(group)/_layout', + FileRoutesByPath['/(group)/_layout']['parentRoute'], + FileRoutesByPath['/(group)/_layout']['id'], + FileRoutesByPath['/(group)/_layout']['path'], + FileRoutesByPath['/(group)/_layout']['fullPath'] + > +} +declare module './routes/(group)/inside' { + const createFileRoute: CreateFileRoute< + '/(group)/inside', + FileRoutesByPath['/(group)/inside']['parentRoute'], + FileRoutesByPath['/(group)/inside']['id'], + FileRoutesByPath['/(group)/inside']['path'], + FileRoutesByPath['/(group)/inside']['fullPath'] + > +} +declare module './routes/(group)/lazyinside' { + const createFileRoute: CreateFileRoute< + '/(group)/lazyinside', + FileRoutesByPath['/(group)/lazyinside']['parentRoute'], + FileRoutesByPath['/(group)/lazyinside']['id'], + FileRoutesByPath['/(group)/lazyinside']['path'], + FileRoutesByPath['/(group)/lazyinside']['fullPath'] + > +} +declare module './routes/(group)/lazyinside.lazy' { + const createLazyFileRoute: CreateFileRoute< + '/(group)/lazyinside', + FileRoutesByPath['/(group)/lazyinside']['parentRoute'], + FileRoutesByPath['/(group)/lazyinside']['id'], + FileRoutesByPath['/(group)/lazyinside']['path'], + FileRoutesByPath['/(group)/lazyinside']['fullPath'] + > +} +declare module './routes/_layout/_layout-2' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2', + FileRoutesByPath['/_layout/_layout-2']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2']['id'], + FileRoutesByPath['/_layout/_layout-2']['path'], + FileRoutesByPath['/_layout/_layout-2']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/redirect/$target' { + const createFileRoute: CreateFileRoute< + '/redirect/$target', + FileRoutesByPath['/redirect/$target']['parentRoute'], + FileRoutesByPath['/redirect/$target']['id'], + FileRoutesByPath['/redirect/$target']['path'], + FileRoutesByPath['/redirect/$target']['fullPath'] + > +} +declare module './routes/structural-sharing.$enabled' { + const createFileRoute: CreateFileRoute< + '/structural-sharing/$enabled', + FileRoutesByPath['/structural-sharing/$enabled']['parentRoute'], + FileRoutesByPath['/structural-sharing/$enabled']['id'], + FileRoutesByPath['/structural-sharing/$enabled']['path'], + FileRoutesByPath['/structural-sharing/$enabled']['fullPath'] + > +} +declare module './routes/params-ps/index' { + const createFileRoute: CreateFileRoute< + '/params-ps/', + FileRoutesByPath['/params-ps/']['parentRoute'], + FileRoutesByPath['/params-ps/']['id'], + FileRoutesByPath['/params-ps/']['path'], + FileRoutesByPath['/params-ps/']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/redirect/index' { + const createFileRoute: CreateFileRoute< + '/redirect/', + FileRoutesByPath['/redirect/']['parentRoute'], + FileRoutesByPath['/redirect/']['id'], + FileRoutesByPath['/redirect/']['path'], + FileRoutesByPath['/redirect/']['fullPath'] + > +} +declare module './routes/(group)/_layout.insidelayout' { + const createFileRoute: CreateFileRoute< + '/(group)/_layout/insidelayout', + FileRoutesByPath['/(group)/_layout/insidelayout']['parentRoute'], + FileRoutesByPath['/(group)/_layout/insidelayout']['id'], + FileRoutesByPath['/(group)/_layout/insidelayout']['path'], + FileRoutesByPath['/(group)/_layout/insidelayout']['fullPath'] + > +} +declare module './routes/(group)/subfolder/inside' { + const createFileRoute: CreateFileRoute< + '/(group)/subfolder/inside', + FileRoutesByPath['/(group)/subfolder/inside']['parentRoute'], + FileRoutesByPath['/(group)/subfolder/inside']['id'], + FileRoutesByPath['/(group)/subfolder/inside']['path'], + FileRoutesByPath['/(group)/subfolder/inside']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-a' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-a', + FileRoutesByPath['/_layout/_layout-2/layout-a']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-b' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-b', + FileRoutesByPath['/_layout/_layout-2/layout-b']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['fullPath'] + > +} +declare module './routes/params-ps/named/$foo' { + const createFileRoute: CreateFileRoute< + '/params-ps/named/$foo', + FileRoutesByPath['/params-ps/named/$foo']['parentRoute'], + FileRoutesByPath['/params-ps/named/$foo']['id'], + FileRoutesByPath['/params-ps/named/$foo']['path'], + FileRoutesByPath['/params-ps/named/$foo']['fullPath'] + > +} +declare module './routes/params-ps/named/prefix{$foo}' { + const createFileRoute: CreateFileRoute< + '/params-ps/named/prefix{$foo}', + FileRoutesByPath['/params-ps/named/prefix{$foo}']['parentRoute'], + FileRoutesByPath['/params-ps/named/prefix{$foo}']['id'], + FileRoutesByPath['/params-ps/named/prefix{$foo}']['path'], + FileRoutesByPath['/params-ps/named/prefix{$foo}']['fullPath'] + > +} +declare module './routes/params-ps/named/{$foo}suffix' { + const createFileRoute: CreateFileRoute< + '/params-ps/named/{$foo}suffix', + FileRoutesByPath['/params-ps/named/{$foo}suffix']['parentRoute'], + FileRoutesByPath['/params-ps/named/{$foo}suffix']['id'], + FileRoutesByPath['/params-ps/named/{$foo}suffix']['path'], + FileRoutesByPath['/params-ps/named/{$foo}suffix']['fullPath'] + > +} +declare module './routes/params-ps/wildcard/$' { + const createFileRoute: CreateFileRoute< + '/params-ps/wildcard/$', + FileRoutesByPath['/params-ps/wildcard/$']['parentRoute'], + FileRoutesByPath['/params-ps/wildcard/$']['id'], + FileRoutesByPath['/params-ps/wildcard/$']['path'], + FileRoutesByPath['/params-ps/wildcard/$']['fullPath'] + > +} +declare module './routes/params-ps/wildcard/prefix{$}' { + const createFileRoute: CreateFileRoute< + '/params-ps/wildcard/prefix{$}', + FileRoutesByPath['/params-ps/wildcard/prefix{$}']['parentRoute'], + FileRoutesByPath['/params-ps/wildcard/prefix{$}']['id'], + FileRoutesByPath['/params-ps/wildcard/prefix{$}']['path'], + FileRoutesByPath['/params-ps/wildcard/prefix{$}']['fullPath'] + > +} +declare module './routes/params-ps/wildcard/{$}suffix' { + const createFileRoute: CreateFileRoute< + '/params-ps/wildcard/{$}suffix', + FileRoutesByPath['/params-ps/wildcard/{$}suffix']['parentRoute'], + FileRoutesByPath['/params-ps/wildcard/{$}suffix']['id'], + FileRoutesByPath['/params-ps/wildcard/{$}suffix']['path'], + FileRoutesByPath['/params-ps/wildcard/{$}suffix']['fullPath'] + > +} +declare module './routes/params.single.$value' { + const createFileRoute: CreateFileRoute< + '/params/single/$value', + FileRoutesByPath['/params/single/$value']['parentRoute'], + FileRoutesByPath['/params/single/$value']['id'], + FileRoutesByPath['/params/single/$value']['path'], + FileRoutesByPath['/params/single/$value']['fullPath'] + > +} +declare module './routes/posts_.$postId.edit' { + const createFileRoute: CreateFileRoute< + '/posts_/$postId/edit', + FileRoutesByPath['/posts_/$postId/edit']['parentRoute'], + FileRoutesByPath['/posts_/$postId/edit']['id'], + FileRoutesByPath['/posts_/$postId/edit']['path'], + FileRoutesByPath['/posts_/$postId/edit']['fullPath'] + > +} +declare module './routes/redirect/$target/via-beforeLoad' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/via-beforeLoad', + FileRoutesByPath['/redirect/$target/via-beforeLoad']['parentRoute'], + FileRoutesByPath['/redirect/$target/via-beforeLoad']['id'], + FileRoutesByPath['/redirect/$target/via-beforeLoad']['path'], + FileRoutesByPath['/redirect/$target/via-beforeLoad']['fullPath'] + > +} +declare module './routes/redirect/$target/via-loader' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/via-loader', + FileRoutesByPath['/redirect/$target/via-loader']['parentRoute'], + FileRoutesByPath['/redirect/$target/via-loader']['id'], + FileRoutesByPath['/redirect/$target/via-loader']['path'], + FileRoutesByPath['/redirect/$target/via-loader']['fullPath'] + > +} +declare module './routes/redirect/preload/first' { + const createFileRoute: CreateFileRoute< + '/redirect/preload/first', + FileRoutesByPath['/redirect/preload/first']['parentRoute'], + FileRoutesByPath['/redirect/preload/first']['id'], + FileRoutesByPath['/redirect/preload/first']['path'], + FileRoutesByPath['/redirect/preload/first']['fullPath'] + > +} +declare module './routes/redirect/preload/second' { + const createFileRoute: CreateFileRoute< + '/redirect/preload/second', + FileRoutesByPath['/redirect/preload/second']['parentRoute'], + FileRoutesByPath['/redirect/preload/second']['id'], + FileRoutesByPath['/redirect/preload/second']['path'], + FileRoutesByPath['/redirect/preload/second']['fullPath'] + > +} +declare module './routes/redirect/preload/third' { + const createFileRoute: CreateFileRoute< + '/redirect/preload/third', + FileRoutesByPath['/redirect/preload/third']['parentRoute'], + FileRoutesByPath['/redirect/preload/third']['id'], + FileRoutesByPath['/redirect/preload/third']['path'], + FileRoutesByPath['/redirect/preload/third']['fullPath'] + > +} +declare module './routes/params-ps/named/index' { + const createFileRoute: CreateFileRoute< + '/params-ps/named/', + FileRoutesByPath['/params-ps/named/']['parentRoute'], + FileRoutesByPath['/params-ps/named/']['id'], + FileRoutesByPath['/params-ps/named/']['path'], + FileRoutesByPath['/params-ps/named/']['fullPath'] + > +} +declare module './routes/params-ps/wildcard/index' { + const createFileRoute: CreateFileRoute< + '/params-ps/wildcard/', + FileRoutesByPath['/params-ps/wildcard/']['parentRoute'], + FileRoutesByPath['/params-ps/wildcard/']['id'], + FileRoutesByPath['/params-ps/wildcard/']['path'], + FileRoutesByPath['/params-ps/wildcard/']['fullPath'] + > +} +declare module './routes/redirect/$target/index' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/', + FileRoutesByPath['/redirect/$target/']['parentRoute'], + FileRoutesByPath['/redirect/$target/']['id'], + FileRoutesByPath['/redirect/$target/']['path'], + FileRoutesByPath['/redirect/$target/']['fullPath'] + > +} + // Create and export the route tree interface LayoutLayout2RouteChildren { @@ -528,12 +1014,19 @@ export interface FileRoutesByFullPath { '/posts/$postId': typeof PostsPostIdRoute '/redirect/$target': typeof RedirectTargetRouteWithChildren '/structural-sharing/$enabled': typeof StructuralSharingEnabledRoute + '/params-ps': typeof ParamsPsIndexRoute '/posts/': typeof PostsIndexRoute '/redirect': typeof RedirectIndexRoute '/insidelayout': typeof groupLayoutInsidelayoutRoute '/subfolder/inside': typeof groupSubfolderInsideRoute '/layout-a': typeof LayoutLayout2LayoutARoute '/layout-b': typeof LayoutLayout2LayoutBRoute + '/params-ps/named/$foo': typeof ParamsPsNamedFooRoute + '/params-ps/named/prefix{$foo}': typeof ParamsPsNamedPrefixChar123fooChar125Route + '/params-ps/named/{$foo}suffix': typeof ParamsPsNamedChar123fooChar125suffixRoute + '/params-ps/wildcard/$': typeof ParamsPsWildcardSplatRoute + '/params-ps/wildcard/prefix{$}': typeof ParamsPsWildcardPrefixChar123Char125Route + '/params-ps/wildcard/{$}suffix': typeof ParamsPsWildcardChar123Char125suffixRoute '/params/single/$value': typeof ParamsSingleValueRoute '/posts/$postId/edit': typeof PostsPostIdEditRoute '/redirect/$target/via-beforeLoad': typeof RedirectTargetViaBeforeLoadRoute @@ -541,6 +1034,8 @@ export interface FileRoutesByFullPath { '/redirect/preload/first': typeof RedirectPreloadFirstRoute '/redirect/preload/second': typeof RedirectPreloadSecondRoute '/redirect/preload/third': typeof RedirectPreloadThirdRoute + '/params-ps/named': typeof ParamsPsNamedIndexRoute + '/params-ps/wildcard': typeof ParamsPsWildcardIndexRoute '/redirect/$target/': typeof RedirectTargetIndexRoute } @@ -555,12 +1050,19 @@ export interface FileRoutesByTo { '/lazyinside': typeof groupLazyinsideRoute '/posts/$postId': typeof PostsPostIdRoute '/structural-sharing/$enabled': typeof StructuralSharingEnabledRoute + '/params-ps': typeof ParamsPsIndexRoute '/posts': typeof PostsIndexRoute '/redirect': typeof RedirectIndexRoute '/insidelayout': typeof groupLayoutInsidelayoutRoute '/subfolder/inside': typeof groupSubfolderInsideRoute '/layout-a': typeof LayoutLayout2LayoutARoute '/layout-b': typeof LayoutLayout2LayoutBRoute + '/params-ps/named/$foo': typeof ParamsPsNamedFooRoute + '/params-ps/named/prefix{$foo}': typeof ParamsPsNamedPrefixChar123fooChar125Route + '/params-ps/named/{$foo}suffix': typeof ParamsPsNamedChar123fooChar125suffixRoute + '/params-ps/wildcard/$': typeof ParamsPsWildcardSplatRoute + '/params-ps/wildcard/prefix{$}': typeof ParamsPsWildcardPrefixChar123Char125Route + '/params-ps/wildcard/{$}suffix': typeof ParamsPsWildcardChar123Char125suffixRoute '/params/single/$value': typeof ParamsSingleValueRoute '/posts/$postId/edit': typeof PostsPostIdEditRoute '/redirect/$target/via-beforeLoad': typeof RedirectTargetViaBeforeLoadRoute @@ -568,6 +1070,8 @@ export interface FileRoutesByTo { '/redirect/preload/first': typeof RedirectPreloadFirstRoute '/redirect/preload/second': typeof RedirectPreloadSecondRoute '/redirect/preload/third': typeof RedirectPreloadThirdRoute + '/params-ps/named': typeof ParamsPsNamedIndexRoute + '/params-ps/wildcard': typeof ParamsPsWildcardIndexRoute '/redirect/$target': typeof RedirectTargetIndexRoute } @@ -588,12 +1092,19 @@ export interface FileRoutesById { '/posts/$postId': typeof PostsPostIdRoute '/redirect/$target': typeof RedirectTargetRouteWithChildren '/structural-sharing/$enabled': typeof StructuralSharingEnabledRoute + '/params-ps/': typeof ParamsPsIndexRoute '/posts/': typeof PostsIndexRoute '/redirect/': typeof RedirectIndexRoute '/(group)/_layout/insidelayout': typeof groupLayoutInsidelayoutRoute '/(group)/subfolder/inside': typeof groupSubfolderInsideRoute '/_layout/_layout-2/layout-a': typeof LayoutLayout2LayoutARoute '/_layout/_layout-2/layout-b': typeof LayoutLayout2LayoutBRoute + '/params-ps/named/$foo': typeof ParamsPsNamedFooRoute + '/params-ps/named/prefix{$foo}': typeof ParamsPsNamedPrefixChar123fooChar125Route + '/params-ps/named/{$foo}suffix': typeof ParamsPsNamedChar123fooChar125suffixRoute + '/params-ps/wildcard/$': typeof ParamsPsWildcardSplatRoute + '/params-ps/wildcard/prefix{$}': typeof ParamsPsWildcardPrefixChar123Char125Route + '/params-ps/wildcard/{$}suffix': typeof ParamsPsWildcardChar123Char125suffixRoute '/params/single/$value': typeof ParamsSingleValueRoute '/posts_/$postId/edit': typeof PostsPostIdEditRoute '/redirect/$target/via-beforeLoad': typeof RedirectTargetViaBeforeLoadRoute @@ -601,6 +1112,8 @@ export interface FileRoutesById { '/redirect/preload/first': typeof RedirectPreloadFirstRoute '/redirect/preload/second': typeof RedirectPreloadSecondRoute '/redirect/preload/third': typeof RedirectPreloadThirdRoute + '/params-ps/named/': typeof ParamsPsNamedIndexRoute + '/params-ps/wildcard/': typeof ParamsPsWildcardIndexRoute '/redirect/$target/': typeof RedirectTargetIndexRoute } @@ -619,12 +1132,19 @@ export interface FileRouteTypes { | '/posts/$postId' | '/redirect/$target' | '/structural-sharing/$enabled' + | '/params-ps' | '/posts/' | '/redirect' | '/insidelayout' | '/subfolder/inside' | '/layout-a' | '/layout-b' + | '/params-ps/named/$foo' + | '/params-ps/named/prefix{$foo}' + | '/params-ps/named/{$foo}suffix' + | '/params-ps/wildcard/$' + | '/params-ps/wildcard/prefix{$}' + | '/params-ps/wildcard/{$}suffix' | '/params/single/$value' | '/posts/$postId/edit' | '/redirect/$target/via-beforeLoad' @@ -632,6 +1152,8 @@ export interface FileRouteTypes { | '/redirect/preload/first' | '/redirect/preload/second' | '/redirect/preload/third' + | '/params-ps/named' + | '/params-ps/wildcard' | '/redirect/$target/' fileRoutesByTo: FileRoutesByTo to: @@ -645,12 +1167,19 @@ export interface FileRouteTypes { | '/lazyinside' | '/posts/$postId' | '/structural-sharing/$enabled' + | '/params-ps' | '/posts' | '/redirect' | '/insidelayout' | '/subfolder/inside' | '/layout-a' | '/layout-b' + | '/params-ps/named/$foo' + | '/params-ps/named/prefix{$foo}' + | '/params-ps/named/{$foo}suffix' + | '/params-ps/wildcard/$' + | '/params-ps/wildcard/prefix{$}' + | '/params-ps/wildcard/{$}suffix' | '/params/single/$value' | '/posts/$postId/edit' | '/redirect/$target/via-beforeLoad' @@ -658,6 +1187,8 @@ export interface FileRouteTypes { | '/redirect/preload/first' | '/redirect/preload/second' | '/redirect/preload/third' + | '/params-ps/named' + | '/params-ps/wildcard' | '/redirect/$target' id: | '__root__' @@ -676,12 +1207,19 @@ export interface FileRouteTypes { | '/posts/$postId' | '/redirect/$target' | '/structural-sharing/$enabled' + | '/params-ps/' | '/posts/' | '/redirect/' | '/(group)/_layout/insidelayout' | '/(group)/subfolder/inside' | '/_layout/_layout-2/layout-a' | '/_layout/_layout-2/layout-b' + | '/params-ps/named/$foo' + | '/params-ps/named/prefix{$foo}' + | '/params-ps/named/{$foo}suffix' + | '/params-ps/wildcard/$' + | '/params-ps/wildcard/prefix{$}' + | '/params-ps/wildcard/{$}suffix' | '/params/single/$value' | '/posts_/$postId/edit' | '/redirect/$target/via-beforeLoad' @@ -689,6 +1227,8 @@ export interface FileRouteTypes { | '/redirect/preload/first' | '/redirect/preload/second' | '/redirect/preload/third' + | '/params-ps/named/' + | '/params-ps/wildcard/' | '/redirect/$target/' fileRoutesById: FileRoutesById } @@ -704,12 +1244,21 @@ export interface RootRouteChildren { groupRoute: typeof groupRouteWithChildren RedirectTargetRoute: typeof RedirectTargetRouteWithChildren StructuralSharingEnabledRoute: typeof StructuralSharingEnabledRoute + ParamsPsIndexRoute: typeof ParamsPsIndexRoute RedirectIndexRoute: typeof RedirectIndexRoute + ParamsPsNamedFooRoute: typeof ParamsPsNamedFooRoute + ParamsPsNamedPrefixChar123fooChar125Route: typeof ParamsPsNamedPrefixChar123fooChar125Route + ParamsPsNamedChar123fooChar125suffixRoute: typeof ParamsPsNamedChar123fooChar125suffixRoute + ParamsPsWildcardSplatRoute: typeof ParamsPsWildcardSplatRoute + ParamsPsWildcardPrefixChar123Char125Route: typeof ParamsPsWildcardPrefixChar123Char125Route + ParamsPsWildcardChar123Char125suffixRoute: typeof ParamsPsWildcardChar123Char125suffixRoute ParamsSingleValueRoute: typeof ParamsSingleValueRoute PostsPostIdEditRoute: typeof PostsPostIdEditRoute RedirectPreloadFirstRoute: typeof RedirectPreloadFirstRoute RedirectPreloadSecondRoute: typeof RedirectPreloadSecondRoute RedirectPreloadThirdRoute: typeof RedirectPreloadThirdRoute + ParamsPsNamedIndexRoute: typeof ParamsPsNamedIndexRoute + ParamsPsWildcardIndexRoute: typeof ParamsPsWildcardIndexRoute } const rootRouteChildren: RootRouteChildren = { @@ -723,18 +1272,34 @@ const rootRouteChildren: RootRouteChildren = { groupRoute: groupRouteWithChildren, RedirectTargetRoute: RedirectTargetRouteWithChildren, StructuralSharingEnabledRoute: StructuralSharingEnabledRoute, + ParamsPsIndexRoute: ParamsPsIndexRoute, RedirectIndexRoute: RedirectIndexRoute, + ParamsPsNamedFooRoute: ParamsPsNamedFooRoute, + ParamsPsNamedPrefixChar123fooChar125Route: + ParamsPsNamedPrefixChar123fooChar125Route, + ParamsPsNamedChar123fooChar125suffixRoute: + ParamsPsNamedChar123fooChar125suffixRoute, + ParamsPsWildcardSplatRoute: ParamsPsWildcardSplatRoute, + ParamsPsWildcardPrefixChar123Char125Route: + ParamsPsWildcardPrefixChar123Char125Route, + ParamsPsWildcardChar123Char125suffixRoute: + ParamsPsWildcardChar123Char125suffixRoute, ParamsSingleValueRoute: ParamsSingleValueRoute, PostsPostIdEditRoute: PostsPostIdEditRoute, RedirectPreloadFirstRoute: RedirectPreloadFirstRoute, RedirectPreloadSecondRoute: RedirectPreloadSecondRoute, RedirectPreloadThirdRoute: RedirectPreloadThirdRoute, + ParamsPsNamedIndexRoute: ParamsPsNamedIndexRoute, + ParamsPsWildcardIndexRoute: ParamsPsWildcardIndexRoute, } export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { @@ -751,12 +1316,21 @@ export const routeTree = rootRoute "/(group)", "/redirect/$target", "/structural-sharing/$enabled", + "/params-ps/", "/redirect/", + "/params-ps/named/$foo", + "/params-ps/named/prefix{$foo}", + "/params-ps/named/{$foo}suffix", + "/params-ps/wildcard/$", + "/params-ps/wildcard/prefix{$}", + "/params-ps/wildcard/{$}suffix", "/params/single/$value", "/posts_/$postId/edit", "/redirect/preload/first", "/redirect/preload/second", - "/redirect/preload/third" + "/redirect/preload/third", + "/params-ps/named/", + "/params-ps/wildcard/" ] }, "/": { @@ -834,6 +1408,9 @@ export const routeTree = rootRoute "/structural-sharing/$enabled": { "filePath": "structural-sharing.$enabled.tsx" }, + "/params-ps/": { + "filePath": "params-ps/index.tsx" + }, "/posts/": { "filePath": "posts.index.tsx", "parent": "/posts" @@ -857,6 +1434,24 @@ export const routeTree = rootRoute "filePath": "_layout/_layout-2/layout-b.tsx", "parent": "/_layout/_layout-2" }, + "/params-ps/named/$foo": { + "filePath": "params-ps/named/$foo.tsx" + }, + "/params-ps/named/prefix{$foo}": { + "filePath": "params-ps/named/prefix{$foo}.tsx" + }, + "/params-ps/named/{$foo}suffix": { + "filePath": "params-ps/named/{$foo}suffix.tsx" + }, + "/params-ps/wildcard/$": { + "filePath": "params-ps/wildcard/$.tsx" + }, + "/params-ps/wildcard/prefix{$}": { + "filePath": "params-ps/wildcard/prefix{$}.tsx" + }, + "/params-ps/wildcard/{$}suffix": { + "filePath": "params-ps/wildcard/{$}suffix.tsx" + }, "/params/single/$value": { "filePath": "params.single.$value.tsx" }, @@ -880,6 +1475,12 @@ export const routeTree = rootRoute "/redirect/preload/third": { "filePath": "redirect/preload/third.tsx" }, + "/params-ps/named/": { + "filePath": "params-ps/named/index.tsx" + }, + "/params-ps/wildcard/": { + "filePath": "params-ps/wildcard/index.tsx" + }, "/redirect/$target/": { "filePath": "redirect/$target/index.tsx", "parent": "/redirect/$target" diff --git a/e2e/react-router/basic-file-based/src/routes/(another-group)/onlyrouteinside.tsx b/e2e/react-router/basic-file-based/src/routes/(another-group)/onlyrouteinside.tsx index bbd1eedb6f..62a41d2cf2 100644 --- a/e2e/react-router/basic-file-based/src/routes/(another-group)/onlyrouteinside.tsx +++ b/e2e/react-router/basic-file-based/src/routes/(another-group)/onlyrouteinside.tsx @@ -1,10 +1,10 @@ -import { createFileRoute, getRouteApi, useSearch } from '@tanstack/react-router' +import { getRouteApi, useSearch } from '@tanstack/react-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' const routeApi = getRouteApi('/(another-group)/onlyrouteinside') -export const Route = createFileRoute('/(another-group)/onlyrouteinside')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ hello: z.string().optional() })), component: () => { const searchViaHook = useSearch({ diff --git a/e2e/react-router/basic-file-based/src/routes/(group)/_layout.insidelayout.tsx b/e2e/react-router/basic-file-based/src/routes/(group)/_layout.insidelayout.tsx index 2975baedc9..0672b308e9 100644 --- a/e2e/react-router/basic-file-based/src/routes/(group)/_layout.insidelayout.tsx +++ b/e2e/react-router/basic-file-based/src/routes/(group)/_layout.insidelayout.tsx @@ -1,10 +1,10 @@ -import { createFileRoute, getRouteApi, useSearch } from '@tanstack/react-router' +import { getRouteApi, useSearch } from '@tanstack/react-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' const routeApi = getRouteApi('/(group)/_layout/insidelayout') -export const Route = createFileRoute('/(group)/_layout/insidelayout')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ hello: z.string().optional() })), component: () => { const searchViaHook = useSearch({ from: '/(group)/_layout/insidelayout' }) diff --git a/e2e/react-router/basic-file-based/src/routes/(group)/_layout.tsx b/e2e/react-router/basic-file-based/src/routes/(group)/_layout.tsx index 4b755791c0..7806ad35db 100644 --- a/e2e/react-router/basic-file-based/src/routes/(group)/_layout.tsx +++ b/e2e/react-router/basic-file-based/src/routes/(group)/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/(group)/_layout')({ +export const Route = createFileRoute({ component: () => ( <>
/(group)/_layout!
diff --git a/e2e/react-router/basic-file-based/src/routes/(group)/inside.tsx b/e2e/react-router/basic-file-based/src/routes/(group)/inside.tsx index 356ff96003..146dfb8c01 100644 --- a/e2e/react-router/basic-file-based/src/routes/(group)/inside.tsx +++ b/e2e/react-router/basic-file-based/src/routes/(group)/inside.tsx @@ -1,10 +1,10 @@ -import { createFileRoute, getRouteApi, useSearch } from '@tanstack/react-router' +import { getRouteApi, useSearch } from '@tanstack/react-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' const routeApi = getRouteApi('/(group)/inside') -export const Route = createFileRoute('/(group)/inside')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ hello: z.string().optional() })), component: () => { const searchViaHook = useSearch({ from: '/(group)/inside' }) diff --git a/e2e/react-router/basic-file-based/src/routes/(group)/lazyinside.lazy.tsx b/e2e/react-router/basic-file-based/src/routes/(group)/lazyinside.lazy.tsx index 527be4f520..dc10d92fae 100644 --- a/e2e/react-router/basic-file-based/src/routes/(group)/lazyinside.lazy.tsx +++ b/e2e/react-router/basic-file-based/src/routes/(group)/lazyinside.lazy.tsx @@ -1,12 +1,8 @@ -import { - createLazyFileRoute, - getRouteApi, - useSearch, -} from '@tanstack/react-router' +import { getRouteApi, useSearch } from '@tanstack/react-router' const routeApi = getRouteApi('/(group)/lazyinside') -export const Route = createLazyFileRoute('/(group)/lazyinside')({ +export const Route = createLazyFileRoute({ component: () => { const searchViaHook = useSearch({ from: '/(group)/lazyinside' }) const searchViaRouteHook = Route.useSearch() diff --git a/e2e/react-router/basic-file-based/src/routes/(group)/lazyinside.tsx b/e2e/react-router/basic-file-based/src/routes/(group)/lazyinside.tsx index 0f52a40d98..c11aef8fd1 100644 --- a/e2e/react-router/basic-file-based/src/routes/(group)/lazyinside.tsx +++ b/e2e/react-router/basic-file-based/src/routes/(group)/lazyinside.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' -export const Route = createFileRoute('/(group)/lazyinside')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ hello: z.string().optional() })), }) diff --git a/e2e/react-router/basic-file-based/src/routes/(group)/subfolder/inside.tsx b/e2e/react-router/basic-file-based/src/routes/(group)/subfolder/inside.tsx index 3a4a051e8a..31830d399e 100644 --- a/e2e/react-router/basic-file-based/src/routes/(group)/subfolder/inside.tsx +++ b/e2e/react-router/basic-file-based/src/routes/(group)/subfolder/inside.tsx @@ -1,10 +1,10 @@ -import { createFileRoute, getRouteApi, useSearch } from '@tanstack/react-router' +import { getRouteApi, useSearch } from '@tanstack/react-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' const routeApi = getRouteApi('/(group)/subfolder/inside') -export const Route = createFileRoute('/(group)/subfolder/inside')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ hello: z.string().optional() })), component: () => { const searchViaHook = useSearch({ from: '/(group)/subfolder/inside' }) diff --git a/e2e/react-router/basic-file-based/src/routes/_layout.tsx b/e2e/react-router/basic-file-based/src/routes/_layout.tsx index 02ddbb1cd9..5c4a461d8d 100644 --- a/e2e/react-router/basic-file-based/src/routes/_layout.tsx +++ b/e2e/react-router/basic-file-based/src/routes/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/basic-file-based/src/routes/_layout/_layout-2.tsx b/e2e/react-router/basic-file-based/src/routes/_layout/_layout-2.tsx index 3b7dbf2903..483b910862 100644 --- a/e2e/react-router/basic-file-based/src/routes/_layout/_layout-2.tsx +++ b/e2e/react-router/basic-file-based/src/routes/_layout/_layout-2.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout/_layout-2')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx b/e2e/react-router/basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx index 61e19b4d9f..a190b24202 100644 --- a/e2e/react-router/basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx +++ b/e2e/react-router/basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/react-router/basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx b/e2e/react-router/basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx index cceed1fb9a..505f8f6fbf 100644 --- a/e2e/react-router/basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx +++ b/e2e/react-router/basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/react-router/basic-file-based/src/routes/anchor.tsx b/e2e/react-router/basic-file-based/src/routes/anchor.tsx index 93975ba621..26d02d6b2c 100644 --- a/e2e/react-router/basic-file-based/src/routes/anchor.tsx +++ b/e2e/react-router/basic-file-based/src/routes/anchor.tsx @@ -1,12 +1,7 @@ import { useLayoutEffect, useRef, useState } from 'react' -import { - Link, - createFileRoute, - useLocation, - useNavigate, -} from '@tanstack/react-router' +import { Link, useLocation, useNavigate } from '@tanstack/react-router' -export const Route = createFileRoute('/anchor')({ +export const Route = createFileRoute({ component: AnchorComponent, }) diff --git a/e2e/react-router/basic-file-based/src/routes/editing-a.tsx b/e2e/react-router/basic-file-based/src/routes/editing-a.tsx index cecd0dfed1..62a2dadeb4 100644 --- a/e2e/react-router/basic-file-based/src/routes/editing-a.tsx +++ b/e2e/react-router/basic-file-based/src/routes/editing-a.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { createFileRoute, useBlocker } from '@tanstack/react-router' +import { useBlocker } from '@tanstack/react-router' -export const Route = createFileRoute('/editing-a')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/react-router/basic-file-based/src/routes/editing-b.tsx b/e2e/react-router/basic-file-based/src/routes/editing-b.tsx index 1a85e72e26..5afd5c8863 100644 --- a/e2e/react-router/basic-file-based/src/routes/editing-b.tsx +++ b/e2e/react-router/basic-file-based/src/routes/editing-b.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { createFileRoute, useBlocker } from '@tanstack/react-router' +import { useBlocker } from '@tanstack/react-router' -export const Route = createFileRoute('/editing-b')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/react-router/basic-file-based/src/routes/index.tsx b/e2e/react-router/basic-file-based/src/routes/index.tsx index eac82a9174..b23956ae17 100644 --- a/e2e/react-router/basic-file-based/src/routes/index.tsx +++ b/e2e/react-router/basic-file-based/src/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/index.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/index.tsx new file mode 100644 index 0000000000..8bfb406f4f --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/index.tsx @@ -0,0 +1,77 @@ +import { Link } from '@tanstack/react-router' + +export const Route = createFileRoute({ + component: RouteComponent, +}) + +function RouteComponent() { + return ( +
+

Named path params

+
    +
  • + + /params-ps/named/$foo + +
  • +
  • + + /params-ps/named/{'prefix{$foo}'} + +
  • +
  • + + /params-ps/named/{'{$foo}suffix'} + +
  • +
+
+

Wildcard path params

+
    +
  • + + /params-ps/wildcard/$ + +
  • +
  • + + /params-ps/wildcard/{'prefix{$}'} + +
  • +
  • + + /params-ps/wildcard/{'{$}suffix'} + +
  • +
+
+ ) +} diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo.tsx new file mode 100644 index 0000000000..59186ab217 --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo.tsx @@ -0,0 +1,13 @@ +export const Route = createFileRoute({ + component: RouteComponent, +}) + +function RouteComponent() { + const p = Route.useParams() + return ( +
+

ParamsNamedFoo

+
{JSON.stringify(p)}
+
+ ) +} diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/named/index.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/named/index.tsx new file mode 100644 index 0000000000..114137f3b4 --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/named/index.tsx @@ -0,0 +1,7 @@ +import { redirect } from '@tanstack/react-router' + +export const Route = createFileRoute({ + beforeLoad: () => { + throw redirect({ to: '/params-ps' }) + }, +}) diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/named/prefix{$foo}.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/named/prefix{$foo}.tsx new file mode 100644 index 0000000000..8febd60160 --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/named/prefix{$foo}.tsx @@ -0,0 +1,13 @@ +export const Route = createFileRoute({ + component: RouteComponent, +}) + +function RouteComponent() { + const p = Route.useParams() + return ( +
+

ParamsNamedFooPrefix

+
{JSON.stringify(p)}
+
+ ) +} diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/named/{$foo}suffix.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/named/{$foo}suffix.tsx new file mode 100644 index 0000000000..c5598bffcf --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/named/{$foo}suffix.tsx @@ -0,0 +1,13 @@ +export const Route = createFileRoute({ + component: RouteComponent, +}) + +function RouteComponent() { + const p = Route.useParams() + return ( +
+

ParamsNamedFooSuffix

+
{JSON.stringify(p)}
+
+ ) +} diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/wildcard/$.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/wildcard/$.tsx new file mode 100644 index 0000000000..d82806aef2 --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/wildcard/$.tsx @@ -0,0 +1,13 @@ +export const Route = createFileRoute({ + component: RouteComponent, +}) + +function RouteComponent() { + const p = Route.useParams() + return ( +
+

ParamsWildcardSplat

+
{JSON.stringify(p)}
+
+ ) +} diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/wildcard/index.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/wildcard/index.tsx new file mode 100644 index 0000000000..114137f3b4 --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/wildcard/index.tsx @@ -0,0 +1,7 @@ +import { redirect } from '@tanstack/react-router' + +export const Route = createFileRoute({ + beforeLoad: () => { + throw redirect({ to: '/params-ps' }) + }, +}) diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/wildcard/prefix{$}.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/wildcard/prefix{$}.tsx new file mode 100644 index 0000000000..42865fafc1 --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/wildcard/prefix{$}.tsx @@ -0,0 +1,13 @@ +export const Route = createFileRoute({ + component: RouteComponent, +}) + +function RouteComponent() { + const p = Route.useParams() + return ( +
+

ParamsWildcardSplatPrefix

+
{JSON.stringify(p)}
+
+ ) +} diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/wildcard/{$}suffix.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/wildcard/{$}suffix.tsx new file mode 100644 index 0000000000..db9ecbbbca --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/wildcard/{$}suffix.tsx @@ -0,0 +1,13 @@ +export const Route = createFileRoute({ + component: RouteComponent, +}) + +function RouteComponent() { + const p = Route.useParams() + return ( +
+

ParamsWildcardSplatSuffix

+
{JSON.stringify(p)}
+
+ ) +} diff --git a/e2e/react-router/basic-file-based/src/routes/params.single.$value.tsx b/e2e/react-router/basic-file-based/src/routes/params.single.$value.tsx index b5761e839e..b7d7ed81db 100644 --- a/e2e/react-router/basic-file-based/src/routes/params.single.$value.tsx +++ b/e2e/react-router/basic-file-based/src/routes/params.single.$value.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/params/single/$value')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/react-router/basic-file-based/src/routes/posts.$postId.tsx b/e2e/react-router/basic-file-based/src/routes/posts.$postId.tsx index df51873ddf..13708e04a2 100644 --- a/e2e/react-router/basic-file-based/src/routes/posts.$postId.tsx +++ b/e2e/react-router/basic-file-based/src/routes/posts.$postId.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import { fetchPost } from '../posts' import type { ErrorComponentProps } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent, notFoundComponent: () => { diff --git a/e2e/react-router/basic-file-based/src/routes/posts.index.tsx b/e2e/react-router/basic-file-based/src/routes/posts.index.tsx index ab89fb5a62..ab5f3c2ff3 100644 --- a/e2e/react-router/basic-file-based/src/routes/posts.index.tsx +++ b/e2e/react-router/basic-file-based/src/routes/posts.index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-router/basic-file-based/src/routes/posts.tsx b/e2e/react-router/basic-file-based/src/routes/posts.tsx index 9eabdd5b33..839bf039d6 100644 --- a/e2e/react-router/basic-file-based/src/routes/posts.tsx +++ b/e2e/react-router/basic-file-based/src/routes/posts.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ head: () => ({ meta: [ { diff --git a/e2e/react-router/basic-file-based/src/routes/posts_.$postId.edit.tsx b/e2e/react-router/basic-file-based/src/routes/posts_.$postId.edit.tsx index 44a62b0004..827d546135 100644 --- a/e2e/react-router/basic-file-based/src/routes/posts_.$postId.edit.tsx +++ b/e2e/react-router/basic-file-based/src/routes/posts_.$postId.edit.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, getRouteApi, useParams } from '@tanstack/react-router' +import { getRouteApi, useParams } from '@tanstack/react-router' -export const Route = createFileRoute('/posts_/$postId/edit')({ +export const Route = createFileRoute({ component: PostEditPage, }) diff --git a/e2e/react-router/basic-file-based/src/routes/redirect/$target.tsx b/e2e/react-router/basic-file-based/src/routes/redirect/$target.tsx index 686f1c7056..099a7ab0be 100644 --- a/e2e/react-router/basic-file-based/src/routes/redirect/$target.tsx +++ b/e2e/react-router/basic-file-based/src/routes/redirect/$target.tsx @@ -1,7 +1,7 @@ -import { createFileRoute, retainSearchParams } from '@tanstack/react-router' +import { retainSearchParams } from '@tanstack/react-router' import z from 'zod' -export const Route = createFileRoute('/redirect/$target')({ +export const Route = createFileRoute({ params: { parse: (p) => z diff --git a/e2e/react-router/basic-file-based/src/routes/redirect/$target/index.tsx b/e2e/react-router/basic-file-based/src/routes/redirect/$target/index.tsx index 57760cec88..29df874863 100644 --- a/e2e/react-router/basic-file-based/src/routes/redirect/$target/index.tsx +++ b/e2e/react-router/basic-file-based/src/routes/redirect/$target/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/redirect/$target/')({ +export const Route = createFileRoute({ component: () => { const preload = Route.useSearch({ select: (s) => s.preload }) return ( diff --git a/e2e/react-router/basic-file-based/src/routes/redirect/$target/via-beforeLoad.tsx b/e2e/react-router/basic-file-based/src/routes/redirect/$target/via-beforeLoad.tsx index 14a2492331..bfda558451 100644 --- a/e2e/react-router/basic-file-based/src/routes/redirect/$target/via-beforeLoad.tsx +++ b/e2e/react-router/basic-file-based/src/routes/redirect/$target/via-beforeLoad.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' -export const Route = createFileRoute('/redirect/$target/via-beforeLoad')({ +export const Route = createFileRoute({ beforeLoad: ({ params: { target }, search: { reloadDocument, externalHost }, diff --git a/e2e/react-router/basic-file-based/src/routes/redirect/$target/via-loader.tsx b/e2e/react-router/basic-file-based/src/routes/redirect/$target/via-loader.tsx index 9e6a3fc9db..022d5c1f8c 100644 --- a/e2e/react-router/basic-file-based/src/routes/redirect/$target/via-loader.tsx +++ b/e2e/react-router/basic-file-based/src/routes/redirect/$target/via-loader.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' -export const Route = createFileRoute('/redirect/$target/via-loader')({ +export const Route = createFileRoute({ loaderDeps: ({ search: { reloadDocument, externalHost } }) => ({ reloadDocument, externalHost, diff --git a/e2e/react-router/basic-file-based/src/routes/redirect/index.tsx b/e2e/react-router/basic-file-based/src/routes/redirect/index.tsx index c0b26a1df4..a400e552ab 100644 --- a/e2e/react-router/basic-file-based/src/routes/redirect/index.tsx +++ b/e2e/react-router/basic-file-based/src/routes/redirect/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/redirect/')({ +export const Route = createFileRoute({ component: () => (
{ await new Promise((r) => setTimeout(r, 1000)) throw redirect({ from: Route.fullPath, to: '../third' }) diff --git a/e2e/react-router/basic-file-based/src/routes/redirect/preload/third.tsx b/e2e/react-router/basic-file-based/src/routes/redirect/preload/third.tsx index e882d29e69..cc162b05d9 100644 --- a/e2e/react-router/basic-file-based/src/routes/redirect/preload/third.tsx +++ b/e2e/react-router/basic-file-based/src/routes/redirect/preload/third.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/redirect/preload/third')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/react-router/basic-file-based/src/routes/structural-sharing.$enabled.tsx b/e2e/react-router/basic-file-based/src/routes/structural-sharing.$enabled.tsx index 4a477f7ccd..da4ff770a1 100644 --- a/e2e/react-router/basic-file-based/src/routes/structural-sharing.$enabled.tsx +++ b/e2e/react-router/basic-file-based/src/routes/structural-sharing.$enabled.tsx @@ -1,9 +1,4 @@ -import { - Link, - createFileRoute, - getRouteApi, - useSearch, -} from '@tanstack/react-router' +import { Link, getRouteApi, useSearch } from '@tanstack/react-router' import React from 'react' import { z } from 'zod' @@ -17,7 +12,7 @@ const enabledSchema = { }, z.boolean()), } -export const Route = createFileRoute('/structural-sharing/$enabled')({ +export const Route = createFileRoute({ component: RouteComponent, params: { parse: (p) => z.object(enabledSchema).parse(p), diff --git a/e2e/react-router/basic-file-based/tests/params.spec.ts b/e2e/react-router/basic-file-based/tests/params.spec.ts index e95bc56c59..5d4c6111b7 100644 --- a/e2e/react-router/basic-file-based/tests/params.spec.ts +++ b/e2e/react-router/basic-file-based/tests/params.spec.ts @@ -54,3 +54,151 @@ test.describe('ensure single params have been parsed correctly whilst being stab }) } }) + +test.describe('params operations + prefix/suffix', () => { + test.beforeEach(async ({ page }) => { + await page.goto('/params-ps') + }) + + test.describe('named params', () => { + const NAMED_PARAMS_PAIRS = [ + // Test ID | Expected href + { + id: 'l-to-named-foo', + pathname: '/params-ps/named/foo', + params: { foo: 'foo' }, + destHeadingId: 'ParamsNamedFoo', + }, + { + id: 'l-to-named-prefixfoo', + pathname: '/params-ps/named/prefixfoo', + params: { foo: 'foo' }, + destHeadingId: 'ParamsNamedFooPrefix', + }, + { + id: 'l-to-named-foosuffix', + pathname: '/params-ps/named/foosuffix', + params: { foo: 'foo' }, + destHeadingId: 'ParamsNamedFooSuffix', + }, + ] satisfies Array<{ + id: string + pathname: string + params: Record + destHeadingId: string + }> + + test.describe('Link', () => { + NAMED_PARAMS_PAIRS.forEach(({ id, pathname }) => { + test(`interpolation for testid="${id}" has href="${pathname}"`, async ({ + page, + }) => { + const link = page.getByTestId(id) + await expect(link).toHaveAttribute('href', pathname) + }) + }) + + NAMED_PARAMS_PAIRS.forEach(({ id, pathname }) => { + test(`navigation for testid="${id}" succeeds to href="${pathname}"`, async ({ + page, + }) => { + const link = page.getByTestId(id) + await link.click() + await page.waitForLoadState('networkidle') + const pagePathname = new URL(page.url()).pathname + expect(pagePathname).toBe(pathname) + }) + }) + }) + + NAMED_PARAMS_PAIRS.forEach(({ pathname, params, destHeadingId }) => { + test(`on first-load to "${pathname}" has correct params`, async ({ + page, + }) => { + await page.goto(pathname) + await page.waitForLoadState('networkidle') + const pagePathname = new URL(page.url()).pathname + expect(pagePathname).toBe(pathname) + + const headingEl = page.getByRole('heading', { name: destHeadingId }) + await expect(headingEl).toBeVisible() + + const paramsEl = page.getByTestId('params-output') + const paramsText = await paramsEl.innerText() + const paramsObj = JSON.parse(paramsText) + expect(paramsObj).toEqual(params) + }) + }) + }) + + test.describe('wildcard param', () => { + const WILDCARD_PARAM_PAIRS = [ + // Test ID | Expected href + { + id: 'l-to-wildcard-foo', + pathname: '/params-ps/wildcard/foo', + params: { '*': 'foo', _splat: 'foo' }, + destHeadingId: 'ParamsWildcardSplat', + }, + { + id: 'l-to-wildcard-prefixfoo', + pathname: '/params-ps/wildcard/prefixfoo', + params: { '*': 'foo', _splat: 'foo' }, + destHeadingId: 'ParamsWildcardSplatPrefix', + }, + { + id: 'l-to-wildcard-foosuffix', + pathname: '/params-ps/wildcard/foosuffix', + params: { '*': 'foo', _splat: 'foo' }, + destHeadingId: 'ParamsWildcardSplatSuffix', + }, + ] satisfies Array<{ + id: string + pathname: string + params: Record + destHeadingId: string + }> + + test.describe('Link', () => { + WILDCARD_PARAM_PAIRS.forEach(({ id, pathname }) => { + test(`interpolation for testid="${id}" has href="${pathname}"`, async ({ + page, + }) => { + const link = page.getByTestId(id) + await expect(link).toHaveAttribute('href', pathname) + }) + }) + + WILDCARD_PARAM_PAIRS.forEach(({ id, pathname }) => { + test(`navigation for testid="${id}" succeeds to href="${pathname}"`, async ({ + page, + }) => { + const link = page.getByTestId(id) + await link.click() + await page.waitForLoadState('networkidle') + const pagePathname = new URL(page.url()).pathname + expect(pagePathname).toBe(pathname) + }) + }) + }) + + WILDCARD_PARAM_PAIRS.forEach(({ pathname, params, destHeadingId }) => { + test(`on first-load to "${pathname}" has correct params`, async ({ + page, + }) => { + await page.goto(pathname) + await page.waitForLoadState('networkidle') + const pagePathname = new URL(page.url()).pathname + expect(pagePathname).toBe(pathname) + + const headingEl = page.getByRole('heading', { name: destHeadingId }) + await expect(headingEl).toBeVisible() + + const paramsEl = page.getByTestId('params-output') + const paramsText = await paramsEl.innerText() + const paramsObj = JSON.parse(paramsText) + expect(paramsObj).toEqual(params) + }) + }) + }) +}) diff --git a/e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts b/e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts index 375fe8dc91..11f51d2e61 100644 --- a/e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts +++ b/e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts @@ -10,59 +10,60 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostsImport } from './routes/posts' -import { Route as LayoutImport } from './routes/_layout' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as LayoutLayout2Import } from './routes/_layout/_layout-2' -import { Route as LayoutLayout2LayoutBImport } from './routes/_layout/_layout-2/layout-b' -import { Route as LayoutLayout2LayoutAImport } from './routes/_layout/_layout-2/layout-a' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as LayoutRouteImport } from './routes/_layout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2' +import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b' +import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a' // Create/Update Routes -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const LayoutRoute = LayoutImport.update({ +const LayoutRoute = LayoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const LayoutLayout2Route = LayoutLayout2Import.update({ +const LayoutLayout2Route = LayoutLayout2RouteImport.update({ id: '/_layout-2', getParentRoute: () => LayoutRoute, } as any) -const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBImport.update({ +const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => LayoutLayout2Route, } as any) -const LayoutLayout2LayoutARoute = LayoutLayout2LayoutAImport.update({ +const LayoutLayout2LayoutARoute = LayoutLayout2LayoutARouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => LayoutLayout2Route, @@ -76,61 +77,136 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/_layout/_layout-2': { id: '/_layout/_layout-2' path: '' fullPath: '' - preLoaderRoute: typeof LayoutLayout2Import - parentRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutLayout2RouteImport + parentRoute: typeof LayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/_layout/_layout-2/layout-a': { id: '/_layout/_layout-2/layout-a' path: '/layout-a' fullPath: '/layout-a' - preLoaderRoute: typeof LayoutLayout2LayoutAImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutARouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/_layout/_layout-2/layout-b': { id: '/_layout/_layout-2/layout-b' path: '/layout-b' fullPath: '/layout-b' - preLoaderRoute: typeof LayoutLayout2LayoutBImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport + parentRoute: typeof LayoutLayout2RouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/_layout/_layout-2' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2', + FileRoutesByPath['/_layout/_layout-2']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2']['id'], + FileRoutesByPath['/_layout/_layout-2']['path'], + FileRoutesByPath['/_layout/_layout-2']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-a' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-a', + FileRoutesByPath['/_layout/_layout-2/layout-a']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-b' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-b', + FileRoutesByPath['/_layout/_layout-2/layout-b']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['fullPath'] + > +} + // Create and export the route tree interface LayoutLayout2RouteChildren { @@ -242,6 +318,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/react-router/basic-react-query-file-based/src/routes/_layout.tsx b/e2e/react-router/basic-react-query-file-based/src/routes/_layout.tsx index 02ddbb1cd9..5c4a461d8d 100644 --- a/e2e/react-router/basic-react-query-file-based/src/routes/_layout.tsx +++ b/e2e/react-router/basic-react-query-file-based/src/routes/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/basic-react-query-file-based/src/routes/_layout/_layout-2.tsx b/e2e/react-router/basic-react-query-file-based/src/routes/_layout/_layout-2.tsx index 3b7dbf2903..483b910862 100644 --- a/e2e/react-router/basic-react-query-file-based/src/routes/_layout/_layout-2.tsx +++ b/e2e/react-router/basic-react-query-file-based/src/routes/_layout/_layout-2.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout/_layout-2')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/basic-react-query-file-based/src/routes/_layout/_layout-2/layout-a.tsx b/e2e/react-router/basic-react-query-file-based/src/routes/_layout/_layout-2/layout-a.tsx index 61e19b4d9f..a190b24202 100644 --- a/e2e/react-router/basic-react-query-file-based/src/routes/_layout/_layout-2/layout-a.tsx +++ b/e2e/react-router/basic-react-query-file-based/src/routes/_layout/_layout-2/layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/react-router/basic-react-query-file-based/src/routes/_layout/_layout-2/layout-b.tsx b/e2e/react-router/basic-react-query-file-based/src/routes/_layout/_layout-2/layout-b.tsx index cceed1fb9a..505f8f6fbf 100644 --- a/e2e/react-router/basic-react-query-file-based/src/routes/_layout/_layout-2/layout-b.tsx +++ b/e2e/react-router/basic-react-query-file-based/src/routes/_layout/_layout-2/layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/react-router/basic-react-query-file-based/src/routes/index.tsx b/e2e/react-router/basic-react-query-file-based/src/routes/index.tsx index eac82a9174..b23956ae17 100644 --- a/e2e/react-router/basic-react-query-file-based/src/routes/index.tsx +++ b/e2e/react-router/basic-react-query-file-based/src/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-router/basic-react-query-file-based/src/routes/posts.$postId.tsx b/e2e/react-router/basic-react-query-file-based/src/routes/posts.$postId.tsx index 4cf6beca88..c3ae5dc441 100644 --- a/e2e/react-router/basic-react-query-file-based/src/routes/posts.$postId.tsx +++ b/e2e/react-router/basic-react-query-file-based/src/routes/posts.$postId.tsx @@ -1,9 +1,5 @@ import * as React from 'react' -import { - ErrorComponent, - createFileRoute, - useRouter, -} from '@tanstack/react-router' +import { ErrorComponent, useRouter } from '@tanstack/react-router' import { useQueryErrorResetBoundary, useSuspenseQuery, @@ -12,7 +8,7 @@ import { PostNotFoundError } from '../posts' import { postQueryOptions } from '../postQueryOptions' import type { ErrorComponentProps } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: ({ context: { queryClient }, params: { postId } }) => { return queryClient.ensureQueryData(postQueryOptions(postId)) }, diff --git a/e2e/react-router/basic-react-query-file-based/src/routes/posts.index.tsx b/e2e/react-router/basic-react-query-file-based/src/routes/posts.index.tsx index 056433ca0a..fdbe5865e5 100644 --- a/e2e/react-router/basic-react-query-file-based/src/routes/posts.index.tsx +++ b/e2e/react-router/basic-react-query-file-based/src/routes/posts.index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-router/basic-react-query-file-based/src/routes/posts.tsx b/e2e/react-router/basic-react-query-file-based/src/routes/posts.tsx index 86701f982c..f74a7d923f 100644 --- a/e2e/react-router/basic-react-query-file-based/src/routes/posts.tsx +++ b/e2e/react-router/basic-react-query-file-based/src/routes/posts.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { useSuspenseQuery } from '@tanstack/react-query' import { postsQueryOptions } from '../postsQueryOptions' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: ({ context: { queryClient } }) => queryClient.ensureQueryData(postsQueryOptions), component: PostsComponent, diff --git a/e2e/react-router/basic-virtual-file-based/src/routeTree.gen.ts b/e2e/react-router/basic-virtual-file-based/src/routeTree.gen.ts index 01132459aa..d2bf3dceb1 100644 --- a/e2e/react-router/basic-virtual-file-based/src/routeTree.gen.ts +++ b/e2e/react-router/basic-virtual-file-based/src/routeTree.gen.ts @@ -10,87 +10,88 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/root' -import { Route as postsPostsImport } from './routes/posts/posts' -import { Route as layoutFirstLayoutImport } from './routes/layout/first-layout' -import { Route as homeImport } from './routes/home' -import { Route as postsPostsDetailImport } from './routes/posts/posts-detail' -import { Route as layoutSecondLayoutImport } from './routes/layout/second-layout' -import { Route as postsPostsHomeImport } from './routes/posts/posts-home' -import { Route as ClassicHelloRouteImport } from './routes/file-based-subtree/hello/route' -import { Route as ClassicHelloIndexImport } from './routes/file-based-subtree/hello/index' -import { Route as ClassicHelloWorldImport } from './routes/file-based-subtree/hello/world' -import { Route as ClassicHelloUniverseImport } from './routes/file-based-subtree/hello/universe' -import { Route as bImport } from './routes/b' -import { Route as aImport } from './routes/a' +import { Route as postsPostsRouteImport } from './routes/posts/posts' +import { Route as layoutFirstLayoutRouteImport } from './routes/layout/first-layout' +import { Route as homeRouteImport } from './routes/home' +import { Route as postsPostsDetailRouteImport } from './routes/posts/posts-detail' +import { Route as layoutSecondLayoutRouteImport } from './routes/layout/second-layout' +import { Route as postsPostsHomeRouteImport } from './routes/posts/posts-home' +import { Route as ClassicHelloRouteRouteImport } from './routes/file-based-subtree/hello/route' +import { Route as ClassicHelloIndexRouteImport } from './routes/file-based-subtree/hello/index' +import { Route as ClassicHelloWorldRouteImport } from './routes/file-based-subtree/hello/world' +import { Route as ClassicHelloUniverseRouteImport } from './routes/file-based-subtree/hello/universe' +import { Route as bRouteImport } from './routes/b' +import { Route as aRouteImport } from './routes/a' // Create/Update Routes -const postsPostsRoute = postsPostsImport.update({ +const postsPostsRoute = postsPostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const layoutFirstLayoutRoute = layoutFirstLayoutImport.update({ +const layoutFirstLayoutRoute = layoutFirstLayoutRouteImport.update({ id: '/_first', getParentRoute: () => rootRoute, } as any) -const homeRoute = homeImport.update({ +const homeRoute = homeRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const postsPostsDetailRoute = postsPostsDetailImport.update({ +const postsPostsDetailRoute = postsPostsDetailRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => postsPostsRoute, } as any) -const layoutSecondLayoutRoute = layoutSecondLayoutImport.update({ +const layoutSecondLayoutRoute = layoutSecondLayoutRouteImport.update({ id: '/_second', getParentRoute: () => layoutFirstLayoutRoute, } as any) -const postsPostsHomeRoute = postsPostsHomeImport.update({ +const postsPostsHomeRoute = postsPostsHomeRouteImport.update({ id: '/', path: '/', getParentRoute: () => postsPostsRoute, } as any) -const ClassicHelloRouteRoute = ClassicHelloRouteImport.update({ +const ClassicHelloRouteRoute = ClassicHelloRouteRouteImport.update({ id: '/classic/hello', path: '/classic/hello', getParentRoute: () => rootRoute, } as any) -const ClassicHelloIndexRoute = ClassicHelloIndexImport.update({ +const ClassicHelloIndexRoute = ClassicHelloIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => ClassicHelloRouteRoute, } as any) -const ClassicHelloWorldRoute = ClassicHelloWorldImport.update({ +const ClassicHelloWorldRoute = ClassicHelloWorldRouteImport.update({ id: '/world', path: '/world', getParentRoute: () => ClassicHelloRouteRoute, } as any) -const ClassicHelloUniverseRoute = ClassicHelloUniverseImport.update({ +const ClassicHelloUniverseRoute = ClassicHelloUniverseRouteImport.update({ id: '/universe', path: '/universe', getParentRoute: () => ClassicHelloRouteRoute, } as any) -const bRoute = bImport.update({ +const bRoute = bRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => layoutSecondLayoutRoute, } as any) -const aRoute = aImport.update({ +const aRoute = aRouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => layoutSecondLayoutRoute, @@ -104,89 +105,200 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof homeImport + preLoaderRoute: typeof homeRouteImport parentRoute: typeof rootRoute } '/_first': { id: '/_first' path: '' fullPath: '' - preLoaderRoute: typeof layoutFirstLayoutImport + preLoaderRoute: typeof layoutFirstLayoutRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof postsPostsImport + preLoaderRoute: typeof postsPostsRouteImport parentRoute: typeof rootRoute } '/classic/hello': { id: '/classic/hello' path: '/classic/hello' fullPath: '/classic/hello' - preLoaderRoute: typeof ClassicHelloRouteImport + preLoaderRoute: typeof ClassicHelloRouteRouteImport parentRoute: typeof rootRoute } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof postsPostsHomeImport - parentRoute: typeof postsPostsImport + preLoaderRoute: typeof postsPostsHomeRouteImport + parentRoute: typeof postsPostsRouteImport } '/_first/_second': { id: '/_first/_second' path: '' fullPath: '' - preLoaderRoute: typeof layoutSecondLayoutImport - parentRoute: typeof layoutFirstLayoutImport + preLoaderRoute: typeof layoutSecondLayoutRouteImport + parentRoute: typeof layoutFirstLayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof postsPostsDetailImport - parentRoute: typeof postsPostsImport + preLoaderRoute: typeof postsPostsDetailRouteImport + parentRoute: typeof postsPostsRouteImport } '/_first/_second/layout-a': { id: '/_first/_second/layout-a' path: '/layout-a' fullPath: '/layout-a' - preLoaderRoute: typeof aImport - parentRoute: typeof layoutSecondLayoutImport + preLoaderRoute: typeof aRouteImport + parentRoute: typeof layoutSecondLayoutRouteImport } '/_first/_second/layout-b': { id: '/_first/_second/layout-b' path: '/layout-b' fullPath: '/layout-b' - preLoaderRoute: typeof bImport - parentRoute: typeof layoutSecondLayoutImport + preLoaderRoute: typeof bRouteImport + parentRoute: typeof layoutSecondLayoutRouteImport } '/classic/hello/universe': { id: '/classic/hello/universe' path: '/universe' fullPath: '/classic/hello/universe' - preLoaderRoute: typeof ClassicHelloUniverseImport - parentRoute: typeof ClassicHelloRouteImport + preLoaderRoute: typeof ClassicHelloUniverseRouteImport + parentRoute: typeof ClassicHelloRouteRouteImport } '/classic/hello/world': { id: '/classic/hello/world' path: '/world' fullPath: '/classic/hello/world' - preLoaderRoute: typeof ClassicHelloWorldImport - parentRoute: typeof ClassicHelloRouteImport + preLoaderRoute: typeof ClassicHelloWorldRouteImport + parentRoute: typeof ClassicHelloRouteRouteImport } '/classic/hello/': { id: '/classic/hello/' path: '/' fullPath: '/classic/hello/' - preLoaderRoute: typeof ClassicHelloIndexImport - parentRoute: typeof ClassicHelloRouteImport + preLoaderRoute: typeof ClassicHelloIndexRouteImport + parentRoute: typeof ClassicHelloRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/home' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/layout/first-layout' { + const createFileRoute: CreateFileRoute< + '/_first', + FileRoutesByPath['/_first']['parentRoute'], + FileRoutesByPath['/_first']['id'], + FileRoutesByPath['/_first']['path'], + FileRoutesByPath['/_first']['fullPath'] + > +} +declare module './routes/posts/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/file-based-subtree/hello/route' { + const createFileRoute: CreateFileRoute< + '/classic/hello', + FileRoutesByPath['/classic/hello']['parentRoute'], + FileRoutesByPath['/classic/hello']['id'], + FileRoutesByPath['/classic/hello']['path'], + FileRoutesByPath['/classic/hello']['fullPath'] + > +} +declare module './routes/posts/posts-home' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/layout/second-layout' { + const createFileRoute: CreateFileRoute< + '/_first/_second', + FileRoutesByPath['/_first/_second']['parentRoute'], + FileRoutesByPath['/_first/_second']['id'], + FileRoutesByPath['/_first/_second']['path'], + FileRoutesByPath['/_first/_second']['fullPath'] + > +} +declare module './routes/posts/posts-detail' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/a' { + const createFileRoute: CreateFileRoute< + '/_first/_second/layout-a', + FileRoutesByPath['/_first/_second/layout-a']['parentRoute'], + FileRoutesByPath['/_first/_second/layout-a']['id'], + FileRoutesByPath['/_first/_second/layout-a']['path'], + FileRoutesByPath['/_first/_second/layout-a']['fullPath'] + > +} +declare module './routes/b' { + const createFileRoute: CreateFileRoute< + '/_first/_second/layout-b', + FileRoutesByPath['/_first/_second/layout-b']['parentRoute'], + FileRoutesByPath['/_first/_second/layout-b']['id'], + FileRoutesByPath['/_first/_second/layout-b']['path'], + FileRoutesByPath['/_first/_second/layout-b']['fullPath'] + > +} +declare module './routes/file-based-subtree/hello/universe' { + const createFileRoute: CreateFileRoute< + '/classic/hello/universe', + FileRoutesByPath['/classic/hello/universe']['parentRoute'], + FileRoutesByPath['/classic/hello/universe']['id'], + FileRoutesByPath['/classic/hello/universe']['path'], + FileRoutesByPath['/classic/hello/universe']['fullPath'] + > +} +declare module './routes/file-based-subtree/hello/world' { + const createFileRoute: CreateFileRoute< + '/classic/hello/world', + FileRoutesByPath['/classic/hello/world']['parentRoute'], + FileRoutesByPath['/classic/hello/world']['id'], + FileRoutesByPath['/classic/hello/world']['path'], + FileRoutesByPath['/classic/hello/world']['fullPath'] + > +} +declare module './routes/file-based-subtree/hello/index' { + const createFileRoute: CreateFileRoute< + '/classic/hello/', + FileRoutesByPath['/classic/hello/']['parentRoute'], + FileRoutesByPath['/classic/hello/']['id'], + FileRoutesByPath['/classic/hello/']['path'], + FileRoutesByPath['/classic/hello/']['fullPath'] + > +} + // Create and export the route tree interface layoutSecondLayoutRouteChildren { @@ -344,6 +456,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/react-router/basic-virtual-file-based/src/routes/a.tsx b/e2e/react-router/basic-virtual-file-based/src/routes/a.tsx index 6cccd02950..a190b24202 100644 --- a/e2e/react-router/basic-virtual-file-based/src/routes/a.tsx +++ b/e2e/react-router/basic-virtual-file-based/src/routes/a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_first/_second/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/react-router/basic-virtual-file-based/src/routes/b.tsx b/e2e/react-router/basic-virtual-file-based/src/routes/b.tsx index 98bb842612..505f8f6fbf 100644 --- a/e2e/react-router/basic-virtual-file-based/src/routes/b.tsx +++ b/e2e/react-router/basic-virtual-file-based/src/routes/b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_first/_second/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/index.tsx b/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/index.tsx index c7417e5eeb..f86335e291 100644 --- a/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/index.tsx +++ b/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/classic/hello/')({ +export const Route = createFileRoute({ component: () =>
This is the index
, }) diff --git a/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/route.tsx b/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/route.tsx index 566efc8777..620dd2b76b 100644 --- a/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/route.tsx +++ b/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/route.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/classic/hello')({ +export const Route = createFileRoute({ component: () => (
Hello! diff --git a/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/universe.tsx b/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/universe.tsx index e00c47d74b..20b07c41cc 100644 --- a/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/universe.tsx +++ b/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/universe.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/classic/hello/universe')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/universe!
, }) diff --git a/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/world.tsx b/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/world.tsx index 9783557342..4af11357a2 100644 --- a/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/world.tsx +++ b/e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/world.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/classic/hello/world')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/world!
, }) diff --git a/e2e/react-router/basic-virtual-file-based/src/routes/home.tsx b/e2e/react-router/basic-virtual-file-based/src/routes/home.tsx index eac82a9174..b23956ae17 100644 --- a/e2e/react-router/basic-virtual-file-based/src/routes/home.tsx +++ b/e2e/react-router/basic-virtual-file-based/src/routes/home.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-router/basic-virtual-file-based/src/routes/layout/first-layout.tsx b/e2e/react-router/basic-virtual-file-based/src/routes/layout/first-layout.tsx index d39e206f2d..5c4a461d8d 100644 --- a/e2e/react-router/basic-virtual-file-based/src/routes/layout/first-layout.tsx +++ b/e2e/react-router/basic-virtual-file-based/src/routes/layout/first-layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_first')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/basic-virtual-file-based/src/routes/layout/second-layout.tsx b/e2e/react-router/basic-virtual-file-based/src/routes/layout/second-layout.tsx index ef178a6e16..483b910862 100644 --- a/e2e/react-router/basic-virtual-file-based/src/routes/layout/second-layout.tsx +++ b/e2e/react-router/basic-virtual-file-based/src/routes/layout/second-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_first/_second')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/basic-virtual-file-based/src/routes/posts/posts-detail.tsx b/e2e/react-router/basic-virtual-file-based/src/routes/posts/posts-detail.tsx index 948d52d6d6..654f3cfd18 100644 --- a/e2e/react-router/basic-virtual-file-based/src/routes/posts/posts-detail.tsx +++ b/e2e/react-router/basic-virtual-file-based/src/routes/posts/posts-detail.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import { fetchPost } from '../../posts' import type { ErrorComponentProps } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent as any, notFoundComponent: () => { diff --git a/e2e/react-router/basic-virtual-file-based/src/routes/posts/posts-home.tsx b/e2e/react-router/basic-virtual-file-based/src/routes/posts/posts-home.tsx index 056433ca0a..fdbe5865e5 100644 --- a/e2e/react-router/basic-virtual-file-based/src/routes/posts/posts-home.tsx +++ b/e2e/react-router/basic-virtual-file-based/src/routes/posts/posts-home.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-router/basic-virtual-file-based/src/routes/posts/posts.tsx b/e2e/react-router/basic-virtual-file-based/src/routes/posts/posts.tsx index a2ab1ee388..f92c37f537 100644 --- a/e2e/react-router/basic-virtual-file-based/src/routes/posts/posts.tsx +++ b/e2e/react-router/basic-virtual-file-based/src/routes/posts/posts.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsComponent, }) diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/a.tsx b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/a.tsx index 6cccd02950..a190b24202 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/a.tsx +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_first/_second/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/b.tsx b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/b.tsx index 98bb842612..505f8f6fbf 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/b.tsx +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_first/_second/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx index c7417e5eeb..f86335e291 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/classic/hello/')({ +export const Route = createFileRoute({ component: () =>
This is the index
, }) diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx index 566efc8777..620dd2b76b 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/classic/hello')({ +export const Route = createFileRoute({ component: () => (
Hello! diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx index e00c47d74b..20b07c41cc 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/classic/hello/universe')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/universe!
, }) diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx index 9783557342..4af11357a2 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/classic/hello/world')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/world!
, }) diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/home.tsx b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/home.tsx index eac82a9174..b23956ae17 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/home.tsx +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/home.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx index d39e206f2d..5c4a461d8d 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_first')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx index ef178a6e16..483b910862 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_first/_second')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx index 948d52d6d6..654f3cfd18 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import { fetchPost } from '../../posts' import type { ErrorComponentProps } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent as any, notFoundComponent: () => { diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx index 056433ca0a..fdbe5865e5 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx index a2ab1ee388..f92c37f537 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsComponent, }) diff --git a/e2e/react-router/basic/src/main.tsx b/e2e/react-router/basic/src/main.tsx index 2ffee37679..24e89eb47a 100644 --- a/e2e/react-router/basic/src/main.tsx +++ b/e2e/react-router/basic/src/main.tsx @@ -7,6 +7,7 @@ import { createRootRoute, createRoute, createRouter, + redirect, } from '@tanstack/react-router' import { TanStackRouterDevtools } from '@tanstack/react-router-devtools' import { NotFoundError, fetchPost, fetchPosts } from './posts' @@ -205,11 +206,217 @@ function LayoutBComponent() { return
I'm layout B!
} +const paramsPsRoute = createRoute({ + getParentRoute: () => rootRoute, + path: '/params-ps', +}) + +const paramsPsIndexRoute = createRoute({ + getParentRoute: () => paramsPsRoute, + path: '/', + component: function ParamsIndex() { + return ( +
+

Named path params

+
    +
  • + + /params-ps/named/$foo + +
  • +
  • + + /params-ps/named/{'prefix{$foo}'} + +
  • +
  • + + /params-ps/named/{'{$foo}suffix'} + +
  • +
+
+

Wildcard path params

+
    +
  • + + /params-ps/wildcard/$ + +
  • +
  • + + /params-ps/wildcard/{'prefix{$}'} + +
  • +
  • + + /params-ps/wildcard/{'{$}suffix'} + +
  • +
+
+ ) + }, +}) + +const paramsPsNamedRoute = createRoute({ + getParentRoute: () => paramsPsRoute, + path: '/named', +}) + +const paramsPsNamedIndexRoute = createRoute({ + getParentRoute: () => paramsPsNamedRoute, + path: '/', + beforeLoad: () => { + throw redirect({ to: '/params-ps' }) + }, +}) + +const paramsPsNamedFooRoute = createRoute({ + getParentRoute: () => paramsPsNamedRoute, + path: '/$foo', + component: function ParamsNamedFoo() { + const p = paramsPsNamedFooRoute.useParams() + return ( +
+

ParamsNamedFoo

+
{JSON.stringify(p)}
+
+ ) + }, +}) + +const paramsPsNamedFooPrefixRoute = createRoute({ + getParentRoute: () => paramsPsNamedRoute, + path: '/prefix{$foo}', + component: function ParamsNamedFooMarkdown() { + const p = paramsPsNamedFooPrefixRoute.useParams() + return ( +
+

ParamsNamedFooPrefix

+
{JSON.stringify(p)}
+
+ ) + }, +}) + +const paramsPsNamedFooSuffixRoute = createRoute({ + getParentRoute: () => paramsPsNamedRoute, + path: '/{$foo}suffix', + component: function ParamsNamedFooSuffix() { + const p = paramsPsNamedFooSuffixRoute.useParams() + return ( +
+

ParamsNamedFooSuffix

+
{JSON.stringify(p)}
+
+ ) + }, +}) + +const paramsPsWildcardRoute = createRoute({ + getParentRoute: () => paramsPsRoute, + path: '/wildcard', +}) + +const paramsPsWildcardIndexRoute = createRoute({ + getParentRoute: () => paramsPsWildcardRoute, + path: '/', + beforeLoad: () => { + throw redirect({ to: '/params-ps' }) + }, +}) + +const paramsPsWildcardSplatRoute = createRoute({ + getParentRoute: () => paramsPsWildcardRoute, + path: '$', + component: function ParamsWildcardSplat() { + const p = paramsPsWildcardSplatRoute.useParams() + return ( +
+

ParamsWildcardSplat

+
{JSON.stringify(p)}
+
+ ) + }, +}) + +const paramsPsWildcardSplatPrefixRoute = createRoute({ + getParentRoute: () => paramsPsWildcardRoute, + path: 'prefix{$}', + component: function ParamsWildcardSplatPrefix() { + const p = paramsPsWildcardSplatPrefixRoute.useParams() + return ( +
+

ParamsWildcardSplatPrefix

+
{JSON.stringify(p)}
+
+ ) + }, +}) + +const paramsPsWildcardSplatSuffixRoute = createRoute({ + getParentRoute: () => paramsPsWildcardRoute, + path: '{$}suffix', + component: function ParamsWildcardSplatSuffix() { + const p = paramsPsWildcardSplatSuffixRoute.useParams() + return ( +
+

ParamsWildcardSplatSuffix

+
{JSON.stringify(p)}
+
+ ) + }, +}) + const routeTree = rootRoute.addChildren([ postsRoute.addChildren([postRoute, postsIndexRoute]), layoutRoute.addChildren([ layout2Route.addChildren([layoutARoute, layoutBRoute]), ]), + paramsPsRoute.addChildren([ + paramsPsNamedRoute.addChildren([ + paramsPsNamedFooPrefixRoute, + paramsPsNamedFooSuffixRoute, + paramsPsNamedFooRoute, + paramsPsNamedIndexRoute, + ]), + paramsPsWildcardRoute.addChildren([ + paramsPsWildcardSplatRoute, + paramsPsWildcardSplatPrefixRoute, + paramsPsWildcardSplatSuffixRoute, + paramsPsWildcardIndexRoute, + ]), + paramsPsIndexRoute, + ]), indexRoute, ]) diff --git a/e2e/react-router/basic/tests/params.spec.ts b/e2e/react-router/basic/tests/params.spec.ts new file mode 100644 index 0000000000..ac18f39864 --- /dev/null +++ b/e2e/react-router/basic/tests/params.spec.ts @@ -0,0 +1,149 @@ +import { expect, test } from '@playwright/test' + +test.describe('params operations + prefix/suffix', () => { + test.beforeEach(async ({ page }) => { + await page.goto('/params-ps') + }) + + test.describe('named params', () => { + const NAMED_PARAMS_PAIRS = [ + // Test ID | Expected href + { + id: 'l-to-named-foo', + pathname: '/params-ps/named/foo', + params: { foo: 'foo' }, + destHeadingId: 'ParamsNamedFoo', + }, + { + id: 'l-to-named-prefixfoo', + pathname: '/params-ps/named/prefixfoo', + params: { foo: 'foo' }, + destHeadingId: 'ParamsNamedFooPrefix', + }, + { + id: 'l-to-named-foosuffix', + pathname: '/params-ps/named/foosuffix', + params: { foo: 'foo' }, + destHeadingId: 'ParamsNamedFooSuffix', + }, + ] satisfies Array<{ + id: string + pathname: string + params: Record + destHeadingId: string + }> + + test.describe('Link', () => { + NAMED_PARAMS_PAIRS.forEach(({ id, pathname }) => { + test(`interpolation for testid="${id}" has href="${pathname}"`, async ({ + page, + }) => { + const link = page.getByTestId(id) + await expect(link).toHaveAttribute('href', pathname) + }) + }) + + NAMED_PARAMS_PAIRS.forEach(({ id, pathname }) => { + test(`navigation for testid="${id}" succeeds to href="${pathname}"`, async ({ + page, + }) => { + const link = page.getByTestId(id) + await link.click() + await page.waitForLoadState('networkidle') + const pagePathname = new URL(page.url()).pathname + expect(pagePathname).toBe(pathname) + }) + }) + }) + + NAMED_PARAMS_PAIRS.forEach(({ pathname, params, destHeadingId }) => { + test(`on first-load to "${pathname}" has correct params`, async ({ + page, + }) => { + await page.goto(pathname) + await page.waitForLoadState('networkidle') + const pagePathname = new URL(page.url()).pathname + expect(pagePathname).toBe(pathname) + + const headingEl = page.getByRole('heading', { name: destHeadingId }) + await expect(headingEl).toBeVisible() + + const paramsEl = page.getByTestId('params-output') + const paramsText = await paramsEl.innerText() + const paramsObj = JSON.parse(paramsText) + expect(paramsObj).toEqual(params) + }) + }) + }) + + test.describe('wildcard param', () => { + const WILDCARD_PARAM_PAIRS = [ + // Test ID | Expected href + { + id: 'l-to-wildcard-foo', + pathname: '/params-ps/wildcard/foo', + params: { '*': 'foo', _splat: 'foo' }, + destHeadingId: 'ParamsWildcardSplat', + }, + { + id: 'l-to-wildcard-prefixfoo', + pathname: '/params-ps/wildcard/prefixfoo', + params: { '*': 'foo', _splat: 'foo' }, + destHeadingId: 'ParamsWildcardSplatPrefix', + }, + { + id: 'l-to-wildcard-foosuffix', + pathname: '/params-ps/wildcard/foosuffix', + params: { '*': 'foo', _splat: 'foo' }, + destHeadingId: 'ParamsWildcardSplatSuffix', + }, + ] satisfies Array<{ + id: string + pathname: string + params: Record + destHeadingId: string + }> + + test.describe('Link', () => { + WILDCARD_PARAM_PAIRS.forEach(({ id, pathname }) => { + test(`interpolation for testid="${id}" has href="${pathname}"`, async ({ + page, + }) => { + const link = page.getByTestId(id) + await expect(link).toHaveAttribute('href', pathname) + }) + }) + + WILDCARD_PARAM_PAIRS.forEach(({ id, pathname }) => { + test(`navigation for testid="${id}" succeeds to href="${pathname}"`, async ({ + page, + }) => { + const link = page.getByTestId(id) + await link.click() + await page.waitForLoadState('networkidle') + const pagePathname = new URL(page.url()).pathname + expect(pagePathname).toBe(pathname) + }) + }) + }) + + WILDCARD_PARAM_PAIRS.forEach(({ pathname, params, destHeadingId }) => { + test(`on first-load to "${pathname}" has correct params`, async ({ + page, + }) => { + await page.goto(pathname) + await page.waitForLoadState('networkidle') + const pagePathname = new URL(page.url()).pathname + expect(pagePathname).toBe(pathname) + + const headingEl = page.getByRole('heading', { name: destHeadingId }) + await expect(headingEl).toBeVisible() + + const paramsEl = page.getByTestId('params-output') + const paramsText = await paramsEl.innerText() + const paramsObj = JSON.parse(paramsText) + expect(paramsObj).toEqual(params) + }) + }) + }) +}) diff --git a/e2e/react-router/generator-cli-only/src/routeTree.gen.ts b/e2e/react-router/generator-cli-only/src/routeTree.gen.ts index 1ecbd67da9..b853eedf87 100644 --- a/e2e/react-router/generator-cli-only/src/routeTree.gen.ts +++ b/e2e/react-router/generator-cli-only/src/routeTree.gen.ts @@ -10,63 +10,63 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PathlessLayoutImport } from './routes/_pathlessLayout' -import { Route as PostsRouteImport } from './routes/posts.route' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as PathlessLayoutNestedLayoutImport } from './routes/_pathlessLayout/_nested-layout' -import { Route as PathlessLayoutNestedLayoutRouteBImport } from './routes/_pathlessLayout/_nested-layout/route-b' -import { Route as PathlessLayoutNestedLayoutRouteAImport } from './routes/_pathlessLayout/_nested-layout/route-a' +import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' +import { Route as PostsRouteRouteImport } from './routes/posts.route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as PathlessLayoutNestedLayoutRouteImport } from './routes/_pathlessLayout/_nested-layout' +import { Route as PathlessLayoutNestedLayoutRouteBRouteImport } from './routes/_pathlessLayout/_nested-layout/route-b' +import { Route as PathlessLayoutNestedLayoutRouteARouteImport } from './routes/_pathlessLayout/_nested-layout/route-a' // Create/Update Routes -const PathlessLayoutRoute = PathlessLayoutImport.update({ +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', getParentRoute: () => rootRoute, } as any) -const PostsRouteRoute = PostsRouteImport.update({ +const PostsRouteRoute = PostsRouteRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRouteRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRouteRoute, } as any) -const PathlessLayoutNestedLayoutRoute = PathlessLayoutNestedLayoutImport.update( - { +const PathlessLayoutNestedLayoutRoute = + PathlessLayoutNestedLayoutRouteImport.update({ id: '/_nested-layout', getParentRoute: () => PathlessLayoutRoute, - } as any, -) + } as any) const PathlessLayoutNestedLayoutRouteBRoute = - PathlessLayoutNestedLayoutRouteBImport.update({ + PathlessLayoutNestedLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutNestedLayoutRoute, } as any) const PathlessLayoutNestedLayoutRouteARoute = - PathlessLayoutNestedLayoutRouteAImport.update({ + PathlessLayoutNestedLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutNestedLayoutRoute, @@ -80,61 +80,136 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsRouteRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout': { id: '/_pathlessLayout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout/_nested-layout': { id: '/_pathlessLayout/_nested-layout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutNestedLayoutImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteRouteImport } '/_pathlessLayout/_nested-layout/route-a': { id: '/_pathlessLayout/_nested-layout/route-a' path: '/route-a' fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteAImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/_pathlessLayout/_nested-layout/route-b': { id: '/_pathlessLayout/_nested-layout/route-b' path: '/route-b' fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/posts.route' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/_pathlessLayout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout', + FileRoutesByPath['/_pathlessLayout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout']['id'], + FileRoutesByPath['/_pathlessLayout']['path'], + FileRoutesByPath['/_pathlessLayout']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout', + FileRoutesByPath['/_pathlessLayout/_nested-layout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-a' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-a', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-b' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-b', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['fullPath'] + > +} + // Create and export the route tree interface PostsRouteRouteChildren { @@ -252,3 +327,6 @@ const rootRouteChildren: RootRouteChildren = { export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() + +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' diff --git a/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout.tsx b/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout.tsx index 202070f1ff..fd83a0eaa0 100644 --- a/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout.tsx +++ b/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout/_nested-layout.tsx b/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout/_nested-layout.tsx index c5bcffd5a4..abd82a2bf6 100644 --- a/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout/_nested-layout.tsx +++ b/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout/_nested-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout/_nested-layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout/_nested-layout/route-a.tsx b/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout/_nested-layout/route-a.tsx index 5649f77d8e..a190b24202 100644 --- a/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout/_nested-layout/route-a.tsx +++ b/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout/_nested-layout/route-a.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-a')( - { - component: LayoutAComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutAComponent, +}) function LayoutAComponent() { return
I'm layout A!
diff --git a/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout/_nested-layout/route-b.tsx b/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout/_nested-layout/route-b.tsx index 742e48bfb4..505f8f6fbf 100644 --- a/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout/_nested-layout/route-b.tsx +++ b/e2e/react-router/generator-cli-only/src/routes/_pathlessLayout/_nested-layout/route-b.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-b')( - { - component: LayoutBComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutBComponent, +}) function LayoutBComponent() { return
I'm layout B!
diff --git a/e2e/react-router/generator-cli-only/src/routes/index.tsx b/e2e/react-router/generator-cli-only/src/routes/index.tsx index eac82a9174..b23956ae17 100644 --- a/e2e/react-router/generator-cli-only/src/routes/index.tsx +++ b/e2e/react-router/generator-cli-only/src/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-router/generator-cli-only/src/routes/posts.$postId.tsx b/e2e/react-router/generator-cli-only/src/routes/posts.$postId.tsx index cded91ef96..0578182ecb 100644 --- a/e2e/react-router/generator-cli-only/src/routes/posts.$postId.tsx +++ b/e2e/react-router/generator-cli-only/src/routes/posts.$postId.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import { fetchPost } from '../posts' import type { ErrorComponentProps } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent, notFoundComponent: () => { diff --git a/e2e/react-router/generator-cli-only/src/routes/posts.index.tsx b/e2e/react-router/generator-cli-only/src/routes/posts.index.tsx index 056433ca0a..fdbe5865e5 100644 --- a/e2e/react-router/generator-cli-only/src/routes/posts.index.tsx +++ b/e2e/react-router/generator-cli-only/src/routes/posts.index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-router/generator-cli-only/src/routes/posts.route.tsx b/e2e/react-router/generator-cli-only/src/routes/posts.route.tsx index 0115fc8063..0aca21ad57 100644 --- a/e2e/react-router/generator-cli-only/src/routes/posts.route.tsx +++ b/e2e/react-router/generator-cli-only/src/routes/posts.route.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsLayoutComponent, }) diff --git a/e2e/react-router/js-only-file-based/src/routeTree.gen.js b/e2e/react-router/js-only-file-based/src/routeTree.gen.js index c98d6e89eb..d730c68ee9 100644 --- a/e2e/react-router/js-only-file-based/src/routeTree.gen.js +++ b/e2e/react-router/js-only-file-based/src/routeTree.gen.js @@ -11,62 +11,61 @@ // Import Routes import { Route as rootRoute } from './routes/__root' -import { Route as PathlessLayoutImport } from './routes/_pathlessLayout' -import { Route as PostsRouteImport } from './routes/posts.route' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as PathlessLayoutNestedLayoutImport } from './routes/_pathlessLayout/_nested-layout' -import { Route as PathlessLayoutNestedLayoutRouteBImport } from './routes/_pathlessLayout/_nested-layout/route-b' -import { Route as PathlessLayoutNestedLayoutRouteAImport } from './routes/_pathlessLayout/_nested-layout/route-a' +import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' +import { Route as PostsRouteRouteImport } from './routes/posts.route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as PathlessLayoutNestedLayoutRouteImport } from './routes/_pathlessLayout/_nested-layout' +import { Route as PathlessLayoutNestedLayoutRouteBRouteImport } from './routes/_pathlessLayout/_nested-layout/route-b' +import { Route as PathlessLayoutNestedLayoutRouteARouteImport } from './routes/_pathlessLayout/_nested-layout/route-a' // Create/Update Routes -const PathlessLayoutRoute = PathlessLayoutImport.update({ +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', getParentRoute: () => rootRoute, }) -const PostsRouteRoute = PostsRouteImport.update({ +const PostsRouteRoute = PostsRouteRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, }) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, }) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRouteRoute, }) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRouteRoute, }) -const PathlessLayoutNestedLayoutRoute = PathlessLayoutNestedLayoutImport.update( - { +const PathlessLayoutNestedLayoutRoute = + PathlessLayoutNestedLayoutRouteImport.update({ id: '/_nested-layout', getParentRoute: () => PathlessLayoutRoute, - }, -) + }) const PathlessLayoutNestedLayoutRouteBRoute = - PathlessLayoutNestedLayoutRouteBImport.update({ + PathlessLayoutNestedLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutNestedLayoutRoute, }) const PathlessLayoutNestedLayoutRouteARoute = - PathlessLayoutNestedLayoutRouteAImport.update({ + PathlessLayoutNestedLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutNestedLayoutRoute, diff --git a/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout.jsx b/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout.jsx index 202070f1ff..fd83a0eaa0 100644 --- a/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout.jsx +++ b/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout.jsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout/_nested-layout.jsx b/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout/_nested-layout.jsx index c5bcffd5a4..abd82a2bf6 100644 --- a/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout/_nested-layout.jsx +++ b/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout/_nested-layout.jsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout/_nested-layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.jsx b/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.jsx index 5649f77d8e..a190b24202 100644 --- a/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.jsx +++ b/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.jsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-a')( - { - component: LayoutAComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutAComponent, +}) function LayoutAComponent() { return
I'm layout A!
diff --git a/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.jsx b/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.jsx index 742e48bfb4..505f8f6fbf 100644 --- a/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.jsx +++ b/e2e/react-router/js-only-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.jsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-b')( - { - component: LayoutBComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutBComponent, +}) function LayoutBComponent() { return
I'm layout B!
diff --git a/e2e/react-router/js-only-file-based/src/routes/index.jsx b/e2e/react-router/js-only-file-based/src/routes/index.jsx index eac82a9174..b23956ae17 100644 --- a/e2e/react-router/js-only-file-based/src/routes/index.jsx +++ b/e2e/react-router/js-only-file-based/src/routes/index.jsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-router/js-only-file-based/src/routes/posts.$postId.jsx b/e2e/react-router/js-only-file-based/src/routes/posts.$postId.jsx index d26d271b9d..c010a465e6 100644 --- a/e2e/react-router/js-only-file-based/src/routes/posts.$postId.jsx +++ b/e2e/react-router/js-only-file-based/src/routes/posts.$postId.jsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import { fetchPost } from '../posts' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent, notFoundComponent: () => { diff --git a/e2e/react-router/js-only-file-based/src/routes/posts.index.jsx b/e2e/react-router/js-only-file-based/src/routes/posts.index.jsx index 056433ca0a..fdbe5865e5 100644 --- a/e2e/react-router/js-only-file-based/src/routes/posts.index.jsx +++ b/e2e/react-router/js-only-file-based/src/routes/posts.index.jsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-router/js-only-file-based/src/routes/posts.route.jsx b/e2e/react-router/js-only-file-based/src/routes/posts.route.jsx index 0115fc8063..0aca21ad57 100644 --- a/e2e/react-router/js-only-file-based/src/routes/posts.route.jsx +++ b/e2e/react-router/js-only-file-based/src/routes/posts.route.jsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsLayoutComponent, }) diff --git a/e2e/react-router/rspack-basic-file-based/src/routes/_layout.tsx b/e2e/react-router/rspack-basic-file-based/src/routes/_layout.tsx index 02ddbb1cd9..5c4a461d8d 100644 --- a/e2e/react-router/rspack-basic-file-based/src/routes/_layout.tsx +++ b/e2e/react-router/rspack-basic-file-based/src/routes/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/rspack-basic-file-based/src/routes/_layout/_layout-2.tsx b/e2e/react-router/rspack-basic-file-based/src/routes/_layout/_layout-2.tsx index 3b7dbf2903..483b910862 100644 --- a/e2e/react-router/rspack-basic-file-based/src/routes/_layout/_layout-2.tsx +++ b/e2e/react-router/rspack-basic-file-based/src/routes/_layout/_layout-2.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout/_layout-2')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx b/e2e/react-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx index 61e19b4d9f..a190b24202 100644 --- a/e2e/react-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx +++ b/e2e/react-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/react-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx b/e2e/react-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx index cceed1fb9a..505f8f6fbf 100644 --- a/e2e/react-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx +++ b/e2e/react-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/react-router/rspack-basic-file-based/src/routes/index.tsx b/e2e/react-router/rspack-basic-file-based/src/routes/index.tsx index eac82a9174..b23956ae17 100644 --- a/e2e/react-router/rspack-basic-file-based/src/routes/index.tsx +++ b/e2e/react-router/rspack-basic-file-based/src/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-router/rspack-basic-file-based/src/routes/posts.$postId.tsx b/e2e/react-router/rspack-basic-file-based/src/routes/posts.$postId.tsx index cded91ef96..0578182ecb 100644 --- a/e2e/react-router/rspack-basic-file-based/src/routes/posts.$postId.tsx +++ b/e2e/react-router/rspack-basic-file-based/src/routes/posts.$postId.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import { fetchPost } from '../posts' import type { ErrorComponentProps } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent, notFoundComponent: () => { diff --git a/e2e/react-router/rspack-basic-file-based/src/routes/posts.index.tsx b/e2e/react-router/rspack-basic-file-based/src/routes/posts.index.tsx index 056433ca0a..fdbe5865e5 100644 --- a/e2e/react-router/rspack-basic-file-based/src/routes/posts.index.tsx +++ b/e2e/react-router/rspack-basic-file-based/src/routes/posts.index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-router/rspack-basic-file-based/src/routes/posts.tsx b/e2e/react-router/rspack-basic-file-based/src/routes/posts.tsx index c7a09ed7f8..4469b2216a 100644 --- a/e2e/react-router/rspack-basic-file-based/src/routes/posts.tsx +++ b/e2e/react-router/rspack-basic-file-based/src/routes/posts.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsComponent, }) diff --git a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/a.tsx b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/a.tsx index 6cccd02950..a190b24202 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/a.tsx +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_first/_second/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/b.tsx b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/b.tsx index 98bb842612..505f8f6fbf 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/b.tsx +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_first/_second/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx index c7417e5eeb..f86335e291 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/classic/hello/')({ +export const Route = createFileRoute({ component: () =>
This is the index
, }) diff --git a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx index 566efc8777..620dd2b76b 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/classic/hello')({ +export const Route = createFileRoute({ component: () => (
Hello! diff --git a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx index e00c47d74b..20b07c41cc 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/classic/hello/universe')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/universe!
, }) diff --git a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx index 9783557342..4af11357a2 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/classic/hello/world')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/world!
, }) diff --git a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/home.tsx b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/home.tsx index eac82a9174..b23956ae17 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/home.tsx +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/home.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx index d39e206f2d..5c4a461d8d 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_first')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx index ef178a6e16..483b910862 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_first/_second')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx index 948d52d6d6..654f3cfd18 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import { fetchPost } from '../../posts' import type { ErrorComponentProps } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent as any, notFoundComponent: () => { diff --git a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx index 056433ca0a..fdbe5865e5 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx index a2ab1ee388..f92c37f537 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsComponent, }) diff --git a/e2e/react-router/scroll-restoration-sandbox-vite/src/routeTree.gen.ts b/e2e/react-router/scroll-restoration-sandbox-vite/src/routeTree.gen.ts index ae605007e3..73852ef2da 100644 --- a/e2e/react-router/scroll-restoration-sandbox-vite/src/routeTree.gen.ts +++ b/e2e/react-router/scroll-restoration-sandbox-vite/src/routeTree.gen.ts @@ -12,26 +12,29 @@ import { createFileRoute } from '@tanstack/react-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' -import { Route as testsPageWithSearchImport } from './routes/(tests)/page-with-search' -import { Route as testsNormalPageImport } from './routes/(tests)/normal-page' -import { Route as testsLazyWithLoaderPageImport } from './routes/(tests)/lazy-with-loader-page' -import { Route as testsLazyPageImport } from './routes/(tests)/lazy-page' +import { Route as IndexRouteImport } from './routes/index' +import { Route as testsPageWithSearchRouteImport } from './routes/(tests)/page-with-search' +import { Route as testsNormalPageRouteImport } from './routes/(tests)/normal-page' +import { Route as testsLazyWithLoaderPageRouteImport } from './routes/(tests)/lazy-with-loader-page' +import { Route as testsLazyPageRouteImport } from './routes/(tests)/lazy-page' // Create Virtual Routes -const testsVirtualPageLazyImport = createFileRoute('/(tests)/virtual-page')() +const testsVirtualPageLazyRouteImport = createFileRoute( + '/(tests)/virtual-page', +)() // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const testsVirtualPageLazyRoute = testsVirtualPageLazyImport +const testsVirtualPageLazyRoute = testsVirtualPageLazyRouteImport .update({ id: '/(tests)/virtual-page', path: '/virtual-page', @@ -39,19 +42,19 @@ const testsVirtualPageLazyRoute = testsVirtualPageLazyImport } as any) .lazy(() => import('./routes/(tests)/virtual-page.lazy').then((d) => d.Route)) -const testsPageWithSearchRoute = testsPageWithSearchImport.update({ +const testsPageWithSearchRoute = testsPageWithSearchRouteImport.update({ id: '/(tests)/page-with-search', path: '/page-with-search', getParentRoute: () => rootRoute, } as any) -const testsNormalPageRoute = testsNormalPageImport.update({ +const testsNormalPageRoute = testsNormalPageRouteImport.update({ id: '/(tests)/normal-page', path: '/normal-page', getParentRoute: () => rootRoute, } as any) -const testsLazyWithLoaderPageRoute = testsLazyWithLoaderPageImport +const testsLazyWithLoaderPageRoute = testsLazyWithLoaderPageRouteImport .update({ id: '/(tests)/lazy-with-loader-page', path: '/lazy-with-loader-page', @@ -61,7 +64,7 @@ const testsLazyWithLoaderPageRoute = testsLazyWithLoaderPageImport import('./routes/(tests)/lazy-with-loader-page.lazy').then((d) => d.Route), ) -const testsLazyPageRoute = testsLazyPageImport +const testsLazyPageRoute = testsLazyPageRouteImport .update({ id: '/(tests)/lazy-page', path: '/lazy-page', @@ -77,47 +80,131 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/(tests)/lazy-page': { id: '/(tests)/lazy-page' path: '/lazy-page' fullPath: '/lazy-page' - preLoaderRoute: typeof testsLazyPageImport + preLoaderRoute: typeof testsLazyPageRouteImport parentRoute: typeof rootRoute } '/(tests)/lazy-with-loader-page': { id: '/(tests)/lazy-with-loader-page' path: '/lazy-with-loader-page' fullPath: '/lazy-with-loader-page' - preLoaderRoute: typeof testsLazyWithLoaderPageImport + preLoaderRoute: typeof testsLazyWithLoaderPageRouteImport parentRoute: typeof rootRoute } '/(tests)/normal-page': { id: '/(tests)/normal-page' path: '/normal-page' fullPath: '/normal-page' - preLoaderRoute: typeof testsNormalPageImport + preLoaderRoute: typeof testsNormalPageRouteImport parentRoute: typeof rootRoute } '/(tests)/page-with-search': { id: '/(tests)/page-with-search' path: '/page-with-search' fullPath: '/page-with-search' - preLoaderRoute: typeof testsPageWithSearchImport + preLoaderRoute: typeof testsPageWithSearchRouteImport parentRoute: typeof rootRoute } '/(tests)/virtual-page': { id: '/(tests)/virtual-page' path: '/virtual-page' fullPath: '/virtual-page' - preLoaderRoute: typeof testsVirtualPageLazyImport + preLoaderRoute: typeof testsVirtualPageLazyRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/(tests)/lazy-page' { + const createFileRoute: CreateFileRoute< + '/(tests)/lazy-page', + FileRoutesByPath['/(tests)/lazy-page']['parentRoute'], + FileRoutesByPath['/(tests)/lazy-page']['id'], + FileRoutesByPath['/(tests)/lazy-page']['path'], + FileRoutesByPath['/(tests)/lazy-page']['fullPath'] + > +} +declare module './routes/(tests)/lazy-page.lazy' { + const createLazyFileRoute: CreateFileRoute< + '/(tests)/lazy-page', + FileRoutesByPath['/(tests)/lazy-page']['parentRoute'], + FileRoutesByPath['/(tests)/lazy-page']['id'], + FileRoutesByPath['/(tests)/lazy-page']['path'], + FileRoutesByPath['/(tests)/lazy-page']['fullPath'] + > +} +declare module './routes/(tests)/lazy-with-loader-page' { + const createFileRoute: CreateFileRoute< + '/(tests)/lazy-with-loader-page', + FileRoutesByPath['/(tests)/lazy-with-loader-page']['parentRoute'], + FileRoutesByPath['/(tests)/lazy-with-loader-page']['id'], + FileRoutesByPath['/(tests)/lazy-with-loader-page']['path'], + FileRoutesByPath['/(tests)/lazy-with-loader-page']['fullPath'] + > +} +declare module './routes/(tests)/lazy-with-loader-page.lazy' { + const createLazyFileRoute: CreateFileRoute< + '/(tests)/lazy-with-loader-page', + FileRoutesByPath['/(tests)/lazy-with-loader-page']['parentRoute'], + FileRoutesByPath['/(tests)/lazy-with-loader-page']['id'], + FileRoutesByPath['/(tests)/lazy-with-loader-page']['path'], + FileRoutesByPath['/(tests)/lazy-with-loader-page']['fullPath'] + > +} +declare module './routes/(tests)/normal-page' { + const createFileRoute: CreateFileRoute< + '/(tests)/normal-page', + FileRoutesByPath['/(tests)/normal-page']['parentRoute'], + FileRoutesByPath['/(tests)/normal-page']['id'], + FileRoutesByPath['/(tests)/normal-page']['path'], + FileRoutesByPath['/(tests)/normal-page']['fullPath'] + > +} +declare module './routes/(tests)/page-with-search' { + const createFileRoute: CreateFileRoute< + '/(tests)/page-with-search', + FileRoutesByPath['/(tests)/page-with-search']['parentRoute'], + FileRoutesByPath['/(tests)/page-with-search']['id'], + FileRoutesByPath['/(tests)/page-with-search']['path'], + FileRoutesByPath['/(tests)/page-with-search']['fullPath'] + > +} +declare module './routes/(tests)/virtual-page.lazy' { + const createFileRoute: CreateFileRoute< + '/(tests)/virtual-page', + FileRoutesByPath['/(tests)/virtual-page']['parentRoute'], + FileRoutesByPath['/(tests)/virtual-page']['id'], + FileRoutesByPath['/(tests)/virtual-page']['path'], + FileRoutesByPath['/(tests)/virtual-page']['fullPath'] + > +} +declare module './routes/(tests)/virtual-page.lazy' { + const createLazyFileRoute: CreateFileRoute< + '/(tests)/virtual-page', + FileRoutesByPath['/(tests)/virtual-page']['parentRoute'], + FileRoutesByPath['/(tests)/virtual-page']['id'], + FileRoutesByPath['/(tests)/virtual-page']['path'], + FileRoutesByPath['/(tests)/virtual-page']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -198,6 +285,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.lazy.tsx b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.lazy.tsx index d774a43935..dfe060ac82 100644 --- a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.lazy.tsx +++ b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.lazy.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { createLazyFileRoute } from '@tanstack/react-router' + import { ScrollBlock } from '../-components/scroll-block' -export const Route = createLazyFileRoute('/(tests)/lazy-page')({ +export const Route = createLazyFileRoute({ component: Component, }) diff --git a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.tsx b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.tsx index 9c59a0d1f1..79405e27e7 100644 --- a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.tsx +++ b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.tsx @@ -1,3 +1 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(tests)/lazy-page')({}) +export const Route = createFileRoute({}) diff --git a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.lazy.tsx b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.lazy.tsx index 8311f36f45..c56fefa910 100644 --- a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.lazy.tsx +++ b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.lazy.tsx @@ -1,7 +1,6 @@ -import { createLazyFileRoute } from '@tanstack/react-router' import { ScrollBlock } from '../-components/scroll-block' -export const Route = createLazyFileRoute('/(tests)/lazy-with-loader-page')({ +export const Route = createLazyFileRoute({ component: Component, }) diff --git a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.tsx b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.tsx index 3fdc078569..5463a153af 100644 --- a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.tsx +++ b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { sleep } from '../../posts' -export const Route = createFileRoute('/(tests)/lazy-with-loader-page')({ +export const Route = createFileRoute({ loader: async () => { await sleep(1000) return { foo: 'bar' } diff --git a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/normal-page.tsx b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/normal-page.tsx index 95fb7e119e..1d897c8e5d 100644 --- a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/normal-page.tsx +++ b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/normal-page.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' + import { ScrollBlock } from '../-components/scroll-block' -export const Route = createFileRoute('/(tests)/normal-page')({ +export const Route = createFileRoute({ component: Component, }) diff --git a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/page-with-search.tsx b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/page-with-search.tsx index d9591671f5..21e7635e29 100644 --- a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/page-with-search.tsx +++ b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/page-with-search.tsx @@ -1,9 +1,8 @@ -import { createFileRoute } from '@tanstack/react-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' import { ScrollBlock } from '../-components/scroll-block' -export const Route = createFileRoute('/(tests)/page-with-search')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ where: z.string() })), component: Component, }) diff --git a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/virtual-page.lazy.tsx b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/virtual-page.lazy.tsx index aa446121f4..ca3bf045e9 100644 --- a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/virtual-page.lazy.tsx +++ b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/(tests)/virtual-page.lazy.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { createLazyFileRoute } from '@tanstack/react-router' + import { ScrollBlock } from '../-components/scroll-block' -export const Route = createLazyFileRoute('/(tests)/virtual-page')({ +export const Route = createLazyFileRoute({ component: Component, }) diff --git a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/index.tsx b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/index.tsx index 49f6d4bff0..843919d994 100644 --- a/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/index.tsx +++ b/e2e/react-router/scroll-restoration-sandbox-vite/src/routes/index.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, createFileRoute, linkOptions } from '@tanstack/react-router' +import { Link, linkOptions } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: HomeComponent, }) diff --git a/e2e/react-start/basic-auth/.gitignore b/e2e/react-start/basic-auth/.gitignore index b15fed94e2..75a469e80c 100644 --- a/e2e/react-start/basic-auth/.gitignore +++ b/e2e/react-start/basic-auth/.gitignore @@ -7,13 +7,11 @@ yarn.lock .cache .vercel .output -.vinxi /build/ /api/ /server/build /public/build -.vinxi # Sentry Config File .env.sentry-build-plugin /test-results/ diff --git a/e2e/react-start/basic-auth/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/react-start/basic-auth/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/e2e/react-start/basic-auth/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/react-start/basic-auth/app.config.ts b/e2e/react-start/basic-auth/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/e2e/react-start/basic-auth/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/e2e/react-start/basic-auth/package.json b/e2e/react-start/basic-auth/package.json index bb04401e02..6311e126f4 100644 --- a/e2e/react-start/basic-auth/package.json +++ b/e2e/react-start/basic-auth/package.json @@ -4,10 +4,10 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev --port 3000", - "dev:e2e": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start", + "dev": "vite dev --port 3000", + "dev:e2e": "vite dev", + "build": "vite build", + "start": "node .output/server/index.mjs", "prisma-generate": "prisma generate", "test:e2e": "exit 0; pnpm run prisma-generate && playwright test --project=chromium" }, @@ -21,7 +21,7 @@ "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3" + "vite": "6.1.4" }, "devDependencies": { "@playwright/test": "^1.50.1", @@ -30,8 +30,8 @@ "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", - "postcss": "^8.5.1", "autoprefixer": "^10.4.20", + "postcss": "^8.5.1", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", "vite-tsconfig-paths": "^5.1.4" diff --git a/e2e/react-start/basic-auth/playwright.config.ts b/e2e/react-start/basic-auth/playwright.config.ts index bb77d0cf70..9806e0c136 100644 --- a/e2e/react-start/basic-auth/playwright.config.ts +++ b/e2e/react-start/basic-auth/playwright.config.ts @@ -19,7 +19,7 @@ export default defineConfig({ }, webServer: { - command: `VITE_SERVER_PORT=${PORT} pnpm build && VITE_SERVER_PORT=${PORT} pnpm start --port ${PORT}`, + command: `VITE_SERVER_PORT=${PORT} pnpm build && PORT=${PORT} VITE_SERVER_PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', diff --git a/e2e/react-start/basic-auth/src/client.tsx b/e2e/react-start/basic-auth/src/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/e2e/react-start/basic-auth/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/e2e/react-start/basic-auth/src/routeTree.gen.ts b/e2e/react-start/basic-auth/src/routeTree.gen.ts index a37809fd07..73917eb528 100644 --- a/e2e/react-start/basic-auth/src/routeTree.gen.ts +++ b/e2e/react-start/basic-auth/src/routeTree.gen.ts @@ -10,60 +10,61 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as SignupImport } from './routes/signup' -import { Route as LogoutImport } from './routes/logout' -import { Route as LoginImport } from './routes/login' -import { Route as AuthedImport } from './routes/_authed' -import { Route as IndexImport } from './routes/index' -import { Route as AuthedPostsImport } from './routes/_authed/posts' -import { Route as AuthedPostsIndexImport } from './routes/_authed/posts.index' -import { Route as AuthedPostsPostIdImport } from './routes/_authed/posts.$postId' +import { Route as SignupRouteImport } from './routes/signup' +import { Route as LogoutRouteImport } from './routes/logout' +import { Route as LoginRouteImport } from './routes/login' +import { Route as AuthedRouteImport } from './routes/_authed' +import { Route as IndexRouteImport } from './routes/index' +import { Route as AuthedPostsRouteImport } from './routes/_authed/posts' +import { Route as AuthedPostsIndexRouteImport } from './routes/_authed/posts.index' +import { Route as AuthedPostsPostIdRouteImport } from './routes/_authed/posts.$postId' // Create/Update Routes -const SignupRoute = SignupImport.update({ +const SignupRoute = SignupRouteImport.update({ id: '/signup', path: '/signup', getParentRoute: () => rootRoute, } as any) -const LogoutRoute = LogoutImport.update({ +const LogoutRoute = LogoutRouteImport.update({ id: '/logout', path: '/logout', getParentRoute: () => rootRoute, } as any) -const LoginRoute = LoginImport.update({ +const LoginRoute = LoginRouteImport.update({ id: '/login', path: '/login', getParentRoute: () => rootRoute, } as any) -const AuthedRoute = AuthedImport.update({ +const AuthedRoute = AuthedRouteImport.update({ id: '/_authed', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const AuthedPostsRoute = AuthedPostsImport.update({ +const AuthedPostsRoute = AuthedPostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => AuthedRoute, } as any) -const AuthedPostsIndexRoute = AuthedPostsIndexImport.update({ +const AuthedPostsIndexRoute = AuthedPostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => AuthedPostsRoute, } as any) -const AuthedPostsPostIdRoute = AuthedPostsPostIdImport.update({ +const AuthedPostsPostIdRoute = AuthedPostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => AuthedPostsRoute, @@ -77,61 +78,136 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_authed': { id: '/_authed' path: '' fullPath: '' - preLoaderRoute: typeof AuthedImport + preLoaderRoute: typeof AuthedRouteImport parentRoute: typeof rootRoute } '/login': { id: '/login' path: '/login' fullPath: '/login' - preLoaderRoute: typeof LoginImport + preLoaderRoute: typeof LoginRouteImport parentRoute: typeof rootRoute } '/logout': { id: '/logout' path: '/logout' fullPath: '/logout' - preLoaderRoute: typeof LogoutImport + preLoaderRoute: typeof LogoutRouteImport parentRoute: typeof rootRoute } '/signup': { id: '/signup' path: '/signup' fullPath: '/signup' - preLoaderRoute: typeof SignupImport + preLoaderRoute: typeof SignupRouteImport parentRoute: typeof rootRoute } '/_authed/posts': { id: '/_authed/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof AuthedPostsImport - parentRoute: typeof AuthedImport + preLoaderRoute: typeof AuthedPostsRouteImport + parentRoute: typeof AuthedRouteImport } '/_authed/posts/$postId': { id: '/_authed/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof AuthedPostsPostIdImport - parentRoute: typeof AuthedPostsImport + preLoaderRoute: typeof AuthedPostsPostIdRouteImport + parentRoute: typeof AuthedPostsRouteImport } '/_authed/posts/': { id: '/_authed/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof AuthedPostsIndexImport - parentRoute: typeof AuthedPostsImport + preLoaderRoute: typeof AuthedPostsIndexRouteImport + parentRoute: typeof AuthedPostsRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_authed' { + const createFileRoute: CreateFileRoute< + '/_authed', + FileRoutesByPath['/_authed']['parentRoute'], + FileRoutesByPath['/_authed']['id'], + FileRoutesByPath['/_authed']['path'], + FileRoutesByPath['/_authed']['fullPath'] + > +} +declare module './routes/login' { + const createFileRoute: CreateFileRoute< + '/login', + FileRoutesByPath['/login']['parentRoute'], + FileRoutesByPath['/login']['id'], + FileRoutesByPath['/login']['path'], + FileRoutesByPath['/login']['fullPath'] + > +} +declare module './routes/logout' { + const createFileRoute: CreateFileRoute< + '/logout', + FileRoutesByPath['/logout']['parentRoute'], + FileRoutesByPath['/logout']['id'], + FileRoutesByPath['/logout']['path'], + FileRoutesByPath['/logout']['fullPath'] + > +} +declare module './routes/signup' { + const createFileRoute: CreateFileRoute< + '/signup', + FileRoutesByPath['/signup']['parentRoute'], + FileRoutesByPath['/signup']['id'], + FileRoutesByPath['/signup']['path'], + FileRoutesByPath['/signup']['fullPath'] + > +} +declare module './routes/_authed/posts' { + const createFileRoute: CreateFileRoute< + '/_authed/posts', + FileRoutesByPath['/_authed/posts']['parentRoute'], + FileRoutesByPath['/_authed/posts']['id'], + FileRoutesByPath['/_authed/posts']['path'], + FileRoutesByPath['/_authed/posts']['fullPath'] + > +} +declare module './routes/_authed/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/_authed/posts/$postId', + FileRoutesByPath['/_authed/posts/$postId']['parentRoute'], + FileRoutesByPath['/_authed/posts/$postId']['id'], + FileRoutesByPath['/_authed/posts/$postId']['path'], + FileRoutesByPath['/_authed/posts/$postId']['fullPath'] + > +} +declare module './routes/_authed/posts.index' { + const createFileRoute: CreateFileRoute< + '/_authed/posts/', + FileRoutesByPath['/_authed/posts/']['parentRoute'], + FileRoutesByPath['/_authed/posts/']['id'], + FileRoutesByPath['/_authed/posts/']['path'], + FileRoutesByPath['/_authed/posts/']['fullPath'] + > +} + // Create and export the route tree interface AuthedPostsRouteChildren { @@ -238,6 +314,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/react-start/basic-auth/src/routes/_authed.tsx b/e2e/react-start/basic-auth/src/routes/_authed.tsx index c457cf5e57..10c620a9ae 100644 --- a/e2e/react-start/basic-auth/src/routes/_authed.tsx +++ b/e2e/react-start/basic-auth/src/routes/_authed.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' import { hashPassword, prismaClient } from '~/utils/prisma' @@ -45,7 +44,7 @@ export const loginFn = createServerFn({ }) }) -export const Route = createFileRoute('/_authed')({ +export const Route = createFileRoute({ beforeLoad: ({ context }) => { if (!context.user) { throw new Error('Not authenticated') diff --git a/e2e/react-start/basic-auth/src/routes/_authed/posts.$postId.tsx b/e2e/react-start/basic-auth/src/routes/_authed/posts.$postId.tsx index 27296b9658..49cad9b374 100644 --- a/e2e/react-start/basic-auth/src/routes/_authed/posts.$postId.tsx +++ b/e2e/react-start/basic-auth/src/routes/_authed/posts.$postId.tsx @@ -1,10 +1,10 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import type { ErrorComponentProps } from '@tanstack/react-router' import { NotFound } from '~/components/NotFound.js' import { fetchPost } from '~/utils/posts.js' -export const Route = createFileRoute('/_authed/posts/$postId')({ +export const Route = createFileRoute({ loader: ({ params: { postId } }) => fetchPost({ data: postId }), errorComponent: PostErrorComponent, component: PostComponent, diff --git a/e2e/react-start/basic-auth/src/routes/_authed/posts.index.tsx b/e2e/react-start/basic-auth/src/routes/_authed/posts.index.tsx index ea9e667e54..13529228bb 100644 --- a/e2e/react-start/basic-auth/src/routes/_authed/posts.index.tsx +++ b/e2e/react-start/basic-auth/src/routes/_authed/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_authed/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-start/basic-auth/src/routes/_authed/posts.tsx b/e2e/react-start/basic-auth/src/routes/_authed/posts.tsx index c01f12c49a..6c37957e8c 100644 --- a/e2e/react-start/basic-auth/src/routes/_authed/posts.tsx +++ b/e2e/react-start/basic-auth/src/routes/_authed/posts.tsx @@ -1,8 +1,8 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '~/utils/posts.js' -export const Route = createFileRoute('/_authed/posts')({ +export const Route = createFileRoute({ loader: () => fetchPosts(), component: PostsComponent, }) diff --git a/e2e/react-start/basic-auth/src/routes/index.tsx b/e2e/react-start/basic-auth/src/routes/index.tsx index 09a907cb18..f6c5b98b02 100644 --- a/e2e/react-start/basic-auth/src/routes/index.tsx +++ b/e2e/react-start/basic-auth/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-start/basic-auth/src/routes/login.tsx b/e2e/react-start/basic-auth/src/routes/login.tsx index 19dc34a439..269ca5e816 100644 --- a/e2e/react-start/basic-auth/src/routes/login.tsx +++ b/e2e/react-start/basic-auth/src/routes/login.tsx @@ -1,8 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - import { Login } from '~/components/Login' -export const Route = createFileRoute('/login')({ +export const Route = createFileRoute({ component: LoginComp, }) diff --git a/e2e/react-start/basic-auth/src/routes/logout.tsx b/e2e/react-start/basic-auth/src/routes/logout.tsx index 43a14fa39a..43553a6290 100644 --- a/e2e/react-start/basic-auth/src/routes/logout.tsx +++ b/e2e/react-start/basic-auth/src/routes/logout.tsx @@ -1,4 +1,4 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' import { useAppSession } from '~/utils/session' @@ -13,7 +13,7 @@ const logoutFn = createServerFn({ method: 'POST' }).handler(async () => { }) }) -export const Route = createFileRoute('/logout')({ +export const Route = createFileRoute({ preload: false, loader: () => logoutFn(), }) diff --git a/e2e/react-start/basic-auth/src/routes/signup.tsx b/e2e/react-start/basic-auth/src/routes/signup.tsx index 5edbb4993f..e852b267e2 100644 --- a/e2e/react-start/basic-auth/src/routes/signup.tsx +++ b/e2e/react-start/basic-auth/src/routes/signup.tsx @@ -1,4 +1,4 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' import { createServerFn, useServerFn } from '@tanstack/react-start' import { hashPassword, prismaClient } from '~/utils/prisma' @@ -65,7 +65,7 @@ export const signupFn = createServerFn({ }) }) -export const Route = createFileRoute('/signup')({ +export const Route = createFileRoute({ component: SignupComp, }) diff --git a/e2e/react-start/basic-auth/vite.config.ts b/e2e/react-start/basic-auth/vite.config.ts new file mode 100644 index 0000000000..82d4065454 --- /dev/null +++ b/e2e/react-start/basic-auth/vite.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' + +export default defineConfig({ + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/e2e/react-start/basic-react-query/.gitignore b/e2e/react-start/basic-react-query/.gitignore index be342025da..ca63f49885 100644 --- a/e2e/react-start/basic-react-query/.gitignore +++ b/e2e/react-start/basic-react-query/.gitignore @@ -7,14 +7,10 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ diff --git a/e2e/react-start/basic-react-query/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/react-start/basic-react-query/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..87c0856e21 --- /dev/null +++ b/e2e/react-start/basic-react-query/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,155 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +import { ServerRoute as ApiUsersRouteImport } from './../../src/routes/api.users' +import { ServerRoute as ApiUsersIdRouteImport } from './../../src/routes/api/users.$id' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +const ApiUsersRoute = ApiUsersRouteImport.update({ + id: '/api/users', + path: '/api/users', + getParentRoute: () => rootRoute, +} as any) + +const ApiUsersIdRoute = ApiUsersIdRouteImport.update({ + id: '/$id', + path: '/$id', + getParentRoute: () => ApiUsersRoute, +} as any) + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath { + '/api/users': { + id: '/api/users' + path: '/api/users' + fullPath: '/api/users' + preLoaderRoute: typeof ApiUsersRouteImport + parentRoute: typeof rootRoute + } + '/api/users/$id': { + id: '/api/users/$id' + path: '/$id' + fullPath: '/api/users/$id' + preLoaderRoute: typeof ApiUsersIdRouteImport + parentRoute: typeof ApiUsersRouteImport + } + } +} + +// Add type-safety to the createFileRoute function across the route tree + +declare module './../../src/routes/api.users' { + const createServerFileRoute: CreateServerFileRoute< + FileRoutesByPath['/api/users']['parentRoute'], + FileRoutesByPath['/api/users']['id'], + FileRoutesByPath['/api/users']['path'], + FileRoutesByPath['/api/users']['fullPath'], + ApiUsersRouteChildren + > +} +declare module './../../src/routes/api/users.$id' { + const createServerFileRoute: CreateServerFileRoute< + FileRoutesByPath['/api/users/$id']['parentRoute'], + FileRoutesByPath['/api/users/$id']['id'], + FileRoutesByPath['/api/users/$id']['path'], + FileRoutesByPath['/api/users/$id']['fullPath'], + unknown + > +} + +// Create and export the route tree + +interface ApiUsersRouteChildren { + ApiUsersIdRoute: typeof ApiUsersIdRoute +} + +const ApiUsersRouteChildren: ApiUsersRouteChildren = { + ApiUsersIdRoute: ApiUsersIdRoute, +} + +const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren( + ApiUsersRouteChildren, +) + +export interface FileRoutesByFullPath { + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$id': typeof ApiUsersIdRoute +} + +export interface FileRoutesByTo { + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$id': typeof ApiUsersIdRoute +} + +export interface FileRoutesById { + __root__: typeof rootRoute + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$id': typeof ApiUsersIdRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: '/api/users' | '/api/users/$id' + fileRoutesByTo: FileRoutesByTo + to: '/api/users' | '/api/users/$id' + id: '__root__' | '/api/users' | '/api/users/$id' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren { + ApiUsersRoute: typeof ApiUsersRouteWithChildren +} + +const rootRouteChildren: RootRouteChildren = { + ApiUsersRoute: ApiUsersRouteWithChildren, +} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [ + "/api/users" + ] + }, + "/api/users": { + "filePath": "api.users.ts", + "children": [ + "/api/users/$id" + ] + }, + "/api/users/$id": { + "filePath": "api/users.$id.ts", + "parent": "/api/users" + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/react-start/basic-react-query/app.config.ts b/e2e/react-start/basic-react-query/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/e2e/react-start/basic-react-query/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/e2e/react-start/basic-react-query/package.json b/e2e/react-start/basic-react-query/package.json index 4cc7162526..ddf4092545 100644 --- a/e2e/react-start/basic-react-query/package.json +++ b/e2e/react-start/basic-react-query/package.json @@ -4,24 +4,24 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev --port 3000", - "dev:e2e": "vinxi dev", - "build": "vinxi build && tsc --noEmit", - "start": "vinxi start", + "dev": "vite dev --port 3000", + "dev:e2e": "vite dev", + "build": "vite build && tsc --noEmit", + "start": "node .output/server/index.mjs", "test:e2e": "playwright test --project=chromium" }, "dependencies": { "@tanstack/react-query": "^5.66.0", "@tanstack/react-query-devtools": "^5.66.0", "@tanstack/react-router": "workspace:^", - "@tanstack/react-router-with-query": "workspace:^", "@tanstack/react-router-devtools": "workspace:^", + "@tanstack/react-router-with-query": "workspace:^", "@tanstack/react-start": "workspace:^", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3" + "vite": "6.1.4" }, "devDependencies": { "@playwright/test": "^1.50.1", @@ -30,8 +30,8 @@ "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", - "postcss": "^8.5.1", "autoprefixer": "^10.4.20", + "postcss": "^8.5.1", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", "vite-tsconfig-paths": "^5.1.4" diff --git a/e2e/react-start/basic-react-query/playwright.config.ts b/e2e/react-start/basic-react-query/playwright.config.ts index bb77d0cf70..9806e0c136 100644 --- a/e2e/react-start/basic-react-query/playwright.config.ts +++ b/e2e/react-start/basic-react-query/playwright.config.ts @@ -19,7 +19,7 @@ export default defineConfig({ }, webServer: { - command: `VITE_SERVER_PORT=${PORT} pnpm build && VITE_SERVER_PORT=${PORT} pnpm start --port ${PORT}`, + command: `VITE_SERVER_PORT=${PORT} pnpm build && PORT=${PORT} VITE_SERVER_PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', diff --git a/e2e/react-start/basic-react-query/src/api.ts b/e2e/react-start/basic-react-query/src/api.ts deleted file mode 100644 index 8b9fef1667..0000000000 --- a/e2e/react-start/basic-react-query/src/api.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { - createStartAPIHandler, - defaultAPIFileRouteHandler, -} from '@tanstack/react-start/api' - -export default createStartAPIHandler(defaultAPIFileRouteHandler) diff --git a/e2e/react-start/basic-react-query/src/client.tsx b/e2e/react-start/basic-react-query/src/client.tsx deleted file mode 100644 index 31385f57f1..0000000000 --- a/e2e/react-start/basic-react-query/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document!, ) diff --git a/e2e/react-start/basic-react-query/src/routeTree.gen.ts b/e2e/react-start/basic-react-query/src/routeTree.gen.ts index 9f7ab8107b..c9d48e43bf 100644 --- a/e2e/react-start/basic-react-query/src/routeTree.gen.ts +++ b/e2e/react-start/basic-react-query/src/routeTree.gen.ts @@ -10,101 +10,102 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as UsersImport } from './routes/users' -import { Route as RedirectImport } from './routes/redirect' -import { Route as PostsImport } from './routes/posts' -import { Route as DeferredImport } from './routes/deferred' -import { Route as LayoutImport } from './routes/_layout' -import { Route as IndexImport } from './routes/index' -import { Route as UsersIndexImport } from './routes/users.index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as UsersUserIdImport } from './routes/users.$userId' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as LayoutLayout2Import } from './routes/_layout/_layout-2' -import { Route as PostsPostIdDeepImport } from './routes/posts_.$postId.deep' -import { Route as LayoutLayout2LayoutBImport } from './routes/_layout/_layout-2/layout-b' -import { Route as LayoutLayout2LayoutAImport } from './routes/_layout/_layout-2/layout-a' +import { Route as UsersRouteImport } from './routes/users' +import { Route as RedirectRouteImport } from './routes/redirect' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as DeferredRouteImport } from './routes/deferred' +import { Route as LayoutRouteImport } from './routes/_layout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as UsersIndexRouteImport } from './routes/users.index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as UsersUserIdRouteImport } from './routes/users.$userId' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2' +import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep' +import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b' +import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a' // Create/Update Routes -const UsersRoute = UsersImport.update({ +const UsersRoute = UsersRouteImport.update({ id: '/users', path: '/users', getParentRoute: () => rootRoute, } as any) -const RedirectRoute = RedirectImport.update({ +const RedirectRoute = RedirectRouteImport.update({ id: '/redirect', path: '/redirect', getParentRoute: () => rootRoute, } as any) -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const DeferredRoute = DeferredImport.update({ +const DeferredRoute = DeferredRouteImport.update({ id: '/deferred', path: '/deferred', getParentRoute: () => rootRoute, } as any) -const LayoutRoute = LayoutImport.update({ +const LayoutRoute = LayoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const UsersIndexRoute = UsersIndexImport.update({ +const UsersIndexRoute = UsersIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => UsersRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const UsersUserIdRoute = UsersUserIdImport.update({ +const UsersUserIdRoute = UsersUserIdRouteImport.update({ id: '/$userId', path: '/$userId', getParentRoute: () => UsersRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const LayoutLayout2Route = LayoutLayout2Import.update({ +const LayoutLayout2Route = LayoutLayout2RouteImport.update({ id: '/_layout-2', getParentRoute: () => LayoutRoute, } as any) -const PostsPostIdDeepRoute = PostsPostIdDeepImport.update({ +const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ id: '/posts_/$postId/deep', path: '/posts/$postId/deep', getParentRoute: () => rootRoute, } as any) -const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBImport.update({ +const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => LayoutLayout2Route, } as any) -const LayoutLayout2LayoutARoute = LayoutLayout2LayoutAImport.update({ +const LayoutLayout2LayoutARoute = LayoutLayout2LayoutARouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => LayoutLayout2Route, @@ -118,103 +119,232 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutRouteImport parentRoute: typeof rootRoute } '/deferred': { id: '/deferred' path: '/deferred' fullPath: '/deferred' - preLoaderRoute: typeof DeferredImport + preLoaderRoute: typeof DeferredRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/redirect': { id: '/redirect' path: '/redirect' fullPath: '/redirect' - preLoaderRoute: typeof RedirectImport + preLoaderRoute: typeof RedirectRouteImport parentRoute: typeof rootRoute } '/users': { id: '/users' path: '/users' fullPath: '/users' - preLoaderRoute: typeof UsersImport + preLoaderRoute: typeof UsersRouteImport parentRoute: typeof rootRoute } '/_layout/_layout-2': { id: '/_layout/_layout-2' path: '' fullPath: '' - preLoaderRoute: typeof LayoutLayout2Import - parentRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutLayout2RouteImport + parentRoute: typeof LayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/users/$userId': { id: '/users/$userId' path: '/$userId' fullPath: '/users/$userId' - preLoaderRoute: typeof UsersUserIdImport - parentRoute: typeof UsersImport + preLoaderRoute: typeof UsersUserIdRouteImport + parentRoute: typeof UsersRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/users/': { id: '/users/' path: '/' fullPath: '/users/' - preLoaderRoute: typeof UsersIndexImport - parentRoute: typeof UsersImport + preLoaderRoute: typeof UsersIndexRouteImport + parentRoute: typeof UsersRouteImport } '/_layout/_layout-2/layout-a': { id: '/_layout/_layout-2/layout-a' path: '/layout-a' fullPath: '/layout-a' - preLoaderRoute: typeof LayoutLayout2LayoutAImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutARouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/_layout/_layout-2/layout-b': { id: '/_layout/_layout-2/layout-b' path: '/layout-b' fullPath: '/layout-b' - preLoaderRoute: typeof LayoutLayout2LayoutBImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/posts_/$postId/deep': { id: '/posts_/$postId/deep' path: '/posts/$postId/deep' fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepImport + preLoaderRoute: typeof PostsPostIdDeepRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/deferred' { + const createFileRoute: CreateFileRoute< + '/deferred', + FileRoutesByPath['/deferred']['parentRoute'], + FileRoutesByPath['/deferred']['id'], + FileRoutesByPath['/deferred']['path'], + FileRoutesByPath['/deferred']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/redirect' { + const createFileRoute: CreateFileRoute< + '/redirect', + FileRoutesByPath['/redirect']['parentRoute'], + FileRoutesByPath['/redirect']['id'], + FileRoutesByPath['/redirect']['path'], + FileRoutesByPath['/redirect']['fullPath'] + > +} +declare module './routes/users' { + const createFileRoute: CreateFileRoute< + '/users', + FileRoutesByPath['/users']['parentRoute'], + FileRoutesByPath['/users']['id'], + FileRoutesByPath['/users']['path'], + FileRoutesByPath['/users']['fullPath'] + > +} +declare module './routes/_layout/_layout-2' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2', + FileRoutesByPath['/_layout/_layout-2']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2']['id'], + FileRoutesByPath['/_layout/_layout-2']['path'], + FileRoutesByPath['/_layout/_layout-2']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/users.$userId' { + const createFileRoute: CreateFileRoute< + '/users/$userId', + FileRoutesByPath['/users/$userId']['parentRoute'], + FileRoutesByPath['/users/$userId']['id'], + FileRoutesByPath['/users/$userId']['path'], + FileRoutesByPath['/users/$userId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/users.index' { + const createFileRoute: CreateFileRoute< + '/users/', + FileRoutesByPath['/users/']['parentRoute'], + FileRoutesByPath['/users/']['id'], + FileRoutesByPath['/users/']['path'], + FileRoutesByPath['/users/']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-a' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-a', + FileRoutesByPath['/_layout/_layout-2/layout-a']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-b' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-b', + FileRoutesByPath['/_layout/_layout-2/layout-b']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['fullPath'] + > +} +declare module './routes/posts_.$postId.deep' { + const createFileRoute: CreateFileRoute< + '/posts_/$postId/deep', + FileRoutesByPath['/posts_/$postId/deep']['parentRoute'], + FileRoutesByPath['/posts_/$postId/deep']['id'], + FileRoutesByPath['/posts_/$postId/deep']['path'], + FileRoutesByPath['/posts_/$postId/deep']['fullPath'] + > +} + // Create and export the route tree interface LayoutLayout2RouteChildren { @@ -386,6 +516,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/react-start/basic-react-query/src/routes/_layout.tsx b/e2e/react-start/basic-react-query/src/routes/_layout.tsx index af5585728e..810465a9ba 100644 --- a/e2e/react-start/basic-react-query/src/routes/_layout.tsx +++ b/e2e/react-start/basic-react-query/src/routes/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-start/basic-react-query/src/routes/_layout/_layout-2.tsx b/e2e/react-start/basic-react-query/src/routes/_layout/_layout-2.tsx index 2167ce27ce..a1ed146002 100644 --- a/e2e/react-start/basic-react-query/src/routes/_layout/_layout-2.tsx +++ b/e2e/react-start/basic-react-query/src/routes/_layout/_layout-2.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout/_layout-2')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-start/basic-react-query/src/routes/_layout/_layout-2/layout-a.tsx b/e2e/react-start/basic-react-query/src/routes/_layout/_layout-2/layout-a.tsx index bb8d3d277d..a0bd5240b7 100644 --- a/e2e/react-start/basic-react-query/src/routes/_layout/_layout-2/layout-a.tsx +++ b/e2e/react-start/basic-react-query/src/routes/_layout/_layout-2/layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/react-start/basic-react-query/src/routes/_layout/_layout-2/layout-b.tsx b/e2e/react-start/basic-react-query/src/routes/_layout/_layout-2/layout-b.tsx index 69f6158958..2864ec1f28 100644 --- a/e2e/react-start/basic-react-query/src/routes/_layout/_layout-2/layout-b.tsx +++ b/e2e/react-start/basic-react-query/src/routes/_layout/_layout-2/layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/react-start/basic-react-query/src/routes/api.users.ts b/e2e/react-start/basic-react-query/src/routes/api.users.ts index 481085ef3f..3a37e5691a 100644 --- a/e2e/react-start/basic-react-query/src/routes/api.users.ts +++ b/e2e/react-start/basic-react-query/src/routes/api.users.ts @@ -1,9 +1,8 @@ import { json } from '@tanstack/react-start' -import { createAPIFileRoute } from '@tanstack/react-start/api' import axios from 'redaxios' import type { User } from '../utils/users' -export const APIRoute = createAPIFileRoute('/api/users')({ +export const ServerRoute = createServerFileRoute().methods({ GET: async ({ request }) => { console.info('Fetching users... @', request.url) const res = await axios.get>( diff --git a/e2e/react-start/basic-react-query/src/routes/api/users.$id.ts b/e2e/react-start/basic-react-query/src/routes/api/users.$id.ts index b1797e7917..81494c2e93 100644 --- a/e2e/react-start/basic-react-query/src/routes/api/users.$id.ts +++ b/e2e/react-start/basic-react-query/src/routes/api/users.$id.ts @@ -1,9 +1,8 @@ import { json } from '@tanstack/react-start' -import { createAPIFileRoute } from '@tanstack/react-start/api' import axios from 'redaxios' import type { User } from '../../utils/users' -export const APIRoute = createAPIFileRoute('/api/users/$id')({ +export const ServerRoute = createServerFileRoute().methods({ GET: async ({ request, params }) => { console.info(`Fetching users by id=${params.id}... @`, request.url) try { diff --git a/e2e/react-start/basic-react-query/src/routes/deferred.tsx b/e2e/react-start/basic-react-query/src/routes/deferred.tsx index 666ae26e49..16a9f72593 100644 --- a/e2e/react-start/basic-react-query/src/routes/deferred.tsx +++ b/e2e/react-start/basic-react-query/src/routes/deferred.tsx @@ -1,5 +1,5 @@ import { queryOptions, useSuspenseQuery } from '@tanstack/react-query' -import { createFileRoute } from '@tanstack/react-router' +import {} from '@tanstack/react-router' import { Suspense, useState } from 'react' const deferredQueryOptions = () => @@ -15,7 +15,7 @@ const deferredQueryOptions = () => }, }) -export const Route = createFileRoute('/deferred')({ +export const Route = createFileRoute({ loader: ({ context }) => { // Kick off loading as early as possible! context.queryClient.prefetchQuery(deferredQueryOptions()) diff --git a/e2e/react-start/basic-react-query/src/routes/index.tsx b/e2e/react-start/basic-react-query/src/routes/index.tsx index 09a907cb18..f6c5b98b02 100644 --- a/e2e/react-start/basic-react-query/src/routes/index.tsx +++ b/e2e/react-start/basic-react-query/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-start/basic-react-query/src/routes/posts.$postId.tsx b/e2e/react-start/basic-react-query/src/routes/posts.$postId.tsx index 16a6bf29aa..f3aa0e7201 100644 --- a/e2e/react-start/basic-react-query/src/routes/posts.$postId.tsx +++ b/e2e/react-start/basic-react-query/src/routes/posts.$postId.tsx @@ -1,11 +1,11 @@ -import { ErrorComponent, Link, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent, Link } from '@tanstack/react-router' import { useSuspenseQuery } from '@tanstack/react-query' import type { ErrorComponentProps } from '@tanstack/react-router' import { postQueryOptions } from '~/utils/posts' import { NotFound } from '~/components/NotFound' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId }, context }) => { const data = await context.queryClient.ensureQueryData( postQueryOptions(postId), @@ -43,7 +43,7 @@ function PostComponent() { postId: postQuery.data.id, }} activeProps={{ className: 'text-black font-bold' }} - className="block py-1 text-blue-800 hover:text-blue-600" + className="inline-block py-1 text-blue-800 hover:text-blue-600" > Deep View diff --git a/e2e/react-start/basic-react-query/src/routes/posts.index.tsx b/e2e/react-start/basic-react-query/src/routes/posts.index.tsx index 5b5f08f95b..13529228bb 100644 --- a/e2e/react-start/basic-react-query/src/routes/posts.index.tsx +++ b/e2e/react-start/basic-react-query/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-start/basic-react-query/src/routes/posts.tsx b/e2e/react-start/basic-react-query/src/routes/posts.tsx index 3f678ed1f1..00d91fd049 100644 --- a/e2e/react-start/basic-react-query/src/routes/posts.tsx +++ b/e2e/react-start/basic-react-query/src/routes/posts.tsx @@ -1,9 +1,9 @@ import { useSuspenseQuery } from '@tanstack/react-query' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { postsQueryOptions } from '~/utils/posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: async ({ context }) => { await context.queryClient.ensureQueryData(postsQueryOptions()) }, diff --git a/e2e/react-start/basic-react-query/src/routes/posts_.$postId.deep.tsx b/e2e/react-start/basic-react-query/src/routes/posts_.$postId.deep.tsx index 33f6475a55..4d91776273 100644 --- a/e2e/react-start/basic-react-query/src/routes/posts_.$postId.deep.tsx +++ b/e2e/react-start/basic-react-query/src/routes/posts_.$postId.deep.tsx @@ -1,9 +1,9 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import { useSuspenseQuery } from '@tanstack/react-query' import { postQueryOptions } from '../utils/posts' import { PostErrorComponent } from './posts.$postId' -export const Route = createFileRoute('/posts_/$postId/deep')({ +export const Route = createFileRoute({ loader: async ({ params: { postId }, context }) => { const data = await context.queryClient.ensureQueryData( postQueryOptions(postId), diff --git a/e2e/react-start/basic-react-query/src/routes/redirect.tsx b/e2e/react-start/basic-react-query/src/routes/redirect.tsx index c9286de13d..68a98d5683 100644 --- a/e2e/react-start/basic-react-query/src/routes/redirect.tsx +++ b/e2e/react-start/basic-react-query/src/routes/redirect.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' -export const Route = createFileRoute('/redirect')({ +export const Route = createFileRoute({ beforeLoad: async () => { throw redirect({ to: '/posts', diff --git a/e2e/react-start/basic-react-query/src/routes/users.$userId.tsx b/e2e/react-start/basic-react-query/src/routes/users.$userId.tsx index 656fb6dbb8..7f8bab0e1d 100644 --- a/e2e/react-start/basic-react-query/src/routes/users.$userId.tsx +++ b/e2e/react-start/basic-react-query/src/routes/users.$userId.tsx @@ -1,11 +1,11 @@ import { useSuspenseQuery } from '@tanstack/react-query' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import type { ErrorComponentProps } from '@tanstack/react-router' import { NotFound } from '~/components/NotFound' import { userQueryOptions } from '~/utils/users' -export const Route = createFileRoute('/users/$userId')({ +export const Route = createFileRoute({ loader: async ({ context, params: { userId } }) => { await context.queryClient.ensureQueryData(userQueryOptions(userId)) }, diff --git a/e2e/react-start/basic-react-query/src/routes/users.index.tsx b/e2e/react-start/basic-react-query/src/routes/users.index.tsx index b6b0ee67fb..662e8b6c68 100644 --- a/e2e/react-start/basic-react-query/src/routes/users.index.tsx +++ b/e2e/react-start/basic-react-query/src/routes/users.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/users/')({ +export const Route = createFileRoute({ component: UsersIndexComponent, }) diff --git a/e2e/react-start/basic-react-query/src/routes/users.tsx b/e2e/react-start/basic-react-query/src/routes/users.tsx index 1b56bb9890..8a90dd8412 100644 --- a/e2e/react-start/basic-react-query/src/routes/users.tsx +++ b/e2e/react-start/basic-react-query/src/routes/users.tsx @@ -1,9 +1,9 @@ import { useSuspenseQuery } from '@tanstack/react-query' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { usersQueryOptions } from '~/utils/users' -export const Route = createFileRoute('/users')({ +export const Route = createFileRoute({ loader: async ({ context }) => { await context.queryClient.ensureQueryData(usersQueryOptions()) }, diff --git a/e2e/react-start/basic-react-query/tsconfig.json b/e2e/react-start/basic-react-query/tsconfig.json index 3a9fb7cd71..bb7f28fe27 100644 --- a/e2e/react-start/basic-react-query/tsconfig.json +++ b/e2e/react-start/basic-react-query/tsconfig.json @@ -17,6 +17,7 @@ "paths": { "~/*": ["./src/*"] }, + "types": ["vite/client"], "noEmit": true } } diff --git a/e2e/react-start/basic-react-query/vite.config.ts b/e2e/react-start/basic-react-query/vite.config.ts new file mode 100644 index 0000000000..82d4065454 --- /dev/null +++ b/e2e/react-start/basic-react-query/vite.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' + +export default defineConfig({ + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/e2e/react-start/basic-rsc/.gitignore b/e2e/react-start/basic-rsc/.gitignore index d3387e00cd..3c8e6870b3 100644 --- a/e2e/react-start/basic-rsc/.gitignore +++ b/e2e/react-start/basic-rsc/.gitignore @@ -7,12 +7,8 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin diff --git a/e2e/react-start/basic-rsc/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/react-start/basic-rsc/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/e2e/react-start/basic-rsc/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/react-start/basic-rsc/app.config.ts b/e2e/react-start/basic-rsc/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/e2e/react-start/basic-rsc/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/e2e/react-start/basic-rsc/package.json b/e2e/react-start/basic-rsc/package.json index c93361fa88..d488eae149 100644 --- a/e2e/react-start/basic-rsc/package.json +++ b/e2e/react-start/basic-rsc/package.json @@ -4,9 +4,9 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "node .output/server/index.mjs" }, "dependencies": { "@babel/plugin-syntax-typescript": "^7.25.9", @@ -17,14 +17,14 @@ "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3" + "vite": "6.1.4" }, "devDependencies": { "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", - "postcss": "^8.5.1", "autoprefixer": "^10.4.20", + "postcss": "^8.5.1", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", "vite-tsconfig-paths": "^5.1.4" diff --git a/e2e/react-start/basic-rsc/src/client.tsx b/e2e/react-start/basic-rsc/src/client.tsx deleted file mode 100644 index 31385f57f1..0000000000 --- a/e2e/react-start/basic-rsc/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document!, ) diff --git a/e2e/react-start/basic-rsc/src/routeTree.gen.ts b/e2e/react-start/basic-rsc/src/routeTree.gen.ts index 1918b25c80..cc937db3fc 100644 --- a/e2e/react-start/basic-rsc/src/routeTree.gen.ts +++ b/e2e/react-start/basic-rsc/src/routeTree.gen.ts @@ -10,66 +10,67 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostsImport } from './routes/posts' -import { Route as LayoutImport } from './routes/_layout' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as LayoutLayout2Import } from './routes/_layout/_layout-2' -import { Route as PostsPostIdDeepImport } from './routes/posts_.$postId.deep' -import { Route as LayoutLayout2LayoutBImport } from './routes/_layout/_layout-2/layout-b' -import { Route as LayoutLayout2LayoutAImport } from './routes/_layout/_layout-2/layout-a' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as LayoutRouteImport } from './routes/_layout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2' +import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep' +import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b' +import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a' // Create/Update Routes -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const LayoutRoute = LayoutImport.update({ +const LayoutRoute = LayoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const LayoutLayout2Route = LayoutLayout2Import.update({ +const LayoutLayout2Route = LayoutLayout2RouteImport.update({ id: '/_layout-2', getParentRoute: () => LayoutRoute, } as any) -const PostsPostIdDeepRoute = PostsPostIdDeepImport.update({ +const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ id: '/posts_/$postId/deep', path: '/posts/$postId/deep', getParentRoute: () => rootRoute, } as any) -const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBImport.update({ +const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => LayoutLayout2Route, } as any) -const LayoutLayout2LayoutARoute = LayoutLayout2LayoutAImport.update({ +const LayoutLayout2LayoutARoute = LayoutLayout2LayoutARouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => LayoutLayout2Route, @@ -83,68 +84,152 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/_layout/_layout-2': { id: '/_layout/_layout-2' path: '' fullPath: '' - preLoaderRoute: typeof LayoutLayout2Import - parentRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutLayout2RouteImport + parentRoute: typeof LayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/_layout/_layout-2/layout-a': { id: '/_layout/_layout-2/layout-a' path: '/layout-a' fullPath: '/layout-a' - preLoaderRoute: typeof LayoutLayout2LayoutAImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutARouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/_layout/_layout-2/layout-b': { id: '/_layout/_layout-2/layout-b' path: '/layout-b' fullPath: '/layout-b' - preLoaderRoute: typeof LayoutLayout2LayoutBImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/posts_/$postId/deep': { id: '/posts_/$postId/deep' path: '/posts/$postId/deep' fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepImport + preLoaderRoute: typeof PostsPostIdDeepRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/_layout/_layout-2' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2', + FileRoutesByPath['/_layout/_layout-2']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2']['id'], + FileRoutesByPath['/_layout/_layout-2']['path'], + FileRoutesByPath['/_layout/_layout-2']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-a' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-a', + FileRoutesByPath['/_layout/_layout-2/layout-a']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-b' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-b', + FileRoutesByPath['/_layout/_layout-2/layout-b']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['fullPath'] + > +} +declare module './routes/posts_.$postId.deep' { + const createFileRoute: CreateFileRoute< + '/posts_/$postId/deep', + FileRoutesByPath['/posts_/$postId/deep']['parentRoute'], + FileRoutesByPath['/posts_/$postId/deep']['id'], + FileRoutesByPath['/posts_/$postId/deep']['path'], + FileRoutesByPath['/posts_/$postId/deep']['fullPath'] + > +} + // Create and export the route tree interface LayoutLayout2RouteChildren { @@ -270,6 +355,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/react-start/basic-rsc/src/routes/_layout.tsx b/e2e/react-start/basic-rsc/src/routes/_layout.tsx index 02ddbb1cd9..5c4a461d8d 100644 --- a/e2e/react-start/basic-rsc/src/routes/_layout.tsx +++ b/e2e/react-start/basic-rsc/src/routes/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-start/basic-rsc/src/routes/_layout/_layout-2.tsx b/e2e/react-start/basic-rsc/src/routes/_layout/_layout-2.tsx index 3b7dbf2903..483b910862 100644 --- a/e2e/react-start/basic-rsc/src/routes/_layout/_layout-2.tsx +++ b/e2e/react-start/basic-rsc/src/routes/_layout/_layout-2.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout/_layout-2')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-start/basic-rsc/src/routes/_layout/_layout-2/layout-a.tsx b/e2e/react-start/basic-rsc/src/routes/_layout/_layout-2/layout-a.tsx index 61e19b4d9f..a190b24202 100644 --- a/e2e/react-start/basic-rsc/src/routes/_layout/_layout-2/layout-a.tsx +++ b/e2e/react-start/basic-rsc/src/routes/_layout/_layout-2/layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/react-start/basic-rsc/src/routes/_layout/_layout-2/layout-b.tsx b/e2e/react-start/basic-rsc/src/routes/_layout/_layout-2/layout-b.tsx index cceed1fb9a..505f8f6fbf 100644 --- a/e2e/react-start/basic-rsc/src/routes/_layout/_layout-2/layout-b.tsx +++ b/e2e/react-start/basic-rsc/src/routes/_layout/_layout-2/layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/react-start/basic-rsc/src/routes/index.tsx b/e2e/react-start/basic-rsc/src/routes/index.tsx index b7b6138529..a693dcbf14 100644 --- a/e2e/react-start/basic-rsc/src/routes/index.tsx +++ b/e2e/react-start/basic-rsc/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-start/basic-rsc/src/routes/posts.$postId.tsx b/e2e/react-start/basic-rsc/src/routes/posts.$postId.tsx index 7dd63a2cd0..43f780f6fe 100644 --- a/e2e/react-start/basic-rsc/src/routes/posts.$postId.tsx +++ b/e2e/react-start/basic-rsc/src/routes/posts.$postId.tsx @@ -1,4 +1,4 @@ -import { ErrorComponent, Link, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent, Link } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' import type { ErrorComponentProps } from '@tanstack/react-router' @@ -28,7 +28,7 @@ const renderPost = createServerFn({ method: 'GET' }) ) }) -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => renderPost({ data: postId }), errorComponent: PostErrorComponent, component: PostComponent, diff --git a/e2e/react-start/basic-rsc/src/routes/posts.index.tsx b/e2e/react-start/basic-rsc/src/routes/posts.index.tsx index 5b5f08f95b..13529228bb 100644 --- a/e2e/react-start/basic-rsc/src/routes/posts.index.tsx +++ b/e2e/react-start/basic-rsc/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-start/basic-rsc/src/routes/posts.tsx b/e2e/react-start/basic-rsc/src/routes/posts.tsx index a3ef2a2e20..131cec4b9b 100644 --- a/e2e/react-start/basic-rsc/src/routes/posts.tsx +++ b/e2e/react-start/basic-rsc/src/routes/posts.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' import { createServerFn, renderRsc } from '@tanstack/react-start' import { renderPosts } from '~/utils/renderPosts' @@ -6,7 +5,7 @@ export const serverRenderPosts = createServerFn({ method: 'GET' }).handler( renderPosts, ) -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: async () => serverRenderPosts(), component: PostsComponent, }) diff --git a/e2e/react-start/basic-rsc/src/routes/posts_.$postId.deep.tsx b/e2e/react-start/basic-rsc/src/routes/posts_.$postId.deep.tsx index 13d368cf9c..bf2edef3c9 100644 --- a/e2e/react-start/basic-rsc/src/routes/posts_.$postId.deep.tsx +++ b/e2e/react-start/basic-rsc/src/routes/posts_.$postId.deep.tsx @@ -1,8 +1,8 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import { fetchPost } from '../utils/posts' import { PostErrorComponent } from './posts.$postId' -export const Route = createFileRoute('/posts_/$postId/deep')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent, component: PostDeepComponent, diff --git a/e2e/react-start/basic-rsc/tsconfig.json b/e2e/react-start/basic-rsc/tsconfig.json index 3a9fb7cd71..a07911fe5f 100644 --- a/e2e/react-start/basic-rsc/tsconfig.json +++ b/e2e/react-start/basic-rsc/tsconfig.json @@ -17,6 +17,7 @@ "paths": { "~/*": ["./src/*"] }, - "noEmit": true + "noEmit": true, + "types": ["vite/client"] } } diff --git a/e2e/react-start/basic-rsc/vite.config.ts b/e2e/react-start/basic-rsc/vite.config.ts new file mode 100644 index 0000000000..82d4065454 --- /dev/null +++ b/e2e/react-start/basic-rsc/vite.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' + +export default defineConfig({ + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/e2e/react-start/basic-tsr-config/.gitignore b/e2e/react-start/basic-tsr-config/.gitignore index 2b76174be5..08eba9e706 100644 --- a/e2e/react-start/basic-tsr-config/.gitignore +++ b/e2e/react-start/basic-tsr-config/.gitignore @@ -7,14 +7,10 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ diff --git a/e2e/react-start/basic-tsr-config/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/react-start/basic-tsr-config/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/e2e/react-start/basic-tsr-config/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/react-start/basic-tsr-config/app.config.ts b/e2e/react-start/basic-tsr-config/app.config.ts deleted file mode 100644 index 8989703df9..0000000000 --- a/e2e/react-start/basic-tsr-config/app.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -// app.config.ts -import { defineConfig } from '@tanstack/react-start/config' - -export default defineConfig({ - tsr: { - appDirectory: './src/app', - }, -}) diff --git a/e2e/react-start/basic-tsr-config/package.json b/e2e/react-start/basic-tsr-config/package.json index cd697d2bfb..b90665eaa2 100644 --- a/e2e/react-start/basic-tsr-config/package.json +++ b/e2e/react-start/basic-tsr-config/package.json @@ -4,10 +4,10 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev --port 3000", - "dev:e2e": "vinxi dev", - "build": "rimraf ./count.txt && vinxi build && tsc --noEmit", - "start": "vinxi start", + "dev": "vite dev --port 3000", + "dev:e2e": "vite dev", + "build": "rimraf ./count.txt && vite build && tsc --noEmit", + "start": "node .output/server/index.mjs", "test:e2e": "playwright test --project=chromium" }, "dependencies": { @@ -15,7 +15,7 @@ "@tanstack/react-start": "workspace:^", "react": "^19.0.0", "react-dom": "^19.0.0", - "vinxi": "0.5.3" + "vite": "6.1.4" }, "devDependencies": { "@tanstack/router-e2e-utils": "workspace:^", diff --git a/e2e/react-start/basic-tsr-config/playwright.config.ts b/e2e/react-start/basic-tsr-config/playwright.config.ts index bb77d0cf70..9806e0c136 100644 --- a/e2e/react-start/basic-tsr-config/playwright.config.ts +++ b/e2e/react-start/basic-tsr-config/playwright.config.ts @@ -19,7 +19,7 @@ export default defineConfig({ }, webServer: { - command: `VITE_SERVER_PORT=${PORT} pnpm build && VITE_SERVER_PORT=${PORT} pnpm start --port ${PORT}`, + command: `VITE_SERVER_PORT=${PORT} pnpm build && PORT=${PORT} VITE_SERVER_PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', diff --git a/e2e/react-start/basic-tsr-config/src/app/client.tsx b/e2e/react-start/basic-tsr-config/src/app/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/e2e/react-start/basic-tsr-config/src/app/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/e2e/react-start/basic-tsr-config/src/app/routeTree.gen.ts b/e2e/react-start/basic-tsr-config/src/app/routeTree.gen.ts index 5e682936ba..51a482ccab 100644 --- a/e2e/react-start/basic-tsr-config/src/app/routeTree.gen.ts +++ b/e2e/react-start/basic-tsr-config/src/app/routeTree.gen.ts @@ -10,12 +10,13 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -29,12 +30,24 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -71,6 +84,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/react-start/basic-tsr-config/src/app/routes/index.tsx b/e2e/react-start/basic-tsr-config/src/app/routes/index.tsx index aaa4bdfdb3..3c1ef4b5d8 100644 --- a/e2e/react-start/basic-tsr-config/src/app/routes/index.tsx +++ b/e2e/react-start/basic-tsr-config/src/app/routes/index.tsx @@ -1,5 +1,5 @@ import fs from 'node:fs' -import { createFileRoute, useRouter } from '@tanstack/react-router' +import { useRouter } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' const filePath = 'count.txt' @@ -17,7 +17,7 @@ const updateCount = createServerFn({ method: 'POST' }) const count = await getCount() await fs.promises.writeFile(filePath, `${count + data}`) }) -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, loader: async () => await getCount(), }) diff --git a/e2e/react-start/basic-tsr-config/vite.config.ts b/e2e/react-start/basic-tsr-config/vite.config.ts new file mode 100644 index 0000000000..78f72b969d --- /dev/null +++ b/e2e/react-start/basic-tsr-config/vite.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'vite' +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + TanStackStartVitePlugin({ + tsr: { + srcDirectory: './src/app', + }, + }), + ], +}) diff --git a/e2e/react-start/basic/.gitignore b/e2e/react-start/basic/.gitignore index be342025da..a79d5cf129 100644 --- a/e2e/react-start/basic/.gitignore +++ b/e2e/react-start/basic/.gitignore @@ -7,13 +7,11 @@ yarn.lock .env .vercel .output -.vinxi /build/ /api/ /server/build /public/build -.vinxi # Sentry Config File .env.sentry-build-plugin /test-results/ diff --git a/e2e/react-start/basic/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/react-start/basic/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..87c0856e21 --- /dev/null +++ b/e2e/react-start/basic/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,155 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +import { ServerRoute as ApiUsersRouteImport } from './../../src/routes/api.users' +import { ServerRoute as ApiUsersIdRouteImport } from './../../src/routes/api/users.$id' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +const ApiUsersRoute = ApiUsersRouteImport.update({ + id: '/api/users', + path: '/api/users', + getParentRoute: () => rootRoute, +} as any) + +const ApiUsersIdRoute = ApiUsersIdRouteImport.update({ + id: '/$id', + path: '/$id', + getParentRoute: () => ApiUsersRoute, +} as any) + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath { + '/api/users': { + id: '/api/users' + path: '/api/users' + fullPath: '/api/users' + preLoaderRoute: typeof ApiUsersRouteImport + parentRoute: typeof rootRoute + } + '/api/users/$id': { + id: '/api/users/$id' + path: '/$id' + fullPath: '/api/users/$id' + preLoaderRoute: typeof ApiUsersIdRouteImport + parentRoute: typeof ApiUsersRouteImport + } + } +} + +// Add type-safety to the createFileRoute function across the route tree + +declare module './../../src/routes/api.users' { + const createServerFileRoute: CreateServerFileRoute< + FileRoutesByPath['/api/users']['parentRoute'], + FileRoutesByPath['/api/users']['id'], + FileRoutesByPath['/api/users']['path'], + FileRoutesByPath['/api/users']['fullPath'], + ApiUsersRouteChildren + > +} +declare module './../../src/routes/api/users.$id' { + const createServerFileRoute: CreateServerFileRoute< + FileRoutesByPath['/api/users/$id']['parentRoute'], + FileRoutesByPath['/api/users/$id']['id'], + FileRoutesByPath['/api/users/$id']['path'], + FileRoutesByPath['/api/users/$id']['fullPath'], + unknown + > +} + +// Create and export the route tree + +interface ApiUsersRouteChildren { + ApiUsersIdRoute: typeof ApiUsersIdRoute +} + +const ApiUsersRouteChildren: ApiUsersRouteChildren = { + ApiUsersIdRoute: ApiUsersIdRoute, +} + +const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren( + ApiUsersRouteChildren, +) + +export interface FileRoutesByFullPath { + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$id': typeof ApiUsersIdRoute +} + +export interface FileRoutesByTo { + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$id': typeof ApiUsersIdRoute +} + +export interface FileRoutesById { + __root__: typeof rootRoute + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$id': typeof ApiUsersIdRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: '/api/users' | '/api/users/$id' + fileRoutesByTo: FileRoutesByTo + to: '/api/users' | '/api/users/$id' + id: '__root__' | '/api/users' | '/api/users/$id' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren { + ApiUsersRoute: typeof ApiUsersRouteWithChildren +} + +const rootRouteChildren: RootRouteChildren = { + ApiUsersRoute: ApiUsersRouteWithChildren, +} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [ + "/api/users" + ] + }, + "/api/users": { + "filePath": "api.users.ts", + "children": [ + "/api/users/$id" + ] + }, + "/api/users/$id": { + "filePath": "api/users.$id.ts", + "parent": "/api/users" + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/react-start/basic/app.config.ts b/e2e/react-start/basic/app.config.ts deleted file mode 100644 index 421aeca7b0..0000000000 --- a/e2e/react-start/basic/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/e2e/react-start/basic/package.json b/e2e/react-start/basic/package.json index 2046e82f17..9aeb351526 100644 --- a/e2e/react-start/basic/package.json +++ b/e2e/react-start/basic/package.json @@ -4,21 +4,20 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev --port 3000", - "dev:e2e": "vinxi dev", - "build": "vinxi build && tsc --noEmit", - "start": "vinxi start", + "dev": "vite dev --port 3000", + "dev:e2e": "vite dev", + "build": "vite build && tsc --noEmit", + "start": "node .output/server/index.mjs", "test:e2e": "playwright test --project=chromium" }, "dependencies": { "@tanstack/react-router": "workspace:^", "@tanstack/react-router-devtools": "workspace:^", - "@tanstack/start": "workspace:^", + "@tanstack/react-start": "workspace:^", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3", "zod": "^3.24.2" }, "devDependencies": { diff --git a/e2e/react-start/basic/playwright.config.ts b/e2e/react-start/basic/playwright.config.ts index 95d043d48b..e834d88cf4 100644 --- a/e2e/react-start/basic/playwright.config.ts +++ b/e2e/react-start/basic/playwright.config.ts @@ -20,7 +20,7 @@ export default defineConfig({ }, webServer: { - command: `VITE_SERVER_PORT=${PORT} pnpm build && VITE_SERVER_PORT=${PORT} pnpm start --port ${PORT}`, + command: `pnpm build && VITE_SERVER_PORT=${PORT} PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', diff --git a/e2e/react-start/basic/src/api.ts b/e2e/react-start/basic/src/api.ts deleted file mode 100644 index 0caf78bb9d..0000000000 --- a/e2e/react-start/basic/src/api.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { - createStartAPIHandler, - defaultAPIFileRouteHandler, -} from '@tanstack/start/api' - -export default createStartAPIHandler(defaultAPIFileRouteHandler) diff --git a/e2e/react-start/basic/src/client.tsx b/e2e/react-start/basic/src/client.tsx deleted file mode 100644 index b14d8aac68..0000000000 --- a/e2e/react-start/basic/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/e2e/react-start/basic/src/components/RedirectOnClick.tsx b/e2e/react-start/basic/src/components/RedirectOnClick.tsx index ec7445df5a..37b434c2e7 100644 --- a/e2e/react-start/basic/src/components/RedirectOnClick.tsx +++ b/e2e/react-start/basic/src/components/RedirectOnClick.tsx @@ -1,4 +1,4 @@ -import { useServerFn } from '@tanstack/start' +import { useServerFn } from '@tanstack/react-start' import { throwRedirect } from './throwRedirect' interface RedirectOnClickProps { diff --git a/e2e/react-start/basic/src/components/throwRedirect.ts b/e2e/react-start/basic/src/components/throwRedirect.ts index 9cef423d23..56495095a6 100644 --- a/e2e/react-start/basic/src/components/throwRedirect.ts +++ b/e2e/react-start/basic/src/components/throwRedirect.ts @@ -1,5 +1,5 @@ import { redirect } from '@tanstack/react-router' -import { createServerFn } from '@tanstack/start' +import { createServerFn } from '@tanstack/react-start' export const throwRedirect = createServerFn() .validator( @@ -11,7 +11,13 @@ export const throwRedirect = createServerFn() ) .handler((ctx) => { if (ctx.data.target === 'internal') { - throw redirect({ to: '/posts', reloadDocument: ctx.data.reloadDocument }) + throw redirect({ + to: '/posts/$postId/deep', + params: { + postId: '1', + }, + reloadDocument: ctx.data.reloadDocument, + }) } const href = ctx.data.externalHost ?? 'http://example.com' throw redirect({ diff --git a/e2e/react-start/basic/src/routeTree.gen.ts b/e2e/react-start/basic/src/routeTree.gen.ts index 1335898845..7bc77be89a 100644 --- a/e2e/react-start/basic/src/routeTree.gen.ts +++ b/e2e/react-start/basic/src/routeTree.gen.ts @@ -10,218 +10,219 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as UsersImport } from './routes/users' -import { Route as StreamImport } from './routes/stream' -import { Route as SearchParamsImport } from './routes/search-params' -import { Route as ScriptsImport } from './routes/scripts' -import { Route as PostsImport } from './routes/posts' -import { Route as LinksImport } from './routes/links' -import { Route as DeferredImport } from './routes/deferred' -import { Route as LayoutImport } from './routes/_layout' -import { Route as NotFoundRouteImport } from './routes/not-found/route' -import { Route as IndexImport } from './routes/index' -import { Route as UsersIndexImport } from './routes/users.index' -import { Route as RedirectIndexImport } from './routes/redirect/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as NotFoundIndexImport } from './routes/not-found/index' -import { Route as UsersUserIdImport } from './routes/users.$userId' -import { Route as RedirectTargetImport } from './routes/redirect/$target' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as NotFoundViaLoaderImport } from './routes/not-found/via-loader' -import { Route as NotFoundViaBeforeLoadImport } from './routes/not-found/via-beforeLoad' -import { Route as LayoutLayout2Import } from './routes/_layout/_layout-2' -import { Route as RedirectTargetIndexImport } from './routes/redirect/$target/index' -import { Route as RedirectTargetViaLoaderImport } from './routes/redirect/$target/via-loader' -import { Route as RedirectTargetViaBeforeLoadImport } from './routes/redirect/$target/via-beforeLoad' -import { Route as PostsPostIdDeepImport } from './routes/posts_.$postId.deep' -import { Route as LayoutLayout2LayoutBImport } from './routes/_layout/_layout-2/layout-b' -import { Route as LayoutLayout2LayoutAImport } from './routes/_layout/_layout-2/layout-a' -import { Route as RedirectTargetServerFnIndexImport } from './routes/redirect/$target/serverFn/index' -import { Route as RedirectTargetServerFnViaUseServerFnImport } from './routes/redirect/$target/serverFn/via-useServerFn' -import { Route as RedirectTargetServerFnViaLoaderImport } from './routes/redirect/$target/serverFn/via-loader' -import { Route as RedirectTargetServerFnViaBeforeLoadImport } from './routes/redirect/$target/serverFn/via-beforeLoad' +import { Route as UsersRouteImport } from './routes/users' +import { Route as StreamRouteImport } from './routes/stream' +import { Route as SearchParamsRouteImport } from './routes/search-params' +import { Route as ScriptsRouteImport } from './routes/scripts' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as LinksRouteImport } from './routes/links' +import { Route as DeferredRouteImport } from './routes/deferred' +import { Route as LayoutRouteImport } from './routes/_layout' +import { Route as NotFoundRouteRouteImport } from './routes/not-found/route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as UsersIndexRouteImport } from './routes/users.index' +import { Route as RedirectIndexRouteImport } from './routes/redirect/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as NotFoundIndexRouteImport } from './routes/not-found/index' +import { Route as UsersUserIdRouteImport } from './routes/users.$userId' +import { Route as RedirectTargetRouteImport } from './routes/redirect/$target' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as NotFoundViaLoaderRouteImport } from './routes/not-found/via-loader' +import { Route as NotFoundViaBeforeLoadRouteImport } from './routes/not-found/via-beforeLoad' +import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2' +import { Route as RedirectTargetIndexRouteImport } from './routes/redirect/$target/index' +import { Route as RedirectTargetViaLoaderRouteImport } from './routes/redirect/$target/via-loader' +import { Route as RedirectTargetViaBeforeLoadRouteImport } from './routes/redirect/$target/via-beforeLoad' +import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep' +import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b' +import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a' +import { Route as RedirectTargetServerFnIndexRouteImport } from './routes/redirect/$target/serverFn/index' +import { Route as RedirectTargetServerFnViaUseServerFnRouteImport } from './routes/redirect/$target/serverFn/via-useServerFn' +import { Route as RedirectTargetServerFnViaLoaderRouteImport } from './routes/redirect/$target/serverFn/via-loader' +import { Route as RedirectTargetServerFnViaBeforeLoadRouteImport } from './routes/redirect/$target/serverFn/via-beforeLoad' // Create/Update Routes -const UsersRoute = UsersImport.update({ +const UsersRoute = UsersRouteImport.update({ id: '/users', path: '/users', getParentRoute: () => rootRoute, } as any) -const StreamRoute = StreamImport.update({ +const StreamRoute = StreamRouteImport.update({ id: '/stream', path: '/stream', getParentRoute: () => rootRoute, } as any) -const SearchParamsRoute = SearchParamsImport.update({ +const SearchParamsRoute = SearchParamsRouteImport.update({ id: '/search-params', path: '/search-params', getParentRoute: () => rootRoute, } as any) -const ScriptsRoute = ScriptsImport.update({ +const ScriptsRoute = ScriptsRouteImport.update({ id: '/scripts', path: '/scripts', getParentRoute: () => rootRoute, } as any) -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const LinksRoute = LinksImport.update({ +const LinksRoute = LinksRouteImport.update({ id: '/links', path: '/links', getParentRoute: () => rootRoute, } as any) -const DeferredRoute = DeferredImport.update({ +const DeferredRoute = DeferredRouteImport.update({ id: '/deferred', path: '/deferred', getParentRoute: () => rootRoute, } as any) -const LayoutRoute = LayoutImport.update({ +const LayoutRoute = LayoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const NotFoundRouteRoute = NotFoundRouteImport.update({ +const NotFoundRouteRoute = NotFoundRouteRouteImport.update({ id: '/not-found', path: '/not-found', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const UsersIndexRoute = UsersIndexImport.update({ +const UsersIndexRoute = UsersIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => UsersRoute, } as any) -const RedirectIndexRoute = RedirectIndexImport.update({ +const RedirectIndexRoute = RedirectIndexRouteImport.update({ id: '/redirect/', path: '/redirect/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const NotFoundIndexRoute = NotFoundIndexImport.update({ +const NotFoundIndexRoute = NotFoundIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => NotFoundRouteRoute, } as any) -const UsersUserIdRoute = UsersUserIdImport.update({ +const UsersUserIdRoute = UsersUserIdRouteImport.update({ id: '/$userId', path: '/$userId', getParentRoute: () => UsersRoute, } as any) -const RedirectTargetRoute = RedirectTargetImport.update({ +const RedirectTargetRoute = RedirectTargetRouteImport.update({ id: '/redirect/$target', path: '/redirect/$target', getParentRoute: () => rootRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const NotFoundViaLoaderRoute = NotFoundViaLoaderImport.update({ +const NotFoundViaLoaderRoute = NotFoundViaLoaderRouteImport.update({ id: '/via-loader', path: '/via-loader', getParentRoute: () => NotFoundRouteRoute, } as any) -const NotFoundViaBeforeLoadRoute = NotFoundViaBeforeLoadImport.update({ +const NotFoundViaBeforeLoadRoute = NotFoundViaBeforeLoadRouteImport.update({ id: '/via-beforeLoad', path: '/via-beforeLoad', getParentRoute: () => NotFoundRouteRoute, } as any) -const LayoutLayout2Route = LayoutLayout2Import.update({ +const LayoutLayout2Route = LayoutLayout2RouteImport.update({ id: '/_layout-2', getParentRoute: () => LayoutRoute, } as any) -const RedirectTargetIndexRoute = RedirectTargetIndexImport.update({ +const RedirectTargetIndexRoute = RedirectTargetIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => RedirectTargetRoute, } as any) -const RedirectTargetViaLoaderRoute = RedirectTargetViaLoaderImport.update({ +const RedirectTargetViaLoaderRoute = RedirectTargetViaLoaderRouteImport.update({ id: '/via-loader', path: '/via-loader', getParentRoute: () => RedirectTargetRoute, } as any) const RedirectTargetViaBeforeLoadRoute = - RedirectTargetViaBeforeLoadImport.update({ + RedirectTargetViaBeforeLoadRouteImport.update({ id: '/via-beforeLoad', path: '/via-beforeLoad', getParentRoute: () => RedirectTargetRoute, } as any) -const PostsPostIdDeepRoute = PostsPostIdDeepImport.update({ +const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ id: '/posts_/$postId/deep', path: '/posts/$postId/deep', getParentRoute: () => rootRoute, } as any) -const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBImport.update({ +const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => LayoutLayout2Route, } as any) -const LayoutLayout2LayoutARoute = LayoutLayout2LayoutAImport.update({ +const LayoutLayout2LayoutARoute = LayoutLayout2LayoutARouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => LayoutLayout2Route, } as any) const RedirectTargetServerFnIndexRoute = - RedirectTargetServerFnIndexImport.update({ + RedirectTargetServerFnIndexRouteImport.update({ id: '/serverFn/', path: '/serverFn/', getParentRoute: () => RedirectTargetRoute, } as any) const RedirectTargetServerFnViaUseServerFnRoute = - RedirectTargetServerFnViaUseServerFnImport.update({ + RedirectTargetServerFnViaUseServerFnRouteImport.update({ id: '/serverFn/via-useServerFn', path: '/serverFn/via-useServerFn', getParentRoute: () => RedirectTargetRoute, } as any) const RedirectTargetServerFnViaLoaderRoute = - RedirectTargetServerFnViaLoaderImport.update({ + RedirectTargetServerFnViaLoaderRouteImport.update({ id: '/serverFn/via-loader', path: '/serverFn/via-loader', getParentRoute: () => RedirectTargetRoute, } as any) const RedirectTargetServerFnViaBeforeLoadRoute = - RedirectTargetServerFnViaBeforeLoadImport.update({ + RedirectTargetServerFnViaBeforeLoadRouteImport.update({ id: '/serverFn/via-beforeLoad', path: '/serverFn/via-beforeLoad', getParentRoute: () => RedirectTargetRoute, @@ -235,215 +236,488 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/not-found': { id: '/not-found' path: '/not-found' fullPath: '/not-found' - preLoaderRoute: typeof NotFoundRouteImport + preLoaderRoute: typeof NotFoundRouteRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutRouteImport parentRoute: typeof rootRoute } '/deferred': { id: '/deferred' path: '/deferred' fullPath: '/deferred' - preLoaderRoute: typeof DeferredImport + preLoaderRoute: typeof DeferredRouteImport parentRoute: typeof rootRoute } '/links': { id: '/links' path: '/links' fullPath: '/links' - preLoaderRoute: typeof LinksImport + preLoaderRoute: typeof LinksRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/scripts': { id: '/scripts' path: '/scripts' fullPath: '/scripts' - preLoaderRoute: typeof ScriptsImport + preLoaderRoute: typeof ScriptsRouteImport parentRoute: typeof rootRoute } '/search-params': { id: '/search-params' path: '/search-params' fullPath: '/search-params' - preLoaderRoute: typeof SearchParamsImport + preLoaderRoute: typeof SearchParamsRouteImport parentRoute: typeof rootRoute } '/stream': { id: '/stream' path: '/stream' fullPath: '/stream' - preLoaderRoute: typeof StreamImport + preLoaderRoute: typeof StreamRouteImport parentRoute: typeof rootRoute } '/users': { id: '/users' path: '/users' fullPath: '/users' - preLoaderRoute: typeof UsersImport + preLoaderRoute: typeof UsersRouteImport parentRoute: typeof rootRoute } '/_layout/_layout-2': { id: '/_layout/_layout-2' path: '' fullPath: '' - preLoaderRoute: typeof LayoutLayout2Import - parentRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutLayout2RouteImport + parentRoute: typeof LayoutRouteImport } '/not-found/via-beforeLoad': { id: '/not-found/via-beforeLoad' path: '/via-beforeLoad' fullPath: '/not-found/via-beforeLoad' - preLoaderRoute: typeof NotFoundViaBeforeLoadImport - parentRoute: typeof NotFoundRouteImport + preLoaderRoute: typeof NotFoundViaBeforeLoadRouteImport + parentRoute: typeof NotFoundRouteRouteImport } '/not-found/via-loader': { id: '/not-found/via-loader' path: '/via-loader' fullPath: '/not-found/via-loader' - preLoaderRoute: typeof NotFoundViaLoaderImport - parentRoute: typeof NotFoundRouteImport + preLoaderRoute: typeof NotFoundViaLoaderRouteImport + parentRoute: typeof NotFoundRouteRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/redirect/$target': { id: '/redirect/$target' path: '/redirect/$target' fullPath: '/redirect/$target' - preLoaderRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetRouteImport parentRoute: typeof rootRoute } '/users/$userId': { id: '/users/$userId' path: '/$userId' fullPath: '/users/$userId' - preLoaderRoute: typeof UsersUserIdImport - parentRoute: typeof UsersImport + preLoaderRoute: typeof UsersUserIdRouteImport + parentRoute: typeof UsersRouteImport } '/not-found/': { id: '/not-found/' path: '/' fullPath: '/not-found/' - preLoaderRoute: typeof NotFoundIndexImport - parentRoute: typeof NotFoundRouteImport + preLoaderRoute: typeof NotFoundIndexRouteImport + parentRoute: typeof NotFoundRouteRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/redirect/': { id: '/redirect/' path: '/redirect' fullPath: '/redirect' - preLoaderRoute: typeof RedirectIndexImport + preLoaderRoute: typeof RedirectIndexRouteImport parentRoute: typeof rootRoute } '/users/': { id: '/users/' path: '/' fullPath: '/users/' - preLoaderRoute: typeof UsersIndexImport - parentRoute: typeof UsersImport + preLoaderRoute: typeof UsersIndexRouteImport + parentRoute: typeof UsersRouteImport } '/_layout/_layout-2/layout-a': { id: '/_layout/_layout-2/layout-a' path: '/layout-a' fullPath: '/layout-a' - preLoaderRoute: typeof LayoutLayout2LayoutAImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutARouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/_layout/_layout-2/layout-b': { id: '/_layout/_layout-2/layout-b' path: '/layout-b' fullPath: '/layout-b' - preLoaderRoute: typeof LayoutLayout2LayoutBImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/posts_/$postId/deep': { id: '/posts_/$postId/deep' path: '/posts/$postId/deep' fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepImport + preLoaderRoute: typeof PostsPostIdDeepRouteImport parentRoute: typeof rootRoute } '/redirect/$target/via-beforeLoad': { id: '/redirect/$target/via-beforeLoad' path: '/via-beforeLoad' fullPath: '/redirect/$target/via-beforeLoad' - preLoaderRoute: typeof RedirectTargetViaBeforeLoadImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetViaBeforeLoadRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/via-loader': { id: '/redirect/$target/via-loader' path: '/via-loader' fullPath: '/redirect/$target/via-loader' - preLoaderRoute: typeof RedirectTargetViaLoaderImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetViaLoaderRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/': { id: '/redirect/$target/' path: '/' fullPath: '/redirect/$target/' - preLoaderRoute: typeof RedirectTargetIndexImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetIndexRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/serverFn/via-beforeLoad': { id: '/redirect/$target/serverFn/via-beforeLoad' path: '/serverFn/via-beforeLoad' fullPath: '/redirect/$target/serverFn/via-beforeLoad' - preLoaderRoute: typeof RedirectTargetServerFnViaBeforeLoadImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetServerFnViaBeforeLoadRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/serverFn/via-loader': { id: '/redirect/$target/serverFn/via-loader' path: '/serverFn/via-loader' fullPath: '/redirect/$target/serverFn/via-loader' - preLoaderRoute: typeof RedirectTargetServerFnViaLoaderImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetServerFnViaLoaderRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/serverFn/via-useServerFn': { id: '/redirect/$target/serverFn/via-useServerFn' path: '/serverFn/via-useServerFn' fullPath: '/redirect/$target/serverFn/via-useServerFn' - preLoaderRoute: typeof RedirectTargetServerFnViaUseServerFnImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetServerFnViaUseServerFnRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/serverFn/': { id: '/redirect/$target/serverFn/' path: '/serverFn' fullPath: '/redirect/$target/serverFn' - preLoaderRoute: typeof RedirectTargetServerFnIndexImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetServerFnIndexRouteImport + parentRoute: typeof RedirectTargetRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/not-found/route' { + const createFileRoute: CreateFileRoute< + '/not-found', + FileRoutesByPath['/not-found']['parentRoute'], + FileRoutesByPath['/not-found']['id'], + FileRoutesByPath['/not-found']['path'], + FileRoutesByPath['/not-found']['fullPath'] + > +} +declare module './routes/_layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/deferred' { + const createFileRoute: CreateFileRoute< + '/deferred', + FileRoutesByPath['/deferred']['parentRoute'], + FileRoutesByPath['/deferred']['id'], + FileRoutesByPath['/deferred']['path'], + FileRoutesByPath['/deferred']['fullPath'] + > +} +declare module './routes/links' { + const createFileRoute: CreateFileRoute< + '/links', + FileRoutesByPath['/links']['parentRoute'], + FileRoutesByPath['/links']['id'], + FileRoutesByPath['/links']['path'], + FileRoutesByPath['/links']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/scripts' { + const createFileRoute: CreateFileRoute< + '/scripts', + FileRoutesByPath['/scripts']['parentRoute'], + FileRoutesByPath['/scripts']['id'], + FileRoutesByPath['/scripts']['path'], + FileRoutesByPath['/scripts']['fullPath'] + > +} +declare module './routes/search-params' { + const createFileRoute: CreateFileRoute< + '/search-params', + FileRoutesByPath['/search-params']['parentRoute'], + FileRoutesByPath['/search-params']['id'], + FileRoutesByPath['/search-params']['path'], + FileRoutesByPath['/search-params']['fullPath'] + > +} +declare module './routes/stream' { + const createFileRoute: CreateFileRoute< + '/stream', + FileRoutesByPath['/stream']['parentRoute'], + FileRoutesByPath['/stream']['id'], + FileRoutesByPath['/stream']['path'], + FileRoutesByPath['/stream']['fullPath'] + > +} +declare module './routes/users' { + const createFileRoute: CreateFileRoute< + '/users', + FileRoutesByPath['/users']['parentRoute'], + FileRoutesByPath['/users']['id'], + FileRoutesByPath['/users']['path'], + FileRoutesByPath['/users']['fullPath'] + > +} +declare module './routes/_layout/_layout-2' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2', + FileRoutesByPath['/_layout/_layout-2']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2']['id'], + FileRoutesByPath['/_layout/_layout-2']['path'], + FileRoutesByPath['/_layout/_layout-2']['fullPath'] + > +} +declare module './routes/not-found/via-beforeLoad' { + const createFileRoute: CreateFileRoute< + '/not-found/via-beforeLoad', + FileRoutesByPath['/not-found/via-beforeLoad']['parentRoute'], + FileRoutesByPath['/not-found/via-beforeLoad']['id'], + FileRoutesByPath['/not-found/via-beforeLoad']['path'], + FileRoutesByPath['/not-found/via-beforeLoad']['fullPath'] + > +} +declare module './routes/not-found/via-loader' { + const createFileRoute: CreateFileRoute< + '/not-found/via-loader', + FileRoutesByPath['/not-found/via-loader']['parentRoute'], + FileRoutesByPath['/not-found/via-loader']['id'], + FileRoutesByPath['/not-found/via-loader']['path'], + FileRoutesByPath['/not-found/via-loader']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/redirect/$target' { + const createFileRoute: CreateFileRoute< + '/redirect/$target', + FileRoutesByPath['/redirect/$target']['parentRoute'], + FileRoutesByPath['/redirect/$target']['id'], + FileRoutesByPath['/redirect/$target']['path'], + FileRoutesByPath['/redirect/$target']['fullPath'] + > +} +declare module './routes/users.$userId' { + const createFileRoute: CreateFileRoute< + '/users/$userId', + FileRoutesByPath['/users/$userId']['parentRoute'], + FileRoutesByPath['/users/$userId']['id'], + FileRoutesByPath['/users/$userId']['path'], + FileRoutesByPath['/users/$userId']['fullPath'] + > +} +declare module './routes/not-found/index' { + const createFileRoute: CreateFileRoute< + '/not-found/', + FileRoutesByPath['/not-found/']['parentRoute'], + FileRoutesByPath['/not-found/']['id'], + FileRoutesByPath['/not-found/']['path'], + FileRoutesByPath['/not-found/']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/redirect/index' { + const createFileRoute: CreateFileRoute< + '/redirect/', + FileRoutesByPath['/redirect/']['parentRoute'], + FileRoutesByPath['/redirect/']['id'], + FileRoutesByPath['/redirect/']['path'], + FileRoutesByPath['/redirect/']['fullPath'] + > +} +declare module './routes/users.index' { + const createFileRoute: CreateFileRoute< + '/users/', + FileRoutesByPath['/users/']['parentRoute'], + FileRoutesByPath['/users/']['id'], + FileRoutesByPath['/users/']['path'], + FileRoutesByPath['/users/']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-a' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-a', + FileRoutesByPath['/_layout/_layout-2/layout-a']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-b' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-b', + FileRoutesByPath['/_layout/_layout-2/layout-b']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['fullPath'] + > +} +declare module './routes/posts_.$postId.deep' { + const createFileRoute: CreateFileRoute< + '/posts_/$postId/deep', + FileRoutesByPath['/posts_/$postId/deep']['parentRoute'], + FileRoutesByPath['/posts_/$postId/deep']['id'], + FileRoutesByPath['/posts_/$postId/deep']['path'], + FileRoutesByPath['/posts_/$postId/deep']['fullPath'] + > +} +declare module './routes/redirect/$target/via-beforeLoad' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/via-beforeLoad', + FileRoutesByPath['/redirect/$target/via-beforeLoad']['parentRoute'], + FileRoutesByPath['/redirect/$target/via-beforeLoad']['id'], + FileRoutesByPath['/redirect/$target/via-beforeLoad']['path'], + FileRoutesByPath['/redirect/$target/via-beforeLoad']['fullPath'] + > +} +declare module './routes/redirect/$target/via-loader' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/via-loader', + FileRoutesByPath['/redirect/$target/via-loader']['parentRoute'], + FileRoutesByPath['/redirect/$target/via-loader']['id'], + FileRoutesByPath['/redirect/$target/via-loader']['path'], + FileRoutesByPath['/redirect/$target/via-loader']['fullPath'] + > +} +declare module './routes/redirect/$target/index' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/', + FileRoutesByPath['/redirect/$target/']['parentRoute'], + FileRoutesByPath['/redirect/$target/']['id'], + FileRoutesByPath['/redirect/$target/']['path'], + FileRoutesByPath['/redirect/$target/']['fullPath'] + > +} +declare module './routes/redirect/$target/serverFn/via-beforeLoad' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/serverFn/via-beforeLoad', + FileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['parentRoute'], + FileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['id'], + FileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['path'], + FileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['fullPath'] + > +} +declare module './routes/redirect/$target/serverFn/via-loader' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/serverFn/via-loader', + FileRoutesByPath['/redirect/$target/serverFn/via-loader']['parentRoute'], + FileRoutesByPath['/redirect/$target/serverFn/via-loader']['id'], + FileRoutesByPath['/redirect/$target/serverFn/via-loader']['path'], + FileRoutesByPath['/redirect/$target/serverFn/via-loader']['fullPath'] + > +} +declare module './routes/redirect/$target/serverFn/via-useServerFn' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/serverFn/via-useServerFn', + FileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['parentRoute'], + FileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['id'], + FileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['path'], + FileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['fullPath'] + > +} +declare module './routes/redirect/$target/serverFn/index' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/serverFn/', + FileRoutesByPath['/redirect/$target/serverFn/']['parentRoute'], + FileRoutesByPath['/redirect/$target/serverFn/']['id'], + FileRoutesByPath['/redirect/$target/serverFn/']['path'], + FileRoutesByPath['/redirect/$target/serverFn/']['fullPath'] + > +} + // Create and export the route tree interface NotFoundRouteRouteChildren { @@ -761,6 +1035,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/react-start/basic/src/routes/_layout.tsx b/e2e/react-start/basic/src/routes/_layout.tsx index 02ddbb1cd9..5c4a461d8d 100644 --- a/e2e/react-start/basic/src/routes/_layout.tsx +++ b/e2e/react-start/basic/src/routes/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-start/basic/src/routes/_layout/_layout-2.tsx b/e2e/react-start/basic/src/routes/_layout/_layout-2.tsx index 3b7dbf2903..483b910862 100644 --- a/e2e/react-start/basic/src/routes/_layout/_layout-2.tsx +++ b/e2e/react-start/basic/src/routes/_layout/_layout-2.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout/_layout-2')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/react-start/basic/src/routes/_layout/_layout-2/layout-a.tsx b/e2e/react-start/basic/src/routes/_layout/_layout-2/layout-a.tsx index 61e19b4d9f..a190b24202 100644 --- a/e2e/react-start/basic/src/routes/_layout/_layout-2/layout-a.tsx +++ b/e2e/react-start/basic/src/routes/_layout/_layout-2/layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/react-start/basic/src/routes/_layout/_layout-2/layout-b.tsx b/e2e/react-start/basic/src/routes/_layout/_layout-2/layout-b.tsx index cceed1fb9a..505f8f6fbf 100644 --- a/e2e/react-start/basic/src/routes/_layout/_layout-2/layout-b.tsx +++ b/e2e/react-start/basic/src/routes/_layout/_layout-2/layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/react-start/basic/src/routes/api.users.ts b/e2e/react-start/basic/src/routes/api.users.ts index 74b4ad35ba..5d16d71aa6 100644 --- a/e2e/react-start/basic/src/routes/api.users.ts +++ b/e2e/react-start/basic/src/routes/api.users.ts @@ -1,10 +1,9 @@ -import { json } from '@tanstack/start' -import { createAPIFileRoute } from '@tanstack/start/api' +import { json } from '@tanstack/react-start' import axios from 'redaxios' import type { User } from '~/utils/users' -export const APIRoute = createAPIFileRoute('/api/users')({ +export const ServerRoute = createServerFileRoute().methods({ GET: async ({ request }) => { console.info('Fetching users... @', request.url) const res = await axios.get>( diff --git a/e2e/react-start/basic/src/routes/api/users.$id.ts b/e2e/react-start/basic/src/routes/api/users.$id.ts index 2cfe2322ef..3998d60611 100644 --- a/e2e/react-start/basic/src/routes/api/users.$id.ts +++ b/e2e/react-start/basic/src/routes/api/users.$id.ts @@ -1,10 +1,8 @@ -import { json } from '@tanstack/start' -import { createAPIFileRoute } from '@tanstack/start/api' +import { json } from '@tanstack/react-start' import axios from 'redaxios' - import type { User } from '~/utils/users' -export const APIRoute = createAPIFileRoute('/api/users/$id')({ +export const ServerRoute = createServerFileRoute().methods({ GET: async ({ request, params }) => { console.info(`Fetching users by id=${params.id}... @`, request.url) try { diff --git a/e2e/react-start/basic/src/routes/deferred.tsx b/e2e/react-start/basic/src/routes/deferred.tsx index ae64951716..6b128efea0 100644 --- a/e2e/react-start/basic/src/routes/deferred.tsx +++ b/e2e/react-start/basic/src/routes/deferred.tsx @@ -1,5 +1,5 @@ -import { Await, createFileRoute } from '@tanstack/react-router' -import { createServerFn } from '@tanstack/start' +import { Await } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/react-start' import { Suspense, useState } from 'react' const personServerFn = createServerFn({ method: 'GET' }) @@ -15,7 +15,7 @@ const slowServerFn = createServerFn({ method: 'GET' }) return { name: data.name, randomNumber: Math.floor(Math.random() * 100) } }) -export const Route = createFileRoute('/deferred')({ +export const Route = createFileRoute({ loader: async () => { return { deferredStuff: new Promise((r) => diff --git a/e2e/react-start/basic/src/routes/index.tsx b/e2e/react-start/basic/src/routes/index.tsx index 37169a78b4..f2bb5d3f32 100644 --- a/e2e/react-start/basic/src/routes/index.tsx +++ b/e2e/react-start/basic/src/routes/index.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { CustomMessage } from '~/components/CustomMessage' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-start/basic/src/routes/links.tsx b/e2e/react-start/basic/src/routes/links.tsx index adc8fe9c4d..81b53edfd7 100644 --- a/e2e/react-start/basic/src/routes/links.tsx +++ b/e2e/react-start/basic/src/routes/links.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/links')({ +export const Route = createFileRoute({ component: () => { const navigate = Route.useNavigate() return ( diff --git a/e2e/react-start/basic/src/routes/not-found/index.tsx b/e2e/react-start/basic/src/routes/not-found/index.tsx index e754f83c74..7abe4a389f 100644 --- a/e2e/react-start/basic/src/routes/not-found/index.tsx +++ b/e2e/react-start/basic/src/routes/not-found/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/not-found/')({ +export const Route = createFileRoute({ component: () => { const preload = Route.useSearch({ select: (s) => s.preload }) return ( diff --git a/e2e/react-start/basic/src/routes/not-found/route.tsx b/e2e/react-start/basic/src/routes/not-found/route.tsx index e604e098fd..b8343167f5 100644 --- a/e2e/react-start/basic/src/routes/not-found/route.tsx +++ b/e2e/react-start/basic/src/routes/not-found/route.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import z from 'zod' -export const Route = createFileRoute('/not-found')({ +export const Route = createFileRoute({ validateSearch: z.object({ preload: z.literal(false).optional(), }), diff --git a/e2e/react-start/basic/src/routes/not-found/via-beforeLoad.tsx b/e2e/react-start/basic/src/routes/not-found/via-beforeLoad.tsx index 85164dbab5..cc04e59dec 100644 --- a/e2e/react-start/basic/src/routes/not-found/via-beforeLoad.tsx +++ b/e2e/react-start/basic/src/routes/not-found/via-beforeLoad.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, notFound } from '@tanstack/react-router' +import { notFound } from '@tanstack/react-router' -export const Route = createFileRoute('/not-found/via-beforeLoad')({ +export const Route = createFileRoute({ beforeLoad: () => { throw notFound() }, diff --git a/e2e/react-start/basic/src/routes/not-found/via-loader.tsx b/e2e/react-start/basic/src/routes/not-found/via-loader.tsx index 6174b27f77..8ca69f7bb6 100644 --- a/e2e/react-start/basic/src/routes/not-found/via-loader.tsx +++ b/e2e/react-start/basic/src/routes/not-found/via-loader.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, notFound } from '@tanstack/react-router' +import { notFound } from '@tanstack/react-router' -export const Route = createFileRoute('/not-found/via-loader')({ +export const Route = createFileRoute({ loader: () => { throw notFound() }, diff --git a/e2e/react-start/basic/src/routes/posts.$postId.tsx b/e2e/react-start/basic/src/routes/posts.$postId.tsx index 005228a0fe..68c663c7e8 100644 --- a/e2e/react-start/basic/src/routes/posts.$postId.tsx +++ b/e2e/react-start/basic/src/routes/posts.$postId.tsx @@ -1,10 +1,10 @@ -import { ErrorComponent, Link, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent, Link } from '@tanstack/react-router' import type { ErrorComponentProps } from '@tanstack/react-router' import { fetchPost } from '~/utils/posts' import { NotFound } from '~/components/NotFound' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost({ data: postId }), errorComponent: PostErrorComponent, component: PostComponent, @@ -30,7 +30,7 @@ function PostComponent() { postId: post.id, }} activeProps={{ className: 'text-black font-bold' }} - className="block py-1 text-blue-800 hover:text-blue-600" + className="inline-block py-1 text-blue-800 hover:text-blue-600" > Deep View diff --git a/e2e/react-start/basic/src/routes/posts.index.tsx b/e2e/react-start/basic/src/routes/posts.index.tsx index 1bad79b0f7..07e41d1b0b 100644 --- a/e2e/react-start/basic/src/routes/posts.index.tsx +++ b/e2e/react-start/basic/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-start/basic/src/routes/posts.tsx b/e2e/react-start/basic/src/routes/posts.tsx index 0f69c18341..6fa5bfbe8b 100644 --- a/e2e/react-start/basic/src/routes/posts.tsx +++ b/e2e/react-start/basic/src/routes/posts.tsx @@ -1,8 +1,8 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '~/utils/posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ head: () => ({ meta: [ { diff --git a/e2e/react-start/basic/src/routes/posts_.$postId.deep.tsx b/e2e/react-start/basic/src/routes/posts_.$postId.deep.tsx index e8f733560b..ea326087b8 100644 --- a/e2e/react-start/basic/src/routes/posts_.$postId.deep.tsx +++ b/e2e/react-start/basic/src/routes/posts_.$postId.deep.tsx @@ -1,9 +1,9 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import { PostErrorComponent } from './posts.$postId' import { fetchPost } from '~/utils/posts' -export const Route = createFileRoute('/posts_/$postId/deep')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost({ data: postId }), errorComponent: PostErrorComponent, component: PostDeepComponent, diff --git a/e2e/react-start/basic/src/routes/redirect/$target.tsx b/e2e/react-start/basic/src/routes/redirect/$target.tsx index 686f1c7056..099a7ab0be 100644 --- a/e2e/react-start/basic/src/routes/redirect/$target.tsx +++ b/e2e/react-start/basic/src/routes/redirect/$target.tsx @@ -1,7 +1,7 @@ -import { createFileRoute, retainSearchParams } from '@tanstack/react-router' +import { retainSearchParams } from '@tanstack/react-router' import z from 'zod' -export const Route = createFileRoute('/redirect/$target')({ +export const Route = createFileRoute({ params: { parse: (p) => z diff --git a/e2e/react-start/basic/src/routes/redirect/$target/index.tsx b/e2e/react-start/basic/src/routes/redirect/$target/index.tsx index f399d965cf..d4878e0990 100644 --- a/e2e/react-start/basic/src/routes/redirect/$target/index.tsx +++ b/e2e/react-start/basic/src/routes/redirect/$target/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/redirect/$target/')({ +export const Route = createFileRoute({ component: () => { const preload = Route.useSearch({ select: (s) => s.preload }) return ( diff --git a/e2e/react-start/basic/src/routes/redirect/$target/serverFn/index.tsx b/e2e/react-start/basic/src/routes/redirect/$target/serverFn/index.tsx index ddb0d8e996..12118917d6 100644 --- a/e2e/react-start/basic/src/routes/redirect/$target/serverFn/index.tsx +++ b/e2e/react-start/basic/src/routes/redirect/$target/serverFn/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/redirect/$target/serverFn/')({ +export const Route = createFileRoute({ component: () => (

diff --git a/e2e/react-start/basic/src/routes/redirect/$target/serverFn/via-beforeLoad.tsx b/e2e/react-start/basic/src/routes/redirect/$target/serverFn/via-beforeLoad.tsx index eed26559f3..3aad8bffa4 100644 --- a/e2e/react-start/basic/src/routes/redirect/$target/serverFn/via-beforeLoad.tsx +++ b/e2e/react-start/basic/src/routes/redirect/$target/serverFn/via-beforeLoad.tsx @@ -1,9 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { throwRedirect } from '~/components/throwRedirect' -export const Route = createFileRoute( - '/redirect/$target/serverFn/via-beforeLoad', -)({ +export const Route = createFileRoute({ beforeLoad: ({ params: { target }, search: { reloadDocument, externalHost }, diff --git a/e2e/react-start/basic/src/routes/redirect/$target/serverFn/via-loader.tsx b/e2e/react-start/basic/src/routes/redirect/$target/serverFn/via-loader.tsx index 1db205e311..3087fa2e15 100644 --- a/e2e/react-start/basic/src/routes/redirect/$target/serverFn/via-loader.tsx +++ b/e2e/react-start/basic/src/routes/redirect/$target/serverFn/via-loader.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { throwRedirect } from '~/components/throwRedirect' -export const Route = createFileRoute('/redirect/$target/serverFn/via-loader')({ +export const Route = createFileRoute({ loaderDeps: ({ search: { reloadDocument, externalHost } }) => ({ reloadDocument, externalHost, diff --git a/e2e/react-start/basic/src/routes/redirect/$target/serverFn/via-useServerFn.tsx b/e2e/react-start/basic/src/routes/redirect/$target/serverFn/via-useServerFn.tsx index 866bb19b10..98816a067a 100644 --- a/e2e/react-start/basic/src/routes/redirect/$target/serverFn/via-useServerFn.tsx +++ b/e2e/react-start/basic/src/routes/redirect/$target/serverFn/via-useServerFn.tsx @@ -1,9 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { RedirectOnClick } from '~/components/RedirectOnClick' -export const Route = createFileRoute( - '/redirect/$target/serverFn/via-useServerFn', -)({ +export const Route = createFileRoute({ component: () => { const { target } = Route.useParams() const { reloadDocument, externalHost } = Route.useSearch() diff --git a/e2e/react-start/basic/src/routes/redirect/$target/via-beforeLoad.tsx b/e2e/react-start/basic/src/routes/redirect/$target/via-beforeLoad.tsx index 14a2492331..bfda558451 100644 --- a/e2e/react-start/basic/src/routes/redirect/$target/via-beforeLoad.tsx +++ b/e2e/react-start/basic/src/routes/redirect/$target/via-beforeLoad.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' -export const Route = createFileRoute('/redirect/$target/via-beforeLoad')({ +export const Route = createFileRoute({ beforeLoad: ({ params: { target }, search: { reloadDocument, externalHost }, diff --git a/e2e/react-start/basic/src/routes/redirect/$target/via-loader.tsx b/e2e/react-start/basic/src/routes/redirect/$target/via-loader.tsx index 9e6a3fc9db..022d5c1f8c 100644 --- a/e2e/react-start/basic/src/routes/redirect/$target/via-loader.tsx +++ b/e2e/react-start/basic/src/routes/redirect/$target/via-loader.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' -export const Route = createFileRoute('/redirect/$target/via-loader')({ +export const Route = createFileRoute({ loaderDeps: ({ search: { reloadDocument, externalHost } }) => ({ reloadDocument, externalHost, diff --git a/e2e/react-start/basic/src/routes/redirect/index.tsx b/e2e/react-start/basic/src/routes/redirect/index.tsx index c0b26a1df4..a400e552ab 100644 --- a/e2e/react-start/basic/src/routes/redirect/index.tsx +++ b/e2e/react-start/basic/src/routes/redirect/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/redirect/')({ +export const Route = createFileRoute({ component: () => (
const isProd = import.meta.env.PROD -export const Route = createFileRoute('/scripts')({ +export const Route = createFileRoute({ head: () => ({ scripts: [ { diff --git a/e2e/react-start/basic/src/routes/search-params.tsx b/e2e/react-start/basic/src/routes/search-params.tsx index 8ebe45bc34..5ddddc58f0 100644 --- a/e2e/react-start/basic/src/routes/search-params.tsx +++ b/e2e/react-start/basic/src/routes/search-params.tsx @@ -1,7 +1,7 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' import { z } from 'zod' -export const Route = createFileRoute('/search-params')({ +export const Route = createFileRoute({ component: () => { const search = Route.useSearch() return ( diff --git a/e2e/react-start/basic/src/routes/stream.tsx b/e2e/react-start/basic/src/routes/stream.tsx index 691792ac21..a113492e1c 100644 --- a/e2e/react-start/basic/src/routes/stream.tsx +++ b/e2e/react-start/basic/src/routes/stream.tsx @@ -1,7 +1,7 @@ -import { Await, createFileRoute } from '@tanstack/react-router' +import { Await } from '@tanstack/react-router' import { useEffect, useState } from 'react' -export const Route = createFileRoute('/stream')({ +export const Route = createFileRoute({ component: Home, loader() { return { diff --git a/e2e/react-start/basic/src/routes/users.$userId.tsx b/e2e/react-start/basic/src/routes/users.$userId.tsx index 1e2921411a..7f02e471e8 100644 --- a/e2e/react-start/basic/src/routes/users.$userId.tsx +++ b/e2e/react-start/basic/src/routes/users.$userId.tsx @@ -1,4 +1,4 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import axios from 'redaxios' import type { ErrorComponentProps } from '@tanstack/react-router' @@ -6,7 +6,7 @@ import type { User } from '~/utils/users' import { DEPLOY_URL } from '~/utils/users' import { NotFound } from '~/components/NotFound' -export const Route = createFileRoute('/users/$userId')({ +export const Route = createFileRoute({ loader: async ({ params: { userId } }) => { return await axios .get(DEPLOY_URL + '/api/users/' + userId) @@ -22,7 +22,7 @@ export const Route = createFileRoute('/users/$userId')({ }, }) -export function UserErrorComponent({ error }: ErrorComponentProps) { +function UserErrorComponent({ error }: ErrorComponentProps) { return } diff --git a/e2e/react-start/basic/src/routes/users.index.tsx b/e2e/react-start/basic/src/routes/users.index.tsx index b6b0ee67fb..662e8b6c68 100644 --- a/e2e/react-start/basic/src/routes/users.index.tsx +++ b/e2e/react-start/basic/src/routes/users.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/users/')({ +export const Route = createFileRoute({ component: UsersIndexComponent, }) diff --git a/e2e/react-start/basic/src/routes/users.tsx b/e2e/react-start/basic/src/routes/users.tsx index 45e070657e..06a9eb90d7 100644 --- a/e2e/react-start/basic/src/routes/users.tsx +++ b/e2e/react-start/basic/src/routes/users.tsx @@ -1,10 +1,10 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import axios from 'redaxios' import type { User } from '~/utils/users' import { DEPLOY_URL } from '~/utils/users' -export const Route = createFileRoute('/users')({ +export const Route = createFileRoute({ loader: async () => { return await axios .get>(DEPLOY_URL + '/api/users') diff --git a/e2e/react-start/basic/src/ssr.tsx b/e2e/react-start/basic/src/ssr.tsx deleted file mode 100644 index 62572579ac..0000000000 --- a/e2e/react-start/basic/src/ssr.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/start/server' -import { getRouterManifest } from '@tanstack/start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/e2e/react-start/basic/src/utils/posts.tsx b/e2e/react-start/basic/src/utils/posts.tsx index bf139e0ac8..9fdff27673 100644 --- a/e2e/react-start/basic/src/utils/posts.tsx +++ b/e2e/react-start/basic/src/utils/posts.tsx @@ -1,5 +1,5 @@ import { notFound } from '@tanstack/react-router' -import { createServerFn } from '@tanstack/start' +import { createServerFn } from '@tanstack/react-start' import axios from 'redaxios' export type PostType = { diff --git a/e2e/react-start/basic/src/utils/users.tsx b/e2e/react-start/basic/src/utils/users.tsx index 79b45867d5..46be4b1580 100644 --- a/e2e/react-start/basic/src/utils/users.tsx +++ b/e2e/react-start/basic/src/utils/users.tsx @@ -4,7 +4,6 @@ export type User = { email: string } -const PORT = - import.meta.env.VITE_SERVER_PORT || process.env.VITE_SERVER_PORT || 3000 +const PORT = process.env.VITE_SERVER_PORT || 3000 export const DEPLOY_URL = `http://localhost:${PORT}` diff --git a/e2e/react-start/basic/vite.config.ts b/e2e/react-start/basic/vite.config.ts new file mode 100644 index 0000000000..698e4856da --- /dev/null +++ b/e2e/react-start/basic/vite.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/e2e/react-start/clerk-basic/.gitignore b/e2e/react-start/clerk-basic/.gitignore index b15fed94e2..2818549158 100644 --- a/e2e/react-start/clerk-basic/.gitignore +++ b/e2e/react-start/clerk-basic/.gitignore @@ -7,14 +7,10 @@ yarn.lock .cache .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ diff --git a/e2e/react-start/clerk-basic/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/react-start/clerk-basic/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/e2e/react-start/clerk-basic/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/react-start/clerk-basic/app.config.ts b/e2e/react-start/clerk-basic/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/e2e/react-start/clerk-basic/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/e2e/react-start/clerk-basic/package.json b/e2e/react-start/clerk-basic/package.json index c2c2bb13fe..5ba924c234 100644 --- a/e2e/react-start/clerk-basic/package.json +++ b/e2e/react-start/clerk-basic/package.json @@ -4,10 +4,10 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev --port 3000", - "dev:e2e": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start", + "dev": "vite dev --port 3000", + "dev:e2e": "vite dev", + "build": "vite build", + "start": "node .output/server/index.mjs", "test:e2e": "exit 0; playwright test --project=chromium" }, "dependencies": { @@ -19,7 +19,7 @@ "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3" + "vite": "6.1.4" }, "devDependencies": { "@playwright/test": "^1.50.1", @@ -28,8 +28,8 @@ "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", - "postcss": "^8.5.1", "autoprefixer": "^10.4.20", + "postcss": "^8.5.1", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", "vite-tsconfig-paths": "^5.1.4" diff --git a/e2e/react-start/clerk-basic/playwright.config.ts b/e2e/react-start/clerk-basic/playwright.config.ts index bb77d0cf70..9806e0c136 100644 --- a/e2e/react-start/clerk-basic/playwright.config.ts +++ b/e2e/react-start/clerk-basic/playwright.config.ts @@ -19,7 +19,7 @@ export default defineConfig({ }, webServer: { - command: `VITE_SERVER_PORT=${PORT} pnpm build && VITE_SERVER_PORT=${PORT} pnpm start --port ${PORT}`, + command: `VITE_SERVER_PORT=${PORT} pnpm build && PORT=${PORT} VITE_SERVER_PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', diff --git a/e2e/react-start/clerk-basic/src/client.tsx b/e2e/react-start/clerk-basic/src/client.tsx deleted file mode 100644 index 31385f57f1..0000000000 --- a/e2e/react-start/clerk-basic/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document!, ) diff --git a/e2e/react-start/clerk-basic/src/routeTree.gen.ts b/e2e/react-start/clerk-basic/src/routeTree.gen.ts index b4b4f459a8..c485ac113c 100644 --- a/e2e/react-start/clerk-basic/src/routeTree.gen.ts +++ b/e2e/react-start/clerk-basic/src/routeTree.gen.ts @@ -10,46 +10,47 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as AuthedImport } from './routes/_authed' -import { Route as IndexImport } from './routes/index' -import { Route as AuthedPostsImport } from './routes/_authed/posts' -import { Route as AuthedPostsIndexImport } from './routes/_authed/posts.index' -import { Route as AuthedProfileSplatImport } from './routes/_authed/profile.$' -import { Route as AuthedPostsPostIdImport } from './routes/_authed/posts.$postId' +import { Route as AuthedRouteImport } from './routes/_authed' +import { Route as IndexRouteImport } from './routes/index' +import { Route as AuthedPostsRouteImport } from './routes/_authed/posts' +import { Route as AuthedPostsIndexRouteImport } from './routes/_authed/posts.index' +import { Route as AuthedProfileSplatRouteImport } from './routes/_authed/profile.$' +import { Route as AuthedPostsPostIdRouteImport } from './routes/_authed/posts.$postId' // Create/Update Routes -const AuthedRoute = AuthedImport.update({ +const AuthedRoute = AuthedRouteImport.update({ id: '/_authed', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const AuthedPostsRoute = AuthedPostsImport.update({ +const AuthedPostsRoute = AuthedPostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => AuthedRoute, } as any) -const AuthedPostsIndexRoute = AuthedPostsIndexImport.update({ +const AuthedPostsIndexRoute = AuthedPostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => AuthedPostsRoute, } as any) -const AuthedProfileSplatRoute = AuthedProfileSplatImport.update({ +const AuthedProfileSplatRoute = AuthedProfileSplatRouteImport.update({ id: '/profile/$', path: '/profile/$', getParentRoute: () => AuthedRoute, } as any) -const AuthedPostsPostIdRoute = AuthedPostsPostIdImport.update({ +const AuthedPostsPostIdRoute = AuthedPostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => AuthedPostsRoute, @@ -63,47 +64,104 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_authed': { id: '/_authed' path: '' fullPath: '' - preLoaderRoute: typeof AuthedImport + preLoaderRoute: typeof AuthedRouteImport parentRoute: typeof rootRoute } '/_authed/posts': { id: '/_authed/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof AuthedPostsImport - parentRoute: typeof AuthedImport + preLoaderRoute: typeof AuthedPostsRouteImport + parentRoute: typeof AuthedRouteImport } '/_authed/posts/$postId': { id: '/_authed/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof AuthedPostsPostIdImport - parentRoute: typeof AuthedPostsImport + preLoaderRoute: typeof AuthedPostsPostIdRouteImport + parentRoute: typeof AuthedPostsRouteImport } '/_authed/profile/$': { id: '/_authed/profile/$' path: '/profile/$' fullPath: '/profile/$' - preLoaderRoute: typeof AuthedProfileSplatImport - parentRoute: typeof AuthedImport + preLoaderRoute: typeof AuthedProfileSplatRouteImport + parentRoute: typeof AuthedRouteImport } '/_authed/posts/': { id: '/_authed/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof AuthedPostsIndexImport - parentRoute: typeof AuthedPostsImport + preLoaderRoute: typeof AuthedPostsIndexRouteImport + parentRoute: typeof AuthedPostsRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_authed' { + const createFileRoute: CreateFileRoute< + '/_authed', + FileRoutesByPath['/_authed']['parentRoute'], + FileRoutesByPath['/_authed']['id'], + FileRoutesByPath['/_authed']['path'], + FileRoutesByPath['/_authed']['fullPath'] + > +} +declare module './routes/_authed/posts' { + const createFileRoute: CreateFileRoute< + '/_authed/posts', + FileRoutesByPath['/_authed/posts']['parentRoute'], + FileRoutesByPath['/_authed/posts']['id'], + FileRoutesByPath['/_authed/posts']['path'], + FileRoutesByPath['/_authed/posts']['fullPath'] + > +} +declare module './routes/_authed/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/_authed/posts/$postId', + FileRoutesByPath['/_authed/posts/$postId']['parentRoute'], + FileRoutesByPath['/_authed/posts/$postId']['id'], + FileRoutesByPath['/_authed/posts/$postId']['path'], + FileRoutesByPath['/_authed/posts/$postId']['fullPath'] + > +} +declare module './routes/_authed/profile.$' { + const createFileRoute: CreateFileRoute< + '/_authed/profile/$', + FileRoutesByPath['/_authed/profile/$']['parentRoute'], + FileRoutesByPath['/_authed/profile/$']['id'], + FileRoutesByPath['/_authed/profile/$']['path'], + FileRoutesByPath['/_authed/profile/$']['fullPath'] + > +} +declare module './routes/_authed/posts.index' { + const createFileRoute: CreateFileRoute< + '/_authed/posts/', + FileRoutesByPath['/_authed/posts/']['parentRoute'], + FileRoutesByPath['/_authed/posts/']['id'], + FileRoutesByPath['/_authed/posts/']['path'], + FileRoutesByPath['/_authed/posts/']['fullPath'] + > +} + // Create and export the route tree interface AuthedPostsRouteChildren { @@ -190,6 +248,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/react-start/clerk-basic/src/router.tsx b/e2e/react-start/clerk-basic/src/router.tsx index 5a1c0ad410..63444559c1 100644 --- a/e2e/react-start/clerk-basic/src/router.tsx +++ b/e2e/react-start/clerk-basic/src/router.tsx @@ -1,3 +1,4 @@ +/// import { createRouter as createTanStackRouter } from '@tanstack/react-router' import { routeTree } from './routeTree.gen' import { DefaultCatchBoundary } from './components/DefaultCatchBoundary' diff --git a/e2e/react-start/clerk-basic/src/routes/__root.tsx b/e2e/react-start/clerk-basic/src/routes/__root.tsx index 2806298d49..569979e37a 100644 --- a/e2e/react-start/clerk-basic/src/routes/__root.tsx +++ b/e2e/react-start/clerk-basic/src/routes/__root.tsx @@ -1,4 +1,3 @@ -/// import { HeadContent, Link, diff --git a/e2e/react-start/clerk-basic/src/routes/_authed.tsx b/e2e/react-start/clerk-basic/src/routes/_authed.tsx index 226ae0829f..6242975272 100644 --- a/e2e/react-start/clerk-basic/src/routes/_authed.tsx +++ b/e2e/react-start/clerk-basic/src/routes/_authed.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { SignIn } from '@clerk/tanstack-react-start' -export const Route = createFileRoute('/_authed')({ +export const Route = createFileRoute({ beforeLoad: ({ context }) => { if (!context.user.userId) { throw new Error('Not authenticated') diff --git a/e2e/react-start/clerk-basic/src/routes/_authed/posts.$postId.tsx b/e2e/react-start/clerk-basic/src/routes/_authed/posts.$postId.tsx index 27296b9658..49cad9b374 100644 --- a/e2e/react-start/clerk-basic/src/routes/_authed/posts.$postId.tsx +++ b/e2e/react-start/clerk-basic/src/routes/_authed/posts.$postId.tsx @@ -1,10 +1,10 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import type { ErrorComponentProps } from '@tanstack/react-router' import { NotFound } from '~/components/NotFound.js' import { fetchPost } from '~/utils/posts.js' -export const Route = createFileRoute('/_authed/posts/$postId')({ +export const Route = createFileRoute({ loader: ({ params: { postId } }) => fetchPost({ data: postId }), errorComponent: PostErrorComponent, component: PostComponent, diff --git a/e2e/react-start/clerk-basic/src/routes/_authed/posts.index.tsx b/e2e/react-start/clerk-basic/src/routes/_authed/posts.index.tsx index ea9e667e54..13529228bb 100644 --- a/e2e/react-start/clerk-basic/src/routes/_authed/posts.index.tsx +++ b/e2e/react-start/clerk-basic/src/routes/_authed/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_authed/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/react-start/clerk-basic/src/routes/_authed/posts.tsx b/e2e/react-start/clerk-basic/src/routes/_authed/posts.tsx index c01f12c49a..6c37957e8c 100644 --- a/e2e/react-start/clerk-basic/src/routes/_authed/posts.tsx +++ b/e2e/react-start/clerk-basic/src/routes/_authed/posts.tsx @@ -1,8 +1,8 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '~/utils/posts.js' -export const Route = createFileRoute('/_authed/posts')({ +export const Route = createFileRoute({ loader: () => fetchPosts(), component: PostsComponent, }) diff --git a/e2e/react-start/clerk-basic/src/routes/_authed/profile.$.tsx b/e2e/react-start/clerk-basic/src/routes/_authed/profile.$.tsx index 1e5a8b1429..6c37957e8c 100644 --- a/e2e/react-start/clerk-basic/src/routes/_authed/profile.$.tsx +++ b/e2e/react-start/clerk-basic/src/routes/_authed/profile.$.tsx @@ -1,8 +1,8 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '~/utils/posts.js' -export const Route = createFileRoute('/_authed/profile/$')({ +export const Route = createFileRoute({ loader: () => fetchPosts(), component: PostsComponent, }) diff --git a/e2e/react-start/clerk-basic/src/routes/index.tsx b/e2e/react-start/clerk-basic/src/routes/index.tsx index 6ae388a178..66baf1e9f1 100644 --- a/e2e/react-start/clerk-basic/src/routes/index.tsx +++ b/e2e/react-start/clerk-basic/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-start/clerk-basic/src/server.tsx b/e2e/react-start/clerk-basic/src/server.tsx new file mode 100644 index 0000000000..2987216e24 --- /dev/null +++ b/e2e/react-start/clerk-basic/src/server.tsx @@ -0,0 +1,18 @@ +import { + createStartHandler, + defaultStreamHandler, + defineEventHandler, +} from '@tanstack/react-start/server' +import { createClerkHandler } from '@clerk/tanstack-react-start/server' +import { createRouter } from './router' + +export default defineEventHandler((event) => { + const startHandler = createStartHandler({ + createRouter, + }) + + const withClerkHandler = + createClerkHandler(startHandler)(defaultStreamHandler) + + return withClerkHandler(event) +}) diff --git a/e2e/react-start/clerk-basic/vite.config.ts b/e2e/react-start/clerk-basic/vite.config.ts new file mode 100644 index 0000000000..82d4065454 --- /dev/null +++ b/e2e/react-start/clerk-basic/vite.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' + +export default defineConfig({ + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/e2e/react-start/scroll-restoration/.gitignore b/e2e/react-start/scroll-restoration/.gitignore index be342025da..ca63f49885 100644 --- a/e2e/react-start/scroll-restoration/.gitignore +++ b/e2e/react-start/scroll-restoration/.gitignore @@ -7,14 +7,10 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ diff --git a/e2e/react-start/scroll-restoration/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/react-start/scroll-restoration/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/e2e/react-start/scroll-restoration/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/react-start/scroll-restoration/app.config.ts b/e2e/react-start/scroll-restoration/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/e2e/react-start/scroll-restoration/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/e2e/react-start/scroll-restoration/package.json b/e2e/react-start/scroll-restoration/package.json index 73a72f7300..1ddcb5fb2a 100644 --- a/e2e/react-start/scroll-restoration/package.json +++ b/e2e/react-start/scroll-restoration/package.json @@ -4,10 +4,10 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev --port 3000", - "dev:e2e": "vinxi dev", - "build": "vinxi build && tsc --noEmit", - "start": "vinxi start", + "dev": "vite dev --port 3000", + "dev:e2e": "vite dev", + "build": "vite build && tsc --noEmit", + "start": "node .output/server/index.mjs", "test:e2e": "playwright test --project=chromium" }, "dependencies": { @@ -19,7 +19,7 @@ "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3", + "vite": "6.1.4", "zod": "^3.24.2" }, "devDependencies": { diff --git a/e2e/react-start/scroll-restoration/playwright.config.ts b/e2e/react-start/scroll-restoration/playwright.config.ts index 95d043d48b..cf58d18adf 100644 --- a/e2e/react-start/scroll-restoration/playwright.config.ts +++ b/e2e/react-start/scroll-restoration/playwright.config.ts @@ -20,7 +20,7 @@ export default defineConfig({ }, webServer: { - command: `VITE_SERVER_PORT=${PORT} pnpm build && VITE_SERVER_PORT=${PORT} pnpm start --port ${PORT}`, + command: `VITE_SERVER_PORT=${PORT} pnpm build && PORT=${PORT} VITE_SERVER_PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', diff --git a/e2e/react-start/scroll-restoration/src/api.ts b/e2e/react-start/scroll-restoration/src/api.ts deleted file mode 100644 index 8b9fef1667..0000000000 --- a/e2e/react-start/scroll-restoration/src/api.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { - createStartAPIHandler, - defaultAPIFileRouteHandler, -} from '@tanstack/react-start/api' - -export default createStartAPIHandler(defaultAPIFileRouteHandler) diff --git a/e2e/react-start/scroll-restoration/src/client.tsx b/e2e/react-start/scroll-restoration/src/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/e2e/react-start/scroll-restoration/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/e2e/react-start/scroll-restoration/src/routeTree.gen.ts b/e2e/react-start/scroll-restoration/src/routeTree.gen.ts index f0a79cc008..73c99850a8 100644 --- a/e2e/react-start/scroll-restoration/src/routeTree.gen.ts +++ b/e2e/react-start/scroll-restoration/src/routeTree.gen.ts @@ -10,33 +10,34 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' -import { Route as testsWithSearchImport } from './routes/(tests)/with-search' -import { Route as testsWithLoaderImport } from './routes/(tests)/with-loader' -import { Route as testsNormalPageImport } from './routes/(tests)/normal-page' +import { Route as IndexRouteImport } from './routes/index' +import { Route as testsWithSearchRouteImport } from './routes/(tests)/with-search' +import { Route as testsWithLoaderRouteImport } from './routes/(tests)/with-loader' +import { Route as testsNormalPageRouteImport } from './routes/(tests)/normal-page' // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const testsWithSearchRoute = testsWithSearchImport.update({ +const testsWithSearchRoute = testsWithSearchRouteImport.update({ id: '/(tests)/with-search', path: '/with-search', getParentRoute: () => rootRoute, } as any) -const testsWithLoaderRoute = testsWithLoaderImport.update({ +const testsWithLoaderRoute = testsWithLoaderRouteImport.update({ id: '/(tests)/with-loader', path: '/with-loader', getParentRoute: () => rootRoute, } as any) -const testsNormalPageRoute = testsNormalPageImport.update({ +const testsNormalPageRoute = testsNormalPageRouteImport.update({ id: '/(tests)/normal-page', path: '/normal-page', getParentRoute: () => rootRoute, @@ -50,33 +51,72 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/(tests)/normal-page': { id: '/(tests)/normal-page' path: '/normal-page' fullPath: '/normal-page' - preLoaderRoute: typeof testsNormalPageImport + preLoaderRoute: typeof testsNormalPageRouteImport parentRoute: typeof rootRoute } '/(tests)/with-loader': { id: '/(tests)/with-loader' path: '/with-loader' fullPath: '/with-loader' - preLoaderRoute: typeof testsWithLoaderImport + preLoaderRoute: typeof testsWithLoaderRouteImport parentRoute: typeof rootRoute } '/(tests)/with-search': { id: '/(tests)/with-search' path: '/with-search' fullPath: '/with-search' - preLoaderRoute: typeof testsWithSearchImport + preLoaderRoute: typeof testsWithSearchRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/(tests)/normal-page' { + const createFileRoute: CreateFileRoute< + '/(tests)/normal-page', + FileRoutesByPath['/(tests)/normal-page']['parentRoute'], + FileRoutesByPath['/(tests)/normal-page']['id'], + FileRoutesByPath['/(tests)/normal-page']['path'], + FileRoutesByPath['/(tests)/normal-page']['fullPath'] + > +} +declare module './routes/(tests)/with-loader' { + const createFileRoute: CreateFileRoute< + '/(tests)/with-loader', + FileRoutesByPath['/(tests)/with-loader']['parentRoute'], + FileRoutesByPath['/(tests)/with-loader']['id'], + FileRoutesByPath['/(tests)/with-loader']['path'], + FileRoutesByPath['/(tests)/with-loader']['fullPath'] + > +} +declare module './routes/(tests)/with-search' { + const createFileRoute: CreateFileRoute< + '/(tests)/with-search', + FileRoutesByPath['/(tests)/with-search']['parentRoute'], + FileRoutesByPath['/(tests)/with-search']['id'], + FileRoutesByPath['/(tests)/with-search']['path'], + FileRoutesByPath['/(tests)/with-search']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -133,6 +173,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/react-start/scroll-restoration/src/routes/(tests)/normal-page.tsx b/e2e/react-start/scroll-restoration/src/routes/(tests)/normal-page.tsx index 95fb7e119e..401397d63c 100644 --- a/e2e/react-start/scroll-restoration/src/routes/(tests)/normal-page.tsx +++ b/e2e/react-start/scroll-restoration/src/routes/(tests)/normal-page.tsx @@ -1,8 +1,7 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' import { ScrollBlock } from '../-components/scroll-block' -export const Route = createFileRoute('/(tests)/normal-page')({ +export const Route = createFileRoute({ component: Component, }) diff --git a/e2e/react-start/scroll-restoration/src/routes/(tests)/with-loader.tsx b/e2e/react-start/scroll-restoration/src/routes/(tests)/with-loader.tsx index dfd4c7bf13..a8da1a2594 100644 --- a/e2e/react-start/scroll-restoration/src/routes/(tests)/with-loader.tsx +++ b/e2e/react-start/scroll-restoration/src/routes/(tests)/with-loader.tsx @@ -1,8 +1,7 @@ -import { createFileRoute } from '@tanstack/react-router' import { ScrollBlock } from '../-components/scroll-block' import { sleep } from '~/utils/posts' -export const Route = createFileRoute('/(tests)/with-loader')({ +export const Route = createFileRoute({ loader: async () => { await sleep(1000) return { foo: 'bar' } diff --git a/e2e/react-start/scroll-restoration/src/routes/(tests)/with-search.tsx b/e2e/react-start/scroll-restoration/src/routes/(tests)/with-search.tsx index 7916c18f73..21e7635e29 100644 --- a/e2e/react-start/scroll-restoration/src/routes/(tests)/with-search.tsx +++ b/e2e/react-start/scroll-restoration/src/routes/(tests)/with-search.tsx @@ -1,9 +1,8 @@ -import { createFileRoute } from '@tanstack/react-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' import { ScrollBlock } from '../-components/scroll-block' -export const Route = createFileRoute('/(tests)/with-search')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ where: z.string() })), component: Component, }) diff --git a/e2e/react-start/scroll-restoration/src/routes/__root.tsx b/e2e/react-start/scroll-restoration/src/routes/__root.tsx index bf315e98ae..ac55e334cd 100644 --- a/e2e/react-start/scroll-restoration/src/routes/__root.tsx +++ b/e2e/react-start/scroll-restoration/src/routes/__root.tsx @@ -1,12 +1,13 @@ import * as React from 'react' import { + HeadContent, Link, Outlet, + Scripts, createRootRoute, linkOptions, - HeadContent, - Scripts, } from '@tanstack/react-router' +import { TanStackRouterDevtools } from '@tanstack/react-router-devtools' import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary' import { NotFound } from '~/components/NotFound' import appCss from '~/styles/app.css?url' @@ -66,6 +67,7 @@ function RootComponent() { return ( + ) } diff --git a/e2e/react-start/scroll-restoration/src/routes/index.tsx b/e2e/react-start/scroll-restoration/src/routes/index.tsx index 79453d4967..d97ba9ef54 100644 --- a/e2e/react-start/scroll-restoration/src/routes/index.tsx +++ b/e2e/react-start/scroll-restoration/src/routes/index.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, createFileRoute, linkOptions } from '@tanstack/react-router' +import { Link, linkOptions } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: HomeComponent, }) diff --git a/e2e/react-start/scroll-restoration/tsconfig.json b/e2e/react-start/scroll-restoration/tsconfig.json index b3a2d67dfa..09dd95b355 100644 --- a/e2e/react-start/scroll-restoration/tsconfig.json +++ b/e2e/react-start/scroll-restoration/tsconfig.json @@ -17,6 +17,7 @@ "paths": { "~/*": ["./src/*"] }, + "types": ["vite/client"], "noEmit": true } } diff --git a/e2e/react-start/scroll-restoration/vite.config.ts b/e2e/react-start/scroll-restoration/vite.config.ts new file mode 100644 index 0000000000..988f742887 --- /dev/null +++ b/e2e/react-start/scroll-restoration/vite.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' + +export default defineConfig({ + plugins: [ + tsConfigPaths({ projects: ['./tsconfig.json'] }), + TanStackStartVitePlugin(), + ], +}) diff --git a/e2e/react-start/server-functions/.gitignore b/e2e/react-start/server-functions/.gitignore index be342025da..ca63f49885 100644 --- a/e2e/react-start/server-functions/.gitignore +++ b/e2e/react-start/server-functions/.gitignore @@ -7,14 +7,10 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ diff --git a/e2e/react-start/server-functions/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/react-start/server-functions/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/e2e/react-start/server-functions/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/react-start/server-functions/app.config.ts b/e2e/react-start/server-functions/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/e2e/react-start/server-functions/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/e2e/react-start/server-functions/package.json b/e2e/react-start/server-functions/package.json index 2107818357..04fbdfbce9 100644 --- a/e2e/react-start/server-functions/package.json +++ b/e2e/react-start/server-functions/package.json @@ -4,10 +4,10 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev --port 3000", - "dev:e2e": "vinxi dev", - "build": "vinxi build && tsc --noEmit", - "start": "vinxi start", + "dev": "vite dev --port 3000", + "dev:e2e": "vite dev", + "build": "vite build && tsc --noEmit", + "start": "node .output/server/index.mjs", "test:e2e": "playwright test --project=chromium" }, "dependencies": { @@ -19,7 +19,7 @@ "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3", + "vite": "6.1.4", "zod": "^3.24.2" }, "devDependencies": { diff --git a/e2e/react-start/server-functions/playwright.config.ts b/e2e/react-start/server-functions/playwright.config.ts index 409765549f..88ff69f92e 100644 --- a/e2e/react-start/server-functions/playwright.config.ts +++ b/e2e/react-start/server-functions/playwright.config.ts @@ -20,7 +20,7 @@ export default defineConfig({ }, webServer: { - command: `VITE_SERVER_PORT=${PORT} pnpm build && VITE_SERVER_PORT=${PORT} pnpm start --port ${PORT}`, + command: `VITE_SERVER_PORT=${PORT} pnpm build && PORT=${PORT} VITE_SERVER_PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', diff --git a/e2e/react-start/server-functions/src/client.tsx b/e2e/react-start/server-functions/src/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/e2e/react-start/server-functions/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/e2e/react-start/server-functions/src/routeTree.gen.ts b/e2e/react-start/server-functions/src/routeTree.gen.ts index 6025f04091..4f90b1bfa3 100644 --- a/e2e/react-start/server-functions/src/routeTree.gen.ts +++ b/e2e/react-start/server-functions/src/routeTree.gen.ts @@ -10,110 +10,111 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as SubmitPostFormdataImport } from './routes/submit-post-formdata' -import { Route as StatusImport } from './routes/status' -import { Route as SerializeFormDataImport } from './routes/serialize-form-data' -import { Route as ReturnNullImport } from './routes/return-null' -import { Route as RawResponseImport } from './routes/raw-response' -import { Route as MultipartImport } from './routes/multipart' -import { Route as IsomorphicFnsImport } from './routes/isomorphic-fns' -import { Route as HeadersImport } from './routes/headers' -import { Route as EnvOnlyImport } from './routes/env-only' -import { Route as DeadCodePreserveImport } from './routes/dead-code-preserve' -import { Route as ConsistentImport } from './routes/consistent' -import { Route as AbortSignalImport } from './routes/abort-signal' -import { Route as IndexImport } from './routes/index' -import { Route as CookiesIndexImport } from './routes/cookies/index' -import { Route as CookiesSetImport } from './routes/cookies/set' +import { Route as SubmitPostFormdataRouteImport } from './routes/submit-post-formdata' +import { Route as StatusRouteImport } from './routes/status' +import { Route as SerializeFormDataRouteImport } from './routes/serialize-form-data' +import { Route as ReturnNullRouteImport } from './routes/return-null' +import { Route as RawResponseRouteImport } from './routes/raw-response' +import { Route as MultipartRouteImport } from './routes/multipart' +import { Route as IsomorphicFnsRouteImport } from './routes/isomorphic-fns' +import { Route as HeadersRouteImport } from './routes/headers' +import { Route as EnvOnlyRouteImport } from './routes/env-only' +import { Route as DeadCodePreserveRouteImport } from './routes/dead-code-preserve' +import { Route as ConsistentRouteImport } from './routes/consistent' +import { Route as AbortSignalRouteImport } from './routes/abort-signal' +import { Route as IndexRouteImport } from './routes/index' +import { Route as CookiesIndexRouteImport } from './routes/cookies/index' +import { Route as CookiesSetRouteImport } from './routes/cookies/set' // Create/Update Routes -const SubmitPostFormdataRoute = SubmitPostFormdataImport.update({ +const SubmitPostFormdataRoute = SubmitPostFormdataRouteImport.update({ id: '/submit-post-formdata', path: '/submit-post-formdata', getParentRoute: () => rootRoute, } as any) -const StatusRoute = StatusImport.update({ +const StatusRoute = StatusRouteImport.update({ id: '/status', path: '/status', getParentRoute: () => rootRoute, } as any) -const SerializeFormDataRoute = SerializeFormDataImport.update({ +const SerializeFormDataRoute = SerializeFormDataRouteImport.update({ id: '/serialize-form-data', path: '/serialize-form-data', getParentRoute: () => rootRoute, } as any) -const ReturnNullRoute = ReturnNullImport.update({ +const ReturnNullRoute = ReturnNullRouteImport.update({ id: '/return-null', path: '/return-null', getParentRoute: () => rootRoute, } as any) -const RawResponseRoute = RawResponseImport.update({ +const RawResponseRoute = RawResponseRouteImport.update({ id: '/raw-response', path: '/raw-response', getParentRoute: () => rootRoute, } as any) -const MultipartRoute = MultipartImport.update({ +const MultipartRoute = MultipartRouteImport.update({ id: '/multipart', path: '/multipart', getParentRoute: () => rootRoute, } as any) -const IsomorphicFnsRoute = IsomorphicFnsImport.update({ +const IsomorphicFnsRoute = IsomorphicFnsRouteImport.update({ id: '/isomorphic-fns', path: '/isomorphic-fns', getParentRoute: () => rootRoute, } as any) -const HeadersRoute = HeadersImport.update({ +const HeadersRoute = HeadersRouteImport.update({ id: '/headers', path: '/headers', getParentRoute: () => rootRoute, } as any) -const EnvOnlyRoute = EnvOnlyImport.update({ +const EnvOnlyRoute = EnvOnlyRouteImport.update({ id: '/env-only', path: '/env-only', getParentRoute: () => rootRoute, } as any) -const DeadCodePreserveRoute = DeadCodePreserveImport.update({ +const DeadCodePreserveRoute = DeadCodePreserveRouteImport.update({ id: '/dead-code-preserve', path: '/dead-code-preserve', getParentRoute: () => rootRoute, } as any) -const ConsistentRoute = ConsistentImport.update({ +const ConsistentRoute = ConsistentRouteImport.update({ id: '/consistent', path: '/consistent', getParentRoute: () => rootRoute, } as any) -const AbortSignalRoute = AbortSignalImport.update({ +const AbortSignalRoute = AbortSignalRouteImport.update({ id: '/abort-signal', path: '/abort-signal', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const CookiesIndexRoute = CookiesIndexImport.update({ +const CookiesIndexRoute = CookiesIndexRouteImport.update({ id: '/cookies/', path: '/cookies/', getParentRoute: () => rootRoute, } as any) -const CookiesSetRoute = CookiesSetImport.update({ +const CookiesSetRoute = CookiesSetRouteImport.update({ id: '/cookies/set', path: '/cookies/set', getParentRoute: () => rootRoute, @@ -127,110 +128,248 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/abort-signal': { id: '/abort-signal' path: '/abort-signal' fullPath: '/abort-signal' - preLoaderRoute: typeof AbortSignalImport + preLoaderRoute: typeof AbortSignalRouteImport parentRoute: typeof rootRoute } '/consistent': { id: '/consistent' path: '/consistent' fullPath: '/consistent' - preLoaderRoute: typeof ConsistentImport + preLoaderRoute: typeof ConsistentRouteImport parentRoute: typeof rootRoute } '/dead-code-preserve': { id: '/dead-code-preserve' path: '/dead-code-preserve' fullPath: '/dead-code-preserve' - preLoaderRoute: typeof DeadCodePreserveImport + preLoaderRoute: typeof DeadCodePreserveRouteImport parentRoute: typeof rootRoute } '/env-only': { id: '/env-only' path: '/env-only' fullPath: '/env-only' - preLoaderRoute: typeof EnvOnlyImport + preLoaderRoute: typeof EnvOnlyRouteImport parentRoute: typeof rootRoute } '/headers': { id: '/headers' path: '/headers' fullPath: '/headers' - preLoaderRoute: typeof HeadersImport + preLoaderRoute: typeof HeadersRouteImport parentRoute: typeof rootRoute } '/isomorphic-fns': { id: '/isomorphic-fns' path: '/isomorphic-fns' fullPath: '/isomorphic-fns' - preLoaderRoute: typeof IsomorphicFnsImport + preLoaderRoute: typeof IsomorphicFnsRouteImport parentRoute: typeof rootRoute } '/multipart': { id: '/multipart' path: '/multipart' fullPath: '/multipart' - preLoaderRoute: typeof MultipartImport + preLoaderRoute: typeof MultipartRouteImport parentRoute: typeof rootRoute } '/raw-response': { id: '/raw-response' path: '/raw-response' fullPath: '/raw-response' - preLoaderRoute: typeof RawResponseImport + preLoaderRoute: typeof RawResponseRouteImport parentRoute: typeof rootRoute } '/return-null': { id: '/return-null' path: '/return-null' fullPath: '/return-null' - preLoaderRoute: typeof ReturnNullImport + preLoaderRoute: typeof ReturnNullRouteImport parentRoute: typeof rootRoute } '/serialize-form-data': { id: '/serialize-form-data' path: '/serialize-form-data' fullPath: '/serialize-form-data' - preLoaderRoute: typeof SerializeFormDataImport + preLoaderRoute: typeof SerializeFormDataRouteImport parentRoute: typeof rootRoute } '/status': { id: '/status' path: '/status' fullPath: '/status' - preLoaderRoute: typeof StatusImport + preLoaderRoute: typeof StatusRouteImport parentRoute: typeof rootRoute } '/submit-post-formdata': { id: '/submit-post-formdata' path: '/submit-post-formdata' fullPath: '/submit-post-formdata' - preLoaderRoute: typeof SubmitPostFormdataImport + preLoaderRoute: typeof SubmitPostFormdataRouteImport parentRoute: typeof rootRoute } '/cookies/set': { id: '/cookies/set' path: '/cookies/set' fullPath: '/cookies/set' - preLoaderRoute: typeof CookiesSetImport + preLoaderRoute: typeof CookiesSetRouteImport parentRoute: typeof rootRoute } '/cookies/': { id: '/cookies/' path: '/cookies' fullPath: '/cookies' - preLoaderRoute: typeof CookiesIndexImport + preLoaderRoute: typeof CookiesIndexRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/abort-signal' { + const createFileRoute: CreateFileRoute< + '/abort-signal', + FileRoutesByPath['/abort-signal']['parentRoute'], + FileRoutesByPath['/abort-signal']['id'], + FileRoutesByPath['/abort-signal']['path'], + FileRoutesByPath['/abort-signal']['fullPath'] + > +} +declare module './routes/consistent' { + const createFileRoute: CreateFileRoute< + '/consistent', + FileRoutesByPath['/consistent']['parentRoute'], + FileRoutesByPath['/consistent']['id'], + FileRoutesByPath['/consistent']['path'], + FileRoutesByPath['/consistent']['fullPath'] + > +} +declare module './routes/dead-code-preserve' { + const createFileRoute: CreateFileRoute< + '/dead-code-preserve', + FileRoutesByPath['/dead-code-preserve']['parentRoute'], + FileRoutesByPath['/dead-code-preserve']['id'], + FileRoutesByPath['/dead-code-preserve']['path'], + FileRoutesByPath['/dead-code-preserve']['fullPath'] + > +} +declare module './routes/env-only' { + const createFileRoute: CreateFileRoute< + '/env-only', + FileRoutesByPath['/env-only']['parentRoute'], + FileRoutesByPath['/env-only']['id'], + FileRoutesByPath['/env-only']['path'], + FileRoutesByPath['/env-only']['fullPath'] + > +} +declare module './routes/headers' { + const createFileRoute: CreateFileRoute< + '/headers', + FileRoutesByPath['/headers']['parentRoute'], + FileRoutesByPath['/headers']['id'], + FileRoutesByPath['/headers']['path'], + FileRoutesByPath['/headers']['fullPath'] + > +} +declare module './routes/isomorphic-fns' { + const createFileRoute: CreateFileRoute< + '/isomorphic-fns', + FileRoutesByPath['/isomorphic-fns']['parentRoute'], + FileRoutesByPath['/isomorphic-fns']['id'], + FileRoutesByPath['/isomorphic-fns']['path'], + FileRoutesByPath['/isomorphic-fns']['fullPath'] + > +} +declare module './routes/multipart' { + const createFileRoute: CreateFileRoute< + '/multipart', + FileRoutesByPath['/multipart']['parentRoute'], + FileRoutesByPath['/multipart']['id'], + FileRoutesByPath['/multipart']['path'], + FileRoutesByPath['/multipart']['fullPath'] + > +} +declare module './routes/raw-response' { + const createFileRoute: CreateFileRoute< + '/raw-response', + FileRoutesByPath['/raw-response']['parentRoute'], + FileRoutesByPath['/raw-response']['id'], + FileRoutesByPath['/raw-response']['path'], + FileRoutesByPath['/raw-response']['fullPath'] + > +} +declare module './routes/return-null' { + const createFileRoute: CreateFileRoute< + '/return-null', + FileRoutesByPath['/return-null']['parentRoute'], + FileRoutesByPath['/return-null']['id'], + FileRoutesByPath['/return-null']['path'], + FileRoutesByPath['/return-null']['fullPath'] + > +} +declare module './routes/serialize-form-data' { + const createFileRoute: CreateFileRoute< + '/serialize-form-data', + FileRoutesByPath['/serialize-form-data']['parentRoute'], + FileRoutesByPath['/serialize-form-data']['id'], + FileRoutesByPath['/serialize-form-data']['path'], + FileRoutesByPath['/serialize-form-data']['fullPath'] + > +} +declare module './routes/status' { + const createFileRoute: CreateFileRoute< + '/status', + FileRoutesByPath['/status']['parentRoute'], + FileRoutesByPath['/status']['id'], + FileRoutesByPath['/status']['path'], + FileRoutesByPath['/status']['fullPath'] + > +} +declare module './routes/submit-post-formdata' { + const createFileRoute: CreateFileRoute< + '/submit-post-formdata', + FileRoutesByPath['/submit-post-formdata']['parentRoute'], + FileRoutesByPath['/submit-post-formdata']['id'], + FileRoutesByPath['/submit-post-formdata']['path'], + FileRoutesByPath['/submit-post-formdata']['fullPath'] + > +} +declare module './routes/cookies/set' { + const createFileRoute: CreateFileRoute< + '/cookies/set', + FileRoutesByPath['/cookies/set']['parentRoute'], + FileRoutesByPath['/cookies/set']['id'], + FileRoutesByPath['/cookies/set']['path'], + FileRoutesByPath['/cookies/set']['fullPath'] + > +} +declare module './routes/cookies/index' { + const createFileRoute: CreateFileRoute< + '/cookies/', + FileRoutesByPath['/cookies/']['parentRoute'], + FileRoutesByPath['/cookies/']['id'], + FileRoutesByPath['/cookies/']['path'], + FileRoutesByPath['/cookies/']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -383,6 +522,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/react-start/server-functions/src/routes/abort-signal.tsx b/e2e/react-start/server-functions/src/routes/abort-signal.tsx index 7de90f3143..dd899a4c10 100644 --- a/e2e/react-start/server-functions/src/routes/abort-signal.tsx +++ b/e2e/react-start/server-functions/src/routes/abort-signal.tsx @@ -1,8 +1,7 @@ -import { createFileRoute } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' import React from 'react' -export const Route = createFileRoute('/abort-signal')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/react-start/server-functions/src/routes/consistent.tsx b/e2e/react-start/server-functions/src/routes/consistent.tsx index 5908512fa2..0d07b1833c 100644 --- a/e2e/react-start/server-functions/src/routes/consistent.tsx +++ b/e2e/react-start/server-functions/src/routes/consistent.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' import * as React from 'react' import { createServerFn } from '@tanstack/react-start' @@ -10,7 +9,7 @@ import { createServerFn } from '@tanstack/react-start' * @link https://github.com/TanStack/router/issues/2481 */ -export const Route = createFileRoute('/consistent')({ +export const Route = createFileRoute({ component: ConsistentServerFnCalls, loader: async () => { const data = await cons_serverGetFn1({ data: { username: 'TEST' } }) diff --git a/e2e/react-start/server-functions/src/routes/cookies/index.tsx b/e2e/react-start/server-functions/src/routes/cookies/index.tsx index ae42043959..01a6450bc6 100644 --- a/e2e/react-start/server-functions/src/routes/cookies/index.tsx +++ b/e2e/react-start/server-functions/src/routes/cookies/index.tsx @@ -1,10 +1,10 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import { z } from 'zod' const cookieSchema = z .object({ value: z.string() }) .catch(() => ({ value: `CLIENT-${Date.now()}` })) -export const Route = createFileRoute('/cookies/')({ +export const Route = createFileRoute({ validateSearch: cookieSchema, component: RouteComponent, }) diff --git a/e2e/react-start/server-functions/src/routes/cookies/set.tsx b/e2e/react-start/server-functions/src/routes/cookies/set.tsx index fd9e979ab9..965082750e 100644 --- a/e2e/react-start/server-functions/src/routes/cookies/set.tsx +++ b/e2e/react-start/server-functions/src/routes/cookies/set.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' import { setCookie } from '@tanstack/react-start/server' import { z } from 'zod' @@ -7,7 +6,7 @@ import React, { useEffect } from 'react' const cookieSchema = z.object({ value: z.string() }) -export const Route = createFileRoute('/cookies/set')({ +export const Route = createFileRoute({ validateSearch: cookieSchema, loaderDeps: ({ search }) => search, loader: async ({ deps }) => { diff --git a/e2e/react-start/server-functions/src/routes/dead-code-preserve.tsx b/e2e/react-start/server-functions/src/routes/dead-code-preserve.tsx index 46273c59e3..7c1d879272 100644 --- a/e2e/react-start/server-functions/src/routes/dead-code-preserve.tsx +++ b/e2e/react-start/server-functions/src/routes/dead-code-preserve.tsx @@ -2,9 +2,8 @@ import * as fs from 'node:fs' import { createServerFn } from '@tanstack/react-start' import { getRequestHeader } from '@tanstack/react-start/server' import { useState } from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/dead-code-preserve')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/react-start/server-functions/src/routes/env-only.tsx b/e2e/react-start/server-functions/src/routes/env-only.tsx index fe5ae8c1e8..52af89acc2 100644 --- a/e2e/react-start/server-functions/src/routes/env-only.tsx +++ b/e2e/react-start/server-functions/src/routes/env-only.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' import { clientOnly, createServerFn, serverOnly } from '@tanstack/react-start' import { useState } from 'react' @@ -18,7 +17,7 @@ const testOnServer = createServerFn().handler(() => { return { serverOnServer, clientOnServer } }) -export const Route = createFileRoute('/env-only')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/react-start/server-functions/src/routes/headers.tsx b/e2e/react-start/server-functions/src/routes/headers.tsx index 0b0f1ff7bc..8b282c9d7e 100644 --- a/e2e/react-start/server-functions/src/routes/headers.tsx +++ b/e2e/react-start/server-functions/src/routes/headers.tsx @@ -1,10 +1,9 @@ -import { createFileRoute } from '@tanstack/react-router' import * as React from 'react' import { createServerFn } from '@tanstack/react-start' import { getHeaders, setHeader } from '@tanstack/react-start/server' import type { HTTPHeaderName } from '@tanstack/react-start/server' -export const Route = createFileRoute('/headers')({ +export const Route = createFileRoute({ loader: async () => { return { testHeaders: await getTestHeaders(), diff --git a/e2e/react-start/server-functions/src/routes/index.tsx b/e2e/react-start/server-functions/src/routes/index.tsx index 4c3673ed34..90fdb817cd 100644 --- a/e2e/react-start/server-functions/src/routes/index.tsx +++ b/e2e/react-start/server-functions/src/routes/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-start/server-functions/src/routes/isomorphic-fns.tsx b/e2e/react-start/server-functions/src/routes/isomorphic-fns.tsx index 2c7bbc4a8f..dac800a60f 100644 --- a/e2e/react-start/server-functions/src/routes/isomorphic-fns.tsx +++ b/e2e/react-start/server-functions/src/routes/isomorphic-fns.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' import { createIsomorphicFn, createServerFn } from '@tanstack/react-start' import { useState } from 'react' @@ -16,7 +15,7 @@ const getServerEcho = createServerFn() .validator((input: string) => input) .handler(({ data }) => getEcho(data)) -export const Route = createFileRoute('/isomorphic-fns')({ +export const Route = createFileRoute({ component: RouteComponent, loader() { return { diff --git a/e2e/react-start/server-functions/src/routes/multipart.tsx b/e2e/react-start/server-functions/src/routes/multipart.tsx index a80ca0f1cd..817a181d38 100644 --- a/e2e/react-start/server-functions/src/routes/multipart.tsx +++ b/e2e/react-start/server-functions/src/routes/multipart.tsx @@ -1,8 +1,7 @@ -import { createFileRoute } from '@tanstack/react-router' import * as React from 'react' import { createServerFn } from '@tanstack/react-start' -export const Route = createFileRoute('/multipart')({ +export const Route = createFileRoute({ component: MultipartServerFnCall, }) diff --git a/e2e/react-start/server-functions/src/routes/raw-response.tsx b/e2e/react-start/server-functions/src/routes/raw-response.tsx index cb2c4bfbb8..5c15e08514 100644 --- a/e2e/react-start/server-functions/src/routes/raw-response.tsx +++ b/e2e/react-start/server-functions/src/routes/raw-response.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' + import { createServerFn } from '@tanstack/react-start' -export const Route = createFileRoute('/raw-response')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/react-start/server-functions/src/routes/return-null.tsx b/e2e/react-start/server-functions/src/routes/return-null.tsx index 6d83d2762f..8e6fd55e7f 100644 --- a/e2e/react-start/server-functions/src/routes/return-null.tsx +++ b/e2e/react-start/server-functions/src/routes/return-null.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' import * as React from 'react' @@ -8,7 +7,7 @@ import * as React from 'react' * @link https://github.com/TanStack/router/issues/2776 */ -export const Route = createFileRoute('/return-null')({ +export const Route = createFileRoute({ component: AllowServerFnReturnNull, }) diff --git a/e2e/react-start/server-functions/src/routes/serialize-form-data.tsx b/e2e/react-start/server-functions/src/routes/serialize-form-data.tsx index 901a22fdc0..486b3cf2ee 100644 --- a/e2e/react-start/server-functions/src/routes/serialize-form-data.tsx +++ b/e2e/react-start/server-functions/src/routes/serialize-form-data.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' + import { createServerFn } from '@tanstack/react-start' -export const Route = createFileRoute('/serialize-form-data')({ +export const Route = createFileRoute({ component: SerializeFormDataFnCall, }) diff --git a/e2e/react-start/server-functions/src/routes/status.tsx b/e2e/react-start/server-functions/src/routes/status.tsx index b8dcdee2e6..ec279cf906 100644 --- a/e2e/react-start/server-functions/src/routes/status.tsx +++ b/e2e/react-start/server-functions/src/routes/status.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' import { createServerFn, useServerFn } from '@tanstack/react-start' import { setResponseStatus } from '@tanstack/react-start/server' @@ -9,7 +8,7 @@ const helloFn = createServerFn().handler(() => { } }) -export const Route = createFileRoute('/status')({ +export const Route = createFileRoute({ component: StatusComponent, }) diff --git a/e2e/react-start/server-functions/src/routes/submit-post-formdata.tsx b/e2e/react-start/server-functions/src/routes/submit-post-formdata.tsx index 05df922817..2208875ef5 100644 --- a/e2e/react-start/server-functions/src/routes/submit-post-formdata.tsx +++ b/e2e/react-start/server-functions/src/routes/submit-post-formdata.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' -export const Route = createFileRoute('/submit-post-formdata')({ +export const Route = createFileRoute({ component: SubmitPostFormDataFn, }) diff --git a/e2e/react-start/server-functions/tsconfig.json b/e2e/react-start/server-functions/tsconfig.json index b3a2d67dfa..d35a4b17f4 100644 --- a/e2e/react-start/server-functions/tsconfig.json +++ b/e2e/react-start/server-functions/tsconfig.json @@ -17,6 +17,7 @@ "paths": { "~/*": ["./src/*"] }, - "noEmit": true + "noEmit": true, + "types": ["vite/client"] } } diff --git a/e2e/react-start/server-functions/vite.config.ts b/e2e/react-start/server-functions/vite.config.ts new file mode 100644 index 0000000000..82d4065454 --- /dev/null +++ b/e2e/react-start/server-functions/vite.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' + +export default defineConfig({ + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/e2e/react-start/website/.gitignore b/e2e/react-start/website/.gitignore index be342025da..a5f619189c 100644 --- a/e2e/react-start/website/.gitignore +++ b/e2e/react-start/website/.gitignore @@ -7,16 +7,14 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ /blob-report/ /playwright/.cache/ + +.tanstack-start/build \ No newline at end of file diff --git a/e2e/react-start/website/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/react-start/website/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..ac36454b7c --- /dev/null +++ b/e2e/react-start/website/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,112 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +import { ServerRoute as ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRouteImport } from './../../src/routes/$project.$version.docs.framework.$framework.{$}[.]md' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +const ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute = + ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRouteImport.update({ + id: '/$project/$version/docs/framework/$framework/{$}.md', + path: '/$project/$version/docs/framework/$framework/{$}.md', + getParentRoute: () => rootRoute, + } as any) + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath { + '/$project/$version/docs/framework/$framework/{$}.md': { + id: '/$project/$version/docs/framework/$framework/{$}.md' + path: '/$project/$version/docs/framework/$framework/{$}.md' + fullPath: '/$project/$version/docs/framework/$framework/{$}.md' + preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRouteImport + parentRoute: typeof rootRoute + } + } +} + +// Add type-safety to the createFileRoute function across the route tree + +declare module './../../src/routes/$project.$version.docs.framework.$framework.{$}[.]md' { + const createServerFileRoute: CreateServerFileRoute< + FileRoutesByPath['/$project/$version/docs/framework/$framework/{$}.md']['parentRoute'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/{$}.md']['id'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/{$}.md']['path'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/{$}.md']['fullPath'], + unknown + > +} + +// Create and export the route tree + +export interface FileRoutesByFullPath { + '/$project/$version/docs/framework/$framework/{$}.md': typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute +} + +export interface FileRoutesByTo { + '/$project/$version/docs/framework/$framework/{$}.md': typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute +} + +export interface FileRoutesById { + __root__: typeof rootRoute + '/$project/$version/docs/framework/$framework/{$}.md': typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: '/$project/$version/docs/framework/$framework/{$}.md' + fileRoutesByTo: FileRoutesByTo + to: '/$project/$version/docs/framework/$framework/{$}.md' + id: '__root__' | '/$project/$version/docs/framework/$framework/{$}.md' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren { + ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute: typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute +} + +const rootRouteChildren: RootRouteChildren = { + ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute: + ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute, +} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [ + "/$project/$version/docs/framework/$framework/{$}.md" + ] + }, + "/$project/$version/docs/framework/$framework/{$}.md": { + "filePath": "$project.$version.docs.framework.$framework.{$}[.]md.tsx" + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/react-start/website/app.config.ts b/e2e/react-start/website/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/e2e/react-start/website/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/e2e/react-start/website/package.json b/e2e/react-start/website/package.json index e69c2b3ffa..98ca661a1b 100644 --- a/e2e/react-start/website/package.json +++ b/e2e/react-start/website/package.json @@ -1,13 +1,13 @@ { - "name": "tanstack-start-e2e-website", + "name": "tanstack-react-start-e2e-website", "private": true, "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev --port 3000", - "dev:e2e": "vinxi dev", - "build": "vinxi build && tsc --noEmit", - "start": "vinxi start", + "dev": "vite dev --port 3000", + "dev:e2e": "vite dev", + "build": "vite build && tsc --noEmit", + "start": "node .output/server/index.mjs", "test:e2e": "playwright test --project=chromium" }, "dependencies": { @@ -18,7 +18,6 @@ "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3", "zod": "^3.24.2" }, "devDependencies": { @@ -28,10 +27,11 @@ "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", - "postcss": "^8.5.1", "autoprefixer": "^10.4.20", + "postcss": "^8.5.1", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", + "vite": "6.1.4", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/e2e/react-start/website/playwright.config.ts b/e2e/react-start/website/playwright.config.ts index bb77d0cf70..9806e0c136 100644 --- a/e2e/react-start/website/playwright.config.ts +++ b/e2e/react-start/website/playwright.config.ts @@ -19,7 +19,7 @@ export default defineConfig({ }, webServer: { - command: `VITE_SERVER_PORT=${PORT} pnpm build && VITE_SERVER_PORT=${PORT} pnpm start --port ${PORT}`, + command: `VITE_SERVER_PORT=${PORT} pnpm build && PORT=${PORT} VITE_SERVER_PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', diff --git a/e2e/react-start/website/src/client.tsx b/e2e/react-start/website/src/client.tsx deleted file mode 100644 index 31385f57f1..0000000000 --- a/e2e/react-start/website/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document!, ) diff --git a/e2e/react-start/website/src/routeTree.gen.ts b/e2e/react-start/website/src/routeTree.gen.ts index 72b5ecded6..e1eb6961ae 100644 --- a/e2e/react-start/website/src/routeTree.gen.ts +++ b/e2e/react-start/website/src/routeTree.gen.ts @@ -10,80 +10,80 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as LibraryImport } from './routes/_library' -import { Route as LibraryIndexImport } from './routes/_library.index' -import { Route as ProjectIndexImport } from './routes/$project.index' -import { Route as LibraryProjectImport } from './routes/_library.$project' -import { Route as LibraryProjectVersionIndexImport } from './routes/_library.$project.$version.index' -import { Route as ProjectVersionDocsIndexImport } from './routes/$project.$version.docs.index' -import { Route as ProjectVersionDocsFrameworkFrameworkImport } from './routes/$project.$version.docs.framework.$framework' -import { Route as ProjectVersionDocsFrameworkFrameworkIndexImport } from './routes/$project.$version.docs.framework.$framework.index' -import { Route as ProjectVersionDocsFrameworkFrameworkSplatImport } from './routes/$project.$version.docs.framework.$framework.$' -import { Route as ProjectVersionDocsFrameworkFrameworkExamplesSplatImport } from './routes/$project.$version.docs.framework.$framework.examples.$' +import { Route as LibraryRouteImport } from './routes/_library' +import { Route as LibraryIndexRouteImport } from './routes/_library.index' +import { Route as ProjectIndexRouteImport } from './routes/$project.index' +import { Route as LibraryProjectRouteImport } from './routes/_library.$project' +import { Route as LibraryProjectVersionIndexRouteImport } from './routes/_library.$project.$version.index' +import { Route as ProjectVersionDocsIndexRouteImport } from './routes/$project.$version.docs.index' +import { Route as ProjectVersionDocsFrameworkFrameworkRouteImport } from './routes/$project.$version.docs.framework.$framework' +import { Route as ProjectVersionDocsFrameworkFrameworkIndexRouteImport } from './routes/$project.$version.docs.framework.$framework.index' +import { Route as ProjectVersionDocsFrameworkFrameworkSplatRouteImport } from './routes/$project.$version.docs.framework.$framework.$' +import { Route as ProjectVersionDocsFrameworkFrameworkExamplesSplatRouteImport } from './routes/$project.$version.docs.framework.$framework.examples.$' // Create/Update Routes -const LibraryRoute = LibraryImport.update({ +const LibraryRoute = LibraryRouteImport.update({ id: '/_library', getParentRoute: () => rootRoute, } as any) -const LibraryIndexRoute = LibraryIndexImport.update({ +const LibraryIndexRoute = LibraryIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => LibraryRoute, } as any) -const ProjectIndexRoute = ProjectIndexImport.update({ +const ProjectIndexRoute = ProjectIndexRouteImport.update({ id: '/$project/', path: '/$project/', getParentRoute: () => rootRoute, } as any) -const LibraryProjectRoute = LibraryProjectImport.update({ +const LibraryProjectRoute = LibraryProjectRouteImport.update({ id: '/$project', path: '/$project', getParentRoute: () => LibraryRoute, } as any) -const LibraryProjectVersionIndexRoute = LibraryProjectVersionIndexImport.update( - { +const LibraryProjectVersionIndexRoute = + LibraryProjectVersionIndexRouteImport.update({ id: '/$version/', path: '/$version/', getParentRoute: () => LibraryProjectRoute, - } as any, -) + } as any) -const ProjectVersionDocsIndexRoute = ProjectVersionDocsIndexImport.update({ +const ProjectVersionDocsIndexRoute = ProjectVersionDocsIndexRouteImport.update({ id: '/$project/$version/docs/', path: '/$project/$version/docs/', getParentRoute: () => rootRoute, } as any) const ProjectVersionDocsFrameworkFrameworkRoute = - ProjectVersionDocsFrameworkFrameworkImport.update({ + ProjectVersionDocsFrameworkFrameworkRouteImport.update({ id: '/$project/$version/docs/framework/$framework', path: '/$project/$version/docs/framework/$framework', getParentRoute: () => rootRoute, } as any) const ProjectVersionDocsFrameworkFrameworkIndexRoute = - ProjectVersionDocsFrameworkFrameworkIndexImport.update({ + ProjectVersionDocsFrameworkFrameworkIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => ProjectVersionDocsFrameworkFrameworkRoute, } as any) const ProjectVersionDocsFrameworkFrameworkSplatRoute = - ProjectVersionDocsFrameworkFrameworkSplatImport.update({ + ProjectVersionDocsFrameworkFrameworkSplatRouteImport.update({ id: '/$', path: '/$', getParentRoute: () => ProjectVersionDocsFrameworkFrameworkRoute, } as any) const ProjectVersionDocsFrameworkFrameworkExamplesSplatRoute = - ProjectVersionDocsFrameworkFrameworkExamplesSplatImport.update({ + ProjectVersionDocsFrameworkFrameworkExamplesSplatRouteImport.update({ id: '/examples/$', path: '/examples/$', getParentRoute: () => ProjectVersionDocsFrameworkFrameworkRoute, @@ -97,75 +97,168 @@ declare module '@tanstack/react-router' { id: '/_library' path: '' fullPath: '' - preLoaderRoute: typeof LibraryImport + preLoaderRoute: typeof LibraryRouteImport parentRoute: typeof rootRoute } '/_library/$project': { id: '/_library/$project' path: '/$project' fullPath: '/$project' - preLoaderRoute: typeof LibraryProjectImport - parentRoute: typeof LibraryImport + preLoaderRoute: typeof LibraryProjectRouteImport + parentRoute: typeof LibraryRouteImport } '/$project/': { id: '/$project/' path: '/$project' fullPath: '/$project' - preLoaderRoute: typeof ProjectIndexImport + preLoaderRoute: typeof ProjectIndexRouteImport parentRoute: typeof rootRoute } '/_library/': { id: '/_library/' path: '/' fullPath: '/' - preLoaderRoute: typeof LibraryIndexImport - parentRoute: typeof LibraryImport + preLoaderRoute: typeof LibraryIndexRouteImport + parentRoute: typeof LibraryRouteImport } '/$project/$version/docs/': { id: '/$project/$version/docs/' path: '/$project/$version/docs' fullPath: '/$project/$version/docs' - preLoaderRoute: typeof ProjectVersionDocsIndexImport + preLoaderRoute: typeof ProjectVersionDocsIndexRouteImport parentRoute: typeof rootRoute } '/_library/$project/$version/': { id: '/_library/$project/$version/' path: '/$version' fullPath: '/$project/$version' - preLoaderRoute: typeof LibraryProjectVersionIndexImport - parentRoute: typeof LibraryProjectImport + preLoaderRoute: typeof LibraryProjectVersionIndexRouteImport + parentRoute: typeof LibraryProjectRouteImport } '/$project/$version/docs/framework/$framework': { id: '/$project/$version/docs/framework/$framework' path: '/$project/$version/docs/framework/$framework' fullPath: '/$project/$version/docs/framework/$framework' - preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkImport + preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkRouteImport parentRoute: typeof rootRoute } '/$project/$version/docs/framework/$framework/$': { id: '/$project/$version/docs/framework/$framework/$' path: '/$' fullPath: '/$project/$version/docs/framework/$framework/$' - preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkSplatImport - parentRoute: typeof ProjectVersionDocsFrameworkFrameworkImport + preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkSplatRouteImport + parentRoute: typeof ProjectVersionDocsFrameworkFrameworkRouteImport } '/$project/$version/docs/framework/$framework/': { id: '/$project/$version/docs/framework/$framework/' path: '/' fullPath: '/$project/$version/docs/framework/$framework/' - preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkIndexImport - parentRoute: typeof ProjectVersionDocsFrameworkFrameworkImport + preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkIndexRouteImport + parentRoute: typeof ProjectVersionDocsFrameworkFrameworkRouteImport } '/$project/$version/docs/framework/$framework/examples/$': { id: '/$project/$version/docs/framework/$framework/examples/$' path: '/examples/$' fullPath: '/$project/$version/docs/framework/$framework/examples/$' - preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkExamplesSplatImport - parentRoute: typeof ProjectVersionDocsFrameworkFrameworkImport + preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkExamplesSplatRouteImport + parentRoute: typeof ProjectVersionDocsFrameworkFrameworkRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/_library' { + const createFileRoute: CreateFileRoute< + '/_library', + FileRoutesByPath['/_library']['parentRoute'], + FileRoutesByPath['/_library']['id'], + FileRoutesByPath['/_library']['path'], + FileRoutesByPath['/_library']['fullPath'] + > +} +declare module './routes/_library.$project' { + const createFileRoute: CreateFileRoute< + '/_library/$project', + FileRoutesByPath['/_library/$project']['parentRoute'], + FileRoutesByPath['/_library/$project']['id'], + FileRoutesByPath['/_library/$project']['path'], + FileRoutesByPath['/_library/$project']['fullPath'] + > +} +declare module './routes/$project.index' { + const createFileRoute: CreateFileRoute< + '/$project/', + FileRoutesByPath['/$project/']['parentRoute'], + FileRoutesByPath['/$project/']['id'], + FileRoutesByPath['/$project/']['path'], + FileRoutesByPath['/$project/']['fullPath'] + > +} +declare module './routes/_library.index' { + const createFileRoute: CreateFileRoute< + '/_library/', + FileRoutesByPath['/_library/']['parentRoute'], + FileRoutesByPath['/_library/']['id'], + FileRoutesByPath['/_library/']['path'], + FileRoutesByPath['/_library/']['fullPath'] + > +} +declare module './routes/$project.$version.docs.index' { + const createFileRoute: CreateFileRoute< + '/$project/$version/docs/', + FileRoutesByPath['/$project/$version/docs/']['parentRoute'], + FileRoutesByPath['/$project/$version/docs/']['id'], + FileRoutesByPath['/$project/$version/docs/']['path'], + FileRoutesByPath['/$project/$version/docs/']['fullPath'] + > +} +declare module './routes/_library.$project.$version.index' { + const createFileRoute: CreateFileRoute< + '/_library/$project/$version/', + FileRoutesByPath['/_library/$project/$version/']['parentRoute'], + FileRoutesByPath['/_library/$project/$version/']['id'], + FileRoutesByPath['/_library/$project/$version/']['path'], + FileRoutesByPath['/_library/$project/$version/']['fullPath'] + > +} +declare module './routes/$project.$version.docs.framework.$framework' { + const createFileRoute: CreateFileRoute< + '/$project/$version/docs/framework/$framework', + FileRoutesByPath['/$project/$version/docs/framework/$framework']['parentRoute'], + FileRoutesByPath['/$project/$version/docs/framework/$framework']['id'], + FileRoutesByPath['/$project/$version/docs/framework/$framework']['path'], + FileRoutesByPath['/$project/$version/docs/framework/$framework']['fullPath'] + > +} +declare module './routes/$project.$version.docs.framework.$framework.$' { + const createFileRoute: CreateFileRoute< + '/$project/$version/docs/framework/$framework/$', + FileRoutesByPath['/$project/$version/docs/framework/$framework/$']['parentRoute'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/$']['id'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/$']['path'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/$']['fullPath'] + > +} +declare module './routes/$project.$version.docs.framework.$framework.index' { + const createFileRoute: CreateFileRoute< + '/$project/$version/docs/framework/$framework/', + FileRoutesByPath['/$project/$version/docs/framework/$framework/']['parentRoute'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/']['id'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/']['path'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/']['fullPath'] + > +} +declare module './routes/$project.$version.docs.framework.$framework.examples.$' { + const createFileRoute: CreateFileRoute< + '/$project/$version/docs/framework/$framework/examples/$', + FileRoutesByPath['/$project/$version/docs/framework/$framework/examples/$']['parentRoute'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/examples/$']['id'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/examples/$']['path'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/examples/$']['fullPath'] + > +} + // Create and export the route tree interface LibraryProjectRouteChildren { @@ -305,6 +398,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/react-start/website/src/router.tsx b/e2e/react-start/website/src/router.tsx index 28304cb690..7228520066 100644 --- a/e2e/react-start/website/src/router.tsx +++ b/e2e/react-start/website/src/router.tsx @@ -1,3 +1,4 @@ +/// import { createRouter as createTanStackRouter } from '@tanstack/react-router' import { routeTree } from './routeTree.gen' import { DefaultCatchBoundary } from './components/DefaultCatchBoundary' diff --git a/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.$.tsx b/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.$.tsx index 055f77622b..0c70abc68d 100644 --- a/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.$.tsx +++ b/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.$.tsx @@ -1,12 +1,10 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent, useLocation } from '@tanstack/react-router' import type { ErrorComponentProps } from '@tanstack/react-router' import { NotFound } from '~/components/NotFound' import { getDocument } from '~/server/document' import { capitalize, seo } from '~/utils/seo' -export const Route = createFileRoute( - '/$project/$version/docs/framework/$framework/$', -)({ +export const Route = createFileRoute({ loader: ({ params: { _splat } }) => getDocument({ data: _splat!, @@ -28,6 +26,7 @@ function PostErrorComponent({ error }: ErrorComponentProps) { } function Page() { + const pathname = useLocation({ select: (s) => s.pathname }) const post = Route.useLoaderData() return ( @@ -39,6 +38,11 @@ function Page() { {post.title}

{post.content}
+

+ + View Raw Content + +

) } diff --git a/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.examples.$.tsx b/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.examples.$.tsx index 5d5cbe324d..9e56e61762 100644 --- a/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.examples.$.tsx +++ b/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.examples.$.tsx @@ -1,10 +1,7 @@ -import { createFileRoute } from '@tanstack/react-router' import { NotFound } from '~/components/NotFound' import { capitalize, seo } from '~/utils/seo' -export const Route = createFileRoute( - '/$project/$version/docs/framework/$framework/examples/$', -)({ +export const Route = createFileRoute({ head: ({ params }) => ({ meta: seo({ title: `${capitalize(params._splat || '')} Example | TanStack ${capitalize(params.project)} ${capitalize(params.framework)}`, diff --git a/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.index.tsx b/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.index.tsx index 64a30c1ee1..b791228e26 100644 --- a/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.index.tsx +++ b/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.index.tsx @@ -1,9 +1,7 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' -export const Route = createFileRoute( - '/$project/$version/docs/framework/$framework/', -)({ - loader: () => { +export const Route = createFileRoute({ + beforeLoad: () => { throw redirect({ from: '/$project/$version/docs/framework/$framework/', to: '/$project/$version/docs/framework/$framework/$', diff --git a/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.tsx b/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.tsx index 5d1be9df39..f2b4a24d77 100644 --- a/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.tsx +++ b/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.tsx @@ -1,15 +1,8 @@ -import { - Link, - Outlet, - createFileRoute, - useLocation, -} from '@tanstack/react-router' +import { Link, Outlet, useLocation } from '@tanstack/react-router' import { getDocumentHeads } from '~/server/document' import { getProject } from '~/server/projects' -export const Route = createFileRoute( - '/$project/$version/docs/framework/$framework', -)({ +export const Route = createFileRoute({ loader: async ({ params: { project } }) => { const library = await getProject({ data: project }) const documents = await getDocumentHeads() diff --git a/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.{$}[.]md.tsx b/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.{$}[.]md.tsx new file mode 100644 index 0000000000..0272dc643d --- /dev/null +++ b/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.{$}[.]md.tsx @@ -0,0 +1,23 @@ +import { getDocument } from '~/server/document' + +export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ params }) => { + // @ts-expect-error + const splat = params['_splat'] || '' + const docPath = splat.split('.md')[0] + + if (!docPath) { + return new Response('Document not found', { status: 404 }) + } + + const doc = await getDocument({ data: docPath }) + const markdown = `# ${doc.title}\n\n${doc.content}` + + return new Response(markdown, { + headers: { + 'Content-Type': 'text/markdown', + 'Content-Disposition': `inline; filename="${doc.title}.md"`, + }, + }) + }, +}) diff --git a/e2e/react-start/website/src/routes/$project.$version.docs.index.tsx b/e2e/react-start/website/src/routes/$project.$version.docs.index.tsx index e379d81908..f15e022443 100644 --- a/e2e/react-start/website/src/routes/$project.$version.docs.index.tsx +++ b/e2e/react-start/website/src/routes/$project.$version.docs.index.tsx @@ -1,7 +1,7 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' -export const Route = createFileRoute('/$project/$version/docs/')({ - loader: () => { +export const Route = createFileRoute({ + beforeLoad: () => { throw redirect({ from: '/$project/$version/docs', to: '/$project/$version/docs/framework/$framework/$', diff --git a/e2e/react-start/website/src/routes/$project.index.tsx b/e2e/react-start/website/src/routes/$project.index.tsx index 9c6b935e83..6f5d49cef0 100644 --- a/e2e/react-start/website/src/routes/$project.index.tsx +++ b/e2e/react-start/website/src/routes/$project.index.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' -export const Route = createFileRoute('/$project/')({ +export const Route = createFileRoute({ loader: ({ params }) => { throw redirect({ to: '/$project/$version', diff --git a/e2e/react-start/website/src/routes/__root.tsx b/e2e/react-start/website/src/routes/__root.tsx index 1b98cc37f9..a9a0d5e47f 100644 --- a/e2e/react-start/website/src/routes/__root.tsx +++ b/e2e/react-start/website/src/routes/__root.tsx @@ -1,8 +1,8 @@ import { - Outlet, - createRootRoute, HeadContent, + Outlet, Scripts, + createRootRoute, } from '@tanstack/react-router' import { TanStackRouterDevtools } from '@tanstack/react-router-devtools' import * as React from 'react' diff --git a/e2e/react-start/website/src/routes/_library.$project.$version.index.tsx b/e2e/react-start/website/src/routes/_library.$project.$version.index.tsx index d91b72d2b7..25023822d5 100644 --- a/e2e/react-start/website/src/routes/_library.$project.$version.index.tsx +++ b/e2e/react-start/website/src/routes/_library.$project.$version.index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/_library/$project/$version/')({ +export const Route = createFileRoute({ component: Page, }) @@ -14,7 +14,11 @@ function Page() {

version: {params.version}

- + Get started with our documentation.

diff --git a/e2e/react-start/website/src/routes/_library.$project.tsx b/e2e/react-start/website/src/routes/_library.$project.tsx index 3384fcf3a0..8fb100b563 100644 --- a/e2e/react-start/website/src/routes/_library.$project.tsx +++ b/e2e/react-start/website/src/routes/_library.$project.tsx @@ -1,8 +1,8 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' import { getProject } from '~/server/projects' import { seo } from '~/utils/seo' -export const Route = createFileRoute('/_library/$project')({ +export const Route = createFileRoute({ loader: ({ params: { project } }) => getProject({ data: project }), head: ({ loaderData }) => ({ meta: seo({ title: `TanStack ${loaderData?.name || 'Project'}` }), diff --git a/e2e/react-start/website/src/routes/_library.index.tsx b/e2e/react-start/website/src/routes/_library.index.tsx index f08b6c633a..20e6a7468f 100644 --- a/e2e/react-start/website/src/routes/_library.index.tsx +++ b/e2e/react-start/website/src/routes/_library.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_library/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-start/website/src/routes/_library.tsx b/e2e/react-start/website/src/routes/_library.tsx index e120515350..c3970050ca 100644 --- a/e2e/react-start/website/src/routes/_library.tsx +++ b/e2e/react-start/website/src/routes/_library.tsx @@ -1,12 +1,7 @@ -import { - Link, - Outlet, - createFileRoute, - useLocation, -} from '@tanstack/react-router' +import { Link, Outlet, useLocation } from '@tanstack/react-router' import { getProjects } from '~/server/projects' -export const Route = createFileRoute('/_library')({ +export const Route = createFileRoute({ loader: async () => { const projects = await getProjects() return { diff --git a/e2e/react-start/website/src/ssr.tsx b/e2e/react-start/website/src/ssr.tsx deleted file mode 100644 index 8981a9a338..0000000000 --- a/e2e/react-start/website/src/ssr.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/e2e/react-start/website/tests/app.spec.ts b/e2e/react-start/website/tests/app.spec.ts index f115180956..179fa81bf8 100644 --- a/e2e/react-start/website/tests/app.spec.ts +++ b/e2e/react-start/website/tests/app.spec.ts @@ -17,3 +17,17 @@ test('resolves to the overview docs page', async ({ page }) => { '/router/latest/docs/framework/react/overview', ) }) + +test('clicking on Documentation link navigates to the overview docs page', async ({ + page, +}) => { + await page.goto('/router') + await page.waitForLoadState('networkidle') + + const documentationLink = page.getByLabel('Documentation') + await documentationLink.click() + await page.waitForLoadState('networkidle') + + const pathname = new URL(page.url()).pathname + expect(pathname).toBe('/router/latest/docs/framework/react/overview') +}) diff --git a/e2e/react-start/website/vite.config.ts b/e2e/react-start/website/vite.config.ts new file mode 100644 index 0000000000..698e4856da --- /dev/null +++ b/e2e/react-start/website/vite.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/e2e/solid-router/basic-file-based-code-splitting/src/routeTree.gen.ts b/e2e/solid-router/basic-file-based-code-splitting/src/routeTree.gen.ts index b7e80e980b..d79292e309 100644 --- a/e2e/solid-router/basic-file-based-code-splitting/src/routeTree.gen.ts +++ b/e2e/solid-router/basic-file-based-code-splitting/src/routeTree.gen.ts @@ -10,73 +10,74 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as WithoutLoaderImport } from './routes/without-loader' -import { Route as ViewportTestImport } from './routes/viewport-test' -import { Route as PostsImport } from './routes/posts' -import { Route as LayoutImport } from './routes/_layout' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as LayoutLayout2Import } from './routes/_layout/_layout-2' -import { Route as LayoutLayout2LayoutBImport } from './routes/_layout/_layout-2/layout-b' -import { Route as LayoutLayout2LayoutAImport } from './routes/_layout/_layout-2/layout-a' +import { Route as WithoutLoaderRouteImport } from './routes/without-loader' +import { Route as ViewportTestRouteImport } from './routes/viewport-test' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as LayoutRouteImport } from './routes/_layout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2' +import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b' +import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a' // Create/Update Routes -const WithoutLoaderRoute = WithoutLoaderImport.update({ +const WithoutLoaderRoute = WithoutLoaderRouteImport.update({ id: '/without-loader', path: '/without-loader', getParentRoute: () => rootRoute, } as any) -const ViewportTestRoute = ViewportTestImport.update({ +const ViewportTestRoute = ViewportTestRouteImport.update({ id: '/viewport-test', path: '/viewport-test', getParentRoute: () => rootRoute, } as any) -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const LayoutRoute = LayoutImport.update({ +const LayoutRoute = LayoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const LayoutLayout2Route = LayoutLayout2Import.update({ +const LayoutLayout2Route = LayoutLayout2RouteImport.update({ id: '/_layout-2', getParentRoute: () => LayoutRoute, } as any) -const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBImport.update({ +const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => LayoutLayout2Route, } as any) -const LayoutLayout2LayoutARoute = LayoutLayout2LayoutAImport.update({ +const LayoutLayout2LayoutARoute = LayoutLayout2LayoutARouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => LayoutLayout2Route, @@ -90,75 +91,168 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/viewport-test': { id: '/viewport-test' path: '/viewport-test' fullPath: '/viewport-test' - preLoaderRoute: typeof ViewportTestImport + preLoaderRoute: typeof ViewportTestRouteImport parentRoute: typeof rootRoute } '/without-loader': { id: '/without-loader' path: '/without-loader' fullPath: '/without-loader' - preLoaderRoute: typeof WithoutLoaderImport + preLoaderRoute: typeof WithoutLoaderRouteImport parentRoute: typeof rootRoute } '/_layout/_layout-2': { id: '/_layout/_layout-2' path: '' fullPath: '' - preLoaderRoute: typeof LayoutLayout2Import - parentRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutLayout2RouteImport + parentRoute: typeof LayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/_layout/_layout-2/layout-a': { id: '/_layout/_layout-2/layout-a' path: '/layout-a' fullPath: '/layout-a' - preLoaderRoute: typeof LayoutLayout2LayoutAImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutARouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/_layout/_layout-2/layout-b': { id: '/_layout/_layout-2/layout-b' path: '/layout-b' fullPath: '/layout-b' - preLoaderRoute: typeof LayoutLayout2LayoutBImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport + parentRoute: typeof LayoutLayout2RouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/viewport-test' { + const createFileRoute: CreateFileRoute< + '/viewport-test', + FileRoutesByPath['/viewport-test']['parentRoute'], + FileRoutesByPath['/viewport-test']['id'], + FileRoutesByPath['/viewport-test']['path'], + FileRoutesByPath['/viewport-test']['fullPath'] + > +} +declare module './routes/without-loader' { + const createFileRoute: CreateFileRoute< + '/without-loader', + FileRoutesByPath['/without-loader']['parentRoute'], + FileRoutesByPath['/without-loader']['id'], + FileRoutesByPath['/without-loader']['path'], + FileRoutesByPath['/without-loader']['fullPath'] + > +} +declare module './routes/_layout/_layout-2' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2', + FileRoutesByPath['/_layout/_layout-2']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2']['id'], + FileRoutesByPath['/_layout/_layout-2']['path'], + FileRoutesByPath['/_layout/_layout-2']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-a' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-a', + FileRoutesByPath['/_layout/_layout-2/layout-a']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-b' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-b', + FileRoutesByPath['/_layout/_layout-2/layout-b']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['fullPath'] + > +} + // Create and export the route tree interface LayoutLayout2RouteChildren { @@ -291,3 +385,69 @@ const rootRouteChildren: RootRouteChildren = { export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() + +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [ + "/", + "/_layout", + "/posts", + "/viewport-test", + "/without-loader" + ] + }, + "/": { + "filePath": "index.tsx" + }, + "/_layout": { + "filePath": "_layout.tsx", + "children": [ + "/_layout/_layout-2" + ] + }, + "/posts": { + "filePath": "posts.tsx", + "children": [ + "/posts/$postId", + "/posts/" + ] + }, + "/viewport-test": { + "filePath": "viewport-test.tsx" + }, + "/without-loader": { + "filePath": "without-loader.tsx" + }, + "/_layout/_layout-2": { + "filePath": "_layout/_layout-2.tsx", + "parent": "/_layout", + "children": [ + "/_layout/_layout-2/layout-a", + "/_layout/_layout-2/layout-b" + ] + }, + "/posts/$postId": { + "filePath": "posts.$postId.tsx", + "parent": "/posts" + }, + "/posts/": { + "filePath": "posts.index.tsx", + "parent": "/posts" + }, + "/_layout/_layout-2/layout-a": { + "filePath": "_layout/_layout-2/layout-a.tsx", + "parent": "/_layout/_layout-2" + }, + "/_layout/_layout-2/layout-b": { + "filePath": "_layout/_layout-2/layout-b.tsx", + "parent": "/_layout/_layout-2" + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout.tsx b/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout.tsx index d43b4ef5f5..c549175638 100644 --- a/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout.tsx +++ b/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2.tsx b/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2.tsx index 7a5a3623a0..efeca5ce86 100644 --- a/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2.tsx +++ b/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_layout/_layout-2')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-a.tsx b/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-a.tsx index b69951b246..a190b24202 100644 --- a/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-a.tsx +++ b/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-b.tsx b/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-b.tsx index 30dbcce90f..505f8f6fbf 100644 --- a/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-b.tsx +++ b/e2e/solid-router/basic-file-based-code-splitting/src/routes/_layout/_layout-2/layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/solid-router/basic-file-based-code-splitting/src/routes/index.tsx b/e2e/solid-router/basic-file-based-code-splitting/src/routes/index.tsx index bdfb4c7676..510db79b73 100644 --- a/e2e/solid-router/basic-file-based-code-splitting/src/routes/index.tsx +++ b/e2e/solid-router/basic-file-based-code-splitting/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/solid-router/basic-file-based-code-splitting/src/routes/posts.$postId.tsx b/e2e/solid-router/basic-file-based-code-splitting/src/routes/posts.$postId.tsx index 105f08d64e..e23c29a21a 100644 --- a/e2e/solid-router/basic-file-based-code-splitting/src/routes/posts.$postId.tsx +++ b/e2e/solid-router/basic-file-based-code-splitting/src/routes/posts.$postId.tsx @@ -1,4 +1,4 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/solid-router' +import { ErrorComponent } from '@tanstack/solid-router' import { fetchPost } from '../posts' import type { ErrorComponentProps } from '@tanstack/solid-router' @@ -6,7 +6,7 @@ export function PostErrorComponent({ error }: ErrorComponentProps) { return } -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent as any, notFoundComponent: () => { diff --git a/e2e/solid-router/basic-file-based-code-splitting/src/routes/posts.index.tsx b/e2e/solid-router/basic-file-based-code-splitting/src/routes/posts.index.tsx index 33d0386c19..13529228bb 100644 --- a/e2e/solid-router/basic-file-based-code-splitting/src/routes/posts.index.tsx +++ b/e2e/solid-router/basic-file-based-code-splitting/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/solid-router/basic-file-based-code-splitting/src/routes/posts.tsx b/e2e/solid-router/basic-file-based-code-splitting/src/routes/posts.tsx index 11a999f50a..2e28f9beb3 100644 --- a/e2e/solid-router/basic-file-based-code-splitting/src/routes/posts.tsx +++ b/e2e/solid-router/basic-file-based-code-splitting/src/routes/posts.tsx @@ -1,7 +1,7 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsComponent, }) diff --git a/e2e/solid-router/basic-file-based-code-splitting/src/routes/viewport-test.tsx b/e2e/solid-router/basic-file-based-code-splitting/src/routes/viewport-test.tsx index 22dd8fd282..b182feb7b1 100644 --- a/e2e/solid-router/basic-file-based-code-splitting/src/routes/viewport-test.tsx +++ b/e2e/solid-router/basic-file-based-code-splitting/src/routes/viewport-test.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/viewport-test')({ +export const Route = createFileRoute({ component: () =>
Hello /viewport-test!
, }) diff --git a/e2e/solid-router/basic-file-based-code-splitting/src/routes/without-loader.tsx b/e2e/solid-router/basic-file-based-code-splitting/src/routes/without-loader.tsx index 1506595204..af692bdaca 100644 --- a/e2e/solid-router/basic-file-based-code-splitting/src/routes/without-loader.tsx +++ b/e2e/solid-router/basic-file-based-code-splitting/src/routes/without-loader.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/without-loader')({ +export const Route = createFileRoute({ component: () =>
Hello /without-loader!
, }) diff --git a/e2e/solid-router/basic-file-based/src/routeTree.gen.ts b/e2e/solid-router/basic-file-based/src/routeTree.gen.ts index e41dbee76d..68e26f41f4 100644 --- a/e2e/solid-router/basic-file-based/src/routeTree.gen.ts +++ b/e2e/solid-router/basic-file-based/src/routeTree.gen.ts @@ -12,111 +12,112 @@ import { createFileRoute } from '@tanstack/solid-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostsImport } from './routes/posts' -import { Route as EditingBImport } from './routes/editing-b' -import { Route as EditingAImport } from './routes/editing-a' -import { Route as AnchorImport } from './routes/anchor' -import { Route as LayoutImport } from './routes/_layout' -import { Route as IndexImport } from './routes/index' -import { Route as RedirectIndexImport } from './routes/redirect/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as RedirectTargetImport } from './routes/redirect/$target' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as LayoutLayout2Import } from './routes/_layout/_layout-2' -import { Route as groupLazyinsideImport } from './routes/(group)/lazyinside' -import { Route as groupInsideImport } from './routes/(group)/inside' -import { Route as groupLayoutImport } from './routes/(group)/_layout' -import { Route as anotherGroupOnlyrouteinsideImport } from './routes/(another-group)/onlyrouteinside' -import { Route as RedirectTargetIndexImport } from './routes/redirect/$target/index' -import { Route as RedirectPreloadThirdImport } from './routes/redirect/preload/third' -import { Route as RedirectPreloadSecondImport } from './routes/redirect/preload/second' -import { Route as RedirectPreloadFirstImport } from './routes/redirect/preload/first' -import { Route as RedirectTargetViaLoaderImport } from './routes/redirect/$target/via-loader' -import { Route as RedirectTargetViaBeforeLoadImport } from './routes/redirect/$target/via-beforeLoad' -import { Route as PostsPostIdEditImport } from './routes/posts_.$postId.edit' -import { Route as ParamsSingleValueImport } from './routes/params.single.$value' -import { Route as LayoutLayout2LayoutBImport } from './routes/_layout/_layout-2/layout-b' -import { Route as LayoutLayout2LayoutAImport } from './routes/_layout/_layout-2/layout-a' -import { Route as groupSubfolderInsideImport } from './routes/(group)/subfolder/inside' -import { Route as groupLayoutInsidelayoutImport } from './routes/(group)/_layout.insidelayout' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as EditingBRouteImport } from './routes/editing-b' +import { Route as EditingARouteImport } from './routes/editing-a' +import { Route as AnchorRouteImport } from './routes/anchor' +import { Route as LayoutRouteImport } from './routes/_layout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as RedirectIndexRouteImport } from './routes/redirect/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as RedirectTargetRouteImport } from './routes/redirect/$target' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2' +import { Route as groupLazyinsideRouteImport } from './routes/(group)/lazyinside' +import { Route as groupInsideRouteImport } from './routes/(group)/inside' +import { Route as groupLayoutRouteImport } from './routes/(group)/_layout' +import { Route as anotherGroupOnlyrouteinsideRouteImport } from './routes/(another-group)/onlyrouteinside' +import { Route as RedirectTargetIndexRouteImport } from './routes/redirect/$target/index' +import { Route as RedirectPreloadThirdRouteImport } from './routes/redirect/preload/third' +import { Route as RedirectPreloadSecondRouteImport } from './routes/redirect/preload/second' +import { Route as RedirectPreloadFirstRouteImport } from './routes/redirect/preload/first' +import { Route as RedirectTargetViaLoaderRouteImport } from './routes/redirect/$target/via-loader' +import { Route as RedirectTargetViaBeforeLoadRouteImport } from './routes/redirect/$target/via-beforeLoad' +import { Route as PostsPostIdEditRouteImport } from './routes/posts_.$postId.edit' +import { Route as ParamsSingleValueRouteImport } from './routes/params.single.$value' +import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b' +import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a' +import { Route as groupSubfolderInsideRouteImport } from './routes/(group)/subfolder/inside' +import { Route as groupLayoutInsidelayoutRouteImport } from './routes/(group)/_layout.insidelayout' // Create Virtual Routes -const groupImport = createFileRoute('/(group)')() +const groupRouteImport = createFileRoute('/(group)')() // Create/Update Routes -const groupRoute = groupImport.update({ +const groupRoute = groupRouteImport.update({ id: '/(group)', getParentRoute: () => rootRoute, } as any) -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const EditingBRoute = EditingBImport.update({ +const EditingBRoute = EditingBRouteImport.update({ id: '/editing-b', path: '/editing-b', getParentRoute: () => rootRoute, } as any) -const EditingARoute = EditingAImport.update({ +const EditingARoute = EditingARouteImport.update({ id: '/editing-a', path: '/editing-a', getParentRoute: () => rootRoute, } as any) -const AnchorRoute = AnchorImport.update({ +const AnchorRoute = AnchorRouteImport.update({ id: '/anchor', path: '/anchor', getParentRoute: () => rootRoute, } as any) -const LayoutRoute = LayoutImport.update({ +const LayoutRoute = LayoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const RedirectIndexRoute = RedirectIndexImport.update({ +const RedirectIndexRoute = RedirectIndexRouteImport.update({ id: '/redirect/', path: '/redirect/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const RedirectTargetRoute = RedirectTargetImport.update({ +const RedirectTargetRoute = RedirectTargetRouteImport.update({ id: '/redirect/$target', path: '/redirect/$target', getParentRoute: () => rootRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const LayoutLayout2Route = LayoutLayout2Import.update({ +const LayoutLayout2Route = LayoutLayout2RouteImport.update({ id: '/_layout-2', getParentRoute: () => LayoutRoute, } as any) -const groupLazyinsideRoute = groupLazyinsideImport +const groupLazyinsideRoute = groupLazyinsideRouteImport .update({ id: '/lazyinside', path: '/lazyinside', @@ -124,92 +125,92 @@ const groupLazyinsideRoute = groupLazyinsideImport } as any) .lazy(() => import('./routes/(group)/lazyinside.lazy').then((d) => d.Route)) -const groupInsideRoute = groupInsideImport.update({ +const groupInsideRoute = groupInsideRouteImport.update({ id: '/inside', path: '/inside', getParentRoute: () => groupRoute, } as any) -const groupLayoutRoute = groupLayoutImport.update({ +const groupLayoutRoute = groupLayoutRouteImport.update({ id: '/_layout', getParentRoute: () => groupRoute, } as any) const anotherGroupOnlyrouteinsideRoute = - anotherGroupOnlyrouteinsideImport.update({ + anotherGroupOnlyrouteinsideRouteImport.update({ id: '/(another-group)/onlyrouteinside', path: '/onlyrouteinside', getParentRoute: () => rootRoute, } as any) -const RedirectTargetIndexRoute = RedirectTargetIndexImport.update({ +const RedirectTargetIndexRoute = RedirectTargetIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => RedirectTargetRoute, } as any) -const RedirectPreloadThirdRoute = RedirectPreloadThirdImport.update({ +const RedirectPreloadThirdRoute = RedirectPreloadThirdRouteImport.update({ id: '/redirect/preload/third', path: '/redirect/preload/third', getParentRoute: () => rootRoute, } as any) -const RedirectPreloadSecondRoute = RedirectPreloadSecondImport.update({ +const RedirectPreloadSecondRoute = RedirectPreloadSecondRouteImport.update({ id: '/redirect/preload/second', path: '/redirect/preload/second', getParentRoute: () => rootRoute, } as any) -const RedirectPreloadFirstRoute = RedirectPreloadFirstImport.update({ +const RedirectPreloadFirstRoute = RedirectPreloadFirstRouteImport.update({ id: '/redirect/preload/first', path: '/redirect/preload/first', getParentRoute: () => rootRoute, } as any) -const RedirectTargetViaLoaderRoute = RedirectTargetViaLoaderImport.update({ +const RedirectTargetViaLoaderRoute = RedirectTargetViaLoaderRouteImport.update({ id: '/via-loader', path: '/via-loader', getParentRoute: () => RedirectTargetRoute, } as any) const RedirectTargetViaBeforeLoadRoute = - RedirectTargetViaBeforeLoadImport.update({ + RedirectTargetViaBeforeLoadRouteImport.update({ id: '/via-beforeLoad', path: '/via-beforeLoad', getParentRoute: () => RedirectTargetRoute, } as any) -const PostsPostIdEditRoute = PostsPostIdEditImport.update({ +const PostsPostIdEditRoute = PostsPostIdEditRouteImport.update({ id: '/posts_/$postId/edit', path: '/posts/$postId/edit', getParentRoute: () => rootRoute, } as any) -const ParamsSingleValueRoute = ParamsSingleValueImport.update({ +const ParamsSingleValueRoute = ParamsSingleValueRouteImport.update({ id: '/params/single/$value', path: '/params/single/$value', getParentRoute: () => rootRoute, } as any) -const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBImport.update({ +const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => LayoutLayout2Route, } as any) -const LayoutLayout2LayoutARoute = LayoutLayout2LayoutAImport.update({ +const LayoutLayout2LayoutARoute = LayoutLayout2LayoutARouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => LayoutLayout2Route, } as any) -const groupSubfolderInsideRoute = groupSubfolderInsideImport.update({ +const groupSubfolderInsideRoute = groupSubfolderInsideRouteImport.update({ id: '/subfolder/inside', path: '/subfolder/inside', getParentRoute: () => groupRoute, } as any) -const groupLayoutInsidelayoutRoute = groupLayoutInsidelayoutImport.update({ +const groupLayoutInsidelayoutRoute = groupLayoutInsidelayoutRouteImport.update({ id: '/insidelayout', path: '/insidelayout', getParentRoute: () => groupLayoutRoute, @@ -223,201 +224,465 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutRouteImport parentRoute: typeof rootRoute } '/anchor': { id: '/anchor' path: '/anchor' fullPath: '/anchor' - preLoaderRoute: typeof AnchorImport + preLoaderRoute: typeof AnchorRouteImport parentRoute: typeof rootRoute } '/editing-a': { id: '/editing-a' path: '/editing-a' fullPath: '/editing-a' - preLoaderRoute: typeof EditingAImport + preLoaderRoute: typeof EditingARouteImport parentRoute: typeof rootRoute } '/editing-b': { id: '/editing-b' path: '/editing-b' fullPath: '/editing-b' - preLoaderRoute: typeof EditingBImport + preLoaderRoute: typeof EditingBRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/(another-group)/onlyrouteinside': { id: '/(another-group)/onlyrouteinside' path: '/onlyrouteinside' fullPath: '/onlyrouteinside' - preLoaderRoute: typeof anotherGroupOnlyrouteinsideImport + preLoaderRoute: typeof anotherGroupOnlyrouteinsideRouteImport parentRoute: typeof rootRoute } '/(group)': { id: '/(group)' path: '/' fullPath: '/' - preLoaderRoute: typeof groupImport + preLoaderRoute: typeof groupRouteImport parentRoute: typeof rootRoute } '/(group)/_layout': { id: '/(group)/_layout' path: '/' fullPath: '/' - preLoaderRoute: typeof groupLayoutImport + preLoaderRoute: typeof groupLayoutRouteImport parentRoute: typeof groupRoute } '/(group)/inside': { id: '/(group)/inside' path: '/inside' fullPath: '/inside' - preLoaderRoute: typeof groupInsideImport - parentRoute: typeof groupImport + preLoaderRoute: typeof groupInsideRouteImport + parentRoute: typeof groupRouteImport } '/(group)/lazyinside': { id: '/(group)/lazyinside' path: '/lazyinside' fullPath: '/lazyinside' - preLoaderRoute: typeof groupLazyinsideImport - parentRoute: typeof groupImport + preLoaderRoute: typeof groupLazyinsideRouteImport + parentRoute: typeof groupRouteImport } '/_layout/_layout-2': { id: '/_layout/_layout-2' path: '' fullPath: '' - preLoaderRoute: typeof LayoutLayout2Import - parentRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutLayout2RouteImport + parentRoute: typeof LayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/redirect/$target': { id: '/redirect/$target' path: '/redirect/$target' fullPath: '/redirect/$target' - preLoaderRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetRouteImport parentRoute: typeof rootRoute } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/redirect/': { id: '/redirect/' path: '/redirect' fullPath: '/redirect' - preLoaderRoute: typeof RedirectIndexImport + preLoaderRoute: typeof RedirectIndexRouteImport parentRoute: typeof rootRoute } '/(group)/_layout/insidelayout': { id: '/(group)/_layout/insidelayout' path: '/insidelayout' fullPath: '/insidelayout' - preLoaderRoute: typeof groupLayoutInsidelayoutImport - parentRoute: typeof groupLayoutImport + preLoaderRoute: typeof groupLayoutInsidelayoutRouteImport + parentRoute: typeof groupLayoutRouteImport } '/(group)/subfolder/inside': { id: '/(group)/subfolder/inside' path: '/subfolder/inside' fullPath: '/subfolder/inside' - preLoaderRoute: typeof groupSubfolderInsideImport - parentRoute: typeof groupImport + preLoaderRoute: typeof groupSubfolderInsideRouteImport + parentRoute: typeof groupRouteImport } '/_layout/_layout-2/layout-a': { id: '/_layout/_layout-2/layout-a' path: '/layout-a' fullPath: '/layout-a' - preLoaderRoute: typeof LayoutLayout2LayoutAImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutARouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/_layout/_layout-2/layout-b': { id: '/_layout/_layout-2/layout-b' path: '/layout-b' fullPath: '/layout-b' - preLoaderRoute: typeof LayoutLayout2LayoutBImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/params/single/$value': { id: '/params/single/$value' path: '/params/single/$value' fullPath: '/params/single/$value' - preLoaderRoute: typeof ParamsSingleValueImport + preLoaderRoute: typeof ParamsSingleValueRouteImport parentRoute: typeof rootRoute } '/posts_/$postId/edit': { id: '/posts_/$postId/edit' path: '/posts/$postId/edit' fullPath: '/posts/$postId/edit' - preLoaderRoute: typeof PostsPostIdEditImport + preLoaderRoute: typeof PostsPostIdEditRouteImport parentRoute: typeof rootRoute } '/redirect/$target/via-beforeLoad': { id: '/redirect/$target/via-beforeLoad' path: '/via-beforeLoad' fullPath: '/redirect/$target/via-beforeLoad' - preLoaderRoute: typeof RedirectTargetViaBeforeLoadImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetViaBeforeLoadRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/via-loader': { id: '/redirect/$target/via-loader' path: '/via-loader' fullPath: '/redirect/$target/via-loader' - preLoaderRoute: typeof RedirectTargetViaLoaderImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetViaLoaderRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/preload/first': { id: '/redirect/preload/first' path: '/redirect/preload/first' fullPath: '/redirect/preload/first' - preLoaderRoute: typeof RedirectPreloadFirstImport + preLoaderRoute: typeof RedirectPreloadFirstRouteImport parentRoute: typeof rootRoute } '/redirect/preload/second': { id: '/redirect/preload/second' path: '/redirect/preload/second' fullPath: '/redirect/preload/second' - preLoaderRoute: typeof RedirectPreloadSecondImport + preLoaderRoute: typeof RedirectPreloadSecondRouteImport parentRoute: typeof rootRoute } '/redirect/preload/third': { id: '/redirect/preload/third' path: '/redirect/preload/third' fullPath: '/redirect/preload/third' - preLoaderRoute: typeof RedirectPreloadThirdImport + preLoaderRoute: typeof RedirectPreloadThirdRouteImport parentRoute: typeof rootRoute } '/redirect/$target/': { id: '/redirect/$target/' path: '/' fullPath: '/redirect/$target/' - preLoaderRoute: typeof RedirectTargetIndexImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetIndexRouteImport + parentRoute: typeof RedirectTargetRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/anchor' { + const createFileRoute: CreateFileRoute< + '/anchor', + FileRoutesByPath['/anchor']['parentRoute'], + FileRoutesByPath['/anchor']['id'], + FileRoutesByPath['/anchor']['path'], + FileRoutesByPath['/anchor']['fullPath'] + > +} +declare module './routes/editing-a' { + const createFileRoute: CreateFileRoute< + '/editing-a', + FileRoutesByPath['/editing-a']['parentRoute'], + FileRoutesByPath['/editing-a']['id'], + FileRoutesByPath['/editing-a']['path'], + FileRoutesByPath['/editing-a']['fullPath'] + > +} +declare module './routes/editing-b' { + const createFileRoute: CreateFileRoute< + '/editing-b', + FileRoutesByPath['/editing-b']['parentRoute'], + FileRoutesByPath['/editing-b']['id'], + FileRoutesByPath['/editing-b']['path'], + FileRoutesByPath['/editing-b']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/(another-group)/onlyrouteinside' { + const createFileRoute: CreateFileRoute< + '/(another-group)/onlyrouteinside', + FileRoutesByPath['/(another-group)/onlyrouteinside']['parentRoute'], + FileRoutesByPath['/(another-group)/onlyrouteinside']['id'], + FileRoutesByPath['/(another-group)/onlyrouteinside']['path'], + FileRoutesByPath['/(another-group)/onlyrouteinside']['fullPath'] + > +} +declare module './routes/(group)' { + const createFileRoute: CreateFileRoute< + '/(group)', + FileRoutesByPath['/(group)']['parentRoute'], + FileRoutesByPath['/(group)']['id'], + FileRoutesByPath['/(group)']['path'], + FileRoutesByPath['/(group)']['fullPath'] + > +} +declare module './routes/(group)/_layout' { + const createFileRoute: CreateFileRoute< + '/(group)/_layout', + FileRoutesByPath['/(group)/_layout']['parentRoute'], + FileRoutesByPath['/(group)/_layout']['id'], + FileRoutesByPath['/(group)/_layout']['path'], + FileRoutesByPath['/(group)/_layout']['fullPath'] + > +} +declare module './routes/(group)/inside' { + const createFileRoute: CreateFileRoute< + '/(group)/inside', + FileRoutesByPath['/(group)/inside']['parentRoute'], + FileRoutesByPath['/(group)/inside']['id'], + FileRoutesByPath['/(group)/inside']['path'], + FileRoutesByPath['/(group)/inside']['fullPath'] + > +} +declare module './routes/(group)/lazyinside' { + const createFileRoute: CreateFileRoute< + '/(group)/lazyinside', + FileRoutesByPath['/(group)/lazyinside']['parentRoute'], + FileRoutesByPath['/(group)/lazyinside']['id'], + FileRoutesByPath['/(group)/lazyinside']['path'], + FileRoutesByPath['/(group)/lazyinside']['fullPath'] + > +} +declare module './routes/(group)/lazyinside.lazy' { + const createLazyFileRoute: CreateFileRoute< + '/(group)/lazyinside', + FileRoutesByPath['/(group)/lazyinside']['parentRoute'], + FileRoutesByPath['/(group)/lazyinside']['id'], + FileRoutesByPath['/(group)/lazyinside']['path'], + FileRoutesByPath['/(group)/lazyinside']['fullPath'] + > +} +declare module './routes/_layout/_layout-2' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2', + FileRoutesByPath['/_layout/_layout-2']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2']['id'], + FileRoutesByPath['/_layout/_layout-2']['path'], + FileRoutesByPath['/_layout/_layout-2']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/redirect/$target' { + const createFileRoute: CreateFileRoute< + '/redirect/$target', + FileRoutesByPath['/redirect/$target']['parentRoute'], + FileRoutesByPath['/redirect/$target']['id'], + FileRoutesByPath['/redirect/$target']['path'], + FileRoutesByPath['/redirect/$target']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/redirect/index' { + const createFileRoute: CreateFileRoute< + '/redirect/', + FileRoutesByPath['/redirect/']['parentRoute'], + FileRoutesByPath['/redirect/']['id'], + FileRoutesByPath['/redirect/']['path'], + FileRoutesByPath['/redirect/']['fullPath'] + > +} +declare module './routes/(group)/_layout.insidelayout' { + const createFileRoute: CreateFileRoute< + '/(group)/_layout/insidelayout', + FileRoutesByPath['/(group)/_layout/insidelayout']['parentRoute'], + FileRoutesByPath['/(group)/_layout/insidelayout']['id'], + FileRoutesByPath['/(group)/_layout/insidelayout']['path'], + FileRoutesByPath['/(group)/_layout/insidelayout']['fullPath'] + > +} +declare module './routes/(group)/subfolder/inside' { + const createFileRoute: CreateFileRoute< + '/(group)/subfolder/inside', + FileRoutesByPath['/(group)/subfolder/inside']['parentRoute'], + FileRoutesByPath['/(group)/subfolder/inside']['id'], + FileRoutesByPath['/(group)/subfolder/inside']['path'], + FileRoutesByPath['/(group)/subfolder/inside']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-a' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-a', + FileRoutesByPath['/_layout/_layout-2/layout-a']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-b' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-b', + FileRoutesByPath['/_layout/_layout-2/layout-b']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['fullPath'] + > +} +declare module './routes/params.single.$value' { + const createFileRoute: CreateFileRoute< + '/params/single/$value', + FileRoutesByPath['/params/single/$value']['parentRoute'], + FileRoutesByPath['/params/single/$value']['id'], + FileRoutesByPath['/params/single/$value']['path'], + FileRoutesByPath['/params/single/$value']['fullPath'] + > +} +declare module './routes/posts_.$postId.edit' { + const createFileRoute: CreateFileRoute< + '/posts_/$postId/edit', + FileRoutesByPath['/posts_/$postId/edit']['parentRoute'], + FileRoutesByPath['/posts_/$postId/edit']['id'], + FileRoutesByPath['/posts_/$postId/edit']['path'], + FileRoutesByPath['/posts_/$postId/edit']['fullPath'] + > +} +declare module './routes/redirect/$target/via-beforeLoad' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/via-beforeLoad', + FileRoutesByPath['/redirect/$target/via-beforeLoad']['parentRoute'], + FileRoutesByPath['/redirect/$target/via-beforeLoad']['id'], + FileRoutesByPath['/redirect/$target/via-beforeLoad']['path'], + FileRoutesByPath['/redirect/$target/via-beforeLoad']['fullPath'] + > +} +declare module './routes/redirect/$target/via-loader' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/via-loader', + FileRoutesByPath['/redirect/$target/via-loader']['parentRoute'], + FileRoutesByPath['/redirect/$target/via-loader']['id'], + FileRoutesByPath['/redirect/$target/via-loader']['path'], + FileRoutesByPath['/redirect/$target/via-loader']['fullPath'] + > +} +declare module './routes/redirect/preload/first' { + const createFileRoute: CreateFileRoute< + '/redirect/preload/first', + FileRoutesByPath['/redirect/preload/first']['parentRoute'], + FileRoutesByPath['/redirect/preload/first']['id'], + FileRoutesByPath['/redirect/preload/first']['path'], + FileRoutesByPath['/redirect/preload/first']['fullPath'] + > +} +declare module './routes/redirect/preload/second' { + const createFileRoute: CreateFileRoute< + '/redirect/preload/second', + FileRoutesByPath['/redirect/preload/second']['parentRoute'], + FileRoutesByPath['/redirect/preload/second']['id'], + FileRoutesByPath['/redirect/preload/second']['path'], + FileRoutesByPath['/redirect/preload/second']['fullPath'] + > +} +declare module './routes/redirect/preload/third' { + const createFileRoute: CreateFileRoute< + '/redirect/preload/third', + FileRoutesByPath['/redirect/preload/third']['parentRoute'], + FileRoutesByPath['/redirect/preload/third']['id'], + FileRoutesByPath['/redirect/preload/third']['path'], + FileRoutesByPath['/redirect/preload/third']['fullPath'] + > +} +declare module './routes/redirect/$target/index' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/', + FileRoutesByPath['/redirect/$target/']['parentRoute'], + FileRoutesByPath['/redirect/$target/']['id'], + FileRoutesByPath['/redirect/$target/']['path'], + FileRoutesByPath['/redirect/$target/']['fullPath'] + > +} + // Create and export the route tree interface LayoutLayout2RouteChildren { @@ -713,6 +978,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/solid-router/basic-file-based/src/routes/(another-group)/onlyrouteinside.tsx b/e2e/solid-router/basic-file-based/src/routes/(another-group)/onlyrouteinside.tsx index 5dfc82fc33..02541fcca3 100644 --- a/e2e/solid-router/basic-file-based/src/routes/(another-group)/onlyrouteinside.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/(another-group)/onlyrouteinside.tsx @@ -1,10 +1,10 @@ -import { createFileRoute, getRouteApi, useSearch } from '@tanstack/solid-router' +import { getRouteApi, useSearch } from '@tanstack/solid-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' const routeApi = getRouteApi('/(another-group)/onlyrouteinside') -export const Route = createFileRoute('/(another-group)/onlyrouteinside')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ hello: z.string().optional() })), component: () => { const searchViaHook = useSearch({ diff --git a/e2e/solid-router/basic-file-based/src/routes/(group)/_layout.insidelayout.tsx b/e2e/solid-router/basic-file-based/src/routes/(group)/_layout.insidelayout.tsx index dd06459a35..b38b7f742f 100644 --- a/e2e/solid-router/basic-file-based/src/routes/(group)/_layout.insidelayout.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/(group)/_layout.insidelayout.tsx @@ -1,10 +1,10 @@ -import { createFileRoute, getRouteApi, useSearch } from '@tanstack/solid-router' +import { getRouteApi, useSearch } from '@tanstack/solid-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' const routeApi = getRouteApi('/(group)/_layout/insidelayout') -export const Route = createFileRoute('/(group)/_layout/insidelayout')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ hello: z.string().optional() })), component: () => { const searchViaHook = useSearch({ from: '/(group)/_layout/insidelayout' }) diff --git a/e2e/solid-router/basic-file-based/src/routes/(group)/_layout.tsx b/e2e/solid-router/basic-file-based/src/routes/(group)/_layout.tsx index 660cfb70e6..f4559572c2 100644 --- a/e2e/solid-router/basic-file-based/src/routes/(group)/_layout.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/(group)/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/(group)/_layout')({ +export const Route = createFileRoute({ component: () => ( <>
/(group)/_layout!
diff --git a/e2e/solid-router/basic-file-based/src/routes/(group)/inside.tsx b/e2e/solid-router/basic-file-based/src/routes/(group)/inside.tsx index 76ed0e8a07..eb1d28c1a0 100644 --- a/e2e/solid-router/basic-file-based/src/routes/(group)/inside.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/(group)/inside.tsx @@ -1,10 +1,10 @@ -import { createFileRoute, getRouteApi, useSearch } from '@tanstack/solid-router' +import { getRouteApi, useSearch } from '@tanstack/solid-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' const routeApi = getRouteApi('/(group)/inside') -export const Route = createFileRoute('/(group)/inside')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ hello: z.string().optional() })), component: () => { const searchViaHook = useSearch({ from: '/(group)/inside' }) diff --git a/e2e/solid-router/basic-file-based/src/routes/(group)/lazyinside.lazy.tsx b/e2e/solid-router/basic-file-based/src/routes/(group)/lazyinside.lazy.tsx index a68febeadd..e4671a84ea 100644 --- a/e2e/solid-router/basic-file-based/src/routes/(group)/lazyinside.lazy.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/(group)/lazyinside.lazy.tsx @@ -1,12 +1,8 @@ -import { - createLazyFileRoute, - getRouteApi, - useSearch, -} from '@tanstack/solid-router' +import { getRouteApi, useSearch } from '@tanstack/solid-router' const routeApi = getRouteApi('/(group)/lazyinside') -export const Route = createLazyFileRoute('/(group)/lazyinside')({ +export const Route = createLazyFileRoute({ component: () => { const searchViaHook = useSearch({ from: '/(group)/lazyinside' }) const searchViaRouteHook = Route.useSearch() diff --git a/e2e/solid-router/basic-file-based/src/routes/(group)/lazyinside.tsx b/e2e/solid-router/basic-file-based/src/routes/(group)/lazyinside.tsx index dcaf7b0727..c11aef8fd1 100644 --- a/e2e/solid-router/basic-file-based/src/routes/(group)/lazyinside.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/(group)/lazyinside.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' -export const Route = createFileRoute('/(group)/lazyinside')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ hello: z.string().optional() })), }) diff --git a/e2e/solid-router/basic-file-based/src/routes/(group)/subfolder/inside.tsx b/e2e/solid-router/basic-file-based/src/routes/(group)/subfolder/inside.tsx index 9e963d170c..48b9e1c517 100644 --- a/e2e/solid-router/basic-file-based/src/routes/(group)/subfolder/inside.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/(group)/subfolder/inside.tsx @@ -1,10 +1,10 @@ -import { createFileRoute, getRouteApi, useSearch } from '@tanstack/solid-router' +import { getRouteApi, useSearch } from '@tanstack/solid-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' const routeApi = getRouteApi('/(group)/subfolder/inside') -export const Route = createFileRoute('/(group)/subfolder/inside')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ hello: z.string().optional() })), component: () => { const searchViaHook = useSearch({ from: '/(group)/subfolder/inside' }) diff --git a/e2e/solid-router/basic-file-based/src/routes/_layout.tsx b/e2e/solid-router/basic-file-based/src/routes/_layout.tsx index d43b4ef5f5..c549175638 100644 --- a/e2e/solid-router/basic-file-based/src/routes/_layout.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/basic-file-based/src/routes/_layout/_layout-2.tsx b/e2e/solid-router/basic-file-based/src/routes/_layout/_layout-2.tsx index 7a5a3623a0..efeca5ce86 100644 --- a/e2e/solid-router/basic-file-based/src/routes/_layout/_layout-2.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/_layout/_layout-2.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_layout/_layout-2')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx b/e2e/solid-router/basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx index b69951b246..a190b24202 100644 --- a/e2e/solid-router/basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/solid-router/basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx b/e2e/solid-router/basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx index 30dbcce90f..505f8f6fbf 100644 --- a/e2e/solid-router/basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/solid-router/basic-file-based/src/routes/anchor.tsx b/e2e/solid-router/basic-file-based/src/routes/anchor.tsx index 77c0e5a6de..b14122d179 100644 --- a/e2e/solid-router/basic-file-based/src/routes/anchor.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/anchor.tsx @@ -1,9 +1,4 @@ -import { - Link, - createFileRoute, - useLocation, - useNavigate, -} from '@tanstack/solid-router' +import { Link, useLocation, useNavigate } from '@tanstack/solid-router' import { createEffect, createRenderEffect, @@ -11,7 +6,7 @@ import { onCleanup, } from 'solid-js' -export const Route = createFileRoute('/anchor')({ +export const Route = createFileRoute({ component: AnchorComponent, }) diff --git a/e2e/solid-router/basic-file-based/src/routes/editing-a.tsx b/e2e/solid-router/basic-file-based/src/routes/editing-a.tsx index e893169025..85b10caafe 100644 --- a/e2e/solid-router/basic-file-based/src/routes/editing-a.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/editing-a.tsx @@ -1,7 +1,7 @@ -import { createFileRoute, useBlocker } from '@tanstack/solid-router' +import { useBlocker } from '@tanstack/solid-router' import { createSignal } from 'solid-js' -export const Route = createFileRoute('/editing-a')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/solid-router/basic-file-based/src/routes/editing-b.tsx b/e2e/solid-router/basic-file-based/src/routes/editing-b.tsx index 3dc2d1655f..1d3e27339d 100644 --- a/e2e/solid-router/basic-file-based/src/routes/editing-b.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/editing-b.tsx @@ -1,7 +1,7 @@ -import { createFileRoute, useBlocker } from '@tanstack/solid-router' +import { useBlocker } from '@tanstack/solid-router' import { createEffect, createSignal, createMemo } from 'solid-js' -export const Route = createFileRoute('/editing-b')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/solid-router/basic-file-based/src/routes/index.tsx b/e2e/solid-router/basic-file-based/src/routes/index.tsx index bdfb4c7676..510db79b73 100644 --- a/e2e/solid-router/basic-file-based/src/routes/index.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/solid-router/basic-file-based/src/routes/params.single.$value.tsx b/e2e/solid-router/basic-file-based/src/routes/params.single.$value.tsx index 4aca878470..e370dd594c 100644 --- a/e2e/solid-router/basic-file-based/src/routes/params.single.$value.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/params.single.$value.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' -export const Route = createFileRoute('/params/single/$value')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/solid-router/basic-file-based/src/routes/posts.$postId.tsx b/e2e/solid-router/basic-file-based/src/routes/posts.$postId.tsx index a48895f339..f6445ae3ea 100644 --- a/e2e/solid-router/basic-file-based/src/routes/posts.$postId.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/posts.$postId.tsx @@ -1,4 +1,4 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/solid-router' +import { ErrorComponent } from '@tanstack/solid-router' import { fetchPost } from '../posts' import type { ErrorComponentProps } from '@tanstack/solid-router' @@ -6,7 +6,7 @@ export function PostErrorComponent({ error }: ErrorComponentProps) { return } -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent, notFoundComponent: () => { diff --git a/e2e/solid-router/basic-file-based/src/routes/posts.index.tsx b/e2e/solid-router/basic-file-based/src/routes/posts.index.tsx index c7d8cfe19c..07e41d1b0b 100644 --- a/e2e/solid-router/basic-file-based/src/routes/posts.index.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/solid-router/basic-file-based/src/routes/posts.tsx b/e2e/solid-router/basic-file-based/src/routes/posts.tsx index 9a9568837f..7f56ca2292 100644 --- a/e2e/solid-router/basic-file-based/src/routes/posts.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/posts.tsx @@ -1,7 +1,7 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ head: () => ({ meta: [ { diff --git a/e2e/solid-router/basic-file-based/src/routes/posts_.$postId.edit.tsx b/e2e/solid-router/basic-file-based/src/routes/posts_.$postId.edit.tsx index f38f369b7a..9e4c81d0f6 100644 --- a/e2e/solid-router/basic-file-based/src/routes/posts_.$postId.edit.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/posts_.$postId.edit.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, getRouteApi, useParams } from '@tanstack/solid-router' +import { getRouteApi, useParams } from '@tanstack/solid-router' -export const Route = createFileRoute('/posts_/$postId/edit')({ +export const Route = createFileRoute({ component: PostEditPage, }) diff --git a/e2e/solid-router/basic-file-based/src/routes/redirect/$target.tsx b/e2e/solid-router/basic-file-based/src/routes/redirect/$target.tsx index 525dd9da25..c4c78070d3 100644 --- a/e2e/solid-router/basic-file-based/src/routes/redirect/$target.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/redirect/$target.tsx @@ -1,7 +1,7 @@ -import { createFileRoute, retainSearchParams } from '@tanstack/solid-router' +import { retainSearchParams } from '@tanstack/solid-router' import z from 'zod' -export const Route = createFileRoute('/redirect/$target')({ +export const Route = createFileRoute({ params: { parse: (p) => z diff --git a/e2e/solid-router/basic-file-based/src/routes/redirect/$target/index.tsx b/e2e/solid-router/basic-file-based/src/routes/redirect/$target/index.tsx index a44008e3c6..7f4c505a93 100644 --- a/e2e/solid-router/basic-file-based/src/routes/redirect/$target/index.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/redirect/$target/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' -export const Route = createFileRoute('/redirect/$target/')({ +export const Route = createFileRoute({ component: () => { const preload = Route.useSearch({ select: (s) => s.preload }) return ( diff --git a/e2e/solid-router/basic-file-based/src/routes/redirect/$target/via-beforeLoad.tsx b/e2e/solid-router/basic-file-based/src/routes/redirect/$target/via-beforeLoad.tsx index c88cc07986..bac534bfc5 100644 --- a/e2e/solid-router/basic-file-based/src/routes/redirect/$target/via-beforeLoad.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/redirect/$target/via-beforeLoad.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/solid-router' +import { redirect } from '@tanstack/solid-router' -export const Route = createFileRoute('/redirect/$target/via-beforeLoad')({ +export const Route = createFileRoute({ beforeLoad: ({ params: { target }, search: { reloadDocument, externalHost }, diff --git a/e2e/solid-router/basic-file-based/src/routes/redirect/$target/via-loader.tsx b/e2e/solid-router/basic-file-based/src/routes/redirect/$target/via-loader.tsx index 5c059717c5..686c0d8971 100644 --- a/e2e/solid-router/basic-file-based/src/routes/redirect/$target/via-loader.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/redirect/$target/via-loader.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/solid-router' +import { redirect } from '@tanstack/solid-router' -export const Route = createFileRoute('/redirect/$target/via-loader')({ +export const Route = createFileRoute({ loaderDeps: ({ search: { reloadDocument, externalHost } }) => ({ reloadDocument, externalHost, diff --git a/e2e/solid-router/basic-file-based/src/routes/redirect/index.tsx b/e2e/solid-router/basic-file-based/src/routes/redirect/index.tsx index 043f305e57..26aefc154c 100644 --- a/e2e/solid-router/basic-file-based/src/routes/redirect/index.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/redirect/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' -export const Route = createFileRoute('/redirect/')({ +export const Route = createFileRoute({ component: () => (
{ await new Promise((r) => setTimeout(r, 1000)) throw redirect({ from: Route.fullPath, to: '../third' }) diff --git a/e2e/solid-router/basic-file-based/src/routes/redirect/preload/third.tsx b/e2e/solid-router/basic-file-based/src/routes/redirect/preload/third.tsx index e831276d29..cc162b05d9 100644 --- a/e2e/solid-router/basic-file-based/src/routes/redirect/preload/third.tsx +++ b/e2e/solid-router/basic-file-based/src/routes/redirect/preload/third.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/redirect/preload/third')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.ts b/e2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.ts index 06f55406fb..5a691c2820 100644 --- a/e2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.ts +++ b/e2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.ts @@ -10,59 +10,60 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostsImport } from './routes/posts' -import { Route as LayoutImport } from './routes/_layout' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as LayoutLayout2Import } from './routes/_layout/_layout-2' -import { Route as LayoutLayout2LayoutBImport } from './routes/_layout/_layout-2/layout-b' -import { Route as LayoutLayout2LayoutAImport } from './routes/_layout/_layout-2/layout-a' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as LayoutRouteImport } from './routes/_layout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2' +import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b' +import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a' // Create/Update Routes -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const LayoutRoute = LayoutImport.update({ +const LayoutRoute = LayoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const LayoutLayout2Route = LayoutLayout2Import.update({ +const LayoutLayout2Route = LayoutLayout2RouteImport.update({ id: '/_layout-2', getParentRoute: () => LayoutRoute, } as any) -const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBImport.update({ +const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => LayoutLayout2Route, } as any) -const LayoutLayout2LayoutARoute = LayoutLayout2LayoutAImport.update({ +const LayoutLayout2LayoutARoute = LayoutLayout2LayoutARouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => LayoutLayout2Route, @@ -76,61 +77,136 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/_layout/_layout-2': { id: '/_layout/_layout-2' path: '' fullPath: '' - preLoaderRoute: typeof LayoutLayout2Import - parentRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutLayout2RouteImport + parentRoute: typeof LayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/_layout/_layout-2/layout-a': { id: '/_layout/_layout-2/layout-a' path: '/layout-a' fullPath: '/layout-a' - preLoaderRoute: typeof LayoutLayout2LayoutAImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutARouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/_layout/_layout-2/layout-b': { id: '/_layout/_layout-2/layout-b' path: '/layout-b' fullPath: '/layout-b' - preLoaderRoute: typeof LayoutLayout2LayoutBImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport + parentRoute: typeof LayoutLayout2RouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/_layout/_layout-2' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2', + FileRoutesByPath['/_layout/_layout-2']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2']['id'], + FileRoutesByPath['/_layout/_layout-2']['path'], + FileRoutesByPath['/_layout/_layout-2']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-a' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-a', + FileRoutesByPath['/_layout/_layout-2/layout-a']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-b' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-b', + FileRoutesByPath['/_layout/_layout-2/layout-b']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['fullPath'] + > +} + // Create and export the route tree interface LayoutLayout2RouteChildren { @@ -242,6 +318,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout.tsx b/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout.tsx index d43b4ef5f5..c549175638 100644 --- a/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout.tsx +++ b/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout/_layout-2.tsx b/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout/_layout-2.tsx index 7a5a3623a0..efeca5ce86 100644 --- a/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout/_layout-2.tsx +++ b/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout/_layout-2.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_layout/_layout-2')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout/_layout-2/layout-a.tsx b/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout/_layout-2/layout-a.tsx index b69951b246..a190b24202 100644 --- a/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout/_layout-2/layout-a.tsx +++ b/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout/_layout-2/layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout/_layout-2/layout-b.tsx b/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout/_layout-2/layout-b.tsx index 30dbcce90f..505f8f6fbf 100644 --- a/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout/_layout-2/layout-b.tsx +++ b/e2e/solid-router/basic-solid-query-file-based/src/routes/_layout/_layout-2/layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/solid-router/basic-solid-query-file-based/src/routes/index.tsx b/e2e/solid-router/basic-solid-query-file-based/src/routes/index.tsx index bdfb4c7676..510db79b73 100644 --- a/e2e/solid-router/basic-solid-query-file-based/src/routes/index.tsx +++ b/e2e/solid-router/basic-solid-query-file-based/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/solid-router/basic-solid-query-file-based/src/routes/posts.$postId.tsx b/e2e/solid-router/basic-solid-query-file-based/src/routes/posts.$postId.tsx index 619428c4b5..38ae2af8bd 100644 --- a/e2e/solid-router/basic-solid-query-file-based/src/routes/posts.$postId.tsx +++ b/e2e/solid-router/basic-solid-query-file-based/src/routes/posts.$postId.tsx @@ -1,8 +1,4 @@ -import { - ErrorComponent, - createFileRoute, - useRouter, -} from '@tanstack/solid-router' +import { ErrorComponent, useRouter } from '@tanstack/solid-router' import { useQuery } from '@tanstack/solid-query' import { createEffect, createMemo } from 'solid-js' import { PostNotFoundError } from '../posts' @@ -35,7 +31,7 @@ export function PostErrorComponent({ error, reset }: ErrorComponentProps) { ) } -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: ({ context: { queryClient }, params: { postId } }) => { return queryClient.ensureQueryData(postQueryOptions(postId)) }, diff --git a/e2e/solid-router/basic-solid-query-file-based/src/routes/posts.index.tsx b/e2e/solid-router/basic-solid-query-file-based/src/routes/posts.index.tsx index 33d0386c19..13529228bb 100644 --- a/e2e/solid-router/basic-solid-query-file-based/src/routes/posts.index.tsx +++ b/e2e/solid-router/basic-solid-query-file-based/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/solid-router/basic-solid-query-file-based/src/routes/posts.tsx b/e2e/solid-router/basic-solid-query-file-based/src/routes/posts.tsx index 75d902a00c..8dbecad08e 100644 --- a/e2e/solid-router/basic-solid-query-file-based/src/routes/posts.tsx +++ b/e2e/solid-router/basic-solid-query-file-based/src/routes/posts.tsx @@ -1,9 +1,9 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' import { useQuery } from '@tanstack/solid-query' import { createMemo } from 'solid-js' import { postsQueryOptions } from '../postsQueryOptions' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: ({ context: { queryClient } }) => queryClient.ensureQueryData(postsQueryOptions), component: PostsComponent, diff --git a/e2e/solid-router/basic-virtual-file-based/src/routeTree.gen.ts b/e2e/solid-router/basic-virtual-file-based/src/routeTree.gen.ts index fc2a2b44e1..95c57d250d 100644 --- a/e2e/solid-router/basic-virtual-file-based/src/routeTree.gen.ts +++ b/e2e/solid-router/basic-virtual-file-based/src/routeTree.gen.ts @@ -10,87 +10,88 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/root' -import { Route as postsPostsImport } from './routes/posts/posts' -import { Route as layoutFirstLayoutImport } from './routes/layout/first-layout' -import { Route as homeImport } from './routes/home' -import { Route as postsPostsDetailImport } from './routes/posts/posts-detail' -import { Route as layoutSecondLayoutImport } from './routes/layout/second-layout' -import { Route as postsPostsHomeImport } from './routes/posts/posts-home' -import { Route as ClassicHelloRouteImport } from './routes/file-based-subtree/hello/route' -import { Route as ClassicHelloIndexImport } from './routes/file-based-subtree/hello/index' -import { Route as ClassicHelloWorldImport } from './routes/file-based-subtree/hello/world' -import { Route as ClassicHelloUniverseImport } from './routes/file-based-subtree/hello/universe' -import { Route as bImport } from './routes/b' -import { Route as aImport } from './routes/a' +import { Route as postsPostsRouteImport } from './routes/posts/posts' +import { Route as layoutFirstLayoutRouteImport } from './routes/layout/first-layout' +import { Route as homeRouteImport } from './routes/home' +import { Route as postsPostsDetailRouteImport } from './routes/posts/posts-detail' +import { Route as layoutSecondLayoutRouteImport } from './routes/layout/second-layout' +import { Route as postsPostsHomeRouteImport } from './routes/posts/posts-home' +import { Route as ClassicHelloRouteRouteImport } from './routes/file-based-subtree/hello/route' +import { Route as ClassicHelloIndexRouteImport } from './routes/file-based-subtree/hello/index' +import { Route as ClassicHelloWorldRouteImport } from './routes/file-based-subtree/hello/world' +import { Route as ClassicHelloUniverseRouteImport } from './routes/file-based-subtree/hello/universe' +import { Route as bRouteImport } from './routes/b' +import { Route as aRouteImport } from './routes/a' // Create/Update Routes -const postsPostsRoute = postsPostsImport.update({ +const postsPostsRoute = postsPostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const layoutFirstLayoutRoute = layoutFirstLayoutImport.update({ +const layoutFirstLayoutRoute = layoutFirstLayoutRouteImport.update({ id: '/_first', getParentRoute: () => rootRoute, } as any) -const homeRoute = homeImport.update({ +const homeRoute = homeRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const postsPostsDetailRoute = postsPostsDetailImport.update({ +const postsPostsDetailRoute = postsPostsDetailRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => postsPostsRoute, } as any) -const layoutSecondLayoutRoute = layoutSecondLayoutImport.update({ +const layoutSecondLayoutRoute = layoutSecondLayoutRouteImport.update({ id: '/_second', getParentRoute: () => layoutFirstLayoutRoute, } as any) -const postsPostsHomeRoute = postsPostsHomeImport.update({ +const postsPostsHomeRoute = postsPostsHomeRouteImport.update({ id: '/', path: '/', getParentRoute: () => postsPostsRoute, } as any) -const ClassicHelloRouteRoute = ClassicHelloRouteImport.update({ +const ClassicHelloRouteRoute = ClassicHelloRouteRouteImport.update({ id: '/classic/hello', path: '/classic/hello', getParentRoute: () => rootRoute, } as any) -const ClassicHelloIndexRoute = ClassicHelloIndexImport.update({ +const ClassicHelloIndexRoute = ClassicHelloIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => ClassicHelloRouteRoute, } as any) -const ClassicHelloWorldRoute = ClassicHelloWorldImport.update({ +const ClassicHelloWorldRoute = ClassicHelloWorldRouteImport.update({ id: '/world', path: '/world', getParentRoute: () => ClassicHelloRouteRoute, } as any) -const ClassicHelloUniverseRoute = ClassicHelloUniverseImport.update({ +const ClassicHelloUniverseRoute = ClassicHelloUniverseRouteImport.update({ id: '/universe', path: '/universe', getParentRoute: () => ClassicHelloRouteRoute, } as any) -const bRoute = bImport.update({ +const bRoute = bRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => layoutSecondLayoutRoute, } as any) -const aRoute = aImport.update({ +const aRoute = aRouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => layoutSecondLayoutRoute, @@ -104,89 +105,200 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof homeImport + preLoaderRoute: typeof homeRouteImport parentRoute: typeof rootRoute } '/_first': { id: '/_first' path: '' fullPath: '' - preLoaderRoute: typeof layoutFirstLayoutImport + preLoaderRoute: typeof layoutFirstLayoutRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof postsPostsImport + preLoaderRoute: typeof postsPostsRouteImport parentRoute: typeof rootRoute } '/classic/hello': { id: '/classic/hello' path: '/classic/hello' fullPath: '/classic/hello' - preLoaderRoute: typeof ClassicHelloRouteImport + preLoaderRoute: typeof ClassicHelloRouteRouteImport parentRoute: typeof rootRoute } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof postsPostsHomeImport - parentRoute: typeof postsPostsImport + preLoaderRoute: typeof postsPostsHomeRouteImport + parentRoute: typeof postsPostsRouteImport } '/_first/_second': { id: '/_first/_second' path: '' fullPath: '' - preLoaderRoute: typeof layoutSecondLayoutImport - parentRoute: typeof layoutFirstLayoutImport + preLoaderRoute: typeof layoutSecondLayoutRouteImport + parentRoute: typeof layoutFirstLayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof postsPostsDetailImport - parentRoute: typeof postsPostsImport + preLoaderRoute: typeof postsPostsDetailRouteImport + parentRoute: typeof postsPostsRouteImport } '/_first/_second/layout-a': { id: '/_first/_second/layout-a' path: '/layout-a' fullPath: '/layout-a' - preLoaderRoute: typeof aImport - parentRoute: typeof layoutSecondLayoutImport + preLoaderRoute: typeof aRouteImport + parentRoute: typeof layoutSecondLayoutRouteImport } '/_first/_second/layout-b': { id: '/_first/_second/layout-b' path: '/layout-b' fullPath: '/layout-b' - preLoaderRoute: typeof bImport - parentRoute: typeof layoutSecondLayoutImport + preLoaderRoute: typeof bRouteImport + parentRoute: typeof layoutSecondLayoutRouteImport } '/classic/hello/universe': { id: '/classic/hello/universe' path: '/universe' fullPath: '/classic/hello/universe' - preLoaderRoute: typeof ClassicHelloUniverseImport - parentRoute: typeof ClassicHelloRouteImport + preLoaderRoute: typeof ClassicHelloUniverseRouteImport + parentRoute: typeof ClassicHelloRouteRouteImport } '/classic/hello/world': { id: '/classic/hello/world' path: '/world' fullPath: '/classic/hello/world' - preLoaderRoute: typeof ClassicHelloWorldImport - parentRoute: typeof ClassicHelloRouteImport + preLoaderRoute: typeof ClassicHelloWorldRouteImport + parentRoute: typeof ClassicHelloRouteRouteImport } '/classic/hello/': { id: '/classic/hello/' path: '/' fullPath: '/classic/hello/' - preLoaderRoute: typeof ClassicHelloIndexImport - parentRoute: typeof ClassicHelloRouteImport + preLoaderRoute: typeof ClassicHelloIndexRouteImport + parentRoute: typeof ClassicHelloRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/home' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/layout/first-layout' { + const createFileRoute: CreateFileRoute< + '/_first', + FileRoutesByPath['/_first']['parentRoute'], + FileRoutesByPath['/_first']['id'], + FileRoutesByPath['/_first']['path'], + FileRoutesByPath['/_first']['fullPath'] + > +} +declare module './routes/posts/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/file-based-subtree/hello/route' { + const createFileRoute: CreateFileRoute< + '/classic/hello', + FileRoutesByPath['/classic/hello']['parentRoute'], + FileRoutesByPath['/classic/hello']['id'], + FileRoutesByPath['/classic/hello']['path'], + FileRoutesByPath['/classic/hello']['fullPath'] + > +} +declare module './routes/posts/posts-home' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/layout/second-layout' { + const createFileRoute: CreateFileRoute< + '/_first/_second', + FileRoutesByPath['/_first/_second']['parentRoute'], + FileRoutesByPath['/_first/_second']['id'], + FileRoutesByPath['/_first/_second']['path'], + FileRoutesByPath['/_first/_second']['fullPath'] + > +} +declare module './routes/posts/posts-detail' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/a' { + const createFileRoute: CreateFileRoute< + '/_first/_second/layout-a', + FileRoutesByPath['/_first/_second/layout-a']['parentRoute'], + FileRoutesByPath['/_first/_second/layout-a']['id'], + FileRoutesByPath['/_first/_second/layout-a']['path'], + FileRoutesByPath['/_first/_second/layout-a']['fullPath'] + > +} +declare module './routes/b' { + const createFileRoute: CreateFileRoute< + '/_first/_second/layout-b', + FileRoutesByPath['/_first/_second/layout-b']['parentRoute'], + FileRoutesByPath['/_first/_second/layout-b']['id'], + FileRoutesByPath['/_first/_second/layout-b']['path'], + FileRoutesByPath['/_first/_second/layout-b']['fullPath'] + > +} +declare module './routes/file-based-subtree/hello/universe' { + const createFileRoute: CreateFileRoute< + '/classic/hello/universe', + FileRoutesByPath['/classic/hello/universe']['parentRoute'], + FileRoutesByPath['/classic/hello/universe']['id'], + FileRoutesByPath['/classic/hello/universe']['path'], + FileRoutesByPath['/classic/hello/universe']['fullPath'] + > +} +declare module './routes/file-based-subtree/hello/world' { + const createFileRoute: CreateFileRoute< + '/classic/hello/world', + FileRoutesByPath['/classic/hello/world']['parentRoute'], + FileRoutesByPath['/classic/hello/world']['id'], + FileRoutesByPath['/classic/hello/world']['path'], + FileRoutesByPath['/classic/hello/world']['fullPath'] + > +} +declare module './routes/file-based-subtree/hello/index' { + const createFileRoute: CreateFileRoute< + '/classic/hello/', + FileRoutesByPath['/classic/hello/']['parentRoute'], + FileRoutesByPath['/classic/hello/']['id'], + FileRoutesByPath['/classic/hello/']['path'], + FileRoutesByPath['/classic/hello/']['fullPath'] + > +} + // Create and export the route tree interface layoutSecondLayoutRouteChildren { @@ -343,3 +455,82 @@ const rootRouteChildren: RootRouteChildren = { export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() + +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "root.tsx", + "children": [ + "/", + "/_first", + "/posts", + "/classic/hello" + ] + }, + "/": { + "filePath": "home.tsx" + }, + "/_first": { + "filePath": "layout/first-layout.tsx", + "children": [ + "/_first/_second" + ] + }, + "/posts": { + "filePath": "posts/posts.tsx", + "children": [ + "/posts/", + "/posts/$postId" + ] + }, + "/classic/hello": { + "filePath": "file-based-subtree/hello/route.tsx", + "children": [ + "/classic/hello/universe", + "/classic/hello/world", + "/classic/hello/" + ] + }, + "/posts/": { + "filePath": "posts/posts-home.tsx", + "parent": "/posts" + }, + "/_first/_second": { + "filePath": "layout/second-layout.tsx", + "parent": "/_first", + "children": [ + "/_first/_second/layout-a", + "/_first/_second/layout-b" + ] + }, + "/posts/$postId": { + "filePath": "posts/posts-detail.tsx", + "parent": "/posts" + }, + "/_first/_second/layout-a": { + "filePath": "a.tsx", + "parent": "/_first/_second" + }, + "/_first/_second/layout-b": { + "filePath": "b.tsx", + "parent": "/_first/_second" + }, + "/classic/hello/universe": { + "filePath": "file-based-subtree/hello/universe.tsx", + "parent": "/classic/hello" + }, + "/classic/hello/world": { + "filePath": "file-based-subtree/hello/world.tsx", + "parent": "/classic/hello" + }, + "/classic/hello/": { + "filePath": "file-based-subtree/hello/index.tsx", + "parent": "/classic/hello" + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/solid-router/basic-virtual-file-based/src/routes/a.tsx b/e2e/solid-router/basic-virtual-file-based/src/routes/a.tsx index 055cba1e6f..a190b24202 100644 --- a/e2e/solid-router/basic-virtual-file-based/src/routes/a.tsx +++ b/e2e/solid-router/basic-virtual-file-based/src/routes/a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_first/_second/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/solid-router/basic-virtual-file-based/src/routes/b.tsx b/e2e/solid-router/basic-virtual-file-based/src/routes/b.tsx index c5bb8051af..505f8f6fbf 100644 --- a/e2e/solid-router/basic-virtual-file-based/src/routes/b.tsx +++ b/e2e/solid-router/basic-virtual-file-based/src/routes/b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_first/_second/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/index.tsx b/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/index.tsx index f7ff537916..f86335e291 100644 --- a/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/index.tsx +++ b/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/classic/hello/')({ +export const Route = createFileRoute({ component: () =>
This is the index
, }) diff --git a/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/route.tsx b/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/route.tsx index f4f30d8425..5b95eea555 100644 --- a/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/route.tsx +++ b/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/route.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/classic/hello')({ +export const Route = createFileRoute({ component: () => (
Hello! diff --git a/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/universe.tsx b/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/universe.tsx index 2a6bf16c37..20b07c41cc 100644 --- a/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/universe.tsx +++ b/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/universe.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/classic/hello/universe')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/universe!
, }) diff --git a/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/world.tsx b/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/world.tsx index 03edc7f484..4af11357a2 100644 --- a/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/world.tsx +++ b/e2e/solid-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/world.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/classic/hello/world')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/world!
, }) diff --git a/e2e/solid-router/basic-virtual-file-based/src/routes/home.tsx b/e2e/solid-router/basic-virtual-file-based/src/routes/home.tsx index bdfb4c7676..510db79b73 100644 --- a/e2e/solid-router/basic-virtual-file-based/src/routes/home.tsx +++ b/e2e/solid-router/basic-virtual-file-based/src/routes/home.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/solid-router/basic-virtual-file-based/src/routes/layout/first-layout.tsx b/e2e/solid-router/basic-virtual-file-based/src/routes/layout/first-layout.tsx index 5c77421bb2..c549175638 100644 --- a/e2e/solid-router/basic-virtual-file-based/src/routes/layout/first-layout.tsx +++ b/e2e/solid-router/basic-virtual-file-based/src/routes/layout/first-layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_first')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/basic-virtual-file-based/src/routes/layout/second-layout.tsx b/e2e/solid-router/basic-virtual-file-based/src/routes/layout/second-layout.tsx index 9ab147de5e..efeca5ce86 100644 --- a/e2e/solid-router/basic-virtual-file-based/src/routes/layout/second-layout.tsx +++ b/e2e/solid-router/basic-virtual-file-based/src/routes/layout/second-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_first/_second')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/basic-virtual-file-based/src/routes/posts/posts-detail.tsx b/e2e/solid-router/basic-virtual-file-based/src/routes/posts/posts-detail.tsx index 990f473ae8..ef413c1be0 100644 --- a/e2e/solid-router/basic-virtual-file-based/src/routes/posts/posts-detail.tsx +++ b/e2e/solid-router/basic-virtual-file-based/src/routes/posts/posts-detail.tsx @@ -1,4 +1,4 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/solid-router' +import { ErrorComponent } from '@tanstack/solid-router' import { fetchPost } from '../../posts' import type { ErrorComponentProps } from '@tanstack/solid-router' @@ -6,7 +6,7 @@ export function PostErrorComponent({ error }: ErrorComponentProps) { return } -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent as any, notFoundComponent: () => { diff --git a/e2e/solid-router/basic-virtual-file-based/src/routes/posts/posts-home.tsx b/e2e/solid-router/basic-virtual-file-based/src/routes/posts/posts-home.tsx index 33d0386c19..13529228bb 100644 --- a/e2e/solid-router/basic-virtual-file-based/src/routes/posts/posts-home.tsx +++ b/e2e/solid-router/basic-virtual-file-based/src/routes/posts/posts-home.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/solid-router/basic-virtual-file-based/src/routes/posts/posts.tsx b/e2e/solid-router/basic-virtual-file-based/src/routes/posts/posts.tsx index 9ae6dfc747..46203594d1 100644 --- a/e2e/solid-router/basic-virtual-file-based/src/routes/posts/posts.tsx +++ b/e2e/solid-router/basic-virtual-file-based/src/routes/posts/posts.tsx @@ -1,7 +1,7 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' import { fetchPosts } from '../../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsComponent, }) diff --git a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/a.tsx b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/a.tsx index 055cba1e6f..a190b24202 100644 --- a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/a.tsx +++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_first/_second/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/b.tsx b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/b.tsx index c5bb8051af..505f8f6fbf 100644 --- a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/b.tsx +++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_first/_second/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx index f7ff537916..f86335e291 100644 --- a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx +++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/classic/hello/')({ +export const Route = createFileRoute({ component: () =>
This is the index
, }) diff --git a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx index f4f30d8425..5b95eea555 100644 --- a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx +++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/classic/hello')({ +export const Route = createFileRoute({ component: () => (
Hello! diff --git a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx index 2a6bf16c37..20b07c41cc 100644 --- a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx +++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/classic/hello/universe')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/universe!
, }) diff --git a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx index 03edc7f484..4af11357a2 100644 --- a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx +++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/classic/hello/world')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/world!
, }) diff --git a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/home.tsx b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/home.tsx index bdfb4c7676..510db79b73 100644 --- a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/home.tsx +++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/home.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx index 5c77421bb2..c549175638 100644 --- a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx +++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_first')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx index 9ab147de5e..efeca5ce86 100644 --- a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx +++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_first/_second')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx index 990f473ae8..ef413c1be0 100644 --- a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx +++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx @@ -1,4 +1,4 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/solid-router' +import { ErrorComponent } from '@tanstack/solid-router' import { fetchPost } from '../../posts' import type { ErrorComponentProps } from '@tanstack/solid-router' @@ -6,7 +6,7 @@ export function PostErrorComponent({ error }: ErrorComponentProps) { return } -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent as any, notFoundComponent: () => { diff --git a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx index 33d0386c19..13529228bb 100644 --- a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx +++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx index 9ae6dfc747..46203594d1 100644 --- a/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx +++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx @@ -1,7 +1,7 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' import { fetchPosts } from '../../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsComponent, }) diff --git a/e2e/solid-router/rspack-basic-file-based/src/routes/_layout.tsx b/e2e/solid-router/rspack-basic-file-based/src/routes/_layout.tsx index d43b4ef5f5..c549175638 100644 --- a/e2e/solid-router/rspack-basic-file-based/src/routes/_layout.tsx +++ b/e2e/solid-router/rspack-basic-file-based/src/routes/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/rspack-basic-file-based/src/routes/_layout/_layout-2.tsx b/e2e/solid-router/rspack-basic-file-based/src/routes/_layout/_layout-2.tsx index 7a5a3623a0..efeca5ce86 100644 --- a/e2e/solid-router/rspack-basic-file-based/src/routes/_layout/_layout-2.tsx +++ b/e2e/solid-router/rspack-basic-file-based/src/routes/_layout/_layout-2.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_layout/_layout-2')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx b/e2e/solid-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx index b69951b246..a190b24202 100644 --- a/e2e/solid-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx +++ b/e2e/solid-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/solid-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx b/e2e/solid-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx index 30dbcce90f..505f8f6fbf 100644 --- a/e2e/solid-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx +++ b/e2e/solid-router/rspack-basic-file-based/src/routes/_layout/_layout-2/layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/solid-router/rspack-basic-file-based/src/routes/index.tsx b/e2e/solid-router/rspack-basic-file-based/src/routes/index.tsx index bdfb4c7676..510db79b73 100644 --- a/e2e/solid-router/rspack-basic-file-based/src/routes/index.tsx +++ b/e2e/solid-router/rspack-basic-file-based/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/solid-router/rspack-basic-file-based/src/routes/posts.$postId.tsx b/e2e/solid-router/rspack-basic-file-based/src/routes/posts.$postId.tsx index 55f8871d03..12f48f498d 100644 --- a/e2e/solid-router/rspack-basic-file-based/src/routes/posts.$postId.tsx +++ b/e2e/solid-router/rspack-basic-file-based/src/routes/posts.$postId.tsx @@ -1,4 +1,4 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/solid-router' +import { ErrorComponent } from '@tanstack/solid-router' import { fetchPost } from '../posts' import type { ErrorComponentProps } from '@tanstack/solid-router' @@ -6,7 +6,7 @@ export function PostErrorComponent({ error }: ErrorComponentProps) { return } -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent, notFoundComponent: () => { diff --git a/e2e/solid-router/rspack-basic-file-based/src/routes/posts.index.tsx b/e2e/solid-router/rspack-basic-file-based/src/routes/posts.index.tsx index 33d0386c19..13529228bb 100644 --- a/e2e/solid-router/rspack-basic-file-based/src/routes/posts.index.tsx +++ b/e2e/solid-router/rspack-basic-file-based/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/solid-router/rspack-basic-file-based/src/routes/posts.tsx b/e2e/solid-router/rspack-basic-file-based/src/routes/posts.tsx index 11a999f50a..2e28f9beb3 100644 --- a/e2e/solid-router/rspack-basic-file-based/src/routes/posts.tsx +++ b/e2e/solid-router/rspack-basic-file-based/src/routes/posts.tsx @@ -1,7 +1,7 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsComponent, }) diff --git a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/a.tsx b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/a.tsx index 055cba1e6f..a190b24202 100644 --- a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/a.tsx +++ b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_first/_second/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/b.tsx b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/b.tsx index c5bb8051af..505f8f6fbf 100644 --- a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/b.tsx +++ b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_first/_second/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx index f7ff537916..f86335e291 100644 --- a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx +++ b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/classic/hello/')({ +export const Route = createFileRoute({ component: () =>
This is the index
, }) diff --git a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx index f4f30d8425..5b95eea555 100644 --- a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx +++ b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/route.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/classic/hello')({ +export const Route = createFileRoute({ component: () => (
Hello! diff --git a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx index 2a6bf16c37..20b07c41cc 100644 --- a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx +++ b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/universe.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/classic/hello/universe')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/universe!
, }) diff --git a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx index 03edc7f484..4af11357a2 100644 --- a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx +++ b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/file-based-subtree/hello/world.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/classic/hello/world')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/world!
, }) diff --git a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/home.tsx b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/home.tsx index bdfb4c7676..510db79b73 100644 --- a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/home.tsx +++ b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/home.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx index 5c77421bb2..c549175638 100644 --- a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx +++ b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/first-layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_first')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx index 9ab147de5e..efeca5ce86 100644 --- a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx +++ b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/layout/second-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_first/_second')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx index 990f473ae8..ef413c1be0 100644 --- a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx +++ b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-detail.tsx @@ -1,4 +1,4 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/solid-router' +import { ErrorComponent } from '@tanstack/solid-router' import { fetchPost } from '../../posts' import type { ErrorComponentProps } from '@tanstack/solid-router' @@ -6,7 +6,7 @@ export function PostErrorComponent({ error }: ErrorComponentProps) { return } -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent as any, notFoundComponent: () => { diff --git a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx index 33d0386c19..13529228bb 100644 --- a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx +++ b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts-home.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx index 9ae6dfc747..46203594d1 100644 --- a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx +++ b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/src/routes/posts/posts.tsx @@ -1,7 +1,7 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' import { fetchPosts } from '../../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsComponent, }) diff --git a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routeTree.gen.ts b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routeTree.gen.ts index 03f257bbfa..00acddbffb 100644 --- a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routeTree.gen.ts +++ b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routeTree.gen.ts @@ -12,26 +12,29 @@ import { createFileRoute } from '@tanstack/solid-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' -import { Route as testsPageWithSearchImport } from './routes/(tests)/page-with-search' -import { Route as testsNormalPageImport } from './routes/(tests)/normal-page' -import { Route as testsLazyWithLoaderPageImport } from './routes/(tests)/lazy-with-loader-page' -import { Route as testsLazyPageImport } from './routes/(tests)/lazy-page' +import { Route as IndexRouteImport } from './routes/index' +import { Route as testsPageWithSearchRouteImport } from './routes/(tests)/page-with-search' +import { Route as testsNormalPageRouteImport } from './routes/(tests)/normal-page' +import { Route as testsLazyWithLoaderPageRouteImport } from './routes/(tests)/lazy-with-loader-page' +import { Route as testsLazyPageRouteImport } from './routes/(tests)/lazy-page' // Create Virtual Routes -const testsVirtualPageLazyImport = createFileRoute('/(tests)/virtual-page')() +const testsVirtualPageLazyRouteImport = createFileRoute( + '/(tests)/virtual-page', +)() // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const testsVirtualPageLazyRoute = testsVirtualPageLazyImport +const testsVirtualPageLazyRoute = testsVirtualPageLazyRouteImport .update({ id: '/(tests)/virtual-page', path: '/virtual-page', @@ -39,19 +42,19 @@ const testsVirtualPageLazyRoute = testsVirtualPageLazyImport } as any) .lazy(() => import('./routes/(tests)/virtual-page.lazy').then((d) => d.Route)) -const testsPageWithSearchRoute = testsPageWithSearchImport.update({ +const testsPageWithSearchRoute = testsPageWithSearchRouteImport.update({ id: '/(tests)/page-with-search', path: '/page-with-search', getParentRoute: () => rootRoute, } as any) -const testsNormalPageRoute = testsNormalPageImport.update({ +const testsNormalPageRoute = testsNormalPageRouteImport.update({ id: '/(tests)/normal-page', path: '/normal-page', getParentRoute: () => rootRoute, } as any) -const testsLazyWithLoaderPageRoute = testsLazyWithLoaderPageImport +const testsLazyWithLoaderPageRoute = testsLazyWithLoaderPageRouteImport .update({ id: '/(tests)/lazy-with-loader-page', path: '/lazy-with-loader-page', @@ -61,7 +64,7 @@ const testsLazyWithLoaderPageRoute = testsLazyWithLoaderPageImport import('./routes/(tests)/lazy-with-loader-page.lazy').then((d) => d.Route), ) -const testsLazyPageRoute = testsLazyPageImport +const testsLazyPageRoute = testsLazyPageRouteImport .update({ id: '/(tests)/lazy-page', path: '/lazy-page', @@ -77,47 +80,131 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/(tests)/lazy-page': { id: '/(tests)/lazy-page' path: '/lazy-page' fullPath: '/lazy-page' - preLoaderRoute: typeof testsLazyPageImport + preLoaderRoute: typeof testsLazyPageRouteImport parentRoute: typeof rootRoute } '/(tests)/lazy-with-loader-page': { id: '/(tests)/lazy-with-loader-page' path: '/lazy-with-loader-page' fullPath: '/lazy-with-loader-page' - preLoaderRoute: typeof testsLazyWithLoaderPageImport + preLoaderRoute: typeof testsLazyWithLoaderPageRouteImport parentRoute: typeof rootRoute } '/(tests)/normal-page': { id: '/(tests)/normal-page' path: '/normal-page' fullPath: '/normal-page' - preLoaderRoute: typeof testsNormalPageImport + preLoaderRoute: typeof testsNormalPageRouteImport parentRoute: typeof rootRoute } '/(tests)/page-with-search': { id: '/(tests)/page-with-search' path: '/page-with-search' fullPath: '/page-with-search' - preLoaderRoute: typeof testsPageWithSearchImport + preLoaderRoute: typeof testsPageWithSearchRouteImport parentRoute: typeof rootRoute } '/(tests)/virtual-page': { id: '/(tests)/virtual-page' path: '/virtual-page' fullPath: '/virtual-page' - preLoaderRoute: typeof testsVirtualPageLazyImport + preLoaderRoute: typeof testsVirtualPageLazyRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/(tests)/lazy-page' { + const createFileRoute: CreateFileRoute< + '/(tests)/lazy-page', + FileRoutesByPath['/(tests)/lazy-page']['parentRoute'], + FileRoutesByPath['/(tests)/lazy-page']['id'], + FileRoutesByPath['/(tests)/lazy-page']['path'], + FileRoutesByPath['/(tests)/lazy-page']['fullPath'] + > +} +declare module './routes/(tests)/lazy-page.lazy' { + const createLazyFileRoute: CreateFileRoute< + '/(tests)/lazy-page', + FileRoutesByPath['/(tests)/lazy-page']['parentRoute'], + FileRoutesByPath['/(tests)/lazy-page']['id'], + FileRoutesByPath['/(tests)/lazy-page']['path'], + FileRoutesByPath['/(tests)/lazy-page']['fullPath'] + > +} +declare module './routes/(tests)/lazy-with-loader-page' { + const createFileRoute: CreateFileRoute< + '/(tests)/lazy-with-loader-page', + FileRoutesByPath['/(tests)/lazy-with-loader-page']['parentRoute'], + FileRoutesByPath['/(tests)/lazy-with-loader-page']['id'], + FileRoutesByPath['/(tests)/lazy-with-loader-page']['path'], + FileRoutesByPath['/(tests)/lazy-with-loader-page']['fullPath'] + > +} +declare module './routes/(tests)/lazy-with-loader-page.lazy' { + const createLazyFileRoute: CreateFileRoute< + '/(tests)/lazy-with-loader-page', + FileRoutesByPath['/(tests)/lazy-with-loader-page']['parentRoute'], + FileRoutesByPath['/(tests)/lazy-with-loader-page']['id'], + FileRoutesByPath['/(tests)/lazy-with-loader-page']['path'], + FileRoutesByPath['/(tests)/lazy-with-loader-page']['fullPath'] + > +} +declare module './routes/(tests)/normal-page' { + const createFileRoute: CreateFileRoute< + '/(tests)/normal-page', + FileRoutesByPath['/(tests)/normal-page']['parentRoute'], + FileRoutesByPath['/(tests)/normal-page']['id'], + FileRoutesByPath['/(tests)/normal-page']['path'], + FileRoutesByPath['/(tests)/normal-page']['fullPath'] + > +} +declare module './routes/(tests)/page-with-search' { + const createFileRoute: CreateFileRoute< + '/(tests)/page-with-search', + FileRoutesByPath['/(tests)/page-with-search']['parentRoute'], + FileRoutesByPath['/(tests)/page-with-search']['id'], + FileRoutesByPath['/(tests)/page-with-search']['path'], + FileRoutesByPath['/(tests)/page-with-search']['fullPath'] + > +} +declare module './routes/(tests)/virtual-page.lazy' { + const createFileRoute: CreateFileRoute< + '/(tests)/virtual-page', + FileRoutesByPath['/(tests)/virtual-page']['parentRoute'], + FileRoutesByPath['/(tests)/virtual-page']['id'], + FileRoutesByPath['/(tests)/virtual-page']['path'], + FileRoutesByPath['/(tests)/virtual-page']['fullPath'] + > +} +declare module './routes/(tests)/virtual-page.lazy' { + const createLazyFileRoute: CreateFileRoute< + '/(tests)/virtual-page', + FileRoutesByPath['/(tests)/virtual-page']['parentRoute'], + FileRoutesByPath['/(tests)/virtual-page']['id'], + FileRoutesByPath['/(tests)/virtual-page']['path'], + FileRoutesByPath['/(tests)/virtual-page']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -198,6 +285,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.lazy.tsx b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.lazy.tsx index 2e7b3306d2..ff772de0f5 100644 --- a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.lazy.tsx +++ b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.lazy.tsx @@ -1,7 +1,6 @@ -import { createLazyFileRoute } from '@tanstack/solid-router' import { ScrollBlock } from '../-components/scroll-block' -export const Route = createLazyFileRoute('/(tests)/lazy-page')({ +export const Route = createLazyFileRoute({ component: Component, }) diff --git a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.tsx b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.tsx index 042a053765..79405e27e7 100644 --- a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.tsx +++ b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-page.tsx @@ -1,3 +1 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/(tests)/lazy-page')({}) +export const Route = createFileRoute({}) diff --git a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.lazy.tsx b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.lazy.tsx index 2079777df0..7f5f91be43 100644 --- a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.lazy.tsx +++ b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.lazy.tsx @@ -1,7 +1,6 @@ -import { createLazyFileRoute } from '@tanstack/solid-router' import { ScrollBlock } from '../-components/scroll-block' -export const Route = createLazyFileRoute('/(tests)/lazy-with-loader-page')({ +export const Route = createLazyFileRoute({ component: Component, }) diff --git a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.tsx b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.tsx index 6f2cf280a4..5463a153af 100644 --- a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.tsx +++ b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/lazy-with-loader-page.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' import { sleep } from '../../posts' -export const Route = createFileRoute('/(tests)/lazy-with-loader-page')({ +export const Route = createFileRoute({ loader: async () => { await sleep(1000) return { foo: 'bar' } diff --git a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/normal-page.tsx b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/normal-page.tsx index 6151049c35..af14b9d095 100644 --- a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/normal-page.tsx +++ b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/normal-page.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' import { ScrollBlock } from '../-components/scroll-block' -export const Route = createFileRoute('/(tests)/normal-page')({ +export const Route = createFileRoute({ component: Component, }) diff --git a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/page-with-search.tsx b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/page-with-search.tsx index 4d5953ed67..073dd2501c 100644 --- a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/page-with-search.tsx +++ b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/page-with-search.tsx @@ -1,9 +1,8 @@ -import { createFileRoute } from '@tanstack/solid-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' import { ScrollBlock } from '../-components/scroll-block' -export const Route = createFileRoute('/(tests)/page-with-search')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ where: z.string() })), component: Component, }) diff --git a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/virtual-page.lazy.tsx b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/virtual-page.lazy.tsx index 8c6c8ef353..4e79a19cd9 100644 --- a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/virtual-page.lazy.tsx +++ b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/(tests)/virtual-page.lazy.tsx @@ -1,7 +1,6 @@ -import { createLazyFileRoute } from '@tanstack/solid-router' import { ScrollBlock } from '../-components/scroll-block' -export const Route = createLazyFileRoute('/(tests)/virtual-page')({ +export const Route = createLazyFileRoute({ component: Component, }) diff --git a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/index.tsx b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/index.tsx index 991ecc3435..da8f31fe34 100644 --- a/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/index.tsx +++ b/e2e/solid-router/scroll-restoration-sandbox-vite/src/routes/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute, linkOptions } from '@tanstack/solid-router' +import { Link, linkOptions } from '@tanstack/solid-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: HomeComponent, }) diff --git a/e2e/solid-start/basic-tsr-config/.gitignore b/e2e/solid-start/basic-tsr-config/.gitignore index 2b76174be5..14577724eb 100644 --- a/e2e/solid-start/basic-tsr-config/.gitignore +++ b/e2e/solid-start/basic-tsr-config/.gitignore @@ -7,13 +7,11 @@ yarn.lock .env .vercel .output -.vinxi /build/ /api/ /server/build /public/build -.vinxi # Sentry Config File .env.sentry-build-plugin /test-results/ diff --git a/e2e/solid-start/basic-tsr-config/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/solid-start/basic-tsr-config/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..2dc6bfc4bd --- /dev/null +++ b/e2e/solid-start/basic-tsr-config/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/solid-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/solid-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/solid-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/solid-start/basic-tsr-config/app.config.ts b/e2e/solid-start/basic-tsr-config/app.config.ts deleted file mode 100644 index d798414e98..0000000000 --- a/e2e/solid-start/basic-tsr-config/app.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -// app.config.ts -import { defineConfig } from '@tanstack/solid-start/config' - -export default defineConfig({ - tsr: { - appDirectory: './src/app', - }, -}) diff --git a/e2e/solid-start/basic-tsr-config/package.json b/e2e/solid-start/basic-tsr-config/package.json index 475a1d746b..635a898525 100644 --- a/e2e/solid-start/basic-tsr-config/package.json +++ b/e2e/solid-start/basic-tsr-config/package.json @@ -4,22 +4,22 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev --port 3000", - "dev:e2e": "vinxi dev", - "build": "rimraf ./count.txt && vinxi build && tsc --noEmit", - "start": "vinxi start", + "dev": "vite dev --port 3000", + "dev:e2e": "vite dev", + "build": "rimraf ./count.txt && vite build && tsc --noEmit", + "start": "node .output/server/index.mjs", "test:e2e": "playwright test --project=chromium" }, "dependencies": { "@tanstack/solid-router": "workspace:^", "@tanstack/solid-router-devtools": "workspace:^", "@tanstack/solid-start": "workspace:^", - "solid-js": "^1.9.5", - "vinxi": "0.5.3" + "solid-js": "^1.9.5" }, "devDependencies": { "@tanstack/router-e2e-utils": "workspace:^", "@types/node": "^22.10.2", - "typescript": "^5.7.2" + "typescript": "^5.7.2", + "vite-tsconfig-paths": "^5.1.4" } } diff --git a/e2e/solid-start/basic-tsr-config/playwright.config.ts b/e2e/solid-start/basic-tsr-config/playwright.config.ts index bb77d0cf70..e834d88cf4 100644 --- a/e2e/solid-start/basic-tsr-config/playwright.config.ts +++ b/e2e/solid-start/basic-tsr-config/playwright.config.ts @@ -4,6 +4,7 @@ import packageJson from './package.json' with { type: 'json' } const PORT = derivePort(packageJson.name) const baseURL = `http://localhost:${PORT}` + /** * See https://playwright.dev/docs/test-configuration. */ @@ -19,7 +20,7 @@ export default defineConfig({ }, webServer: { - command: `VITE_SERVER_PORT=${PORT} pnpm build && VITE_SERVER_PORT=${PORT} pnpm start --port ${PORT}`, + command: `pnpm build && VITE_SERVER_PORT=${PORT} PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', diff --git a/e2e/solid-start/basic-tsr-config/src/app/client.tsx b/e2e/solid-start/basic-tsr-config/src/app/client.tsx deleted file mode 100644 index ba0f02fac0..0000000000 --- a/e2e/solid-start/basic-tsr-config/src/app/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrate } from 'solid-js/web' -import { StartClient } from '@tanstack/solid-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrate(() => , document.body) diff --git a/e2e/solid-start/basic-tsr-config/src/app/routeTree.gen.ts b/e2e/solid-start/basic-tsr-config/src/app/routeTree.gen.ts index c260510053..3fc31644ee 100644 --- a/e2e/solid-start/basic-tsr-config/src/app/routeTree.gen.ts +++ b/e2e/solid-start/basic-tsr-config/src/app/routeTree.gen.ts @@ -10,12 +10,13 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -29,12 +30,24 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -71,6 +84,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/solid-start/basic-tsr-config/src/app/routes/index.tsx b/e2e/solid-start/basic-tsr-config/src/app/routes/index.tsx index 4d15620109..32e530dbbf 100644 --- a/e2e/solid-start/basic-tsr-config/src/app/routes/index.tsx +++ b/e2e/solid-start/basic-tsr-config/src/app/routes/index.tsx @@ -1,5 +1,5 @@ import fs from 'node:fs' -import { createFileRoute, useRouter } from '@tanstack/solid-router' +import { useRouter } from '@tanstack/solid-router' import { createServerFn } from '@tanstack/solid-start' const filePath = 'count.txt' @@ -17,7 +17,7 @@ const updateCount = createServerFn({ method: 'POST' }) const count = await getCount() await fs.promises.writeFile(filePath, `${count + data}`) }) -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, loader: async () => await getCount(), }) diff --git a/e2e/solid-start/basic-tsr-config/src/app/ssr.tsx b/e2e/solid-start/basic-tsr-config/src/app/ssr.tsx deleted file mode 100644 index ebd14c8120..0000000000 --- a/e2e/solid-start/basic-tsr-config/src/app/ssr.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/solid-start/server' -import { getRouterManifest } from '@tanstack/solid-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/e2e/solid-start/basic-tsr-config/src/app/vite-env.d.ts b/e2e/solid-start/basic-tsr-config/src/app/vite-env.d.ts new file mode 100644 index 0000000000..0b2af560d6 --- /dev/null +++ b/e2e/solid-start/basic-tsr-config/src/app/vite-env.d.ts @@ -0,0 +1,4 @@ +declare module '*?url' { + const url: string + export default url +} diff --git a/e2e/solid-start/basic-tsr-config/vite.config.ts b/e2e/solid-start/basic-tsr-config/vite.config.ts new file mode 100644 index 0000000000..788ee479b5 --- /dev/null +++ b/e2e/solid-start/basic-tsr-config/vite.config.ts @@ -0,0 +1,19 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/solid-start/plugin' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin({ + tsr: { + srcDirectory: './src/app', + }, + }), + ], +}) diff --git a/e2e/solid-start/basic/.gitignore b/e2e/solid-start/basic/.gitignore index be342025da..a79d5cf129 100644 --- a/e2e/solid-start/basic/.gitignore +++ b/e2e/solid-start/basic/.gitignore @@ -7,13 +7,11 @@ yarn.lock .env .vercel .output -.vinxi /build/ /api/ /server/build /public/build -.vinxi # Sentry Config File .env.sentry-build-plugin /test-results/ diff --git a/e2e/solid-start/basic/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/solid-start/basic/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..e36fccb479 --- /dev/null +++ b/e2e/solid-start/basic/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,155 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/solid-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/solid-start/server' + +import { ServerRoute as ApiUsersRouteImport } from './../../src/routes/api/users' +import { ServerRoute as ApiUsersUserIdRouteImport } from './../../src/routes/api/users.$userId' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +const ApiUsersRoute = ApiUsersRouteImport.update({ + id: '/api/users', + path: '/api/users', + getParentRoute: () => rootRoute, +} as any) + +const ApiUsersUserIdRoute = ApiUsersUserIdRouteImport.update({ + id: '/$userId', + path: '/$userId', + getParentRoute: () => ApiUsersRoute, +} as any) + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/solid-start/server' { + interface FileRoutesByPath { + '/api/users': { + id: '/api/users' + path: '/api/users' + fullPath: '/api/users' + preLoaderRoute: typeof ApiUsersRouteImport + parentRoute: typeof rootRoute + } + '/api/users/$userId': { + id: '/api/users/$userId' + path: '/$userId' + fullPath: '/api/users/$userId' + preLoaderRoute: typeof ApiUsersUserIdRouteImport + parentRoute: typeof ApiUsersRouteImport + } + } +} + +// Add type-safety to the createFileRoute function across the route tree + +declare module './../../src/routes/api/users' { + const createServerFileRoute: CreateServerFileRoute< + FileRoutesByPath['/api/users']['parentRoute'], + FileRoutesByPath['/api/users']['id'], + FileRoutesByPath['/api/users']['path'], + FileRoutesByPath['/api/users']['fullPath'], + ApiUsersRouteChildren + > +} +declare module './../../src/routes/api/users.$userId' { + const createServerFileRoute: CreateServerFileRoute< + FileRoutesByPath['/api/users/$userId']['parentRoute'], + FileRoutesByPath['/api/users/$userId']['id'], + FileRoutesByPath['/api/users/$userId']['path'], + FileRoutesByPath['/api/users/$userId']['fullPath'], + unknown + > +} + +// Create and export the route tree + +interface ApiUsersRouteChildren { + ApiUsersUserIdRoute: typeof ApiUsersUserIdRoute +} + +const ApiUsersRouteChildren: ApiUsersRouteChildren = { + ApiUsersUserIdRoute: ApiUsersUserIdRoute, +} + +const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren( + ApiUsersRouteChildren, +) + +export interface FileRoutesByFullPath { + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$userId': typeof ApiUsersUserIdRoute +} + +export interface FileRoutesByTo { + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$userId': typeof ApiUsersUserIdRoute +} + +export interface FileRoutesById { + __root__: typeof rootRoute + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$userId': typeof ApiUsersUserIdRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: '/api/users' | '/api/users/$userId' + fileRoutesByTo: FileRoutesByTo + to: '/api/users' | '/api/users/$userId' + id: '__root__' | '/api/users' | '/api/users/$userId' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren { + ApiUsersRoute: typeof ApiUsersRouteWithChildren +} + +const rootRouteChildren: RootRouteChildren = { + ApiUsersRoute: ApiUsersRouteWithChildren, +} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [ + "/api/users" + ] + }, + "/api/users": { + "filePath": "api/users.ts", + "children": [ + "/api/users/$userId" + ] + }, + "/api/users/$userId": { + "filePath": "api/users.$userId.ts", + "parent": "/api/users" + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/solid-start/basic/app.config.ts b/e2e/solid-start/basic/app.config.ts deleted file mode 100644 index 2a06e3d3f0..0000000000 --- a/e2e/solid-start/basic/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/solid-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/e2e/solid-start/basic/package.json b/e2e/solid-start/basic/package.json index a10fb47d62..01167c343d 100644 --- a/e2e/solid-start/basic/package.json +++ b/e2e/solid-start/basic/package.json @@ -4,10 +4,10 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev --port 3000", - "dev:e2e": "vinxi dev", - "build": "vinxi build && tsc --noEmit", - "start": "vinxi start", + "dev": "vite dev --port 3000", + "dev:e2e": "vite dev", + "build": "vite build && tsc --noEmit", + "start": "node .output/server/index.mjs", "test:e2e": "playwright test --project=chromium" }, "dependencies": { @@ -17,7 +17,6 @@ "solid-js": "^1.9.5", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3", "zod": "^3.24.2" }, "devDependencies": { diff --git a/e2e/solid-start/basic/playwright.config.ts b/e2e/solid-start/basic/playwright.config.ts index 95d043d48b..e834d88cf4 100644 --- a/e2e/solid-start/basic/playwright.config.ts +++ b/e2e/solid-start/basic/playwright.config.ts @@ -20,7 +20,7 @@ export default defineConfig({ }, webServer: { - command: `VITE_SERVER_PORT=${PORT} pnpm build && VITE_SERVER_PORT=${PORT} pnpm start --port ${PORT}`, + command: `pnpm build && VITE_SERVER_PORT=${PORT} PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', diff --git a/e2e/solid-start/basic/src/api.ts b/e2e/solid-start/basic/src/api.ts deleted file mode 100644 index ed511bcd26..0000000000 --- a/e2e/solid-start/basic/src/api.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { - createStartAPIHandler, - defaultAPIFileRouteHandler, -} from '@tanstack/solid-start/api' - -export default createStartAPIHandler(defaultAPIFileRouteHandler) diff --git a/e2e/solid-start/basic/src/client.tsx b/e2e/solid-start/basic/src/client.tsx deleted file mode 100644 index ba0f02fac0..0000000000 --- a/e2e/solid-start/basic/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrate } from 'solid-js/web' -import { StartClient } from '@tanstack/solid-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrate(() => , document.body) diff --git a/e2e/solid-start/basic/src/routeTree.gen.ts b/e2e/solid-start/basic/src/routeTree.gen.ts index db7101d5f5..a097c9a713 100644 --- a/e2e/solid-start/basic/src/routeTree.gen.ts +++ b/e2e/solid-start/basic/src/routeTree.gen.ts @@ -10,218 +10,219 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as UsersImport } from './routes/users' -import { Route as StreamImport } from './routes/stream' -import { Route as SearchParamsImport } from './routes/search-params' -import { Route as ScriptsImport } from './routes/scripts' -import { Route as PostsImport } from './routes/posts' -import { Route as LinksImport } from './routes/links' -import { Route as DeferredImport } from './routes/deferred' -import { Route as LayoutImport } from './routes/_layout' -import { Route as NotFoundRouteImport } from './routes/not-found/route' -import { Route as IndexImport } from './routes/index' -import { Route as UsersIndexImport } from './routes/users.index' -import { Route as RedirectIndexImport } from './routes/redirect/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as NotFoundIndexImport } from './routes/not-found/index' -import { Route as UsersUserIdImport } from './routes/users.$userId' -import { Route as RedirectTargetImport } from './routes/redirect/$target' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as NotFoundViaLoaderImport } from './routes/not-found/via-loader' -import { Route as NotFoundViaBeforeLoadImport } from './routes/not-found/via-beforeLoad' -import { Route as LayoutLayout2Import } from './routes/_layout/_layout-2' -import { Route as RedirectTargetIndexImport } from './routes/redirect/$target/index' -import { Route as RedirectTargetViaLoaderImport } from './routes/redirect/$target/via-loader' -import { Route as RedirectTargetViaBeforeLoadImport } from './routes/redirect/$target/via-beforeLoad' -import { Route as PostsPostIdDeepImport } from './routes/posts_.$postId.deep' -import { Route as LayoutLayout2LayoutBImport } from './routes/_layout/_layout-2/layout-b' -import { Route as LayoutLayout2LayoutAImport } from './routes/_layout/_layout-2/layout-a' -import { Route as RedirectTargetServerFnIndexImport } from './routes/redirect/$target/serverFn/index' -import { Route as RedirectTargetServerFnViaUseServerFnImport } from './routes/redirect/$target/serverFn/via-useServerFn' -import { Route as RedirectTargetServerFnViaLoaderImport } from './routes/redirect/$target/serverFn/via-loader' -import { Route as RedirectTargetServerFnViaBeforeLoadImport } from './routes/redirect/$target/serverFn/via-beforeLoad' +import { Route as UsersRouteImport } from './routes/users' +import { Route as StreamRouteImport } from './routes/stream' +import { Route as SearchParamsRouteImport } from './routes/search-params' +import { Route as ScriptsRouteImport } from './routes/scripts' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as LinksRouteImport } from './routes/links' +import { Route as DeferredRouteImport } from './routes/deferred' +import { Route as LayoutRouteImport } from './routes/_layout' +import { Route as NotFoundRouteRouteImport } from './routes/not-found/route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as UsersIndexRouteImport } from './routes/users.index' +import { Route as RedirectIndexRouteImport } from './routes/redirect/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as NotFoundIndexRouteImport } from './routes/not-found/index' +import { Route as UsersUserIdRouteImport } from './routes/users.$userId' +import { Route as RedirectTargetRouteImport } from './routes/redirect/$target' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as NotFoundViaLoaderRouteImport } from './routes/not-found/via-loader' +import { Route as NotFoundViaBeforeLoadRouteImport } from './routes/not-found/via-beforeLoad' +import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2' +import { Route as RedirectTargetIndexRouteImport } from './routes/redirect/$target/index' +import { Route as RedirectTargetViaLoaderRouteImport } from './routes/redirect/$target/via-loader' +import { Route as RedirectTargetViaBeforeLoadRouteImport } from './routes/redirect/$target/via-beforeLoad' +import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep' +import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b' +import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a' +import { Route as RedirectTargetServerFnIndexRouteImport } from './routes/redirect/$target/serverFn/index' +import { Route as RedirectTargetServerFnViaUseServerFnRouteImport } from './routes/redirect/$target/serverFn/via-useServerFn' +import { Route as RedirectTargetServerFnViaLoaderRouteImport } from './routes/redirect/$target/serverFn/via-loader' +import { Route as RedirectTargetServerFnViaBeforeLoadRouteImport } from './routes/redirect/$target/serverFn/via-beforeLoad' // Create/Update Routes -const UsersRoute = UsersImport.update({ +const UsersRoute = UsersRouteImport.update({ id: '/users', path: '/users', getParentRoute: () => rootRoute, } as any) -const StreamRoute = StreamImport.update({ +const StreamRoute = StreamRouteImport.update({ id: '/stream', path: '/stream', getParentRoute: () => rootRoute, } as any) -const SearchParamsRoute = SearchParamsImport.update({ +const SearchParamsRoute = SearchParamsRouteImport.update({ id: '/search-params', path: '/search-params', getParentRoute: () => rootRoute, } as any) -const ScriptsRoute = ScriptsImport.update({ +const ScriptsRoute = ScriptsRouteImport.update({ id: '/scripts', path: '/scripts', getParentRoute: () => rootRoute, } as any) -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const LinksRoute = LinksImport.update({ +const LinksRoute = LinksRouteImport.update({ id: '/links', path: '/links', getParentRoute: () => rootRoute, } as any) -const DeferredRoute = DeferredImport.update({ +const DeferredRoute = DeferredRouteImport.update({ id: '/deferred', path: '/deferred', getParentRoute: () => rootRoute, } as any) -const LayoutRoute = LayoutImport.update({ +const LayoutRoute = LayoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const NotFoundRouteRoute = NotFoundRouteImport.update({ +const NotFoundRouteRoute = NotFoundRouteRouteImport.update({ id: '/not-found', path: '/not-found', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const UsersIndexRoute = UsersIndexImport.update({ +const UsersIndexRoute = UsersIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => UsersRoute, } as any) -const RedirectIndexRoute = RedirectIndexImport.update({ +const RedirectIndexRoute = RedirectIndexRouteImport.update({ id: '/redirect/', path: '/redirect/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const NotFoundIndexRoute = NotFoundIndexImport.update({ +const NotFoundIndexRoute = NotFoundIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => NotFoundRouteRoute, } as any) -const UsersUserIdRoute = UsersUserIdImport.update({ +const UsersUserIdRoute = UsersUserIdRouteImport.update({ id: '/$userId', path: '/$userId', getParentRoute: () => UsersRoute, } as any) -const RedirectTargetRoute = RedirectTargetImport.update({ +const RedirectTargetRoute = RedirectTargetRouteImport.update({ id: '/redirect/$target', path: '/redirect/$target', getParentRoute: () => rootRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const NotFoundViaLoaderRoute = NotFoundViaLoaderImport.update({ +const NotFoundViaLoaderRoute = NotFoundViaLoaderRouteImport.update({ id: '/via-loader', path: '/via-loader', getParentRoute: () => NotFoundRouteRoute, } as any) -const NotFoundViaBeforeLoadRoute = NotFoundViaBeforeLoadImport.update({ +const NotFoundViaBeforeLoadRoute = NotFoundViaBeforeLoadRouteImport.update({ id: '/via-beforeLoad', path: '/via-beforeLoad', getParentRoute: () => NotFoundRouteRoute, } as any) -const LayoutLayout2Route = LayoutLayout2Import.update({ +const LayoutLayout2Route = LayoutLayout2RouteImport.update({ id: '/_layout-2', getParentRoute: () => LayoutRoute, } as any) -const RedirectTargetIndexRoute = RedirectTargetIndexImport.update({ +const RedirectTargetIndexRoute = RedirectTargetIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => RedirectTargetRoute, } as any) -const RedirectTargetViaLoaderRoute = RedirectTargetViaLoaderImport.update({ +const RedirectTargetViaLoaderRoute = RedirectTargetViaLoaderRouteImport.update({ id: '/via-loader', path: '/via-loader', getParentRoute: () => RedirectTargetRoute, } as any) const RedirectTargetViaBeforeLoadRoute = - RedirectTargetViaBeforeLoadImport.update({ + RedirectTargetViaBeforeLoadRouteImport.update({ id: '/via-beforeLoad', path: '/via-beforeLoad', getParentRoute: () => RedirectTargetRoute, } as any) -const PostsPostIdDeepRoute = PostsPostIdDeepImport.update({ +const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ id: '/posts_/$postId/deep', path: '/posts/$postId/deep', getParentRoute: () => rootRoute, } as any) -const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBImport.update({ +const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => LayoutLayout2Route, } as any) -const LayoutLayout2LayoutARoute = LayoutLayout2LayoutAImport.update({ +const LayoutLayout2LayoutARoute = LayoutLayout2LayoutARouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => LayoutLayout2Route, } as any) const RedirectTargetServerFnIndexRoute = - RedirectTargetServerFnIndexImport.update({ + RedirectTargetServerFnIndexRouteImport.update({ id: '/serverFn/', path: '/serverFn/', getParentRoute: () => RedirectTargetRoute, } as any) const RedirectTargetServerFnViaUseServerFnRoute = - RedirectTargetServerFnViaUseServerFnImport.update({ + RedirectTargetServerFnViaUseServerFnRouteImport.update({ id: '/serverFn/via-useServerFn', path: '/serverFn/via-useServerFn', getParentRoute: () => RedirectTargetRoute, } as any) const RedirectTargetServerFnViaLoaderRoute = - RedirectTargetServerFnViaLoaderImport.update({ + RedirectTargetServerFnViaLoaderRouteImport.update({ id: '/serverFn/via-loader', path: '/serverFn/via-loader', getParentRoute: () => RedirectTargetRoute, } as any) const RedirectTargetServerFnViaBeforeLoadRoute = - RedirectTargetServerFnViaBeforeLoadImport.update({ + RedirectTargetServerFnViaBeforeLoadRouteImport.update({ id: '/serverFn/via-beforeLoad', path: '/serverFn/via-beforeLoad', getParentRoute: () => RedirectTargetRoute, @@ -235,215 +236,488 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/not-found': { id: '/not-found' path: '/not-found' fullPath: '/not-found' - preLoaderRoute: typeof NotFoundRouteImport + preLoaderRoute: typeof NotFoundRouteRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutRouteImport parentRoute: typeof rootRoute } '/deferred': { id: '/deferred' path: '/deferred' fullPath: '/deferred' - preLoaderRoute: typeof DeferredImport + preLoaderRoute: typeof DeferredRouteImport parentRoute: typeof rootRoute } '/links': { id: '/links' path: '/links' fullPath: '/links' - preLoaderRoute: typeof LinksImport + preLoaderRoute: typeof LinksRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/scripts': { id: '/scripts' path: '/scripts' fullPath: '/scripts' - preLoaderRoute: typeof ScriptsImport + preLoaderRoute: typeof ScriptsRouteImport parentRoute: typeof rootRoute } '/search-params': { id: '/search-params' path: '/search-params' fullPath: '/search-params' - preLoaderRoute: typeof SearchParamsImport + preLoaderRoute: typeof SearchParamsRouteImport parentRoute: typeof rootRoute } '/stream': { id: '/stream' path: '/stream' fullPath: '/stream' - preLoaderRoute: typeof StreamImport + preLoaderRoute: typeof StreamRouteImport parentRoute: typeof rootRoute } '/users': { id: '/users' path: '/users' fullPath: '/users' - preLoaderRoute: typeof UsersImport + preLoaderRoute: typeof UsersRouteImport parentRoute: typeof rootRoute } '/_layout/_layout-2': { id: '/_layout/_layout-2' path: '' fullPath: '' - preLoaderRoute: typeof LayoutLayout2Import - parentRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutLayout2RouteImport + parentRoute: typeof LayoutRouteImport } '/not-found/via-beforeLoad': { id: '/not-found/via-beforeLoad' path: '/via-beforeLoad' fullPath: '/not-found/via-beforeLoad' - preLoaderRoute: typeof NotFoundViaBeforeLoadImport - parentRoute: typeof NotFoundRouteImport + preLoaderRoute: typeof NotFoundViaBeforeLoadRouteImport + parentRoute: typeof NotFoundRouteRouteImport } '/not-found/via-loader': { id: '/not-found/via-loader' path: '/via-loader' fullPath: '/not-found/via-loader' - preLoaderRoute: typeof NotFoundViaLoaderImport - parentRoute: typeof NotFoundRouteImport + preLoaderRoute: typeof NotFoundViaLoaderRouteImport + parentRoute: typeof NotFoundRouteRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/redirect/$target': { id: '/redirect/$target' path: '/redirect/$target' fullPath: '/redirect/$target' - preLoaderRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetRouteImport parentRoute: typeof rootRoute } '/users/$userId': { id: '/users/$userId' path: '/$userId' fullPath: '/users/$userId' - preLoaderRoute: typeof UsersUserIdImport - parentRoute: typeof UsersImport + preLoaderRoute: typeof UsersUserIdRouteImport + parentRoute: typeof UsersRouteImport } '/not-found/': { id: '/not-found/' path: '/' fullPath: '/not-found/' - preLoaderRoute: typeof NotFoundIndexImport - parentRoute: typeof NotFoundRouteImport + preLoaderRoute: typeof NotFoundIndexRouteImport + parentRoute: typeof NotFoundRouteRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/redirect/': { id: '/redirect/' path: '/redirect' fullPath: '/redirect' - preLoaderRoute: typeof RedirectIndexImport + preLoaderRoute: typeof RedirectIndexRouteImport parentRoute: typeof rootRoute } '/users/': { id: '/users/' path: '/' fullPath: '/users/' - preLoaderRoute: typeof UsersIndexImport - parentRoute: typeof UsersImport + preLoaderRoute: typeof UsersIndexRouteImport + parentRoute: typeof UsersRouteImport } '/_layout/_layout-2/layout-a': { id: '/_layout/_layout-2/layout-a' path: '/layout-a' fullPath: '/layout-a' - preLoaderRoute: typeof LayoutLayout2LayoutAImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutARouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/_layout/_layout-2/layout-b': { id: '/_layout/_layout-2/layout-b' path: '/layout-b' fullPath: '/layout-b' - preLoaderRoute: typeof LayoutLayout2LayoutBImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/posts_/$postId/deep': { id: '/posts_/$postId/deep' path: '/posts/$postId/deep' fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepImport + preLoaderRoute: typeof PostsPostIdDeepRouteImport parentRoute: typeof rootRoute } '/redirect/$target/via-beforeLoad': { id: '/redirect/$target/via-beforeLoad' path: '/via-beforeLoad' fullPath: '/redirect/$target/via-beforeLoad' - preLoaderRoute: typeof RedirectTargetViaBeforeLoadImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetViaBeforeLoadRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/via-loader': { id: '/redirect/$target/via-loader' path: '/via-loader' fullPath: '/redirect/$target/via-loader' - preLoaderRoute: typeof RedirectTargetViaLoaderImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetViaLoaderRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/': { id: '/redirect/$target/' path: '/' fullPath: '/redirect/$target/' - preLoaderRoute: typeof RedirectTargetIndexImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetIndexRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/serverFn/via-beforeLoad': { id: '/redirect/$target/serverFn/via-beforeLoad' path: '/serverFn/via-beforeLoad' fullPath: '/redirect/$target/serverFn/via-beforeLoad' - preLoaderRoute: typeof RedirectTargetServerFnViaBeforeLoadImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetServerFnViaBeforeLoadRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/serverFn/via-loader': { id: '/redirect/$target/serverFn/via-loader' path: '/serverFn/via-loader' fullPath: '/redirect/$target/serverFn/via-loader' - preLoaderRoute: typeof RedirectTargetServerFnViaLoaderImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetServerFnViaLoaderRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/serverFn/via-useServerFn': { id: '/redirect/$target/serverFn/via-useServerFn' path: '/serverFn/via-useServerFn' fullPath: '/redirect/$target/serverFn/via-useServerFn' - preLoaderRoute: typeof RedirectTargetServerFnViaUseServerFnImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetServerFnViaUseServerFnRouteImport + parentRoute: typeof RedirectTargetRouteImport } '/redirect/$target/serverFn/': { id: '/redirect/$target/serverFn/' path: '/serverFn' fullPath: '/redirect/$target/serverFn' - preLoaderRoute: typeof RedirectTargetServerFnIndexImport - parentRoute: typeof RedirectTargetImport + preLoaderRoute: typeof RedirectTargetServerFnIndexRouteImport + parentRoute: typeof RedirectTargetRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/not-found/route' { + const createFileRoute: CreateFileRoute< + '/not-found', + FileRoutesByPath['/not-found']['parentRoute'], + FileRoutesByPath['/not-found']['id'], + FileRoutesByPath['/not-found']['path'], + FileRoutesByPath['/not-found']['fullPath'] + > +} +declare module './routes/_layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/deferred' { + const createFileRoute: CreateFileRoute< + '/deferred', + FileRoutesByPath['/deferred']['parentRoute'], + FileRoutesByPath['/deferred']['id'], + FileRoutesByPath['/deferred']['path'], + FileRoutesByPath['/deferred']['fullPath'] + > +} +declare module './routes/links' { + const createFileRoute: CreateFileRoute< + '/links', + FileRoutesByPath['/links']['parentRoute'], + FileRoutesByPath['/links']['id'], + FileRoutesByPath['/links']['path'], + FileRoutesByPath['/links']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/scripts' { + const createFileRoute: CreateFileRoute< + '/scripts', + FileRoutesByPath['/scripts']['parentRoute'], + FileRoutesByPath['/scripts']['id'], + FileRoutesByPath['/scripts']['path'], + FileRoutesByPath['/scripts']['fullPath'] + > +} +declare module './routes/search-params' { + const createFileRoute: CreateFileRoute< + '/search-params', + FileRoutesByPath['/search-params']['parentRoute'], + FileRoutesByPath['/search-params']['id'], + FileRoutesByPath['/search-params']['path'], + FileRoutesByPath['/search-params']['fullPath'] + > +} +declare module './routes/stream' { + const createFileRoute: CreateFileRoute< + '/stream', + FileRoutesByPath['/stream']['parentRoute'], + FileRoutesByPath['/stream']['id'], + FileRoutesByPath['/stream']['path'], + FileRoutesByPath['/stream']['fullPath'] + > +} +declare module './routes/users' { + const createFileRoute: CreateFileRoute< + '/users', + FileRoutesByPath['/users']['parentRoute'], + FileRoutesByPath['/users']['id'], + FileRoutesByPath['/users']['path'], + FileRoutesByPath['/users']['fullPath'] + > +} +declare module './routes/_layout/_layout-2' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2', + FileRoutesByPath['/_layout/_layout-2']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2']['id'], + FileRoutesByPath['/_layout/_layout-2']['path'], + FileRoutesByPath['/_layout/_layout-2']['fullPath'] + > +} +declare module './routes/not-found/via-beforeLoad' { + const createFileRoute: CreateFileRoute< + '/not-found/via-beforeLoad', + FileRoutesByPath['/not-found/via-beforeLoad']['parentRoute'], + FileRoutesByPath['/not-found/via-beforeLoad']['id'], + FileRoutesByPath['/not-found/via-beforeLoad']['path'], + FileRoutesByPath['/not-found/via-beforeLoad']['fullPath'] + > +} +declare module './routes/not-found/via-loader' { + const createFileRoute: CreateFileRoute< + '/not-found/via-loader', + FileRoutesByPath['/not-found/via-loader']['parentRoute'], + FileRoutesByPath['/not-found/via-loader']['id'], + FileRoutesByPath['/not-found/via-loader']['path'], + FileRoutesByPath['/not-found/via-loader']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/redirect/$target' { + const createFileRoute: CreateFileRoute< + '/redirect/$target', + FileRoutesByPath['/redirect/$target']['parentRoute'], + FileRoutesByPath['/redirect/$target']['id'], + FileRoutesByPath['/redirect/$target']['path'], + FileRoutesByPath['/redirect/$target']['fullPath'] + > +} +declare module './routes/users.$userId' { + const createFileRoute: CreateFileRoute< + '/users/$userId', + FileRoutesByPath['/users/$userId']['parentRoute'], + FileRoutesByPath['/users/$userId']['id'], + FileRoutesByPath['/users/$userId']['path'], + FileRoutesByPath['/users/$userId']['fullPath'] + > +} +declare module './routes/not-found/index' { + const createFileRoute: CreateFileRoute< + '/not-found/', + FileRoutesByPath['/not-found/']['parentRoute'], + FileRoutesByPath['/not-found/']['id'], + FileRoutesByPath['/not-found/']['path'], + FileRoutesByPath['/not-found/']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/redirect/index' { + const createFileRoute: CreateFileRoute< + '/redirect/', + FileRoutesByPath['/redirect/']['parentRoute'], + FileRoutesByPath['/redirect/']['id'], + FileRoutesByPath['/redirect/']['path'], + FileRoutesByPath['/redirect/']['fullPath'] + > +} +declare module './routes/users.index' { + const createFileRoute: CreateFileRoute< + '/users/', + FileRoutesByPath['/users/']['parentRoute'], + FileRoutesByPath['/users/']['id'], + FileRoutesByPath['/users/']['path'], + FileRoutesByPath['/users/']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-a' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-a', + FileRoutesByPath['/_layout/_layout-2/layout-a']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-b' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-b', + FileRoutesByPath['/_layout/_layout-2/layout-b']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['fullPath'] + > +} +declare module './routes/posts_.$postId.deep' { + const createFileRoute: CreateFileRoute< + '/posts_/$postId/deep', + FileRoutesByPath['/posts_/$postId/deep']['parentRoute'], + FileRoutesByPath['/posts_/$postId/deep']['id'], + FileRoutesByPath['/posts_/$postId/deep']['path'], + FileRoutesByPath['/posts_/$postId/deep']['fullPath'] + > +} +declare module './routes/redirect/$target/via-beforeLoad' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/via-beforeLoad', + FileRoutesByPath['/redirect/$target/via-beforeLoad']['parentRoute'], + FileRoutesByPath['/redirect/$target/via-beforeLoad']['id'], + FileRoutesByPath['/redirect/$target/via-beforeLoad']['path'], + FileRoutesByPath['/redirect/$target/via-beforeLoad']['fullPath'] + > +} +declare module './routes/redirect/$target/via-loader' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/via-loader', + FileRoutesByPath['/redirect/$target/via-loader']['parentRoute'], + FileRoutesByPath['/redirect/$target/via-loader']['id'], + FileRoutesByPath['/redirect/$target/via-loader']['path'], + FileRoutesByPath['/redirect/$target/via-loader']['fullPath'] + > +} +declare module './routes/redirect/$target/index' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/', + FileRoutesByPath['/redirect/$target/']['parentRoute'], + FileRoutesByPath['/redirect/$target/']['id'], + FileRoutesByPath['/redirect/$target/']['path'], + FileRoutesByPath['/redirect/$target/']['fullPath'] + > +} +declare module './routes/redirect/$target/serverFn/via-beforeLoad' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/serverFn/via-beforeLoad', + FileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['parentRoute'], + FileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['id'], + FileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['path'], + FileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['fullPath'] + > +} +declare module './routes/redirect/$target/serverFn/via-loader' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/serverFn/via-loader', + FileRoutesByPath['/redirect/$target/serverFn/via-loader']['parentRoute'], + FileRoutesByPath['/redirect/$target/serverFn/via-loader']['id'], + FileRoutesByPath['/redirect/$target/serverFn/via-loader']['path'], + FileRoutesByPath['/redirect/$target/serverFn/via-loader']['fullPath'] + > +} +declare module './routes/redirect/$target/serverFn/via-useServerFn' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/serverFn/via-useServerFn', + FileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['parentRoute'], + FileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['id'], + FileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['path'], + FileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['fullPath'] + > +} +declare module './routes/redirect/$target/serverFn/index' { + const createFileRoute: CreateFileRoute< + '/redirect/$target/serverFn/', + FileRoutesByPath['/redirect/$target/serverFn/']['parentRoute'], + FileRoutesByPath['/redirect/$target/serverFn/']['id'], + FileRoutesByPath['/redirect/$target/serverFn/']['path'], + FileRoutesByPath['/redirect/$target/serverFn/']['fullPath'] + > +} + // Create and export the route tree interface NotFoundRouteRouteChildren { @@ -761,6 +1035,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/solid-start/basic/src/routes/__root.tsx b/e2e/solid-start/basic/src/routes/__root.tsx index 5ef4d4653b..89c60f9113 100644 --- a/e2e/solid-start/basic/src/routes/__root.tsx +++ b/e2e/solid-start/basic/src/routes/__root.tsx @@ -1,9 +1,9 @@ import { Link, Outlet, createRootRoute } from '@tanstack/solid-router' +import { TanStackRouterDevtoolsInProd } from '@tanstack/solid-router-devtools' import { NotFound } from '~/components/NotFound' import appCss from '~/styles/app.css?url' import { seo } from '~/utils/seo' -import { TanStackRouterDevtoolsInProd } from '@tanstack/solid-router-devtools' export const Route = createRootRoute({ head: () => ({ diff --git a/e2e/solid-start/basic/src/routes/_layout.tsx b/e2e/solid-start/basic/src/routes/_layout.tsx index d43b4ef5f5..c549175638 100644 --- a/e2e/solid-start/basic/src/routes/_layout.tsx +++ b/e2e/solid-start/basic/src/routes/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-start/basic/src/routes/_layout/_layout-2.tsx b/e2e/solid-start/basic/src/routes/_layout/_layout-2.tsx index 7a5a3623a0..efeca5ce86 100644 --- a/e2e/solid-start/basic/src/routes/_layout/_layout-2.tsx +++ b/e2e/solid-start/basic/src/routes/_layout/_layout-2.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_layout/_layout-2')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/e2e/solid-start/basic/src/routes/_layout/_layout-2/layout-a.tsx b/e2e/solid-start/basic/src/routes/_layout/_layout-2/layout-a.tsx index b69951b246..a190b24202 100644 --- a/e2e/solid-start/basic/src/routes/_layout/_layout-2/layout-a.tsx +++ b/e2e/solid-start/basic/src/routes/_layout/_layout-2/layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/e2e/solid-start/basic/src/routes/_layout/_layout-2/layout-b.tsx b/e2e/solid-start/basic/src/routes/_layout/_layout-2/layout-b.tsx index 30dbcce90f..505f8f6fbf 100644 --- a/e2e/solid-start/basic/src/routes/_layout/_layout-2/layout-b.tsx +++ b/e2e/solid-start/basic/src/routes/_layout/_layout-2/layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/e2e/solid-start/basic/src/routes/api.users.ts b/e2e/solid-start/basic/src/routes/api.users.ts deleted file mode 100644 index 45ac83b2f0..0000000000 --- a/e2e/solid-start/basic/src/routes/api.users.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { json } from '@tanstack/solid-start' -import { createAPIFileRoute } from '@tanstack/solid-start/api' -import axios from 'redaxios' - -import type { User } from '~/utils/users' - -export const APIRoute = createAPIFileRoute('/api/users')({ - GET: async ({ request }) => { - console.info('Fetching users... @', request.url) - const res = await axios.get>( - 'https://jsonplaceholder.typicode.com/users', - ) - - const list = res.data.slice(0, 10) - - return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email }))) - }, -}) diff --git a/e2e/solid-start/basic/src/routes/api/users.$id.ts b/e2e/solid-start/basic/src/routes/api/users.$id.ts deleted file mode 100644 index 7ee1fccbb4..0000000000 --- a/e2e/solid-start/basic/src/routes/api/users.$id.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { json } from '@tanstack/solid-start' -import { createAPIFileRoute } from '@tanstack/solid-start/api' -import axios from 'redaxios' - -import type { User } from '~/utils/users' - -export const APIRoute = createAPIFileRoute('/api/users/$id')({ - GET: async ({ request, params }) => { - console.info(`Fetching users by id=${params.id}... @`, request.url) - try { - const res = await axios.get( - 'https://jsonplaceholder.typicode.com/users/' + params.id, - ) - - return json({ - id: res.data.id, - name: res.data.name, - email: res.data.email, - }) - } catch (e) { - console.error(e) - return json({ error: 'User not found' }, { status: 404 }) - } - }, -}) diff --git a/e2e/solid-start/basic/src/routes/api/users.$userId.ts b/e2e/solid-start/basic/src/routes/api/users.$userId.ts new file mode 100644 index 0000000000..69d966d982 --- /dev/null +++ b/e2e/solid-start/basic/src/routes/api/users.$userId.ts @@ -0,0 +1,27 @@ +import { json } from '@tanstack/solid-start' +import type { User } from '~/utils/users' + +export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ params, request }) => { + console.info(`Fetching users by id=${params.userId}... @`, request.url) + try { + const res = await fetch( + 'https://jsonplaceholder.typicode.com/users/' + params.userId, + ) + if (!res.ok) { + throw new Error('Failed to fetch user') + } + + const user = (await res.json()) as User + + return json({ + id: user.id, + name: user.name, + email: user.email, + }) + } catch (e) { + console.error(e) + return json({ error: 'User not found' }, { status: 404 }) + } + }, +}) diff --git a/e2e/solid-start/basic/src/routes/api/users.ts b/e2e/solid-start/basic/src/routes/api/users.ts new file mode 100644 index 0000000000..c0a6a1a6a2 --- /dev/null +++ b/e2e/solid-start/basic/src/routes/api/users.ts @@ -0,0 +1,58 @@ +import { createMiddleware, json } from '@tanstack/solid-start' +import type { User } from '~/utils/users' + +const userLoggerMiddleware = createMiddleware({ type: 'request' }).server( + async ({ next, request }) => { + console.info('In: /users') + const result = await next() + result.response.headers.set('x-users', 'true') + console.info('Out: /users') + return result + }, +) + +const testParentMiddleware = createMiddleware({ type: 'request' }).server( + async ({ next, request }) => { + console.info('In: testParentMiddleware') + const result = await next() + result.response.headers.set('x-test-parent', 'true') + console.info('Out: testParentMiddleware') + return result + }, +) + +const testMiddleware = createMiddleware({ type: 'request' }) + .middleware([testParentMiddleware]) + .server(async ({ next, request }) => { + console.info('In: testMiddleware') + const result = await next() + result.response.headers.set('x-test', 'true') + + // if (Math.random() > 0.5) { + // throw new Response(null, { + // status: 302, + // headers: { Location: 'https://www.google.com' }, + // }) + // } + + console.info('Out: testMiddleware') + return result + }) + +export const ServerRoute = createServerFileRoute() + .middleware([testMiddleware, userLoggerMiddleware, testParentMiddleware]) + .methods({ + GET: async ({ request }) => { + console.info('Fetching users... @', request.url) + const res = await fetch('https://jsonplaceholder.typicode.com/users') + if (!res.ok) { + throw new Error('Failed to fetch users') + } + + const data = (await res.json()) as Array + + const list = data.slice(0, 10) + + return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email }))) + }, + }) diff --git a/e2e/solid-start/basic/src/routes/deferred.tsx b/e2e/solid-start/basic/src/routes/deferred.tsx index 2a53643453..5bb96ca571 100644 --- a/e2e/solid-start/basic/src/routes/deferred.tsx +++ b/e2e/solid-start/basic/src/routes/deferred.tsx @@ -1,4 +1,4 @@ -import { Await, createFileRoute } from '@tanstack/solid-router' +import { Await } from '@tanstack/solid-router' import { createServerFn } from '@tanstack/solid-start' import { Suspense, createSignal } from 'solid-js' @@ -15,7 +15,7 @@ const slowServerFn = createServerFn({ method: 'GET' }) return { name: data.name, randomNumber: Math.floor(Math.random() * 100) } }) -export const Route = createFileRoute('/deferred')({ +export const Route = createFileRoute({ loader: async () => { return { deferredStuff: new Promise((r) => diff --git a/e2e/solid-start/basic/src/routes/index.tsx b/e2e/solid-start/basic/src/routes/index.tsx index 6b23caf87b..4024800b8e 100644 --- a/e2e/solid-start/basic/src/routes/index.tsx +++ b/e2e/solid-start/basic/src/routes/index.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' import { CustomMessage } from '~/components/CustomMessage' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/solid-start/basic/src/routes/links.tsx b/e2e/solid-start/basic/src/routes/links.tsx index d6ce6a449b..05fd8f0494 100644 --- a/e2e/solid-start/basic/src/routes/links.tsx +++ b/e2e/solid-start/basic/src/routes/links.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' -export const Route = createFileRoute('/links')({ +export const Route = createFileRoute({ component: () => { const navigate = Route.useNavigate() return ( diff --git a/e2e/solid-start/basic/src/routes/not-found/index.tsx b/e2e/solid-start/basic/src/routes/not-found/index.tsx index 34c8ef6146..79e7b5ae56 100644 --- a/e2e/solid-start/basic/src/routes/not-found/index.tsx +++ b/e2e/solid-start/basic/src/routes/not-found/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' -export const Route = createFileRoute('/not-found/')({ +export const Route = createFileRoute({ component: () => { const preload = Route.useSearch({ select: (s) => s.preload }) return ( diff --git a/e2e/solid-start/basic/src/routes/not-found/route.tsx b/e2e/solid-start/basic/src/routes/not-found/route.tsx index 84f5ef81a5..b8343167f5 100644 --- a/e2e/solid-start/basic/src/routes/not-found/route.tsx +++ b/e2e/solid-start/basic/src/routes/not-found/route.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' import z from 'zod' -export const Route = createFileRoute('/not-found')({ +export const Route = createFileRoute({ validateSearch: z.object({ preload: z.literal(false).optional(), }), diff --git a/e2e/solid-start/basic/src/routes/not-found/via-beforeLoad.tsx b/e2e/solid-start/basic/src/routes/not-found/via-beforeLoad.tsx index 5badde63bd..5277edd901 100644 --- a/e2e/solid-start/basic/src/routes/not-found/via-beforeLoad.tsx +++ b/e2e/solid-start/basic/src/routes/not-found/via-beforeLoad.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, notFound } from '@tanstack/solid-router' +import { notFound } from '@tanstack/solid-router' -export const Route = createFileRoute('/not-found/via-beforeLoad')({ +export const Route = createFileRoute({ beforeLoad: () => { throw notFound() }, diff --git a/e2e/solid-start/basic/src/routes/not-found/via-loader.tsx b/e2e/solid-start/basic/src/routes/not-found/via-loader.tsx index 20956cc43d..bc0fad6c58 100644 --- a/e2e/solid-start/basic/src/routes/not-found/via-loader.tsx +++ b/e2e/solid-start/basic/src/routes/not-found/via-loader.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, notFound } from '@tanstack/solid-router' +import { notFound } from '@tanstack/solid-router' -export const Route = createFileRoute('/not-found/via-loader')({ +export const Route = createFileRoute({ loader: () => { throw notFound() }, diff --git a/e2e/solid-start/basic/src/routes/posts.$postId.tsx b/e2e/solid-start/basic/src/routes/posts.$postId.tsx index c6b2fcf5f9..cefc75cdf1 100644 --- a/e2e/solid-start/basic/src/routes/posts.$postId.tsx +++ b/e2e/solid-start/basic/src/routes/posts.$postId.tsx @@ -1,11 +1,11 @@ -import { ErrorComponent, Link, createFileRoute } from '@tanstack/solid-router' +import { ErrorComponent, Link } from '@tanstack/solid-router' import type { ErrorComponentProps } from '@tanstack/solid-router' import { fetchPost } from '~/utils/posts' import { NotFound } from '~/components/NotFound' import { PostErrorComponent } from '~/components/PostErrorComponent' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost({ data: postId }), errorComponent: PostErrorComponent, component: PostComponent, diff --git a/e2e/solid-start/basic/src/routes/posts.index.tsx b/e2e/solid-start/basic/src/routes/posts.index.tsx index c7d8cfe19c..07e41d1b0b 100644 --- a/e2e/solid-start/basic/src/routes/posts.index.tsx +++ b/e2e/solid-start/basic/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/e2e/solid-start/basic/src/routes/posts.tsx b/e2e/solid-start/basic/src/routes/posts.tsx index 0e94cd4d2c..c053d0de56 100644 --- a/e2e/solid-start/basic/src/routes/posts.tsx +++ b/e2e/solid-start/basic/src/routes/posts.tsx @@ -1,9 +1,9 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' import { For } from 'solid-js' import { fetchPosts } from '~/utils/posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ head: () => ({ meta: [ { diff --git a/e2e/solid-start/basic/src/routes/posts_.$postId.deep.tsx b/e2e/solid-start/basic/src/routes/posts_.$postId.deep.tsx index f8d4627914..4133a9ade9 100644 --- a/e2e/solid-start/basic/src/routes/posts_.$postId.deep.tsx +++ b/e2e/solid-start/basic/src/routes/posts_.$postId.deep.tsx @@ -1,9 +1,9 @@ -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' import { PostErrorComponent } from '~/components/PostErrorComponent' import { fetchPost } from '~/utils/posts' -export const Route = createFileRoute('/posts_/$postId/deep')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost({ data: postId }), errorComponent: PostErrorComponent, component: PostDeepComponent, diff --git a/e2e/solid-start/basic/src/routes/redirect/$target.tsx b/e2e/solid-start/basic/src/routes/redirect/$target.tsx index 525dd9da25..c4c78070d3 100644 --- a/e2e/solid-start/basic/src/routes/redirect/$target.tsx +++ b/e2e/solid-start/basic/src/routes/redirect/$target.tsx @@ -1,7 +1,7 @@ -import { createFileRoute, retainSearchParams } from '@tanstack/solid-router' +import { retainSearchParams } from '@tanstack/solid-router' import z from 'zod' -export const Route = createFileRoute('/redirect/$target')({ +export const Route = createFileRoute({ params: { parse: (p) => z diff --git a/e2e/solid-start/basic/src/routes/redirect/$target/index.tsx b/e2e/solid-start/basic/src/routes/redirect/$target/index.tsx index 916afd450b..0dde05d9e1 100644 --- a/e2e/solid-start/basic/src/routes/redirect/$target/index.tsx +++ b/e2e/solid-start/basic/src/routes/redirect/$target/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' -export const Route = createFileRoute('/redirect/$target/')({ +export const Route = createFileRoute({ component: () => { const preload = Route.useSearch({ select: (s) => s.preload }) return ( diff --git a/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/index.tsx b/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/index.tsx index d404672372..6be32366eb 100644 --- a/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/index.tsx +++ b/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' -export const Route = createFileRoute('/redirect/$target/serverFn/')({ +export const Route = createFileRoute({ component: () => (

diff --git a/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/via-beforeLoad.tsx b/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/via-beforeLoad.tsx index 81f9dd2d36..3aad8bffa4 100644 --- a/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/via-beforeLoad.tsx +++ b/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/via-beforeLoad.tsx @@ -1,9 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' import { throwRedirect } from '~/components/throwRedirect' -export const Route = createFileRoute( - '/redirect/$target/serverFn/via-beforeLoad', -)({ +export const Route = createFileRoute({ beforeLoad: ({ params: { target }, search: { reloadDocument, externalHost }, diff --git a/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/via-loader.tsx b/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/via-loader.tsx index 0b6ac91c15..3087fa2e15 100644 --- a/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/via-loader.tsx +++ b/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/via-loader.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' import { throwRedirect } from '~/components/throwRedirect' -export const Route = createFileRoute('/redirect/$target/serverFn/via-loader')({ +export const Route = createFileRoute({ loaderDeps: ({ search: { reloadDocument, externalHost } }) => ({ reloadDocument, externalHost, diff --git a/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/via-useServerFn.tsx b/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/via-useServerFn.tsx index 5b0c246474..969f6c02c2 100644 --- a/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/via-useServerFn.tsx +++ b/e2e/solid-start/basic/src/routes/redirect/$target/serverFn/via-useServerFn.tsx @@ -1,9 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' import { RedirectOnClick } from '~/components/RedirectOnClick' -export const Route = createFileRoute( - '/redirect/$target/serverFn/via-useServerFn', -)({ +export const Route = createFileRoute({ component: () => { const params = Route.useParams() const search = Route.useSearch() diff --git a/e2e/solid-start/basic/src/routes/redirect/$target/via-beforeLoad.tsx b/e2e/solid-start/basic/src/routes/redirect/$target/via-beforeLoad.tsx index c88cc07986..bac534bfc5 100644 --- a/e2e/solid-start/basic/src/routes/redirect/$target/via-beforeLoad.tsx +++ b/e2e/solid-start/basic/src/routes/redirect/$target/via-beforeLoad.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/solid-router' +import { redirect } from '@tanstack/solid-router' -export const Route = createFileRoute('/redirect/$target/via-beforeLoad')({ +export const Route = createFileRoute({ beforeLoad: ({ params: { target }, search: { reloadDocument, externalHost }, diff --git a/e2e/solid-start/basic/src/routes/redirect/$target/via-loader.tsx b/e2e/solid-start/basic/src/routes/redirect/$target/via-loader.tsx index 5c059717c5..686c0d8971 100644 --- a/e2e/solid-start/basic/src/routes/redirect/$target/via-loader.tsx +++ b/e2e/solid-start/basic/src/routes/redirect/$target/via-loader.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/solid-router' +import { redirect } from '@tanstack/solid-router' -export const Route = createFileRoute('/redirect/$target/via-loader')({ +export const Route = createFileRoute({ loaderDeps: ({ search: { reloadDocument, externalHost } }) => ({ reloadDocument, externalHost, diff --git a/e2e/solid-start/basic/src/routes/redirect/index.tsx b/e2e/solid-start/basic/src/routes/redirect/index.tsx index 043f305e57..26aefc154c 100644 --- a/e2e/solid-start/basic/src/routes/redirect/index.tsx +++ b/e2e/solid-start/basic/src/routes/redirect/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' -export const Route = createFileRoute('/redirect/')({ +export const Route = createFileRoute({ component: () => (
const isProd = import.meta.env.PROD -export const Route = createFileRoute('/scripts')({ +export const Route = createFileRoute({ head: () => ({ scripts: [ { diff --git a/e2e/solid-start/basic/src/routes/search-params.tsx b/e2e/solid-start/basic/src/routes/search-params.tsx index ec941d9a4c..fbacb055ac 100644 --- a/e2e/solid-start/basic/src/routes/search-params.tsx +++ b/e2e/solid-start/basic/src/routes/search-params.tsx @@ -1,7 +1,7 @@ -import { createFileRoute, redirect } from '@tanstack/solid-router' +import { redirect } from '@tanstack/solid-router' import { z } from 'zod' -export const Route = createFileRoute('/search-params')({ +export const Route = createFileRoute({ component: () => { const search = Route.useSearch() return ( diff --git a/e2e/solid-start/basic/src/routes/stream.tsx b/e2e/solid-start/basic/src/routes/stream.tsx index d1d21e344a..d0fb3f82cf 100644 --- a/e2e/solid-start/basic/src/routes/stream.tsx +++ b/e2e/solid-start/basic/src/routes/stream.tsx @@ -1,7 +1,7 @@ -import { Await, createFileRoute } from '@tanstack/solid-router' +import { Await } from '@tanstack/solid-router' import { createEffect, createSignal } from 'solid-js' -export const Route = createFileRoute('/stream')({ +export const Route = createFileRoute({ component: Home, loader() { return { diff --git a/e2e/solid-start/basic/src/routes/users.$userId.tsx b/e2e/solid-start/basic/src/routes/users.$userId.tsx index 6f95652e53..41a545e458 100644 --- a/e2e/solid-start/basic/src/routes/users.$userId.tsx +++ b/e2e/solid-start/basic/src/routes/users.$userId.tsx @@ -1,4 +1,4 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/solid-router' +import { ErrorComponent } from '@tanstack/solid-router' import axios from 'redaxios' import type { ErrorComponentProps } from '@tanstack/solid-router' @@ -7,7 +7,7 @@ import { DEPLOY_URL } from '~/utils/users' import { NotFound } from '~/components/NotFound' import { UserErrorComponent } from '~/components/UserErrorComponent' -export const Route = createFileRoute('/users/$userId')({ +export const Route = createFileRoute({ loader: async ({ params: { userId } }) => { return await axios .get(DEPLOY_URL + '/api/users/' + userId) diff --git a/e2e/solid-start/basic/src/routes/users.index.tsx b/e2e/solid-start/basic/src/routes/users.index.tsx index bbc96801a9..662e8b6c68 100644 --- a/e2e/solid-start/basic/src/routes/users.index.tsx +++ b/e2e/solid-start/basic/src/routes/users.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/users/')({ +export const Route = createFileRoute({ component: UsersIndexComponent, }) diff --git a/e2e/solid-start/basic/src/routes/users.tsx b/e2e/solid-start/basic/src/routes/users.tsx index 3c26badbb4..d25f900f4b 100644 --- a/e2e/solid-start/basic/src/routes/users.tsx +++ b/e2e/solid-start/basic/src/routes/users.tsx @@ -1,10 +1,10 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' import axios from 'redaxios' import type { User } from '~/utils/users' import { DEPLOY_URL } from '~/utils/users' -export const Route = createFileRoute('/users')({ +export const Route = createFileRoute({ loader: async () => { return await axios .get>(DEPLOY_URL + '/api/users') diff --git a/e2e/solid-start/basic/src/ssr.tsx b/e2e/solid-start/basic/src/ssr.tsx deleted file mode 100644 index 6d10bea05f..0000000000 --- a/e2e/solid-start/basic/src/ssr.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/solid-start/server' -import { getRouterManifest } from '@tanstack/solid-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/e2e/solid-start/basic/src/utils/users.tsx b/e2e/solid-start/basic/src/utils/users.tsx index 79b45867d5..46be4b1580 100644 --- a/e2e/solid-start/basic/src/utils/users.tsx +++ b/e2e/solid-start/basic/src/utils/users.tsx @@ -4,7 +4,6 @@ export type User = { email: string } -const PORT = - import.meta.env.VITE_SERVER_PORT || process.env.VITE_SERVER_PORT || 3000 +const PORT = process.env.VITE_SERVER_PORT || 3000 export const DEPLOY_URL = `http://localhost:${PORT}` diff --git a/e2e/solid-start/basic/src/vite-env.d.ts b/e2e/solid-start/basic/src/vite-env.d.ts new file mode 100644 index 0000000000..0b2af560d6 --- /dev/null +++ b/e2e/solid-start/basic/src/vite-env.d.ts @@ -0,0 +1,4 @@ +declare module '*?url' { + const url: string + export default url +} diff --git a/e2e/solid-start/basic/vite.config.ts b/e2e/solid-start/basic/vite.config.ts new file mode 100644 index 0000000000..f6a9e52322 --- /dev/null +++ b/e2e/solid-start/basic/vite.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/solid-start/plugin' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin({}), + ], +}) diff --git a/e2e/solid-start/scroll-restoration/.gitignore b/e2e/solid-start/scroll-restoration/.gitignore index be342025da..a79d5cf129 100644 --- a/e2e/solid-start/scroll-restoration/.gitignore +++ b/e2e/solid-start/scroll-restoration/.gitignore @@ -7,13 +7,11 @@ yarn.lock .env .vercel .output -.vinxi /build/ /api/ /server/build /public/build -.vinxi # Sentry Config File .env.sentry-build-plugin /test-results/ diff --git a/e2e/solid-start/scroll-restoration/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/solid-start/scroll-restoration/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..2dc6bfc4bd --- /dev/null +++ b/e2e/solid-start/scroll-restoration/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/solid-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/solid-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/solid-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/solid-start/scroll-restoration/app.config.ts b/e2e/solid-start/scroll-restoration/app.config.ts deleted file mode 100644 index 2a06e3d3f0..0000000000 --- a/e2e/solid-start/scroll-restoration/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/solid-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/e2e/solid-start/scroll-restoration/package.json b/e2e/solid-start/scroll-restoration/package.json index 81fce6eaea..e42cb920ab 100644 --- a/e2e/solid-start/scroll-restoration/package.json +++ b/e2e/solid-start/scroll-restoration/package.json @@ -4,10 +4,10 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev --port 3000", - "dev:e2e": "vinxi dev", - "build": "vinxi build && tsc --noEmit", - "start": "vinxi start", + "dev": "vite dev --port 3000", + "dev:e2e": "vite dev", + "build": "vite build && tsc --noEmit", + "start": "node .output/server/index.mjs", "test:e2e": "playwright test --project=chromium" }, "dependencies": { @@ -18,7 +18,6 @@ "solid-js": "^1.9.5", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3", "zod": "^3.24.2" }, "devDependencies": { diff --git a/e2e/solid-start/scroll-restoration/playwright.config.ts b/e2e/solid-start/scroll-restoration/playwright.config.ts index 95d043d48b..e834d88cf4 100644 --- a/e2e/solid-start/scroll-restoration/playwright.config.ts +++ b/e2e/solid-start/scroll-restoration/playwright.config.ts @@ -20,7 +20,7 @@ export default defineConfig({ }, webServer: { - command: `VITE_SERVER_PORT=${PORT} pnpm build && VITE_SERVER_PORT=${PORT} pnpm start --port ${PORT}`, + command: `pnpm build && VITE_SERVER_PORT=${PORT} PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', diff --git a/e2e/solid-start/scroll-restoration/src/api.ts b/e2e/solid-start/scroll-restoration/src/api.ts deleted file mode 100644 index ed511bcd26..0000000000 --- a/e2e/solid-start/scroll-restoration/src/api.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { - createStartAPIHandler, - defaultAPIFileRouteHandler, -} from '@tanstack/solid-start/api' - -export default createStartAPIHandler(defaultAPIFileRouteHandler) diff --git a/e2e/solid-start/scroll-restoration/src/client.tsx b/e2e/solid-start/scroll-restoration/src/client.tsx deleted file mode 100644 index ba0f02fac0..0000000000 --- a/e2e/solid-start/scroll-restoration/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrate } from 'solid-js/web' -import { StartClient } from '@tanstack/solid-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrate(() => , document.body) diff --git a/e2e/solid-start/scroll-restoration/src/routeTree.gen.ts b/e2e/solid-start/scroll-restoration/src/routeTree.gen.ts index d5cbca5b25..9057cd106b 100644 --- a/e2e/solid-start/scroll-restoration/src/routeTree.gen.ts +++ b/e2e/solid-start/scroll-restoration/src/routeTree.gen.ts @@ -10,33 +10,34 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' -import { Route as testsWithSearchImport } from './routes/(tests)/with-search' -import { Route as testsWithLoaderImport } from './routes/(tests)/with-loader' -import { Route as testsNormalPageImport } from './routes/(tests)/normal-page' +import { Route as IndexRouteImport } from './routes/index' +import { Route as testsWithSearchRouteImport } from './routes/(tests)/with-search' +import { Route as testsWithLoaderRouteImport } from './routes/(tests)/with-loader' +import { Route as testsNormalPageRouteImport } from './routes/(tests)/normal-page' // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const testsWithSearchRoute = testsWithSearchImport.update({ +const testsWithSearchRoute = testsWithSearchRouteImport.update({ id: '/(tests)/with-search', path: '/with-search', getParentRoute: () => rootRoute, } as any) -const testsWithLoaderRoute = testsWithLoaderImport.update({ +const testsWithLoaderRoute = testsWithLoaderRouteImport.update({ id: '/(tests)/with-loader', path: '/with-loader', getParentRoute: () => rootRoute, } as any) -const testsNormalPageRoute = testsNormalPageImport.update({ +const testsNormalPageRoute = testsNormalPageRouteImport.update({ id: '/(tests)/normal-page', path: '/normal-page', getParentRoute: () => rootRoute, @@ -50,33 +51,72 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/(tests)/normal-page': { id: '/(tests)/normal-page' path: '/normal-page' fullPath: '/normal-page' - preLoaderRoute: typeof testsNormalPageImport + preLoaderRoute: typeof testsNormalPageRouteImport parentRoute: typeof rootRoute } '/(tests)/with-loader': { id: '/(tests)/with-loader' path: '/with-loader' fullPath: '/with-loader' - preLoaderRoute: typeof testsWithLoaderImport + preLoaderRoute: typeof testsWithLoaderRouteImport parentRoute: typeof rootRoute } '/(tests)/with-search': { id: '/(tests)/with-search' path: '/with-search' fullPath: '/with-search' - preLoaderRoute: typeof testsWithSearchImport + preLoaderRoute: typeof testsWithSearchRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/(tests)/normal-page' { + const createFileRoute: CreateFileRoute< + '/(tests)/normal-page', + FileRoutesByPath['/(tests)/normal-page']['parentRoute'], + FileRoutesByPath['/(tests)/normal-page']['id'], + FileRoutesByPath['/(tests)/normal-page']['path'], + FileRoutesByPath['/(tests)/normal-page']['fullPath'] + > +} +declare module './routes/(tests)/with-loader' { + const createFileRoute: CreateFileRoute< + '/(tests)/with-loader', + FileRoutesByPath['/(tests)/with-loader']['parentRoute'], + FileRoutesByPath['/(tests)/with-loader']['id'], + FileRoutesByPath['/(tests)/with-loader']['path'], + FileRoutesByPath['/(tests)/with-loader']['fullPath'] + > +} +declare module './routes/(tests)/with-search' { + const createFileRoute: CreateFileRoute< + '/(tests)/with-search', + FileRoutesByPath['/(tests)/with-search']['parentRoute'], + FileRoutesByPath['/(tests)/with-search']['id'], + FileRoutesByPath['/(tests)/with-search']['path'], + FileRoutesByPath['/(tests)/with-search']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -133,6 +173,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/solid-start/scroll-restoration/src/routes/(tests)/normal-page.tsx b/e2e/solid-start/scroll-restoration/src/routes/(tests)/normal-page.tsx index 76d32719ef..b58a556b4f 100644 --- a/e2e/solid-start/scroll-restoration/src/routes/(tests)/normal-page.tsx +++ b/e2e/solid-start/scroll-restoration/src/routes/(tests)/normal-page.tsx @@ -1,8 +1,8 @@ import * as Solid from 'solid-js' -import { createFileRoute } from '@tanstack/solid-router' + import { ScrollBlock } from '../-components/scroll-block' -export const Route = createFileRoute('/(tests)/normal-page')({ +export const Route = createFileRoute({ component: Component, }) diff --git a/e2e/solid-start/scroll-restoration/src/routes/(tests)/with-loader.tsx b/e2e/solid-start/scroll-restoration/src/routes/(tests)/with-loader.tsx index aae7611b51..212ea0457f 100644 --- a/e2e/solid-start/scroll-restoration/src/routes/(tests)/with-loader.tsx +++ b/e2e/solid-start/scroll-restoration/src/routes/(tests)/with-loader.tsx @@ -1,8 +1,7 @@ -import { createFileRoute } from '@tanstack/solid-router' +import { sleep } from 'src/utils/posts' import { ScrollBlock } from '../-components/scroll-block' -import { sleep } from '~/utils/posts' -export const Route = createFileRoute('/(tests)/with-loader')({ +export const Route = createFileRoute({ loader: async () => { await sleep(1000) return { foo: 'bar' } diff --git a/e2e/solid-start/scroll-restoration/src/routes/(tests)/with-search.tsx b/e2e/solid-start/scroll-restoration/src/routes/(tests)/with-search.tsx index 5d43b7f9bb..073dd2501c 100644 --- a/e2e/solid-start/scroll-restoration/src/routes/(tests)/with-search.tsx +++ b/e2e/solid-start/scroll-restoration/src/routes/(tests)/with-search.tsx @@ -1,9 +1,8 @@ -import { createFileRoute } from '@tanstack/solid-router' import { z } from 'zod' import { zodValidator } from '@tanstack/zod-adapter' import { ScrollBlock } from '../-components/scroll-block' -export const Route = createFileRoute('/(tests)/with-search')({ +export const Route = createFileRoute({ validateSearch: zodValidator(z.object({ where: z.string() })), component: Component, }) diff --git a/e2e/solid-start/scroll-restoration/src/routes/__root.tsx b/e2e/solid-start/scroll-restoration/src/routes/__root.tsx index 5907fa6ecd..4af70096a1 100644 --- a/e2e/solid-start/scroll-restoration/src/routes/__root.tsx +++ b/e2e/solid-start/scroll-restoration/src/routes/__root.tsx @@ -1,18 +1,14 @@ -import * as Solid from 'solid-js' import { Link, Outlet, createRootRoute, linkOptions, - HeadContent, - Scripts, } from '@tanstack/solid-router' -import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary' +import { Dynamic } from 'solid-js/web' +import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools' import { NotFound } from '~/components/NotFound' import appCss from '~/styles/app.css?url' import { seo } from '~/utils/seo' -import { Dynamic } from 'solid-js/web' -import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools' export const Route = createRootRoute({ head: () => ({ diff --git a/e2e/solid-start/scroll-restoration/src/routes/index.tsx b/e2e/solid-start/scroll-restoration/src/routes/index.tsx index e950ce86c9..15c0376e3d 100644 --- a/e2e/solid-start/scroll-restoration/src/routes/index.tsx +++ b/e2e/solid-start/scroll-restoration/src/routes/index.tsx @@ -1,7 +1,7 @@ import * as Solid from 'solid-js' -import { Link, createFileRoute, linkOptions } from '@tanstack/solid-router' +import { Link, linkOptions } from '@tanstack/solid-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: HomeComponent, }) diff --git a/e2e/solid-start/scroll-restoration/src/ssr.tsx b/e2e/solid-start/scroll-restoration/src/ssr.tsx deleted file mode 100644 index 6d10bea05f..0000000000 --- a/e2e/solid-start/scroll-restoration/src/ssr.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/solid-start/server' -import { getRouterManifest } from '@tanstack/solid-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/e2e/solid-start/scroll-restoration/src/utils/users.tsx b/e2e/solid-start/scroll-restoration/src/utils/users.tsx index 79b45867d5..46be4b1580 100644 --- a/e2e/solid-start/scroll-restoration/src/utils/users.tsx +++ b/e2e/solid-start/scroll-restoration/src/utils/users.tsx @@ -4,7 +4,6 @@ export type User = { email: string } -const PORT = - import.meta.env.VITE_SERVER_PORT || process.env.VITE_SERVER_PORT || 3000 +const PORT = process.env.VITE_SERVER_PORT || 3000 export const DEPLOY_URL = `http://localhost:${PORT}` diff --git a/e2e/solid-start/scroll-restoration/src/vite-env.d.ts b/e2e/solid-start/scroll-restoration/src/vite-env.d.ts new file mode 100644 index 0000000000..0b2af560d6 --- /dev/null +++ b/e2e/solid-start/scroll-restoration/src/vite-env.d.ts @@ -0,0 +1,4 @@ +declare module '*?url' { + const url: string + export default url +} diff --git a/e2e/solid-start/scroll-restoration/vite.config.ts b/e2e/solid-start/scroll-restoration/vite.config.ts new file mode 100644 index 0000000000..f6a9e52322 --- /dev/null +++ b/e2e/solid-start/scroll-restoration/vite.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/solid-start/plugin' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin({}), + ], +}) diff --git a/e2e/solid-start/server-functions/.gitignore b/e2e/solid-start/server-functions/.gitignore index be342025da..a79d5cf129 100644 --- a/e2e/solid-start/server-functions/.gitignore +++ b/e2e/solid-start/server-functions/.gitignore @@ -7,13 +7,11 @@ yarn.lock .env .vercel .output -.vinxi /build/ /api/ /server/build /public/build -.vinxi # Sentry Config File .env.sentry-build-plugin /test-results/ diff --git a/e2e/solid-start/server-functions/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/solid-start/server-functions/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..2dc6bfc4bd --- /dev/null +++ b/e2e/solid-start/server-functions/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/solid-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/solid-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/solid-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/solid-start/server-functions/app.config.ts b/e2e/solid-start/server-functions/app.config.ts deleted file mode 100644 index 2a06e3d3f0..0000000000 --- a/e2e/solid-start/server-functions/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/solid-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/e2e/solid-start/server-functions/package.json b/e2e/solid-start/server-functions/package.json index cdb85c86ae..dc7d00752b 100644 --- a/e2e/solid-start/server-functions/package.json +++ b/e2e/solid-start/server-functions/package.json @@ -4,10 +4,10 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev --port 3000", - "dev:e2e": "vinxi dev", - "build": "vinxi build && tsc --noEmit", - "start": "vinxi start", + "dev": "vite dev --port 3000", + "dev:e2e": "vite dev", + "build": "vite build && tsc --noEmit", + "start": "node .output/server/index.mjs", "test:e2e": "playwright test --project=chromium" }, "dependencies": { @@ -18,7 +18,6 @@ "solid-js": "^1.9.5", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3", "zod": "^3.24.2" }, "devDependencies": { diff --git a/e2e/solid-start/server-functions/playwright.config.ts b/e2e/solid-start/server-functions/playwright.config.ts index 409765549f..afe39a46b1 100644 --- a/e2e/solid-start/server-functions/playwright.config.ts +++ b/e2e/solid-start/server-functions/playwright.config.ts @@ -20,7 +20,7 @@ export default defineConfig({ }, webServer: { - command: `VITE_SERVER_PORT=${PORT} pnpm build && VITE_SERVER_PORT=${PORT} pnpm start --port ${PORT}`, + command: `pnpm build && VITE_SERVER_PORT=${PORT} PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', diff --git a/e2e/solid-start/server-functions/src/client.tsx b/e2e/solid-start/server-functions/src/client.tsx deleted file mode 100644 index ba0f02fac0..0000000000 --- a/e2e/solid-start/server-functions/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrate } from 'solid-js/web' -import { StartClient } from '@tanstack/solid-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrate(() => , document.body) diff --git a/e2e/solid-start/server-functions/src/routeTree.gen.ts b/e2e/solid-start/server-functions/src/routeTree.gen.ts index 4a34fccd1c..77ee387afd 100644 --- a/e2e/solid-start/server-functions/src/routeTree.gen.ts +++ b/e2e/solid-start/server-functions/src/routeTree.gen.ts @@ -10,110 +10,111 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as SubmitPostFormdataImport } from './routes/submit-post-formdata' -import { Route as StatusImport } from './routes/status' -import { Route as SerializeFormDataImport } from './routes/serialize-form-data' -import { Route as ReturnNullImport } from './routes/return-null' -import { Route as RawResponseImport } from './routes/raw-response' -import { Route as MultipartImport } from './routes/multipart' -import { Route as IsomorphicFnsImport } from './routes/isomorphic-fns' -import { Route as HeadersImport } from './routes/headers' -import { Route as EnvOnlyImport } from './routes/env-only' -import { Route as DeadCodePreserveImport } from './routes/dead-code-preserve' -import { Route as ConsistentImport } from './routes/consistent' -import { Route as AbortSignalImport } from './routes/abort-signal' -import { Route as IndexImport } from './routes/index' -import { Route as CookiesIndexImport } from './routes/cookies/index' -import { Route as CookiesSetImport } from './routes/cookies/set' +import { Route as SubmitPostFormdataRouteImport } from './routes/submit-post-formdata' +import { Route as StatusRouteImport } from './routes/status' +import { Route as SerializeFormDataRouteImport } from './routes/serialize-form-data' +import { Route as ReturnNullRouteImport } from './routes/return-null' +import { Route as RawResponseRouteImport } from './routes/raw-response' +import { Route as MultipartRouteImport } from './routes/multipart' +import { Route as IsomorphicFnsRouteImport } from './routes/isomorphic-fns' +import { Route as HeadersRouteImport } from './routes/headers' +import { Route as EnvOnlyRouteImport } from './routes/env-only' +import { Route as DeadCodePreserveRouteImport } from './routes/dead-code-preserve' +import { Route as ConsistentRouteImport } from './routes/consistent' +import { Route as AbortSignalRouteImport } from './routes/abort-signal' +import { Route as IndexRouteImport } from './routes/index' +import { Route as CookiesIndexRouteImport } from './routes/cookies/index' +import { Route as CookiesSetRouteImport } from './routes/cookies/set' // Create/Update Routes -const SubmitPostFormdataRoute = SubmitPostFormdataImport.update({ +const SubmitPostFormdataRoute = SubmitPostFormdataRouteImport.update({ id: '/submit-post-formdata', path: '/submit-post-formdata', getParentRoute: () => rootRoute, } as any) -const StatusRoute = StatusImport.update({ +const StatusRoute = StatusRouteImport.update({ id: '/status', path: '/status', getParentRoute: () => rootRoute, } as any) -const SerializeFormDataRoute = SerializeFormDataImport.update({ +const SerializeFormDataRoute = SerializeFormDataRouteImport.update({ id: '/serialize-form-data', path: '/serialize-form-data', getParentRoute: () => rootRoute, } as any) -const ReturnNullRoute = ReturnNullImport.update({ +const ReturnNullRoute = ReturnNullRouteImport.update({ id: '/return-null', path: '/return-null', getParentRoute: () => rootRoute, } as any) -const RawResponseRoute = RawResponseImport.update({ +const RawResponseRoute = RawResponseRouteImport.update({ id: '/raw-response', path: '/raw-response', getParentRoute: () => rootRoute, } as any) -const MultipartRoute = MultipartImport.update({ +const MultipartRoute = MultipartRouteImport.update({ id: '/multipart', path: '/multipart', getParentRoute: () => rootRoute, } as any) -const IsomorphicFnsRoute = IsomorphicFnsImport.update({ +const IsomorphicFnsRoute = IsomorphicFnsRouteImport.update({ id: '/isomorphic-fns', path: '/isomorphic-fns', getParentRoute: () => rootRoute, } as any) -const HeadersRoute = HeadersImport.update({ +const HeadersRoute = HeadersRouteImport.update({ id: '/headers', path: '/headers', getParentRoute: () => rootRoute, } as any) -const EnvOnlyRoute = EnvOnlyImport.update({ +const EnvOnlyRoute = EnvOnlyRouteImport.update({ id: '/env-only', path: '/env-only', getParentRoute: () => rootRoute, } as any) -const DeadCodePreserveRoute = DeadCodePreserveImport.update({ +const DeadCodePreserveRoute = DeadCodePreserveRouteImport.update({ id: '/dead-code-preserve', path: '/dead-code-preserve', getParentRoute: () => rootRoute, } as any) -const ConsistentRoute = ConsistentImport.update({ +const ConsistentRoute = ConsistentRouteImport.update({ id: '/consistent', path: '/consistent', getParentRoute: () => rootRoute, } as any) -const AbortSignalRoute = AbortSignalImport.update({ +const AbortSignalRoute = AbortSignalRouteImport.update({ id: '/abort-signal', path: '/abort-signal', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const CookiesIndexRoute = CookiesIndexImport.update({ +const CookiesIndexRoute = CookiesIndexRouteImport.update({ id: '/cookies/', path: '/cookies/', getParentRoute: () => rootRoute, } as any) -const CookiesSetRoute = CookiesSetImport.update({ +const CookiesSetRoute = CookiesSetRouteImport.update({ id: '/cookies/set', path: '/cookies/set', getParentRoute: () => rootRoute, @@ -127,110 +128,248 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/abort-signal': { id: '/abort-signal' path: '/abort-signal' fullPath: '/abort-signal' - preLoaderRoute: typeof AbortSignalImport + preLoaderRoute: typeof AbortSignalRouteImport parentRoute: typeof rootRoute } '/consistent': { id: '/consistent' path: '/consistent' fullPath: '/consistent' - preLoaderRoute: typeof ConsistentImport + preLoaderRoute: typeof ConsistentRouteImport parentRoute: typeof rootRoute } '/dead-code-preserve': { id: '/dead-code-preserve' path: '/dead-code-preserve' fullPath: '/dead-code-preserve' - preLoaderRoute: typeof DeadCodePreserveImport + preLoaderRoute: typeof DeadCodePreserveRouteImport parentRoute: typeof rootRoute } '/env-only': { id: '/env-only' path: '/env-only' fullPath: '/env-only' - preLoaderRoute: typeof EnvOnlyImport + preLoaderRoute: typeof EnvOnlyRouteImport parentRoute: typeof rootRoute } '/headers': { id: '/headers' path: '/headers' fullPath: '/headers' - preLoaderRoute: typeof HeadersImport + preLoaderRoute: typeof HeadersRouteImport parentRoute: typeof rootRoute } '/isomorphic-fns': { id: '/isomorphic-fns' path: '/isomorphic-fns' fullPath: '/isomorphic-fns' - preLoaderRoute: typeof IsomorphicFnsImport + preLoaderRoute: typeof IsomorphicFnsRouteImport parentRoute: typeof rootRoute } '/multipart': { id: '/multipart' path: '/multipart' fullPath: '/multipart' - preLoaderRoute: typeof MultipartImport + preLoaderRoute: typeof MultipartRouteImport parentRoute: typeof rootRoute } '/raw-response': { id: '/raw-response' path: '/raw-response' fullPath: '/raw-response' - preLoaderRoute: typeof RawResponseImport + preLoaderRoute: typeof RawResponseRouteImport parentRoute: typeof rootRoute } '/return-null': { id: '/return-null' path: '/return-null' fullPath: '/return-null' - preLoaderRoute: typeof ReturnNullImport + preLoaderRoute: typeof ReturnNullRouteImport parentRoute: typeof rootRoute } '/serialize-form-data': { id: '/serialize-form-data' path: '/serialize-form-data' fullPath: '/serialize-form-data' - preLoaderRoute: typeof SerializeFormDataImport + preLoaderRoute: typeof SerializeFormDataRouteImport parentRoute: typeof rootRoute } '/status': { id: '/status' path: '/status' fullPath: '/status' - preLoaderRoute: typeof StatusImport + preLoaderRoute: typeof StatusRouteImport parentRoute: typeof rootRoute } '/submit-post-formdata': { id: '/submit-post-formdata' path: '/submit-post-formdata' fullPath: '/submit-post-formdata' - preLoaderRoute: typeof SubmitPostFormdataImport + preLoaderRoute: typeof SubmitPostFormdataRouteImport parentRoute: typeof rootRoute } '/cookies/set': { id: '/cookies/set' path: '/cookies/set' fullPath: '/cookies/set' - preLoaderRoute: typeof CookiesSetImport + preLoaderRoute: typeof CookiesSetRouteImport parentRoute: typeof rootRoute } '/cookies/': { id: '/cookies/' path: '/cookies' fullPath: '/cookies' - preLoaderRoute: typeof CookiesIndexImport + preLoaderRoute: typeof CookiesIndexRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/abort-signal' { + const createFileRoute: CreateFileRoute< + '/abort-signal', + FileRoutesByPath['/abort-signal']['parentRoute'], + FileRoutesByPath['/abort-signal']['id'], + FileRoutesByPath['/abort-signal']['path'], + FileRoutesByPath['/abort-signal']['fullPath'] + > +} +declare module './routes/consistent' { + const createFileRoute: CreateFileRoute< + '/consistent', + FileRoutesByPath['/consistent']['parentRoute'], + FileRoutesByPath['/consistent']['id'], + FileRoutesByPath['/consistent']['path'], + FileRoutesByPath['/consistent']['fullPath'] + > +} +declare module './routes/dead-code-preserve' { + const createFileRoute: CreateFileRoute< + '/dead-code-preserve', + FileRoutesByPath['/dead-code-preserve']['parentRoute'], + FileRoutesByPath['/dead-code-preserve']['id'], + FileRoutesByPath['/dead-code-preserve']['path'], + FileRoutesByPath['/dead-code-preserve']['fullPath'] + > +} +declare module './routes/env-only' { + const createFileRoute: CreateFileRoute< + '/env-only', + FileRoutesByPath['/env-only']['parentRoute'], + FileRoutesByPath['/env-only']['id'], + FileRoutesByPath['/env-only']['path'], + FileRoutesByPath['/env-only']['fullPath'] + > +} +declare module './routes/headers' { + const createFileRoute: CreateFileRoute< + '/headers', + FileRoutesByPath['/headers']['parentRoute'], + FileRoutesByPath['/headers']['id'], + FileRoutesByPath['/headers']['path'], + FileRoutesByPath['/headers']['fullPath'] + > +} +declare module './routes/isomorphic-fns' { + const createFileRoute: CreateFileRoute< + '/isomorphic-fns', + FileRoutesByPath['/isomorphic-fns']['parentRoute'], + FileRoutesByPath['/isomorphic-fns']['id'], + FileRoutesByPath['/isomorphic-fns']['path'], + FileRoutesByPath['/isomorphic-fns']['fullPath'] + > +} +declare module './routes/multipart' { + const createFileRoute: CreateFileRoute< + '/multipart', + FileRoutesByPath['/multipart']['parentRoute'], + FileRoutesByPath['/multipart']['id'], + FileRoutesByPath['/multipart']['path'], + FileRoutesByPath['/multipart']['fullPath'] + > +} +declare module './routes/raw-response' { + const createFileRoute: CreateFileRoute< + '/raw-response', + FileRoutesByPath['/raw-response']['parentRoute'], + FileRoutesByPath['/raw-response']['id'], + FileRoutesByPath['/raw-response']['path'], + FileRoutesByPath['/raw-response']['fullPath'] + > +} +declare module './routes/return-null' { + const createFileRoute: CreateFileRoute< + '/return-null', + FileRoutesByPath['/return-null']['parentRoute'], + FileRoutesByPath['/return-null']['id'], + FileRoutesByPath['/return-null']['path'], + FileRoutesByPath['/return-null']['fullPath'] + > +} +declare module './routes/serialize-form-data' { + const createFileRoute: CreateFileRoute< + '/serialize-form-data', + FileRoutesByPath['/serialize-form-data']['parentRoute'], + FileRoutesByPath['/serialize-form-data']['id'], + FileRoutesByPath['/serialize-form-data']['path'], + FileRoutesByPath['/serialize-form-data']['fullPath'] + > +} +declare module './routes/status' { + const createFileRoute: CreateFileRoute< + '/status', + FileRoutesByPath['/status']['parentRoute'], + FileRoutesByPath['/status']['id'], + FileRoutesByPath['/status']['path'], + FileRoutesByPath['/status']['fullPath'] + > +} +declare module './routes/submit-post-formdata' { + const createFileRoute: CreateFileRoute< + '/submit-post-formdata', + FileRoutesByPath['/submit-post-formdata']['parentRoute'], + FileRoutesByPath['/submit-post-formdata']['id'], + FileRoutesByPath['/submit-post-formdata']['path'], + FileRoutesByPath['/submit-post-formdata']['fullPath'] + > +} +declare module './routes/cookies/set' { + const createFileRoute: CreateFileRoute< + '/cookies/set', + FileRoutesByPath['/cookies/set']['parentRoute'], + FileRoutesByPath['/cookies/set']['id'], + FileRoutesByPath['/cookies/set']['path'], + FileRoutesByPath['/cookies/set']['fullPath'] + > +} +declare module './routes/cookies/index' { + const createFileRoute: CreateFileRoute< + '/cookies/', + FileRoutesByPath['/cookies/']['parentRoute'], + FileRoutesByPath['/cookies/']['id'], + FileRoutesByPath['/cookies/']['path'], + FileRoutesByPath['/cookies/']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -383,6 +522,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/solid-start/server-functions/src/routes/__root.tsx b/e2e/solid-start/server-functions/src/routes/__root.tsx index 52d64bf7a7..c1855d436a 100644 --- a/e2e/solid-start/server-functions/src/routes/__root.tsx +++ b/e2e/solid-start/server-functions/src/routes/__root.tsx @@ -1,9 +1,8 @@ import { Outlet, createRootRoute } from '@tanstack/solid-router' -import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary' +import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools' import { NotFound } from '~/components/NotFound' import appCss from '~/styles/app.css?url' -import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools' export const Route = createRootRoute({ head: () => ({ diff --git a/e2e/solid-start/server-functions/src/routes/abort-signal.tsx b/e2e/solid-start/server-functions/src/routes/abort-signal.tsx index 752346264e..16aa9bc5b5 100644 --- a/e2e/solid-start/server-functions/src/routes/abort-signal.tsx +++ b/e2e/solid-start/server-functions/src/routes/abort-signal.tsx @@ -1,8 +1,7 @@ -import { createFileRoute } from '@tanstack/solid-router' import { createServerFn } from '@tanstack/solid-start' import * as Solid from 'solid-js' -export const Route = createFileRoute('/abort-signal')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/solid-start/server-functions/src/routes/consistent.tsx b/e2e/solid-start/server-functions/src/routes/consistent.tsx index 9e4c1b3b08..190c64c0f7 100644 --- a/e2e/solid-start/server-functions/src/routes/consistent.tsx +++ b/e2e/solid-start/server-functions/src/routes/consistent.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' import * as Solid from 'solid-js' import { createServerFn } from '@tanstack/solid-start' @@ -10,7 +9,7 @@ import { createServerFn } from '@tanstack/solid-start' * @link https://github.com/TanStack/router/issues/2481 */ -export const Route = createFileRoute('/consistent')({ +export const Route = createFileRoute({ component: ConsistentServerFnCalls, loader: async () => { const data = await cons_serverGetFn1({ data: { username: 'TEST' } }) diff --git a/e2e/solid-start/server-functions/src/routes/cookies/index.tsx b/e2e/solid-start/server-functions/src/routes/cookies/index.tsx index 5cccd18057..13cfd9cbc1 100644 --- a/e2e/solid-start/server-functions/src/routes/cookies/index.tsx +++ b/e2e/solid-start/server-functions/src/routes/cookies/index.tsx @@ -1,10 +1,10 @@ -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' import { z } from 'zod' const cookieSchema = z .object({ value: z.string() }) .catch(() => ({ value: `CLIENT-${Date.now()}` })) -export const Route = createFileRoute('/cookies/')({ +export const Route = createFileRoute({ validateSearch: cookieSchema, component: RouteComponent, }) diff --git a/e2e/solid-start/server-functions/src/routes/cookies/set.tsx b/e2e/solid-start/server-functions/src/routes/cookies/set.tsx index 32e06725cf..0814829dc4 100644 --- a/e2e/solid-start/server-functions/src/routes/cookies/set.tsx +++ b/e2e/solid-start/server-functions/src/routes/cookies/set.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' import { createServerFn } from '@tanstack/solid-start' import { setCookie } from '@tanstack/solid-start/server' import { z } from 'zod' @@ -7,7 +6,7 @@ import * as Solid from 'solid-js' const cookieSchema = z.object({ value: z.string() }) -export const Route = createFileRoute('/cookies/set')({ +export const Route = createFileRoute({ validateSearch: cookieSchema, loaderDeps: ({ search }) => search, loader: async ({ deps }) => { diff --git a/e2e/solid-start/server-functions/src/routes/dead-code-preserve.tsx b/e2e/solid-start/server-functions/src/routes/dead-code-preserve.tsx index 96d7a3ca13..ebf26bfba9 100644 --- a/e2e/solid-start/server-functions/src/routes/dead-code-preserve.tsx +++ b/e2e/solid-start/server-functions/src/routes/dead-code-preserve.tsx @@ -2,9 +2,9 @@ import * as fs from 'node:fs' import { createServerFn } from '@tanstack/solid-start' import { getRequestHeader } from '@tanstack/solid-start/server' import { createSignal } from 'solid-js' -import { createFileRoute } from '@tanstack/solid-router' +import {} from '@tanstack/solid-router' -export const Route = createFileRoute('/dead-code-preserve')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/solid-start/server-functions/src/routes/env-only.tsx b/e2e/solid-start/server-functions/src/routes/env-only.tsx index df8f08eed2..d888d20c80 100644 --- a/e2e/solid-start/server-functions/src/routes/env-only.tsx +++ b/e2e/solid-start/server-functions/src/routes/env-only.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' import { clientOnly, createServerFn, serverOnly } from '@tanstack/solid-start' import { createSignal } from 'solid-js' @@ -18,7 +17,7 @@ const testOnServer = createServerFn().handler(() => { return { serverOnServer, clientOnServer } }) -export const Route = createFileRoute('/env-only')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/solid-start/server-functions/src/routes/headers.tsx b/e2e/solid-start/server-functions/src/routes/headers.tsx index 94ef5a05c1..c8a1344931 100644 --- a/e2e/solid-start/server-functions/src/routes/headers.tsx +++ b/e2e/solid-start/server-functions/src/routes/headers.tsx @@ -1,10 +1,9 @@ -import { createFileRoute } from '@tanstack/solid-router' import * as Solid from 'solid-js' import { createServerFn } from '@tanstack/solid-start' import { getHeaders, setHeader } from '@tanstack/solid-start/server' import type { HTTPHeaderName } from '@tanstack/solid-start/server' -export const Route = createFileRoute('/headers')({ +export const Route = createFileRoute({ loader: async () => { return { testHeaders: await getTestHeaders(), diff --git a/e2e/solid-start/server-functions/src/routes/index.tsx b/e2e/solid-start/server-functions/src/routes/index.tsx index bf28fb8b00..443c52a21c 100644 --- a/e2e/solid-start/server-functions/src/routes/index.tsx +++ b/e2e/solid-start/server-functions/src/routes/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/solid-start/server-functions/src/routes/isomorphic-fns.tsx b/e2e/solid-start/server-functions/src/routes/isomorphic-fns.tsx index 3327b38af7..b01aeb9217 100644 --- a/e2e/solid-start/server-functions/src/routes/isomorphic-fns.tsx +++ b/e2e/solid-start/server-functions/src/routes/isomorphic-fns.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' import { createIsomorphicFn, createServerFn } from '@tanstack/solid-start' import { createSignal } from 'solid-js' @@ -16,7 +15,7 @@ const getServerEcho = createServerFn() .validator((input: string) => input) .handler(({ data }) => getEcho(data)) -export const Route = createFileRoute('/isomorphic-fns')({ +export const Route = createFileRoute({ component: RouteComponent, loader() { return { diff --git a/e2e/solid-start/server-functions/src/routes/multipart.tsx b/e2e/solid-start/server-functions/src/routes/multipart.tsx index 5e959da7ae..5ddb9aa6b5 100644 --- a/e2e/solid-start/server-functions/src/routes/multipart.tsx +++ b/e2e/solid-start/server-functions/src/routes/multipart.tsx @@ -1,8 +1,7 @@ -import { createFileRoute } from '@tanstack/solid-router' import * as Solid from 'solid-js' import { createServerFn } from '@tanstack/solid-start' -export const Route = createFileRoute('/multipart')({ +export const Route = createFileRoute({ component: MultipartServerFnCall, }) diff --git a/e2e/solid-start/server-functions/src/routes/raw-response.tsx b/e2e/solid-start/server-functions/src/routes/raw-response.tsx index d0ff217944..75a605c50b 100644 --- a/e2e/solid-start/server-functions/src/routes/raw-response.tsx +++ b/e2e/solid-start/server-functions/src/routes/raw-response.tsx @@ -1,8 +1,8 @@ import * as Solid from 'solid-js' -import { createFileRoute } from '@tanstack/solid-router' + import { createServerFn } from '@tanstack/solid-start' -export const Route = createFileRoute('/raw-response')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/e2e/solid-start/server-functions/src/routes/return-null.tsx b/e2e/solid-start/server-functions/src/routes/return-null.tsx index 2e789d2eef..319b8ba32a 100644 --- a/e2e/solid-start/server-functions/src/routes/return-null.tsx +++ b/e2e/solid-start/server-functions/src/routes/return-null.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' import { createServerFn } from '@tanstack/solid-start' import * as Solid from 'solid-js' @@ -8,7 +7,7 @@ import * as Solid from 'solid-js' * @link https://github.com/TanStack/router/issues/2776 */ -export const Route = createFileRoute('/return-null')({ +export const Route = createFileRoute({ component: AllowServerFnReturnNull, }) diff --git a/e2e/solid-start/server-functions/src/routes/serialize-form-data.tsx b/e2e/solid-start/server-functions/src/routes/serialize-form-data.tsx index 487d91e86d..d60b4072cf 100644 --- a/e2e/solid-start/server-functions/src/routes/serialize-form-data.tsx +++ b/e2e/solid-start/server-functions/src/routes/serialize-form-data.tsx @@ -1,5 +1,5 @@ import * as Solid from 'solid-js' -import { createFileRoute } from '@tanstack/solid-router' + import { createServerFn } from '@tanstack/solid-start' const testValues = { @@ -79,6 +79,6 @@ export function SerializeFormDataFnCall() { ) } -export const Route = createFileRoute('/serialize-form-data')({ +export const Route = createFileRoute({ component: SerializeFormDataFnCall, }) diff --git a/e2e/solid-start/server-functions/src/routes/status.tsx b/e2e/solid-start/server-functions/src/routes/status.tsx index 22b45bb28f..867bdd6927 100644 --- a/e2e/solid-start/server-functions/src/routes/status.tsx +++ b/e2e/solid-start/server-functions/src/routes/status.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/solid-router' import { createServerFn, useServerFn } from '@tanstack/solid-start' import { setResponseStatus } from '@tanstack/solid-start/server' @@ -9,7 +8,7 @@ const helloFn = createServerFn().handler(() => { } }) -export const Route = createFileRoute('/status')({ +export const Route = createFileRoute({ component: StatusComponent, }) diff --git a/e2e/solid-start/server-functions/src/routes/submit-post-formdata.tsx b/e2e/solid-start/server-functions/src/routes/submit-post-formdata.tsx index 3fb6ea356f..8b881645bb 100644 --- a/e2e/solid-start/server-functions/src/routes/submit-post-formdata.tsx +++ b/e2e/solid-start/server-functions/src/routes/submit-post-formdata.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' import { createServerFn } from '@tanstack/solid-start' -export const Route = createFileRoute('/submit-post-formdata')({ +export const Route = createFileRoute({ component: SubmitPostFormDataFn, }) diff --git a/e2e/solid-start/server-functions/src/ssr.tsx b/e2e/solid-start/server-functions/src/ssr.tsx deleted file mode 100644 index 6d10bea05f..0000000000 --- a/e2e/solid-start/server-functions/src/ssr.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/solid-start/server' -import { getRouterManifest } from '@tanstack/solid-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/e2e/solid-start/server-functions/src/vite-env.d.ts b/e2e/solid-start/server-functions/src/vite-env.d.ts new file mode 100644 index 0000000000..0b2af560d6 --- /dev/null +++ b/e2e/solid-start/server-functions/src/vite-env.d.ts @@ -0,0 +1,4 @@ +declare module '*?url' { + const url: string + export default url +} diff --git a/e2e/solid-start/server-functions/vite.config.ts b/e2e/solid-start/server-functions/vite.config.ts new file mode 100644 index 0000000000..f6a9e52322 --- /dev/null +++ b/e2e/solid-start/server-functions/vite.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/solid-start/plugin' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin({}), + ], +}) diff --git a/e2e/solid-start/website/.gitignore b/e2e/solid-start/website/.gitignore index be342025da..a79d5cf129 100644 --- a/e2e/solid-start/website/.gitignore +++ b/e2e/solid-start/website/.gitignore @@ -7,13 +7,11 @@ yarn.lock .env .vercel .output -.vinxi /build/ /api/ /server/build /public/build -.vinxi # Sentry Config File .env.sentry-build-plugin /test-results/ diff --git a/e2e/solid-start/website/.tanstack-start/server-routes/routeTree.gen.ts b/e2e/solid-start/website/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..2dc6bfc4bd --- /dev/null +++ b/e2e/solid-start/website/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/solid-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/solid-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/solid-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/e2e/solid-start/website/app.config.ts b/e2e/solid-start/website/app.config.ts deleted file mode 100644 index 2a06e3d3f0..0000000000 --- a/e2e/solid-start/website/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/solid-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/e2e/solid-start/website/package.json b/e2e/solid-start/website/package.json index 1f3a38c036..5b6f4bd55f 100644 --- a/e2e/solid-start/website/package.json +++ b/e2e/solid-start/website/package.json @@ -4,10 +4,10 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev --port 3000", - "dev:e2e": "vinxi dev", - "build": "vinxi build && tsc --noEmit", - "start": "vinxi start", + "dev": "vite dev --port 3000", + "dev:e2e": "vite dev", + "build": "vite build && tsc --noEmit", + "start": "node .output/server/index.mjs", "test:e2e": "playwright test --project=chromium" }, "dependencies": { @@ -17,7 +17,6 @@ "solid-js": "^1.9.5", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3", "zod": "^3.24.2" }, "devDependencies": { diff --git a/e2e/solid-start/website/playwright.config.ts b/e2e/solid-start/website/playwright.config.ts index bb77d0cf70..e834d88cf4 100644 --- a/e2e/solid-start/website/playwright.config.ts +++ b/e2e/solid-start/website/playwright.config.ts @@ -4,6 +4,7 @@ import packageJson from './package.json' with { type: 'json' } const PORT = derivePort(packageJson.name) const baseURL = `http://localhost:${PORT}` + /** * See https://playwright.dev/docs/test-configuration. */ @@ -19,7 +20,7 @@ export default defineConfig({ }, webServer: { - command: `VITE_SERVER_PORT=${PORT} pnpm build && VITE_SERVER_PORT=${PORT} pnpm start --port ${PORT}`, + command: `pnpm build && VITE_SERVER_PORT=${PORT} PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', diff --git a/e2e/solid-start/website/src/client.tsx b/e2e/solid-start/website/src/client.tsx deleted file mode 100644 index ba0f02fac0..0000000000 --- a/e2e/solid-start/website/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrate } from 'solid-js/web' -import { StartClient } from '@tanstack/solid-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrate(() => , document.body) diff --git a/e2e/solid-start/website/src/routeTree.gen.ts b/e2e/solid-start/website/src/routeTree.gen.ts index 32515b924b..e2308fd904 100644 --- a/e2e/solid-start/website/src/routeTree.gen.ts +++ b/e2e/solid-start/website/src/routeTree.gen.ts @@ -10,80 +10,80 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as LibraryImport } from './routes/_library' -import { Route as LibraryIndexImport } from './routes/_library.index' -import { Route as ProjectIndexImport } from './routes/$project.index' -import { Route as LibraryProjectImport } from './routes/_library.$project' -import { Route as LibraryProjectVersionIndexImport } from './routes/_library.$project.$version.index' -import { Route as ProjectVersionDocsIndexImport } from './routes/$project.$version.docs.index' -import { Route as ProjectVersionDocsFrameworkFrameworkImport } from './routes/$project.$version.docs.framework.$framework' -import { Route as ProjectVersionDocsFrameworkFrameworkIndexImport } from './routes/$project.$version.docs.framework.$framework.index' -import { Route as ProjectVersionDocsFrameworkFrameworkSplatImport } from './routes/$project.$version.docs.framework.$framework.$' -import { Route as ProjectVersionDocsFrameworkFrameworkExamplesSplatImport } from './routes/$project.$version.docs.framework.$framework.examples.$' +import { Route as LibraryRouteImport } from './routes/_library' +import { Route as LibraryIndexRouteImport } from './routes/_library.index' +import { Route as ProjectIndexRouteImport } from './routes/$project.index' +import { Route as LibraryProjectRouteImport } from './routes/_library.$project' +import { Route as LibraryProjectVersionIndexRouteImport } from './routes/_library.$project.$version.index' +import { Route as ProjectVersionDocsIndexRouteImport } from './routes/$project.$version.docs.index' +import { Route as ProjectVersionDocsFrameworkFrameworkRouteImport } from './routes/$project.$version.docs.framework.$framework' +import { Route as ProjectVersionDocsFrameworkFrameworkIndexRouteImport } from './routes/$project.$version.docs.framework.$framework.index' +import { Route as ProjectVersionDocsFrameworkFrameworkSplatRouteImport } from './routes/$project.$version.docs.framework.$framework.$' +import { Route as ProjectVersionDocsFrameworkFrameworkExamplesSplatRouteImport } from './routes/$project.$version.docs.framework.$framework.examples.$' // Create/Update Routes -const LibraryRoute = LibraryImport.update({ +const LibraryRoute = LibraryRouteImport.update({ id: '/_library', getParentRoute: () => rootRoute, } as any) -const LibraryIndexRoute = LibraryIndexImport.update({ +const LibraryIndexRoute = LibraryIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => LibraryRoute, } as any) -const ProjectIndexRoute = ProjectIndexImport.update({ +const ProjectIndexRoute = ProjectIndexRouteImport.update({ id: '/$project/', path: '/$project/', getParentRoute: () => rootRoute, } as any) -const LibraryProjectRoute = LibraryProjectImport.update({ +const LibraryProjectRoute = LibraryProjectRouteImport.update({ id: '/$project', path: '/$project', getParentRoute: () => LibraryRoute, } as any) -const LibraryProjectVersionIndexRoute = LibraryProjectVersionIndexImport.update( - { +const LibraryProjectVersionIndexRoute = + LibraryProjectVersionIndexRouteImport.update({ id: '/$version/', path: '/$version/', getParentRoute: () => LibraryProjectRoute, - } as any, -) + } as any) -const ProjectVersionDocsIndexRoute = ProjectVersionDocsIndexImport.update({ +const ProjectVersionDocsIndexRoute = ProjectVersionDocsIndexRouteImport.update({ id: '/$project/$version/docs/', path: '/$project/$version/docs/', getParentRoute: () => rootRoute, } as any) const ProjectVersionDocsFrameworkFrameworkRoute = - ProjectVersionDocsFrameworkFrameworkImport.update({ + ProjectVersionDocsFrameworkFrameworkRouteImport.update({ id: '/$project/$version/docs/framework/$framework', path: '/$project/$version/docs/framework/$framework', getParentRoute: () => rootRoute, } as any) const ProjectVersionDocsFrameworkFrameworkIndexRoute = - ProjectVersionDocsFrameworkFrameworkIndexImport.update({ + ProjectVersionDocsFrameworkFrameworkIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => ProjectVersionDocsFrameworkFrameworkRoute, } as any) const ProjectVersionDocsFrameworkFrameworkSplatRoute = - ProjectVersionDocsFrameworkFrameworkSplatImport.update({ + ProjectVersionDocsFrameworkFrameworkSplatRouteImport.update({ id: '/$', path: '/$', getParentRoute: () => ProjectVersionDocsFrameworkFrameworkRoute, } as any) const ProjectVersionDocsFrameworkFrameworkExamplesSplatRoute = - ProjectVersionDocsFrameworkFrameworkExamplesSplatImport.update({ + ProjectVersionDocsFrameworkFrameworkExamplesSplatRouteImport.update({ id: '/examples/$', path: '/examples/$', getParentRoute: () => ProjectVersionDocsFrameworkFrameworkRoute, @@ -97,75 +97,168 @@ declare module '@tanstack/solid-router' { id: '/_library' path: '' fullPath: '' - preLoaderRoute: typeof LibraryImport + preLoaderRoute: typeof LibraryRouteImport parentRoute: typeof rootRoute } '/_library/$project': { id: '/_library/$project' path: '/$project' fullPath: '/$project' - preLoaderRoute: typeof LibraryProjectImport - parentRoute: typeof LibraryImport + preLoaderRoute: typeof LibraryProjectRouteImport + parentRoute: typeof LibraryRouteImport } '/$project/': { id: '/$project/' path: '/$project' fullPath: '/$project' - preLoaderRoute: typeof ProjectIndexImport + preLoaderRoute: typeof ProjectIndexRouteImport parentRoute: typeof rootRoute } '/_library/': { id: '/_library/' path: '/' fullPath: '/' - preLoaderRoute: typeof LibraryIndexImport - parentRoute: typeof LibraryImport + preLoaderRoute: typeof LibraryIndexRouteImport + parentRoute: typeof LibraryRouteImport } '/$project/$version/docs/': { id: '/$project/$version/docs/' path: '/$project/$version/docs' fullPath: '/$project/$version/docs' - preLoaderRoute: typeof ProjectVersionDocsIndexImport + preLoaderRoute: typeof ProjectVersionDocsIndexRouteImport parentRoute: typeof rootRoute } '/_library/$project/$version/': { id: '/_library/$project/$version/' path: '/$version' fullPath: '/$project/$version' - preLoaderRoute: typeof LibraryProjectVersionIndexImport - parentRoute: typeof LibraryProjectImport + preLoaderRoute: typeof LibraryProjectVersionIndexRouteImport + parentRoute: typeof LibraryProjectRouteImport } '/$project/$version/docs/framework/$framework': { id: '/$project/$version/docs/framework/$framework' path: '/$project/$version/docs/framework/$framework' fullPath: '/$project/$version/docs/framework/$framework' - preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkImport + preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkRouteImport parentRoute: typeof rootRoute } '/$project/$version/docs/framework/$framework/$': { id: '/$project/$version/docs/framework/$framework/$' path: '/$' fullPath: '/$project/$version/docs/framework/$framework/$' - preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkSplatImport - parentRoute: typeof ProjectVersionDocsFrameworkFrameworkImport + preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkSplatRouteImport + parentRoute: typeof ProjectVersionDocsFrameworkFrameworkRouteImport } '/$project/$version/docs/framework/$framework/': { id: '/$project/$version/docs/framework/$framework/' path: '/' fullPath: '/$project/$version/docs/framework/$framework/' - preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkIndexImport - parentRoute: typeof ProjectVersionDocsFrameworkFrameworkImport + preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkIndexRouteImport + parentRoute: typeof ProjectVersionDocsFrameworkFrameworkRouteImport } '/$project/$version/docs/framework/$framework/examples/$': { id: '/$project/$version/docs/framework/$framework/examples/$' path: '/examples/$' fullPath: '/$project/$version/docs/framework/$framework/examples/$' - preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkExamplesSplatImport - parentRoute: typeof ProjectVersionDocsFrameworkFrameworkImport + preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkExamplesSplatRouteImport + parentRoute: typeof ProjectVersionDocsFrameworkFrameworkRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/_library' { + const createFileRoute: CreateFileRoute< + '/_library', + FileRoutesByPath['/_library']['parentRoute'], + FileRoutesByPath['/_library']['id'], + FileRoutesByPath['/_library']['path'], + FileRoutesByPath['/_library']['fullPath'] + > +} +declare module './routes/_library.$project' { + const createFileRoute: CreateFileRoute< + '/_library/$project', + FileRoutesByPath['/_library/$project']['parentRoute'], + FileRoutesByPath['/_library/$project']['id'], + FileRoutesByPath['/_library/$project']['path'], + FileRoutesByPath['/_library/$project']['fullPath'] + > +} +declare module './routes/$project.index' { + const createFileRoute: CreateFileRoute< + '/$project/', + FileRoutesByPath['/$project/']['parentRoute'], + FileRoutesByPath['/$project/']['id'], + FileRoutesByPath['/$project/']['path'], + FileRoutesByPath['/$project/']['fullPath'] + > +} +declare module './routes/_library.index' { + const createFileRoute: CreateFileRoute< + '/_library/', + FileRoutesByPath['/_library/']['parentRoute'], + FileRoutesByPath['/_library/']['id'], + FileRoutesByPath['/_library/']['path'], + FileRoutesByPath['/_library/']['fullPath'] + > +} +declare module './routes/$project.$version.docs.index' { + const createFileRoute: CreateFileRoute< + '/$project/$version/docs/', + FileRoutesByPath['/$project/$version/docs/']['parentRoute'], + FileRoutesByPath['/$project/$version/docs/']['id'], + FileRoutesByPath['/$project/$version/docs/']['path'], + FileRoutesByPath['/$project/$version/docs/']['fullPath'] + > +} +declare module './routes/_library.$project.$version.index' { + const createFileRoute: CreateFileRoute< + '/_library/$project/$version/', + FileRoutesByPath['/_library/$project/$version/']['parentRoute'], + FileRoutesByPath['/_library/$project/$version/']['id'], + FileRoutesByPath['/_library/$project/$version/']['path'], + FileRoutesByPath['/_library/$project/$version/']['fullPath'] + > +} +declare module './routes/$project.$version.docs.framework.$framework' { + const createFileRoute: CreateFileRoute< + '/$project/$version/docs/framework/$framework', + FileRoutesByPath['/$project/$version/docs/framework/$framework']['parentRoute'], + FileRoutesByPath['/$project/$version/docs/framework/$framework']['id'], + FileRoutesByPath['/$project/$version/docs/framework/$framework']['path'], + FileRoutesByPath['/$project/$version/docs/framework/$framework']['fullPath'] + > +} +declare module './routes/$project.$version.docs.framework.$framework.$' { + const createFileRoute: CreateFileRoute< + '/$project/$version/docs/framework/$framework/$', + FileRoutesByPath['/$project/$version/docs/framework/$framework/$']['parentRoute'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/$']['id'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/$']['path'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/$']['fullPath'] + > +} +declare module './routes/$project.$version.docs.framework.$framework.index' { + const createFileRoute: CreateFileRoute< + '/$project/$version/docs/framework/$framework/', + FileRoutesByPath['/$project/$version/docs/framework/$framework/']['parentRoute'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/']['id'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/']['path'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/']['fullPath'] + > +} +declare module './routes/$project.$version.docs.framework.$framework.examples.$' { + const createFileRoute: CreateFileRoute< + '/$project/$version/docs/framework/$framework/examples/$', + FileRoutesByPath['/$project/$version/docs/framework/$framework/examples/$']['parentRoute'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/examples/$']['id'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/examples/$']['path'], + FileRoutesByPath['/$project/$version/docs/framework/$framework/examples/$']['fullPath'] + > +} + // Create and export the route tree interface LibraryProjectRouteChildren { @@ -305,6 +398,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.$.tsx b/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.$.tsx index 1df208a1c4..e5da7812c9 100644 --- a/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.$.tsx +++ b/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.$.tsx @@ -1,12 +1,10 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/solid-router' +import { ErrorComponent } from '@tanstack/solid-router' import type { ErrorComponentProps } from '@tanstack/solid-router' import { NotFound } from '~/components/NotFound' import { getDocument } from '~/server/document' import { capitalize, seo } from '~/utils/seo' -export const Route = createFileRoute( - '/$project/$version/docs/framework/$framework/$', -)({ +export const Route = createFileRoute({ loader: ({ params: { _splat } }) => getDocument({ data: _splat!, diff --git a/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.examples.$.tsx b/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.examples.$.tsx index 53e0c46c1b..378623cd08 100644 --- a/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.examples.$.tsx +++ b/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.examples.$.tsx @@ -1,10 +1,7 @@ -import { createFileRoute } from '@tanstack/solid-router' import { NotFound } from '~/components/NotFound' import { capitalize, seo } from '~/utils/seo' -export const Route = createFileRoute( - '/$project/$version/docs/framework/$framework/examples/$', -)({ +export const Route = createFileRoute({ head: ({ params }) => ({ meta: seo({ title: `${capitalize(params._splat || '')} Example | TanStack ${capitalize(params.project)} ${capitalize(params.framework)}`, diff --git a/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.index.tsx b/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.index.tsx index 3f6e4af4ef..ca9ac68ae3 100644 --- a/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.index.tsx +++ b/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.index.tsx @@ -1,9 +1,7 @@ -import { createFileRoute, redirect } from '@tanstack/solid-router' +import { redirect } from '@tanstack/solid-router' -export const Route = createFileRoute( - '/$project/$version/docs/framework/$framework/', -)({ - loader: () => { +export const Route = createFileRoute({ + beforeLoad: () => { throw redirect({ from: '/$project/$version/docs/framework/$framework/', to: '/$project/$version/docs/framework/$framework/$', diff --git a/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.tsx b/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.tsx index 62d59befae..20ff5eb2c0 100644 --- a/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.tsx +++ b/e2e/solid-start/website/src/routes/$project.$version.docs.framework.$framework.tsx @@ -1,15 +1,8 @@ -import { - Link, - Outlet, - createFileRoute, - useLocation, -} from '@tanstack/solid-router' +import { Link, Outlet, useLocation } from '@tanstack/solid-router' import { getDocumentHeads } from '~/server/document' import { getProject } from '~/server/projects' -export const Route = createFileRoute( - '/$project/$version/docs/framework/$framework', -)({ +export const Route = createFileRoute({ loader: async ({ params: { project } }) => { const library = await getProject({ data: project }) const documents = await getDocumentHeads() diff --git a/e2e/solid-start/website/src/routes/$project.$version.docs.index.tsx b/e2e/solid-start/website/src/routes/$project.$version.docs.index.tsx index ff049e373c..275b1df1cd 100644 --- a/e2e/solid-start/website/src/routes/$project.$version.docs.index.tsx +++ b/e2e/solid-start/website/src/routes/$project.$version.docs.index.tsx @@ -1,7 +1,7 @@ -import { createFileRoute, redirect } from '@tanstack/solid-router' +import { redirect } from '@tanstack/solid-router' -export const Route = createFileRoute('/$project/$version/docs/')({ - loader: () => { +export const Route = createFileRoute({ + beforeLoad: () => { throw redirect({ from: '/$project/$version/docs', to: '/$project/$version/docs/framework/$framework/$', diff --git a/e2e/solid-start/website/src/routes/$project.index.tsx b/e2e/solid-start/website/src/routes/$project.index.tsx index 6e250ac011..ee2400f806 100644 --- a/e2e/solid-start/website/src/routes/$project.index.tsx +++ b/e2e/solid-start/website/src/routes/$project.index.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/solid-router' +import { redirect } from '@tanstack/solid-router' -export const Route = createFileRoute('/$project/')({ +export const Route = createFileRoute({ loader: ({ params }) => { throw redirect({ to: '/$project/$version', diff --git a/e2e/solid-start/website/src/routes/__root.tsx b/e2e/solid-start/website/src/routes/__root.tsx index d33148818f..145a126851 100644 --- a/e2e/solid-start/website/src/routes/__root.tsx +++ b/e2e/solid-start/website/src/routes/__root.tsx @@ -1,8 +1,8 @@ import { Outlet, createRootRoute } from '@tanstack/solid-router' +import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools' import { NotFound } from '~/components/NotFound' import appCss from '~/styles/app.css?url' import { seo } from '~/utils/seo' -import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools' export const Route = createRootRoute({ head: () => ({ diff --git a/e2e/solid-start/website/src/routes/_library.$project.$version.index.tsx b/e2e/solid-start/website/src/routes/_library.$project.$version.index.tsx index 201e85f8e9..847edba780 100644 --- a/e2e/solid-start/website/src/routes/_library.$project.$version.index.tsx +++ b/e2e/solid-start/website/src/routes/_library.$project.$version.index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' -export const Route = createFileRoute('/_library/$project/$version/')({ +export const Route = createFileRoute({ component: Page, }) @@ -14,7 +14,7 @@ function Page() {

version: {params().version}

- + Get started with our documentation.

diff --git a/e2e/solid-start/website/src/routes/_library.$project.tsx b/e2e/solid-start/website/src/routes/_library.$project.tsx index 6fdcb8e530..c057827d8b 100644 --- a/e2e/solid-start/website/src/routes/_library.$project.tsx +++ b/e2e/solid-start/website/src/routes/_library.$project.tsx @@ -1,8 +1,8 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' import { getProject } from '~/server/projects' import { seo } from '~/utils/seo' -export const Route = createFileRoute('/_library/$project')({ +export const Route = createFileRoute({ loader: ({ params: { project } }) => getProject({ data: project }), head: ({ loaderData }) => ({ meta: seo({ title: `TanStack ${loaderData?.name || 'Project'}` }), diff --git a/e2e/solid-start/website/src/routes/_library.index.tsx b/e2e/solid-start/website/src/routes/_library.index.tsx index 25bf776480..5e5b1c6cd8 100644 --- a/e2e/solid-start/website/src/routes/_library.index.tsx +++ b/e2e/solid-start/website/src/routes/_library.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_library/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/solid-start/website/src/routes/_library.tsx b/e2e/solid-start/website/src/routes/_library.tsx index c25ae5cfe1..17ce91d83b 100644 --- a/e2e/solid-start/website/src/routes/_library.tsx +++ b/e2e/solid-start/website/src/routes/_library.tsx @@ -1,12 +1,7 @@ -import { - Link, - Outlet, - createFileRoute, - useLocation, -} from '@tanstack/solid-router' +import { Link, Outlet, useLocation } from '@tanstack/solid-router' import { getProjects } from '~/server/projects' -export const Route = createFileRoute('/_library')({ +export const Route = createFileRoute({ loader: async () => { const projects = await getProjects() return { diff --git a/e2e/solid-start/website/src/ssr.tsx b/e2e/solid-start/website/src/ssr.tsx deleted file mode 100644 index ebd14c8120..0000000000 --- a/e2e/solid-start/website/src/ssr.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/solid-start/server' -import { getRouterManifest } from '@tanstack/solid-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/e2e/solid-start/website/src/vite-env.d.ts b/e2e/solid-start/website/src/vite-env.d.ts new file mode 100644 index 0000000000..0b2af560d6 --- /dev/null +++ b/e2e/solid-start/website/src/vite-env.d.ts @@ -0,0 +1,4 @@ +declare module '*?url' { + const url: string + export default url +} diff --git a/e2e/solid-start/website/tests/app.spec.ts b/e2e/solid-start/website/tests/app.spec.ts index 7282086ad4..f697b5c417 100644 --- a/e2e/solid-start/website/tests/app.spec.ts +++ b/e2e/solid-start/website/tests/app.spec.ts @@ -17,3 +17,17 @@ test('resolves to the overview docs page', async ({ page }) => { '/router/latest/docs/framework/solid/overview', ) }) + +test('clicking on Documentation link navigates to the overview docs page', async ({ + page, +}) => { + await page.goto('/router') + await page.waitForLoadState('networkidle') + + const documentationLink = page.getByLabel('Documentation') + await documentationLink.click() + await page.waitForLoadState('networkidle') + + const pathname = new URL(page.url()).pathname + expect(pathname).toBe('/router/latest/docs/framework/solid/overview') +}) diff --git a/e2e/solid-start/website/vite.config.ts b/e2e/solid-start/website/vite.config.ts new file mode 100644 index 0000000000..f6a9e52322 --- /dev/null +++ b/e2e/solid-start/website/vite.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/solid-start/plugin' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin({}), + ], +}) diff --git a/examples/react/authenticated-routes-firebase/src/routeTree.gen.ts b/examples/react/authenticated-routes-firebase/src/routeTree.gen.ts index 173f5e2531..017a4f60ec 100644 --- a/examples/react/authenticated-routes-firebase/src/routeTree.gen.ts +++ b/examples/react/authenticated-routes-firebase/src/routeTree.gen.ts @@ -10,53 +10,54 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as LoginImport } from './routes/login' -import { Route as AuthImport } from './routes/_auth' -import { Route as IndexImport } from './routes/index' -import { Route as AuthInvoicesImport } from './routes/_auth.invoices' -import { Route as AuthDashboardImport } from './routes/_auth.dashboard' -import { Route as AuthInvoicesIndexImport } from './routes/_auth.invoices.index' -import { Route as AuthInvoicesInvoiceIdImport } from './routes/_auth.invoices.$invoiceId' +import { Route as LoginRouteImport } from './routes/login' +import { Route as AuthRouteImport } from './routes/_auth' +import { Route as IndexRouteImport } from './routes/index' +import { Route as AuthInvoicesRouteImport } from './routes/_auth.invoices' +import { Route as AuthDashboardRouteImport } from './routes/_auth.dashboard' +import { Route as AuthInvoicesIndexRouteImport } from './routes/_auth.invoices.index' +import { Route as AuthInvoicesInvoiceIdRouteImport } from './routes/_auth.invoices.$invoiceId' // Create/Update Routes -const LoginRoute = LoginImport.update({ +const LoginRoute = LoginRouteImport.update({ id: '/login', path: '/login', getParentRoute: () => rootRoute, } as any) -const AuthRoute = AuthImport.update({ +const AuthRoute = AuthRouteImport.update({ id: '/_auth', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const AuthInvoicesRoute = AuthInvoicesImport.update({ +const AuthInvoicesRoute = AuthInvoicesRouteImport.update({ id: '/invoices', path: '/invoices', getParentRoute: () => AuthRoute, } as any) -const AuthDashboardRoute = AuthDashboardImport.update({ +const AuthDashboardRoute = AuthDashboardRouteImport.update({ id: '/dashboard', path: '/dashboard', getParentRoute: () => AuthRoute, } as any) -const AuthInvoicesIndexRoute = AuthInvoicesIndexImport.update({ +const AuthInvoicesIndexRoute = AuthInvoicesIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => AuthInvoicesRoute, } as any) -const AuthInvoicesInvoiceIdRoute = AuthInvoicesInvoiceIdImport.update({ +const AuthInvoicesInvoiceIdRoute = AuthInvoicesInvoiceIdRouteImport.update({ id: '/$invoiceId', path: '/$invoiceId', getParentRoute: () => AuthInvoicesRoute, @@ -70,54 +71,120 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_auth': { id: '/_auth' path: '' fullPath: '' - preLoaderRoute: typeof AuthImport + preLoaderRoute: typeof AuthRouteImport parentRoute: typeof rootRoute } '/login': { id: '/login' path: '/login' fullPath: '/login' - preLoaderRoute: typeof LoginImport + preLoaderRoute: typeof LoginRouteImport parentRoute: typeof rootRoute } '/_auth/dashboard': { id: '/_auth/dashboard' path: '/dashboard' fullPath: '/dashboard' - preLoaderRoute: typeof AuthDashboardImport - parentRoute: typeof AuthImport + preLoaderRoute: typeof AuthDashboardRouteImport + parentRoute: typeof AuthRouteImport } '/_auth/invoices': { id: '/_auth/invoices' path: '/invoices' fullPath: '/invoices' - preLoaderRoute: typeof AuthInvoicesImport - parentRoute: typeof AuthImport + preLoaderRoute: typeof AuthInvoicesRouteImport + parentRoute: typeof AuthRouteImport } '/_auth/invoices/$invoiceId': { id: '/_auth/invoices/$invoiceId' path: '/$invoiceId' fullPath: '/invoices/$invoiceId' - preLoaderRoute: typeof AuthInvoicesInvoiceIdImport - parentRoute: typeof AuthInvoicesImport + preLoaderRoute: typeof AuthInvoicesInvoiceIdRouteImport + parentRoute: typeof AuthInvoicesRouteImport } '/_auth/invoices/': { id: '/_auth/invoices/' path: '/' fullPath: '/invoices/' - preLoaderRoute: typeof AuthInvoicesIndexImport - parentRoute: typeof AuthInvoicesImport + preLoaderRoute: typeof AuthInvoicesIndexRouteImport + parentRoute: typeof AuthInvoicesRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_auth' { + const createFileRoute: CreateFileRoute< + '/_auth', + FileRoutesByPath['/_auth']['parentRoute'], + FileRoutesByPath['/_auth']['id'], + FileRoutesByPath['/_auth']['path'], + FileRoutesByPath['/_auth']['fullPath'] + > +} +declare module './routes/login' { + const createFileRoute: CreateFileRoute< + '/login', + FileRoutesByPath['/login']['parentRoute'], + FileRoutesByPath['/login']['id'], + FileRoutesByPath['/login']['path'], + FileRoutesByPath['/login']['fullPath'] + > +} +declare module './routes/_auth.dashboard' { + const createFileRoute: CreateFileRoute< + '/_auth/dashboard', + FileRoutesByPath['/_auth/dashboard']['parentRoute'], + FileRoutesByPath['/_auth/dashboard']['id'], + FileRoutesByPath['/_auth/dashboard']['path'], + FileRoutesByPath['/_auth/dashboard']['fullPath'] + > +} +declare module './routes/_auth.invoices' { + const createFileRoute: CreateFileRoute< + '/_auth/invoices', + FileRoutesByPath['/_auth/invoices']['parentRoute'], + FileRoutesByPath['/_auth/invoices']['id'], + FileRoutesByPath['/_auth/invoices']['path'], + FileRoutesByPath['/_auth/invoices']['fullPath'] + > +} +declare module './routes/_auth.invoices.$invoiceId' { + const createFileRoute: CreateFileRoute< + '/_auth/invoices/$invoiceId', + FileRoutesByPath['/_auth/invoices/$invoiceId']['parentRoute'], + FileRoutesByPath['/_auth/invoices/$invoiceId']['id'], + FileRoutesByPath['/_auth/invoices/$invoiceId']['path'], + FileRoutesByPath['/_auth/invoices/$invoiceId']['fullPath'] + > +} +declare module './routes/_auth.invoices.index' { + const createFileRoute: CreateFileRoute< + '/_auth/invoices/', + FileRoutesByPath['/_auth/invoices/']['parentRoute'], + FileRoutesByPath['/_auth/invoices/']['id'], + FileRoutesByPath['/_auth/invoices/']['path'], + FileRoutesByPath['/_auth/invoices/']['fullPath'] + > +} + // Create and export the route tree interface AuthInvoicesRouteChildren { @@ -216,6 +283,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/authenticated-routes-firebase/src/routes/_auth.dashboard.tsx b/examples/react/authenticated-routes-firebase/src/routes/_auth.dashboard.tsx index a4c6fc7cdf..68231e780c 100644 --- a/examples/react/authenticated-routes-firebase/src/routes/_auth.dashboard.tsx +++ b/examples/react/authenticated-routes-firebase/src/routes/_auth.dashboard.tsx @@ -1,9 +1,8 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' import { useAuth } from '../auth' -export const Route = createFileRoute('/_auth/dashboard')({ +export const Route = createFileRoute({ component: DashboardPage, }) diff --git a/examples/react/authenticated-routes-firebase/src/routes/_auth.invoices.$invoiceId.tsx b/examples/react/authenticated-routes-firebase/src/routes/_auth.invoices.$invoiceId.tsx index 896133db24..fa727b8e49 100644 --- a/examples/react/authenticated-routes-firebase/src/routes/_auth.invoices.$invoiceId.tsx +++ b/examples/react/authenticated-routes-firebase/src/routes/_auth.invoices.$invoiceId.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' + import { fetchInvoiceById } from '../posts' -export const Route = createFileRoute('/_auth/invoices/$invoiceId')({ +export const Route = createFileRoute({ loader: async ({ params: { invoiceId } }) => { return { invoice: await fetchInvoiceById(Number.parseInt(invoiceId)), diff --git a/examples/react/authenticated-routes-firebase/src/routes/_auth.invoices.index.tsx b/examples/react/authenticated-routes-firebase/src/routes/_auth.invoices.index.tsx index 5ba27d4cc0..d0bd95b152 100644 --- a/examples/react/authenticated-routes-firebase/src/routes/_auth.invoices.index.tsx +++ b/examples/react/authenticated-routes-firebase/src/routes/_auth.invoices.index.tsx @@ -1,6 +1,5 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/_auth/invoices/')({ +export const Route = createFileRoute({ component: () =>
Select an invoice to view it!
, }) diff --git a/examples/react/authenticated-routes-firebase/src/routes/_auth.invoices.tsx b/examples/react/authenticated-routes-firebase/src/routes/_auth.invoices.tsx index c3cda59142..5b4c97ee86 100644 --- a/examples/react/authenticated-routes-firebase/src/routes/_auth.invoices.tsx +++ b/examples/react/authenticated-routes-firebase/src/routes/_auth.invoices.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchInvoices } from '../posts' -export const Route = createFileRoute('/_auth/invoices')({ +export const Route = createFileRoute({ loader: async () => ({ invoices: await fetchInvoices(), }), diff --git a/examples/react/authenticated-routes-firebase/src/routes/_auth.tsx b/examples/react/authenticated-routes-firebase/src/routes/_auth.tsx index a218577627..3bceaa2d6f 100644 --- a/examples/react/authenticated-routes-firebase/src/routes/_auth.tsx +++ b/examples/react/authenticated-routes-firebase/src/routes/_auth.tsx @@ -1,13 +1,7 @@ -import { - Link, - Outlet, - createFileRoute, - redirect, - useRouter, -} from '@tanstack/react-router' +import { Link, Outlet, redirect, useRouter } from '@tanstack/react-router' import { useAuth } from '../auth' -export const Route = createFileRoute('/_auth')({ +export const Route = createFileRoute({ beforeLoad: ({ context, location }) => { // Check if user is authenticated if (!context.auth.isAuthenticated) { diff --git a/examples/react/authenticated-routes-firebase/src/routes/index.tsx b/examples/react/authenticated-routes-firebase/src/routes/index.tsx index e9264fed15..fc88a8cbfb 100644 --- a/examples/react/authenticated-routes-firebase/src/routes/index.tsx +++ b/examples/react/authenticated-routes-firebase/src/routes/index.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute, redirect } from '@tanstack/react-router' +import { Link, redirect } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ beforeLoad: ({ context }) => { // Log for debugging console.log('Checking context on index.tsx:', context) // Check if user is authenticated diff --git a/examples/react/authenticated-routes-firebase/src/routes/login.tsx b/examples/react/authenticated-routes-firebase/src/routes/login.tsx index 1c665b9fbc..b46186e353 100644 --- a/examples/react/authenticated-routes-firebase/src/routes/login.tsx +++ b/examples/react/authenticated-routes-firebase/src/routes/login.tsx @@ -1,10 +1,5 @@ import * as React from 'react' -import { - createFileRoute, - redirect, - useRouter, - useRouterState, -} from '@tanstack/react-router' +import { redirect, useRouter, useRouterState } from '@tanstack/react-router' import { z } from 'zod' import { useAuth } from '../auth' @@ -20,7 +15,7 @@ import { // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const fallback = '/dashboard' as const -export const Route = createFileRoute('/login')({ +export const Route = createFileRoute({ validateSearch: z.object({ redirect: z.string().optional().catch(''), }), diff --git a/examples/react/authenticated-routes/src/routeTree.gen.ts b/examples/react/authenticated-routes/src/routeTree.gen.ts index 173f5e2531..017a4f60ec 100644 --- a/examples/react/authenticated-routes/src/routeTree.gen.ts +++ b/examples/react/authenticated-routes/src/routeTree.gen.ts @@ -10,53 +10,54 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as LoginImport } from './routes/login' -import { Route as AuthImport } from './routes/_auth' -import { Route as IndexImport } from './routes/index' -import { Route as AuthInvoicesImport } from './routes/_auth.invoices' -import { Route as AuthDashboardImport } from './routes/_auth.dashboard' -import { Route as AuthInvoicesIndexImport } from './routes/_auth.invoices.index' -import { Route as AuthInvoicesInvoiceIdImport } from './routes/_auth.invoices.$invoiceId' +import { Route as LoginRouteImport } from './routes/login' +import { Route as AuthRouteImport } from './routes/_auth' +import { Route as IndexRouteImport } from './routes/index' +import { Route as AuthInvoicesRouteImport } from './routes/_auth.invoices' +import { Route as AuthDashboardRouteImport } from './routes/_auth.dashboard' +import { Route as AuthInvoicesIndexRouteImport } from './routes/_auth.invoices.index' +import { Route as AuthInvoicesInvoiceIdRouteImport } from './routes/_auth.invoices.$invoiceId' // Create/Update Routes -const LoginRoute = LoginImport.update({ +const LoginRoute = LoginRouteImport.update({ id: '/login', path: '/login', getParentRoute: () => rootRoute, } as any) -const AuthRoute = AuthImport.update({ +const AuthRoute = AuthRouteImport.update({ id: '/_auth', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const AuthInvoicesRoute = AuthInvoicesImport.update({ +const AuthInvoicesRoute = AuthInvoicesRouteImport.update({ id: '/invoices', path: '/invoices', getParentRoute: () => AuthRoute, } as any) -const AuthDashboardRoute = AuthDashboardImport.update({ +const AuthDashboardRoute = AuthDashboardRouteImport.update({ id: '/dashboard', path: '/dashboard', getParentRoute: () => AuthRoute, } as any) -const AuthInvoicesIndexRoute = AuthInvoicesIndexImport.update({ +const AuthInvoicesIndexRoute = AuthInvoicesIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => AuthInvoicesRoute, } as any) -const AuthInvoicesInvoiceIdRoute = AuthInvoicesInvoiceIdImport.update({ +const AuthInvoicesInvoiceIdRoute = AuthInvoicesInvoiceIdRouteImport.update({ id: '/$invoiceId', path: '/$invoiceId', getParentRoute: () => AuthInvoicesRoute, @@ -70,54 +71,120 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_auth': { id: '/_auth' path: '' fullPath: '' - preLoaderRoute: typeof AuthImport + preLoaderRoute: typeof AuthRouteImport parentRoute: typeof rootRoute } '/login': { id: '/login' path: '/login' fullPath: '/login' - preLoaderRoute: typeof LoginImport + preLoaderRoute: typeof LoginRouteImport parentRoute: typeof rootRoute } '/_auth/dashboard': { id: '/_auth/dashboard' path: '/dashboard' fullPath: '/dashboard' - preLoaderRoute: typeof AuthDashboardImport - parentRoute: typeof AuthImport + preLoaderRoute: typeof AuthDashboardRouteImport + parentRoute: typeof AuthRouteImport } '/_auth/invoices': { id: '/_auth/invoices' path: '/invoices' fullPath: '/invoices' - preLoaderRoute: typeof AuthInvoicesImport - parentRoute: typeof AuthImport + preLoaderRoute: typeof AuthInvoicesRouteImport + parentRoute: typeof AuthRouteImport } '/_auth/invoices/$invoiceId': { id: '/_auth/invoices/$invoiceId' path: '/$invoiceId' fullPath: '/invoices/$invoiceId' - preLoaderRoute: typeof AuthInvoicesInvoiceIdImport - parentRoute: typeof AuthInvoicesImport + preLoaderRoute: typeof AuthInvoicesInvoiceIdRouteImport + parentRoute: typeof AuthInvoicesRouteImport } '/_auth/invoices/': { id: '/_auth/invoices/' path: '/' fullPath: '/invoices/' - preLoaderRoute: typeof AuthInvoicesIndexImport - parentRoute: typeof AuthInvoicesImport + preLoaderRoute: typeof AuthInvoicesIndexRouteImport + parentRoute: typeof AuthInvoicesRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_auth' { + const createFileRoute: CreateFileRoute< + '/_auth', + FileRoutesByPath['/_auth']['parentRoute'], + FileRoutesByPath['/_auth']['id'], + FileRoutesByPath['/_auth']['path'], + FileRoutesByPath['/_auth']['fullPath'] + > +} +declare module './routes/login' { + const createFileRoute: CreateFileRoute< + '/login', + FileRoutesByPath['/login']['parentRoute'], + FileRoutesByPath['/login']['id'], + FileRoutesByPath['/login']['path'], + FileRoutesByPath['/login']['fullPath'] + > +} +declare module './routes/_auth.dashboard' { + const createFileRoute: CreateFileRoute< + '/_auth/dashboard', + FileRoutesByPath['/_auth/dashboard']['parentRoute'], + FileRoutesByPath['/_auth/dashboard']['id'], + FileRoutesByPath['/_auth/dashboard']['path'], + FileRoutesByPath['/_auth/dashboard']['fullPath'] + > +} +declare module './routes/_auth.invoices' { + const createFileRoute: CreateFileRoute< + '/_auth/invoices', + FileRoutesByPath['/_auth/invoices']['parentRoute'], + FileRoutesByPath['/_auth/invoices']['id'], + FileRoutesByPath['/_auth/invoices']['path'], + FileRoutesByPath['/_auth/invoices']['fullPath'] + > +} +declare module './routes/_auth.invoices.$invoiceId' { + const createFileRoute: CreateFileRoute< + '/_auth/invoices/$invoiceId', + FileRoutesByPath['/_auth/invoices/$invoiceId']['parentRoute'], + FileRoutesByPath['/_auth/invoices/$invoiceId']['id'], + FileRoutesByPath['/_auth/invoices/$invoiceId']['path'], + FileRoutesByPath['/_auth/invoices/$invoiceId']['fullPath'] + > +} +declare module './routes/_auth.invoices.index' { + const createFileRoute: CreateFileRoute< + '/_auth/invoices/', + FileRoutesByPath['/_auth/invoices/']['parentRoute'], + FileRoutesByPath['/_auth/invoices/']['id'], + FileRoutesByPath['/_auth/invoices/']['path'], + FileRoutesByPath['/_auth/invoices/']['fullPath'] + > +} + // Create and export the route tree interface AuthInvoicesRouteChildren { @@ -216,6 +283,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/authenticated-routes/src/routes/_auth.dashboard.tsx b/examples/react/authenticated-routes/src/routes/_auth.dashboard.tsx index 51fbf3e81a..4a37b7ffd2 100644 --- a/examples/react/authenticated-routes/src/routes/_auth.dashboard.tsx +++ b/examples/react/authenticated-routes/src/routes/_auth.dashboard.tsx @@ -1,9 +1,8 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' import { useAuth } from '../auth' -export const Route = createFileRoute('/_auth/dashboard')({ +export const Route = createFileRoute({ component: DashboardPage, }) diff --git a/examples/react/authenticated-routes/src/routes/_auth.invoices.$invoiceId.tsx b/examples/react/authenticated-routes/src/routes/_auth.invoices.$invoiceId.tsx index 15b502d5e9..754de7c3d8 100644 --- a/examples/react/authenticated-routes/src/routes/_auth.invoices.$invoiceId.tsx +++ b/examples/react/authenticated-routes/src/routes/_auth.invoices.$invoiceId.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' + import { fetchInvoiceById } from '../posts' -export const Route = createFileRoute('/_auth/invoices/$invoiceId')({ +export const Route = createFileRoute({ loader: async ({ params: { invoiceId } }) => { return { invoice: await fetchInvoiceById(parseInt(invoiceId)), diff --git a/examples/react/authenticated-routes/src/routes/_auth.invoices.index.tsx b/examples/react/authenticated-routes/src/routes/_auth.invoices.index.tsx index 5ba27d4cc0..d0bd95b152 100644 --- a/examples/react/authenticated-routes/src/routes/_auth.invoices.index.tsx +++ b/examples/react/authenticated-routes/src/routes/_auth.invoices.index.tsx @@ -1,6 +1,5 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/_auth/invoices/')({ +export const Route = createFileRoute({ component: () =>
Select an invoice to view it!
, }) diff --git a/examples/react/authenticated-routes/src/routes/_auth.invoices.tsx b/examples/react/authenticated-routes/src/routes/_auth.invoices.tsx index c3cda59142..5b4c97ee86 100644 --- a/examples/react/authenticated-routes/src/routes/_auth.invoices.tsx +++ b/examples/react/authenticated-routes/src/routes/_auth.invoices.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchInvoices } from '../posts' -export const Route = createFileRoute('/_auth/invoices')({ +export const Route = createFileRoute({ loader: async () => ({ invoices: await fetchInvoices(), }), diff --git a/examples/react/authenticated-routes/src/routes/_auth.tsx b/examples/react/authenticated-routes/src/routes/_auth.tsx index 00c97cbeb7..b69fcef29b 100644 --- a/examples/react/authenticated-routes/src/routes/_auth.tsx +++ b/examples/react/authenticated-routes/src/routes/_auth.tsx @@ -1,15 +1,9 @@ import * as React from 'react' -import { - Link, - Outlet, - createFileRoute, - redirect, - useRouter, -} from '@tanstack/react-router' +import { Link, Outlet, redirect, useRouter } from '@tanstack/react-router' import { useAuth } from '../auth' -export const Route = createFileRoute('/_auth')({ +export const Route = createFileRoute({ beforeLoad: ({ context, location }) => { if (!context.auth.isAuthenticated) { throw redirect({ diff --git a/examples/react/authenticated-routes/src/routes/index.tsx b/examples/react/authenticated-routes/src/routes/index.tsx index f5fc871378..cf5cf40e2f 100644 --- a/examples/react/authenticated-routes/src/routes/index.tsx +++ b/examples/react/authenticated-routes/src/routes/index.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: HomeComponent, }) diff --git a/examples/react/authenticated-routes/src/routes/login.tsx b/examples/react/authenticated-routes/src/routes/login.tsx index dd78f66f9c..71360e9661 100644 --- a/examples/react/authenticated-routes/src/routes/login.tsx +++ b/examples/react/authenticated-routes/src/routes/login.tsx @@ -1,10 +1,5 @@ import * as React from 'react' -import { - createFileRoute, - redirect, - useRouter, - useRouterState, -} from '@tanstack/react-router' +import { redirect, useRouter, useRouterState } from '@tanstack/react-router' import { z } from 'zod' import { useAuth } from '../auth' @@ -13,7 +8,7 @@ import { sleep } from '../utils' // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const fallback = '/dashboard' as const -export const Route = createFileRoute('/login')({ +export const Route = createFileRoute({ validateSearch: z.object({ redirect: z.string().optional().catch(''), }), diff --git a/examples/react/basic-file-based/src/routeTree.gen.ts b/examples/react/basic-file-based/src/routeTree.gen.ts index 1f98acd3e4..ad1fc6359c 100644 --- a/examples/react/basic-file-based/src/routeTree.gen.ts +++ b/examples/react/basic-file-based/src/routeTree.gen.ts @@ -10,70 +10,70 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as AnchorImport } from './routes/anchor' -import { Route as PathlessLayoutImport } from './routes/_pathlessLayout' -import { Route as PostsRouteImport } from './routes/posts.route' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as PathlessLayoutNestedLayoutImport } from './routes/_pathlessLayout/_nested-layout' -import { Route as PathlessLayoutNestedLayoutRouteBImport } from './routes/_pathlessLayout/_nested-layout/route-b' -import { Route as PathlessLayoutNestedLayoutRouteAImport } from './routes/_pathlessLayout/_nested-layout/route-a' +import { Route as AnchorRouteImport } from './routes/anchor' +import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' +import { Route as PostsRouteRouteImport } from './routes/posts.route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as PathlessLayoutNestedLayoutRouteImport } from './routes/_pathlessLayout/_nested-layout' +import { Route as PathlessLayoutNestedLayoutRouteBRouteImport } from './routes/_pathlessLayout/_nested-layout/route-b' +import { Route as PathlessLayoutNestedLayoutRouteARouteImport } from './routes/_pathlessLayout/_nested-layout/route-a' // Create/Update Routes -const AnchorRoute = AnchorImport.update({ +const AnchorRoute = AnchorRouteImport.update({ id: '/anchor', path: '/anchor', getParentRoute: () => rootRoute, } as any) -const PathlessLayoutRoute = PathlessLayoutImport.update({ +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', getParentRoute: () => rootRoute, } as any) -const PostsRouteRoute = PostsRouteImport.update({ +const PostsRouteRoute = PostsRouteRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRouteRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRouteRoute, } as any) -const PathlessLayoutNestedLayoutRoute = PathlessLayoutNestedLayoutImport.update( - { +const PathlessLayoutNestedLayoutRoute = + PathlessLayoutNestedLayoutRouteImport.update({ id: '/_nested-layout', getParentRoute: () => PathlessLayoutRoute, - } as any, -) + } as any) const PathlessLayoutNestedLayoutRouteBRoute = - PathlessLayoutNestedLayoutRouteBImport.update({ + PathlessLayoutNestedLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutNestedLayoutRoute, } as any) const PathlessLayoutNestedLayoutRouteARoute = - PathlessLayoutNestedLayoutRouteAImport.update({ + PathlessLayoutNestedLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutNestedLayoutRoute, @@ -87,68 +87,152 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsRouteRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout': { id: '/_pathlessLayout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteImport parentRoute: typeof rootRoute } '/anchor': { id: '/anchor' path: '/anchor' fullPath: '/anchor' - preLoaderRoute: typeof AnchorImport + preLoaderRoute: typeof AnchorRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout/_nested-layout': { id: '/_pathlessLayout/_nested-layout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutNestedLayoutImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteRouteImport } '/_pathlessLayout/_nested-layout/route-a': { id: '/_pathlessLayout/_nested-layout/route-a' path: '/route-a' fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteAImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/_pathlessLayout/_nested-layout/route-b': { id: '/_pathlessLayout/_nested-layout/route-b' path: '/route-b' fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/posts.route' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/_pathlessLayout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout', + FileRoutesByPath['/_pathlessLayout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout']['id'], + FileRoutesByPath['/_pathlessLayout']['path'], + FileRoutesByPath['/_pathlessLayout']['fullPath'] + > +} +declare module './routes/anchor' { + const createFileRoute: CreateFileRoute< + '/anchor', + FileRoutesByPath['/anchor']['parentRoute'], + FileRoutesByPath['/anchor']['id'], + FileRoutesByPath['/anchor']['path'], + FileRoutesByPath['/anchor']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout', + FileRoutesByPath['/_pathlessLayout/_nested-layout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-a' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-a', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-b' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-b', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['fullPath'] + > +} + // Create and export the route tree interface PostsRouteRouteChildren { @@ -281,6 +365,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/basic-file-based/src/routes/_pathlessLayout.tsx b/examples/react/basic-file-based/src/routes/_pathlessLayout.tsx index 202070f1ff..fd83a0eaa0 100644 --- a/examples/react/basic-file-based/src/routes/_pathlessLayout.tsx +++ b/examples/react/basic-file-based/src/routes/_pathlessLayout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/basic-file-based/src/routes/_pathlessLayout/_nested-layout.tsx b/examples/react/basic-file-based/src/routes/_pathlessLayout/_nested-layout.tsx index c5bcffd5a4..abd82a2bf6 100644 --- a/examples/react/basic-file-based/src/routes/_pathlessLayout/_nested-layout.tsx +++ b/examples/react/basic-file-based/src/routes/_pathlessLayout/_nested-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout/_nested-layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx b/examples/react/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx index 5649f77d8e..a190b24202 100644 --- a/examples/react/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx +++ b/examples/react/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-a')( - { - component: LayoutAComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutAComponent, +}) function LayoutAComponent() { return
I'm layout A!
diff --git a/examples/react/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx b/examples/react/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx index 742e48bfb4..505f8f6fbf 100644 --- a/examples/react/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx +++ b/examples/react/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-b')( - { - component: LayoutBComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutBComponent, +}) function LayoutBComponent() { return
I'm layout B!
diff --git a/examples/react/basic-file-based/src/routes/anchor.tsx b/examples/react/basic-file-based/src/routes/anchor.tsx index fbe16ed55c..21dce23c39 100644 --- a/examples/react/basic-file-based/src/routes/anchor.tsx +++ b/examples/react/basic-file-based/src/routes/anchor.tsx @@ -1,12 +1,7 @@ import { useLayoutEffect, useRef, useState } from 'react' -import { - Link, - createFileRoute, - useLocation, - useNavigate, -} from '@tanstack/react-router' +import { Link, useLocation, useNavigate } from '@tanstack/react-router' -export const Route = createFileRoute('/anchor')({ +export const Route = createFileRoute({ component: AnchorComponent, }) diff --git a/examples/react/basic-file-based/src/routes/index.tsx b/examples/react/basic-file-based/src/routes/index.tsx index eac82a9174..b23956ae17 100644 --- a/examples/react/basic-file-based/src/routes/index.tsx +++ b/examples/react/basic-file-based/src/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/react/basic-file-based/src/routes/posts.$postId.tsx b/examples/react/basic-file-based/src/routes/posts.$postId.tsx index cded91ef96..0578182ecb 100644 --- a/examples/react/basic-file-based/src/routes/posts.$postId.tsx +++ b/examples/react/basic-file-based/src/routes/posts.$postId.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import { fetchPost } from '../posts' import type { ErrorComponentProps } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent, notFoundComponent: () => { diff --git a/examples/react/basic-file-based/src/routes/posts.index.tsx b/examples/react/basic-file-based/src/routes/posts.index.tsx index 056433ca0a..fdbe5865e5 100644 --- a/examples/react/basic-file-based/src/routes/posts.index.tsx +++ b/examples/react/basic-file-based/src/routes/posts.index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/react/basic-file-based/src/routes/posts.route.tsx b/examples/react/basic-file-based/src/routes/posts.route.tsx index 0115fc8063..0aca21ad57 100644 --- a/examples/react/basic-file-based/src/routes/posts.route.tsx +++ b/examples/react/basic-file-based/src/routes/posts.route.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsLayoutComponent, }) diff --git a/examples/react/basic-react-query-file-based/src/routeTree.gen.ts b/examples/react/basic-react-query-file-based/src/routeTree.gen.ts index 67944b5f0c..7d212bb41a 100644 --- a/examples/react/basic-react-query-file-based/src/routeTree.gen.ts +++ b/examples/react/basic-react-query-file-based/src/routeTree.gen.ts @@ -10,63 +10,63 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PathlessLayoutImport } from './routes/_pathlessLayout' -import { Route as PostsRouteImport } from './routes/posts.route' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as PathlessLayoutNestedLayoutImport } from './routes/_pathlessLayout/_nested-layout' -import { Route as PathlessLayoutNestedLayoutRouteBImport } from './routes/_pathlessLayout/_nested-layout/route-b' -import { Route as PathlessLayoutNestedLayoutRouteAImport } from './routes/_pathlessLayout/_nested-layout/route-a' +import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' +import { Route as PostsRouteRouteImport } from './routes/posts.route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as PathlessLayoutNestedLayoutRouteImport } from './routes/_pathlessLayout/_nested-layout' +import { Route as PathlessLayoutNestedLayoutRouteBRouteImport } from './routes/_pathlessLayout/_nested-layout/route-b' +import { Route as PathlessLayoutNestedLayoutRouteARouteImport } from './routes/_pathlessLayout/_nested-layout/route-a' // Create/Update Routes -const PathlessLayoutRoute = PathlessLayoutImport.update({ +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', getParentRoute: () => rootRoute, } as any) -const PostsRouteRoute = PostsRouteImport.update({ +const PostsRouteRoute = PostsRouteRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRouteRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRouteRoute, } as any) -const PathlessLayoutNestedLayoutRoute = PathlessLayoutNestedLayoutImport.update( - { +const PathlessLayoutNestedLayoutRoute = + PathlessLayoutNestedLayoutRouteImport.update({ id: '/_nested-layout', getParentRoute: () => PathlessLayoutRoute, - } as any, -) + } as any) const PathlessLayoutNestedLayoutRouteBRoute = - PathlessLayoutNestedLayoutRouteBImport.update({ + PathlessLayoutNestedLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutNestedLayoutRoute, } as any) const PathlessLayoutNestedLayoutRouteARoute = - PathlessLayoutNestedLayoutRouteAImport.update({ + PathlessLayoutNestedLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutNestedLayoutRoute, @@ -80,61 +80,136 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsRouteRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout': { id: '/_pathlessLayout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout/_nested-layout': { id: '/_pathlessLayout/_nested-layout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutNestedLayoutImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteRouteImport } '/_pathlessLayout/_nested-layout/route-a': { id: '/_pathlessLayout/_nested-layout/route-a' path: '/route-a' fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteAImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/_pathlessLayout/_nested-layout/route-b': { id: '/_pathlessLayout/_nested-layout/route-b' path: '/route-b' fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/posts.route' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/_pathlessLayout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout', + FileRoutesByPath['/_pathlessLayout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout']['id'], + FileRoutesByPath['/_pathlessLayout']['path'], + FileRoutesByPath['/_pathlessLayout']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout', + FileRoutesByPath['/_pathlessLayout/_nested-layout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-a' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-a', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-b' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-b', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['fullPath'] + > +} + // Create and export the route tree interface PostsRouteRouteChildren { @@ -253,6 +328,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout.tsx b/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout.tsx index c3b12442b8..5c4a461d8d 100644 --- a/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout.tsx +++ b/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout/_nested-layout.tsx b/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout/_nested-layout.tsx index 9a48b73a46..1e1400f5a7 100644 --- a/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout/_nested-layout.tsx +++ b/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout/_nested-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout/_nested-layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx b/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx index 5649f77d8e..a190b24202 100644 --- a/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx +++ b/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-a')( - { - component: LayoutAComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutAComponent, +}) function LayoutAComponent() { return
I'm layout A!
diff --git a/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx b/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx index 742e48bfb4..505f8f6fbf 100644 --- a/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx +++ b/examples/react/basic-react-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-b')( - { - component: LayoutBComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutBComponent, +}) function LayoutBComponent() { return
I'm layout B!
diff --git a/examples/react/basic-react-query-file-based/src/routes/index.tsx b/examples/react/basic-react-query-file-based/src/routes/index.tsx index eac82a9174..b23956ae17 100644 --- a/examples/react/basic-react-query-file-based/src/routes/index.tsx +++ b/examples/react/basic-react-query-file-based/src/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/react/basic-react-query-file-based/src/routes/posts.$postId.tsx b/examples/react/basic-react-query-file-based/src/routes/posts.$postId.tsx index 4cf6beca88..c3ae5dc441 100644 --- a/examples/react/basic-react-query-file-based/src/routes/posts.$postId.tsx +++ b/examples/react/basic-react-query-file-based/src/routes/posts.$postId.tsx @@ -1,9 +1,5 @@ import * as React from 'react' -import { - ErrorComponent, - createFileRoute, - useRouter, -} from '@tanstack/react-router' +import { ErrorComponent, useRouter } from '@tanstack/react-router' import { useQueryErrorResetBoundary, useSuspenseQuery, @@ -12,7 +8,7 @@ import { PostNotFoundError } from '../posts' import { postQueryOptions } from '../postQueryOptions' import type { ErrorComponentProps } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: ({ context: { queryClient }, params: { postId } }) => { return queryClient.ensureQueryData(postQueryOptions(postId)) }, diff --git a/examples/react/basic-react-query-file-based/src/routes/posts.index.tsx b/examples/react/basic-react-query-file-based/src/routes/posts.index.tsx index 056433ca0a..fdbe5865e5 100644 --- a/examples/react/basic-react-query-file-based/src/routes/posts.index.tsx +++ b/examples/react/basic-react-query-file-based/src/routes/posts.index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/react/basic-react-query-file-based/src/routes/posts.route.tsx b/examples/react/basic-react-query-file-based/src/routes/posts.route.tsx index 0ba745c0ab..dc6dcaf036 100644 --- a/examples/react/basic-react-query-file-based/src/routes/posts.route.tsx +++ b/examples/react/basic-react-query-file-based/src/routes/posts.route.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { useSuspenseQuery } from '@tanstack/react-query' import { postsQueryOptions } from '../postsQueryOptions' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: ({ context: { queryClient } }) => queryClient.ensureQueryData(postsQueryOptions), component: PostsLayoutComponent, diff --git a/examples/react/basic-ssr-file-based/src/routeTree.gen.ts b/examples/react/basic-ssr-file-based/src/routeTree.gen.ts index 7092dee6de..4ff6d62320 100644 --- a/examples/react/basic-ssr-file-based/src/routeTree.gen.ts +++ b/examples/react/basic-ssr-file-based/src/routeTree.gen.ts @@ -10,40 +10,41 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as ErrorImport } from './routes/error' -import { Route as PostsRouteImport } from './routes/posts/route' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts/index' -import { Route as PostsPostIdImport } from './routes/posts/$postId' +import { Route as ErrorRouteImport } from './routes/error' +import { Route as PostsRouteRouteImport } from './routes/posts/route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts/index' +import { Route as PostsPostIdRouteImport } from './routes/posts/$postId' // Create/Update Routes -const ErrorRoute = ErrorImport.update({ +const ErrorRoute = ErrorRouteImport.update({ id: '/error', path: '/error', getParentRoute: () => rootRoute, } as any) -const PostsRouteRoute = PostsRouteImport.update({ +const PostsRouteRoute = PostsRouteRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRouteRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRouteRoute, @@ -57,40 +58,88 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsRouteRouteImport parentRoute: typeof rootRoute } '/error': { id: '/error' path: '/error' fullPath: '/error' - preLoaderRoute: typeof ErrorImport + preLoaderRoute: typeof ErrorRouteImport parentRoute: typeof rootRoute } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/posts/route' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/error' { + const createFileRoute: CreateFileRoute< + '/error', + FileRoutesByPath['/error']['parentRoute'], + FileRoutesByPath['/error']['id'], + FileRoutesByPath['/error']['path'], + FileRoutesByPath['/error']['fullPath'] + > +} +declare module './routes/posts/$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts/index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} + // Create and export the route tree interface PostsRouteRouteChildren { @@ -156,6 +205,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/basic-ssr-file-based/src/routes/error.tsx b/examples/react/basic-ssr-file-based/src/routes/error.tsx index 52d42f2a99..33412fe3da 100644 --- a/examples/react/basic-ssr-file-based/src/routes/error.tsx +++ b/examples/react/basic-ssr-file-based/src/routes/error.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import * as React from 'react' -export const Route = createFileRoute('/error')({ +export const Route = createFileRoute({ component: ErrorComponent, loader: async () => { if (Math.random() > 0.5) throw new Error('Random error!') diff --git a/examples/react/basic-ssr-file-based/src/routes/index.tsx b/examples/react/basic-ssr-file-based/src/routes/index.tsx index eac7746031..b27dfd977a 100644 --- a/examples/react/basic-ssr-file-based/src/routes/index.tsx +++ b/examples/react/basic-ssr-file-based/src/routes/index.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import * as React from 'react' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: IndexComponent, }) diff --git a/examples/react/basic-ssr-file-based/src/routes/posts/$postId.tsx b/examples/react/basic-ssr-file-based/src/routes/posts/$postId.tsx index b045eb784f..4f474865dd 100644 --- a/examples/react/basic-ssr-file-based/src/routes/posts/$postId.tsx +++ b/examples/react/basic-ssr-file-based/src/routes/posts/$postId.tsx @@ -1,8 +1,7 @@ -import { createFileRoute } from '@tanstack/react-router' import * as React from 'react' import type { PostType } from '../posts' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params }) => { console.info(`Fetching post with id ${params.postId}...`) diff --git a/examples/react/basic-ssr-file-based/src/routes/posts/index.tsx b/examples/react/basic-ssr-file-based/src/routes/posts/index.tsx index 5b5f08f95b..13529228bb 100644 --- a/examples/react/basic-ssr-file-based/src/routes/posts/index.tsx +++ b/examples/react/basic-ssr-file-based/src/routes/posts/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/react/basic-ssr-file-based/src/routes/posts/route.tsx b/examples/react/basic-ssr-file-based/src/routes/posts/route.tsx index 3699478d0a..4900ccb437 100644 --- a/examples/react/basic-ssr-file-based/src/routes/posts/route.tsx +++ b/examples/react/basic-ssr-file-based/src/routes/posts/route.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' export type PostType = { id: string @@ -7,7 +7,7 @@ export type PostType = { body: string } -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: async () => { console.info('Fetching posts...') await new Promise((r) => diff --git a/examples/react/basic-ssr-streaming-file-based/src/routeTree.gen.ts b/examples/react/basic-ssr-streaming-file-based/src/routeTree.gen.ts index 7092dee6de..4ff6d62320 100644 --- a/examples/react/basic-ssr-streaming-file-based/src/routeTree.gen.ts +++ b/examples/react/basic-ssr-streaming-file-based/src/routeTree.gen.ts @@ -10,40 +10,41 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as ErrorImport } from './routes/error' -import { Route as PostsRouteImport } from './routes/posts/route' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts/index' -import { Route as PostsPostIdImport } from './routes/posts/$postId' +import { Route as ErrorRouteImport } from './routes/error' +import { Route as PostsRouteRouteImport } from './routes/posts/route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts/index' +import { Route as PostsPostIdRouteImport } from './routes/posts/$postId' // Create/Update Routes -const ErrorRoute = ErrorImport.update({ +const ErrorRoute = ErrorRouteImport.update({ id: '/error', path: '/error', getParentRoute: () => rootRoute, } as any) -const PostsRouteRoute = PostsRouteImport.update({ +const PostsRouteRoute = PostsRouteRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRouteRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRouteRoute, @@ -57,40 +58,88 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsRouteRouteImport parentRoute: typeof rootRoute } '/error': { id: '/error' path: '/error' fullPath: '/error' - preLoaderRoute: typeof ErrorImport + preLoaderRoute: typeof ErrorRouteImport parentRoute: typeof rootRoute } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/posts/route' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/error' { + const createFileRoute: CreateFileRoute< + '/error', + FileRoutesByPath['/error']['parentRoute'], + FileRoutesByPath['/error']['id'], + FileRoutesByPath['/error']['path'], + FileRoutesByPath['/error']['fullPath'] + > +} +declare module './routes/posts/$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts/index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} + // Create and export the route tree interface PostsRouteRouteChildren { @@ -156,6 +205,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/basic-ssr-streaming-file-based/src/routes/error.tsx b/examples/react/basic-ssr-streaming-file-based/src/routes/error.tsx index 8ab6d2b52d..a8f14563d2 100644 --- a/examples/react/basic-ssr-streaming-file-based/src/routes/error.tsx +++ b/examples/react/basic-ssr-streaming-file-based/src/routes/error.tsx @@ -1,4 +1,4 @@ -import { Await, createFileRoute } from '@tanstack/react-router' +import { Await } from '@tanstack/react-router' import * as React from 'react' async function loadData() { @@ -7,7 +7,7 @@ async function loadData() { return 'Hello!' } -export const Route = createFileRoute('/error')({ +export const Route = createFileRoute({ component: ErrorComponent, loader: () => { if (Math.random() > 0.5) throw new Error('Random error!') diff --git a/examples/react/basic-ssr-streaming-file-based/src/routes/index.tsx b/examples/react/basic-ssr-streaming-file-based/src/routes/index.tsx index 50c2706a26..33f887a27b 100644 --- a/examples/react/basic-ssr-streaming-file-based/src/routes/index.tsx +++ b/examples/react/basic-ssr-streaming-file-based/src/routes/index.tsx @@ -1,7 +1,7 @@ -import { Await, createFileRoute } from '@tanstack/react-router' +import { Await } from '@tanstack/react-router' import * as React from 'react' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ loader: () => ({ date: new Date(), deferred: new Promise<{ date: Date }>((r) => diff --git a/examples/react/basic-ssr-streaming-file-based/src/routes/posts/$postId.tsx b/examples/react/basic-ssr-streaming-file-based/src/routes/posts/$postId.tsx index 0a3f603008..9466546c60 100644 --- a/examples/react/basic-ssr-streaming-file-based/src/routes/posts/$postId.tsx +++ b/examples/react/basic-ssr-streaming-file-based/src/routes/posts/$postId.tsx @@ -1,4 +1,4 @@ -import { Await, createFileRoute, notFound } from '@tanstack/react-router' +import { Await, notFound } from '@tanstack/react-router' import * as React from 'react' import type { PostType } from './route' @@ -32,7 +32,7 @@ async function fetchComments(postId: string) { ).then((r) => r.json() as Promise>) } -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => { const commentsPromise = fetchComments(postId) const post = await fetchPostById(postId) diff --git a/examples/react/basic-ssr-streaming-file-based/src/routes/posts/index.tsx b/examples/react/basic-ssr-streaming-file-based/src/routes/posts/index.tsx index 2aa298c265..a88aaa8f26 100644 --- a/examples/react/basic-ssr-streaming-file-based/src/routes/posts/index.tsx +++ b/examples/react/basic-ssr-streaming-file-based/src/routes/posts/index.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import * as React from 'react' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, wrapInSuspense: true, errorComponent: ({ error }) => { diff --git a/examples/react/basic-ssr-streaming-file-based/src/routes/posts/route.tsx b/examples/react/basic-ssr-streaming-file-based/src/routes/posts/route.tsx index ad2b0082ad..ceb14625f2 100644 --- a/examples/react/basic-ssr-streaming-file-based/src/routes/posts/route.tsx +++ b/examples/react/basic-ssr-streaming-file-based/src/routes/posts/route.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' export type PostType = { id: string @@ -7,7 +7,7 @@ export type PostType = { body: string } -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: async () => { console.info('Fetching posts...') await new Promise((r) => diff --git a/examples/react/basic-virtual-file-based/src/routeTree.gen.ts b/examples/react/basic-virtual-file-based/src/routeTree.gen.ts index 22a3dcf194..313bfacff4 100644 --- a/examples/react/basic-virtual-file-based/src/routeTree.gen.ts +++ b/examples/react/basic-virtual-file-based/src/routeTree.gen.ts @@ -12,100 +12,101 @@ import { createFileRoute } from '@tanstack/react-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/root' -import { Route as postsPostsImport } from './routes/posts/posts' -import { Route as layoutFirstLayoutImport } from './routes/layout/first-layout' -import { Route as homeImport } from './routes/home' -import { Route as postsPostsDetailImport } from './routes/posts/posts-detail' -import { Route as layoutSecondLayoutImport } from './routes/layout/second-layout' -import { Route as postsPostsHomeImport } from './routes/posts/posts-home' -import { Route as ClassicHelloRouteImport } from './routes/file-based-subtree/hello/route' -import { Route as ClassicHelloIndexImport } from './routes/file-based-subtree/hello/index' -import { Route as ClassicHelloWorldImport } from './routes/file-based-subtree/hello/world' -import { Route as ClassicHelloUniverseImport } from './routes/file-based-subtree/hello/universe' -import { Route as bImport } from './routes/b' -import { Route as aImport } from './routes/a' +import { Route as postsPostsRouteImport } from './routes/posts/posts' +import { Route as layoutFirstLayoutRouteImport } from './routes/layout/first-layout' +import { Route as homeRouteImport } from './routes/home' +import { Route as postsPostsDetailRouteImport } from './routes/posts/posts-detail' +import { Route as layoutSecondLayoutRouteImport } from './routes/layout/second-layout' +import { Route as postsPostsHomeRouteImport } from './routes/posts/posts-home' +import { Route as ClassicHelloRouteRouteImport } from './routes/file-based-subtree/hello/route' +import { Route as ClassicHelloIndexRouteImport } from './routes/file-based-subtree/hello/index' +import { Route as ClassicHelloWorldRouteImport } from './routes/file-based-subtree/hello/world' +import { Route as ClassicHelloUniverseRouteImport } from './routes/file-based-subtree/hello/universe' +import { Route as bRouteImport } from './routes/b' +import { Route as aRouteImport } from './routes/a' // Create Virtual Routes -const FirstSecondLayoutRouteWithoutFileImport = createFileRoute( +const FirstSecondLayoutRouteWithoutFileRouteImport = createFileRoute( '/_first/_second-layout/route-without-file', )() // Create/Update Routes -const postsPostsRoute = postsPostsImport.update({ +const postsPostsRoute = postsPostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const layoutFirstLayoutRoute = layoutFirstLayoutImport.update({ +const layoutFirstLayoutRoute = layoutFirstLayoutRouteImport.update({ id: '/_first', getParentRoute: () => rootRoute, } as any) -const homeRoute = homeImport.update({ +const homeRoute = homeRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const postsPostsDetailRoute = postsPostsDetailImport.update({ +const postsPostsDetailRoute = postsPostsDetailRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => postsPostsRoute, } as any) -const layoutSecondLayoutRoute = layoutSecondLayoutImport.update({ +const layoutSecondLayoutRoute = layoutSecondLayoutRouteImport.update({ id: '/_second-layout', getParentRoute: () => layoutFirstLayoutRoute, } as any) -const postsPostsHomeRoute = postsPostsHomeImport.update({ +const postsPostsHomeRoute = postsPostsHomeRouteImport.update({ id: '/', path: '/', getParentRoute: () => postsPostsRoute, } as any) -const ClassicHelloRouteRoute = ClassicHelloRouteImport.update({ +const ClassicHelloRouteRoute = ClassicHelloRouteRouteImport.update({ id: '/classic/hello', path: '/classic/hello', getParentRoute: () => rootRoute, } as any) -const ClassicHelloIndexRoute = ClassicHelloIndexImport.update({ +const ClassicHelloIndexRoute = ClassicHelloIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => ClassicHelloRouteRoute, } as any) -const ClassicHelloWorldRoute = ClassicHelloWorldImport.update({ +const ClassicHelloWorldRoute = ClassicHelloWorldRouteImport.update({ id: '/world', path: '/world', getParentRoute: () => ClassicHelloRouteRoute, } as any) -const ClassicHelloUniverseRoute = ClassicHelloUniverseImport.update({ +const ClassicHelloUniverseRoute = ClassicHelloUniverseRouteImport.update({ id: '/universe', path: '/universe', getParentRoute: () => ClassicHelloRouteRoute, } as any) const FirstSecondLayoutRouteWithoutFileRoute = - FirstSecondLayoutRouteWithoutFileImport.update({ + FirstSecondLayoutRouteWithoutFileRouteImport.update({ id: '/route-without-file', path: '/route-without-file', getParentRoute: () => layoutSecondLayoutRoute, } as any) -const bRoute = bImport.update({ +const bRoute = bRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => FirstSecondLayoutRouteWithoutFileRoute, } as any) -const aRoute = aImport.update({ +const aRoute = aRouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => FirstSecondLayoutRouteWithoutFileRoute, @@ -119,96 +120,216 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof homeImport + preLoaderRoute: typeof homeRouteImport parentRoute: typeof rootRoute } '/_first': { id: '/_first' path: '' fullPath: '' - preLoaderRoute: typeof layoutFirstLayoutImport + preLoaderRoute: typeof layoutFirstLayoutRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof postsPostsImport + preLoaderRoute: typeof postsPostsRouteImport parentRoute: typeof rootRoute } '/classic/hello': { id: '/classic/hello' path: '/classic/hello' fullPath: '/classic/hello' - preLoaderRoute: typeof ClassicHelloRouteImport + preLoaderRoute: typeof ClassicHelloRouteRouteImport parentRoute: typeof rootRoute } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof postsPostsHomeImport - parentRoute: typeof postsPostsImport + preLoaderRoute: typeof postsPostsHomeRouteImport + parentRoute: typeof postsPostsRouteImport } '/_first/_second-layout': { id: '/_first/_second-layout' path: '' fullPath: '' - preLoaderRoute: typeof layoutSecondLayoutImport - parentRoute: typeof layoutFirstLayoutImport + preLoaderRoute: typeof layoutSecondLayoutRouteImport + parentRoute: typeof layoutFirstLayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof postsPostsDetailImport - parentRoute: typeof postsPostsImport + preLoaderRoute: typeof postsPostsDetailRouteImport + parentRoute: typeof postsPostsRouteImport } '/_first/_second-layout/route-without-file': { id: '/_first/_second-layout/route-without-file' path: '/route-without-file' fullPath: '/route-without-file' - preLoaderRoute: typeof FirstSecondLayoutRouteWithoutFileImport - parentRoute: typeof layoutSecondLayoutImport + preLoaderRoute: typeof FirstSecondLayoutRouteWithoutFileRouteImport + parentRoute: typeof layoutSecondLayoutRouteImport } '/classic/hello/universe': { id: '/classic/hello/universe' path: '/universe' fullPath: '/classic/hello/universe' - preLoaderRoute: typeof ClassicHelloUniverseImport - parentRoute: typeof ClassicHelloRouteImport + preLoaderRoute: typeof ClassicHelloUniverseRouteImport + parentRoute: typeof ClassicHelloRouteRouteImport } '/classic/hello/world': { id: '/classic/hello/world' path: '/world' fullPath: '/classic/hello/world' - preLoaderRoute: typeof ClassicHelloWorldImport - parentRoute: typeof ClassicHelloRouteImport + preLoaderRoute: typeof ClassicHelloWorldRouteImport + parentRoute: typeof ClassicHelloRouteRouteImport } '/classic/hello/': { id: '/classic/hello/' path: '/' fullPath: '/classic/hello/' - preLoaderRoute: typeof ClassicHelloIndexImport - parentRoute: typeof ClassicHelloRouteImport + preLoaderRoute: typeof ClassicHelloIndexRouteImport + parentRoute: typeof ClassicHelloRouteRouteImport } '/_first/_second-layout/route-without-file/layout-a': { id: '/_first/_second-layout/route-without-file/layout-a' path: '/layout-a' fullPath: '/route-without-file/layout-a' - preLoaderRoute: typeof aImport - parentRoute: typeof FirstSecondLayoutRouteWithoutFileImport + preLoaderRoute: typeof aRouteImport + parentRoute: typeof FirstSecondLayoutRouteWithoutFileRouteImport } '/_first/_second-layout/route-without-file/layout-b': { id: '/_first/_second-layout/route-without-file/layout-b' path: '/layout-b' fullPath: '/route-without-file/layout-b' - preLoaderRoute: typeof bImport - parentRoute: typeof FirstSecondLayoutRouteWithoutFileImport + preLoaderRoute: typeof bRouteImport + parentRoute: typeof FirstSecondLayoutRouteWithoutFileRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/home' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/layout/first-layout' { + const createFileRoute: CreateFileRoute< + '/_first', + FileRoutesByPath['/_first']['parentRoute'], + FileRoutesByPath['/_first']['id'], + FileRoutesByPath['/_first']['path'], + FileRoutesByPath['/_first']['fullPath'] + > +} +declare module './routes/posts/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/file-based-subtree/hello/route' { + const createFileRoute: CreateFileRoute< + '/classic/hello', + FileRoutesByPath['/classic/hello']['parentRoute'], + FileRoutesByPath['/classic/hello']['id'], + FileRoutesByPath['/classic/hello']['path'], + FileRoutesByPath['/classic/hello']['fullPath'] + > +} +declare module './routes/posts/posts-home' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/layout/second-layout' { + const createFileRoute: CreateFileRoute< + '/_first/_second-layout', + FileRoutesByPath['/_first/_second-layout']['parentRoute'], + FileRoutesByPath['/_first/_second-layout']['id'], + FileRoutesByPath['/_first/_second-layout']['path'], + FileRoutesByPath['/_first/_second-layout']['fullPath'] + > +} +declare module './routes/posts/posts-detail' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes' { + const createFileRoute: CreateFileRoute< + '/_first/_second-layout/route-without-file', + FileRoutesByPath['/_first/_second-layout/route-without-file']['parentRoute'], + FileRoutesByPath['/_first/_second-layout/route-without-file']['id'], + FileRoutesByPath['/_first/_second-layout/route-without-file']['path'], + FileRoutesByPath['/_first/_second-layout/route-without-file']['fullPath'] + > +} +declare module './routes/file-based-subtree/hello/universe' { + const createFileRoute: CreateFileRoute< + '/classic/hello/universe', + FileRoutesByPath['/classic/hello/universe']['parentRoute'], + FileRoutesByPath['/classic/hello/universe']['id'], + FileRoutesByPath['/classic/hello/universe']['path'], + FileRoutesByPath['/classic/hello/universe']['fullPath'] + > +} +declare module './routes/file-based-subtree/hello/world' { + const createFileRoute: CreateFileRoute< + '/classic/hello/world', + FileRoutesByPath['/classic/hello/world']['parentRoute'], + FileRoutesByPath['/classic/hello/world']['id'], + FileRoutesByPath['/classic/hello/world']['path'], + FileRoutesByPath['/classic/hello/world']['fullPath'] + > +} +declare module './routes/file-based-subtree/hello/index' { + const createFileRoute: CreateFileRoute< + '/classic/hello/', + FileRoutesByPath['/classic/hello/']['parentRoute'], + FileRoutesByPath['/classic/hello/']['id'], + FileRoutesByPath['/classic/hello/']['path'], + FileRoutesByPath['/classic/hello/']['fullPath'] + > +} +declare module './routes/a' { + const createFileRoute: CreateFileRoute< + '/_first/_second-layout/route-without-file/layout-a', + FileRoutesByPath['/_first/_second-layout/route-without-file/layout-a']['parentRoute'], + FileRoutesByPath['/_first/_second-layout/route-without-file/layout-a']['id'], + FileRoutesByPath['/_first/_second-layout/route-without-file/layout-a']['path'], + FileRoutesByPath['/_first/_second-layout/route-without-file/layout-a']['fullPath'] + > +} +declare module './routes/b' { + const createFileRoute: CreateFileRoute< + '/_first/_second-layout/route-without-file/layout-b', + FileRoutesByPath['/_first/_second-layout/route-without-file/layout-b']['parentRoute'], + FileRoutesByPath['/_first/_second-layout/route-without-file/layout-b']['id'], + FileRoutesByPath['/_first/_second-layout/route-without-file/layout-b']['path'], + FileRoutesByPath['/_first/_second-layout/route-without-file/layout-b']['fullPath'] + > +} + // Create and export the route tree interface FirstSecondLayoutRouteWithoutFileRouteChildren { @@ -387,6 +508,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/basic-virtual-file-based/src/routes/a.tsx b/examples/react/basic-virtual-file-based/src/routes/a.tsx index aa765e6891..a190b24202 100644 --- a/examples/react/basic-virtual-file-based/src/routes/a.tsx +++ b/examples/react/basic-virtual-file-based/src/routes/a.tsx @@ -1,8 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute( - '/_first/_second-layout/route-without-file/layout-a', -)({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/examples/react/basic-virtual-file-based/src/routes/b.tsx b/examples/react/basic-virtual-file-based/src/routes/b.tsx index 1a7fcaebdb..505f8f6fbf 100644 --- a/examples/react/basic-virtual-file-based/src/routes/b.tsx +++ b/examples/react/basic-virtual-file-based/src/routes/b.tsx @@ -1,8 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute( - '/_first/_second-layout/route-without-file/layout-b', -)({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/index.tsx b/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/index.tsx index c7417e5eeb..f86335e291 100644 --- a/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/index.tsx +++ b/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/classic/hello/')({ +export const Route = createFileRoute({ component: () =>
This is the index
, }) diff --git a/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/route.tsx b/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/route.tsx index 566efc8777..620dd2b76b 100644 --- a/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/route.tsx +++ b/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/route.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/classic/hello')({ +export const Route = createFileRoute({ component: () => (
Hello! diff --git a/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/universe.tsx b/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/universe.tsx index e00c47d74b..20b07c41cc 100644 --- a/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/universe.tsx +++ b/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/universe.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/classic/hello/universe')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/universe!
, }) diff --git a/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/world.tsx b/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/world.tsx index 9783557342..4af11357a2 100644 --- a/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/world.tsx +++ b/examples/react/basic-virtual-file-based/src/routes/file-based-subtree/hello/world.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/classic/hello/world')({ +export const Route = createFileRoute({ component: () =>
Hello /classic/hello/world!
, }) diff --git a/examples/react/basic-virtual-file-based/src/routes/home.tsx b/examples/react/basic-virtual-file-based/src/routes/home.tsx index eac82a9174..b23956ae17 100644 --- a/examples/react/basic-virtual-file-based/src/routes/home.tsx +++ b/examples/react/basic-virtual-file-based/src/routes/home.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/react/basic-virtual-file-based/src/routes/layout/first-layout.tsx b/examples/react/basic-virtual-file-based/src/routes/layout/first-layout.tsx index d39e206f2d..5c4a461d8d 100644 --- a/examples/react/basic-virtual-file-based/src/routes/layout/first-layout.tsx +++ b/examples/react/basic-virtual-file-based/src/routes/layout/first-layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_first')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/basic-virtual-file-based/src/routes/layout/second-layout.tsx b/examples/react/basic-virtual-file-based/src/routes/layout/second-layout.tsx index 2f56647492..478d9afbec 100644 --- a/examples/react/basic-virtual-file-based/src/routes/layout/second-layout.tsx +++ b/examples/react/basic-virtual-file-based/src/routes/layout/second-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_first/_second-layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/basic-virtual-file-based/src/routes/posts/posts-detail.tsx b/examples/react/basic-virtual-file-based/src/routes/posts/posts-detail.tsx index 948d52d6d6..654f3cfd18 100644 --- a/examples/react/basic-virtual-file-based/src/routes/posts/posts-detail.tsx +++ b/examples/react/basic-virtual-file-based/src/routes/posts/posts-detail.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import { fetchPost } from '../../posts' import type { ErrorComponentProps } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent as any, notFoundComponent: () => { diff --git a/examples/react/basic-virtual-file-based/src/routes/posts/posts-home.tsx b/examples/react/basic-virtual-file-based/src/routes/posts/posts-home.tsx index 056433ca0a..fdbe5865e5 100644 --- a/examples/react/basic-virtual-file-based/src/routes/posts/posts-home.tsx +++ b/examples/react/basic-virtual-file-based/src/routes/posts/posts-home.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/react/basic-virtual-file-based/src/routes/posts/posts.tsx b/examples/react/basic-virtual-file-based/src/routes/posts/posts.tsx index a2ab1ee388..f92c37f537 100644 --- a/examples/react/basic-virtual-file-based/src/routes/posts/posts.tsx +++ b/examples/react/basic-virtual-file-based/src/routes/posts/posts.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsComponent, }) diff --git a/examples/react/basic-virtual-inside-file-based/src/routeTree.gen.ts b/examples/react/basic-virtual-inside-file-based/src/routeTree.gen.ts index 79d98a78be..00c7fb3c3c 100644 --- a/examples/react/basic-virtual-inside-file-based/src/routeTree.gen.ts +++ b/examples/react/basic-virtual-inside-file-based/src/routeTree.gen.ts @@ -10,73 +10,74 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostsImport } from './routes/posts' -import { Route as LayoutImport } from './routes/_layout' -import { Route as IndexImport } from './routes/index' -import { Route as postsDetailsImport } from './routes/posts/details' -import { Route as LayoutLayout2Import } from './routes/_layout/_layout-2' -import { Route as postsHomeImport } from './routes/posts/home' -import { Route as postsLetsGoIndexImport } from './routes/posts/lets-go/index' -import { Route as LayoutLayout2LayoutBImport } from './routes/_layout/_layout-2/layout-b' -import { Route as LayoutLayout2LayoutAImport } from './routes/_layout/_layout-2/layout-a' -import { Route as postsLetsGoDeeperHomeImport } from './routes/posts/lets-go/deeper/home' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as LayoutRouteImport } from './routes/_layout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as postsDetailsRouteImport } from './routes/posts/details' +import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2' +import { Route as postsHomeRouteImport } from './routes/posts/home' +import { Route as postsLetsGoIndexRouteImport } from './routes/posts/lets-go/index' +import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b' +import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a' +import { Route as postsLetsGoDeeperHomeRouteImport } from './routes/posts/lets-go/deeper/home' // Create/Update Routes -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const LayoutRoute = LayoutImport.update({ +const LayoutRoute = LayoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const postsDetailsRoute = postsDetailsImport.update({ +const postsDetailsRoute = postsDetailsRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const LayoutLayout2Route = LayoutLayout2Import.update({ +const LayoutLayout2Route = LayoutLayout2RouteImport.update({ id: '/_layout-2', getParentRoute: () => LayoutRoute, } as any) -const postsHomeRoute = postsHomeImport.update({ +const postsHomeRoute = postsHomeRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const postsLetsGoIndexRoute = postsLetsGoIndexImport.update({ +const postsLetsGoIndexRoute = postsLetsGoIndexRouteImport.update({ id: '/inception/', path: '/inception/', getParentRoute: () => PostsRoute, } as any) -const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBImport.update({ +const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({ id: '/layout-b', path: '/layout-b', getParentRoute: () => LayoutLayout2Route, } as any) -const LayoutLayout2LayoutARoute = LayoutLayout2LayoutAImport.update({ +const LayoutLayout2LayoutARoute = LayoutLayout2LayoutARouteImport.update({ id: '/layout-a', path: '/layout-a', getParentRoute: () => LayoutLayout2Route, } as any) -const postsLetsGoDeeperHomeRoute = postsLetsGoDeeperHomeImport.update({ +const postsLetsGoDeeperHomeRoute = postsLetsGoDeeperHomeRouteImport.update({ id: '/inception/deeper/', path: '/inception/deeper/', getParentRoute: () => PostsRoute, @@ -90,75 +91,168 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof postsHomeImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof postsHomeRouteImport + parentRoute: typeof PostsRouteImport } '/_layout/_layout-2': { id: '/_layout/_layout-2' path: '' fullPath: '' - preLoaderRoute: typeof LayoutLayout2Import - parentRoute: typeof LayoutImport + preLoaderRoute: typeof LayoutLayout2RouteImport + parentRoute: typeof LayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof postsDetailsImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof postsDetailsRouteImport + parentRoute: typeof PostsRouteImport } '/_layout/_layout-2/layout-a': { id: '/_layout/_layout-2/layout-a' path: '/layout-a' fullPath: '/layout-a' - preLoaderRoute: typeof LayoutLayout2LayoutAImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutARouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/_layout/_layout-2/layout-b': { id: '/_layout/_layout-2/layout-b' path: '/layout-b' fullPath: '/layout-b' - preLoaderRoute: typeof LayoutLayout2LayoutBImport - parentRoute: typeof LayoutLayout2Import + preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport + parentRoute: typeof LayoutLayout2RouteImport } '/posts/inception/': { id: '/posts/inception/' path: '/inception' fullPath: '/posts/inception' - preLoaderRoute: typeof postsLetsGoIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof postsLetsGoIndexRouteImport + parentRoute: typeof PostsRouteImport } '/posts/inception/deeper/': { id: '/posts/inception/deeper/' path: '/inception/deeper' fullPath: '/posts/inception/deeper' - preLoaderRoute: typeof postsLetsGoDeeperHomeImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof postsLetsGoDeeperHomeRouteImport + parentRoute: typeof PostsRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/posts/home' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/_layout/_layout-2' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2', + FileRoutesByPath['/_layout/_layout-2']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2']['id'], + FileRoutesByPath['/_layout/_layout-2']['path'], + FileRoutesByPath['/_layout/_layout-2']['fullPath'] + > +} +declare module './routes/posts/details' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-a' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-a', + FileRoutesByPath['/_layout/_layout-2/layout-a']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-a']['fullPath'] + > +} +declare module './routes/_layout/_layout-2/layout-b' { + const createFileRoute: CreateFileRoute< + '/_layout/_layout-2/layout-b', + FileRoutesByPath['/_layout/_layout-2/layout-b']['parentRoute'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['id'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['path'], + FileRoutesByPath['/_layout/_layout-2/layout-b']['fullPath'] + > +} +declare module './routes/posts/lets-go/index' { + const createFileRoute: CreateFileRoute< + '/posts/inception/', + FileRoutesByPath['/posts/inception/']['parentRoute'], + FileRoutesByPath['/posts/inception/']['id'], + FileRoutesByPath['/posts/inception/']['path'], + FileRoutesByPath['/posts/inception/']['fullPath'] + > +} +declare module './routes/posts/lets-go/deeper/home' { + const createFileRoute: CreateFileRoute< + '/posts/inception/deeper/', + FileRoutesByPath['/posts/inception/deeper/']['parentRoute'], + FileRoutesByPath['/posts/inception/deeper/']['id'], + FileRoutesByPath['/posts/inception/deeper/']['path'], + FileRoutesByPath['/posts/inception/deeper/']['fullPath'] + > +} + // Create and export the route tree interface LayoutLayout2RouteChildren { @@ -292,6 +386,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/basic-virtual-inside-file-based/src/routes/_layout.tsx b/examples/react/basic-virtual-inside-file-based/src/routes/_layout.tsx index 02ddbb1cd9..5c4a461d8d 100644 --- a/examples/react/basic-virtual-inside-file-based/src/routes/_layout.tsx +++ b/examples/react/basic-virtual-inside-file-based/src/routes/_layout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/basic-virtual-inside-file-based/src/routes/_layout/_layout-2.tsx b/examples/react/basic-virtual-inside-file-based/src/routes/_layout/_layout-2.tsx index 3b7dbf2903..483b910862 100644 --- a/examples/react/basic-virtual-inside-file-based/src/routes/_layout/_layout-2.tsx +++ b/examples/react/basic-virtual-inside-file-based/src/routes/_layout/_layout-2.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_layout/_layout-2')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/basic-virtual-inside-file-based/src/routes/_layout/_layout-2/layout-a.tsx b/examples/react/basic-virtual-inside-file-based/src/routes/_layout/_layout-2/layout-a.tsx index 61e19b4d9f..a190b24202 100644 --- a/examples/react/basic-virtual-inside-file-based/src/routes/_layout/_layout-2/layout-a.tsx +++ b/examples/react/basic-virtual-inside-file-based/src/routes/_layout/_layout-2/layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/examples/react/basic-virtual-inside-file-based/src/routes/_layout/_layout-2/layout-b.tsx b/examples/react/basic-virtual-inside-file-based/src/routes/_layout/_layout-2/layout-b.tsx index cceed1fb9a..505f8f6fbf 100644 --- a/examples/react/basic-virtual-inside-file-based/src/routes/_layout/_layout-2/layout-b.tsx +++ b/examples/react/basic-virtual-inside-file-based/src/routes/_layout/_layout-2/layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/_layout-2/layout-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/examples/react/basic-virtual-inside-file-based/src/routes/index.tsx b/examples/react/basic-virtual-inside-file-based/src/routes/index.tsx index eac82a9174..b23956ae17 100644 --- a/examples/react/basic-virtual-inside-file-based/src/routes/index.tsx +++ b/examples/react/basic-virtual-inside-file-based/src/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/react/basic-virtual-inside-file-based/src/routes/posts.tsx b/examples/react/basic-virtual-inside-file-based/src/routes/posts.tsx index c7a09ed7f8..4469b2216a 100644 --- a/examples/react/basic-virtual-inside-file-based/src/routes/posts.tsx +++ b/examples/react/basic-virtual-inside-file-based/src/routes/posts.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsComponent, }) diff --git a/examples/react/basic-virtual-inside-file-based/src/routes/posts/details.tsx b/examples/react/basic-virtual-inside-file-based/src/routes/posts/details.tsx index 6479bdf803..fc10978507 100644 --- a/examples/react/basic-virtual-inside-file-based/src/routes/posts/details.tsx +++ b/examples/react/basic-virtual-inside-file-based/src/routes/posts/details.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import { fetchPost } from '../../posts' import type { ErrorComponentProps } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent, notFoundComponent: () => { diff --git a/examples/react/basic-virtual-inside-file-based/src/routes/posts/home.tsx b/examples/react/basic-virtual-inside-file-based/src/routes/posts/home.tsx index 056433ca0a..fdbe5865e5 100644 --- a/examples/react/basic-virtual-inside-file-based/src/routes/posts/home.tsx +++ b/examples/react/basic-virtual-inside-file-based/src/routes/posts/home.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/react/basic-virtual-inside-file-based/src/routes/posts/lets-go/deeper/home.tsx b/examples/react/basic-virtual-inside-file-based/src/routes/posts/lets-go/deeper/home.tsx index 11f7fa95ca..f8bc76644a 100644 --- a/examples/react/basic-virtual-inside-file-based/src/routes/posts/lets-go/deeper/home.tsx +++ b/examples/react/basic-virtual-inside-file-based/src/routes/posts/lets-go/deeper/home.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/inception/deeper/')({ +export const Route = createFileRoute({ component: () =>
Hello /posts/inception/deeper/!
, }) diff --git a/examples/react/basic-virtual-inside-file-based/src/routes/posts/lets-go/index.tsx b/examples/react/basic-virtual-inside-file-based/src/routes/posts/lets-go/index.tsx index 964ab3c900..1c7ea68931 100644 --- a/examples/react/basic-virtual-inside-file-based/src/routes/posts/lets-go/index.tsx +++ b/examples/react/basic-virtual-inside-file-based/src/routes/posts/lets-go/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/inception/')({ +export const Route = createFileRoute({ component: () =>
Hello /posts/inception/!
, }) diff --git a/examples/react/kitchen-sink-file-based/src/routeTree.gen.ts b/examples/react/kitchen-sink-file-based/src/routeTree.gen.ts index 4f3339865d..67b7f42da1 100644 --- a/examples/react/kitchen-sink-file-based/src/routeTree.gen.ts +++ b/examples/react/kitchen-sink-file-based/src/routeTree.gen.ts @@ -10,129 +10,129 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as LoginImport } from './routes/login' -import { Route as PathlessLayoutImport } from './routes/_pathlessLayout' -import { Route as AuthImport } from './routes/_auth' -import { Route as DashboardRouteImport } from './routes/dashboard.route' -import { Route as IndexImport } from './routes/index' -import { Route as ExpensiveIndexImport } from './routes/expensive/index' -import { Route as DashboardIndexImport } from './routes/dashboard.index' -import { Route as PathlessLayoutRouteBImport } from './routes/_pathlessLayout.route-b' -import { Route as PathlessLayoutRouteAImport } from './routes/_pathlessLayout.route-a' -import { Route as AuthProfileImport } from './routes/_auth.profile' -import { Route as thisFolderIsNotInTheUrlRouteGroupImport } from './routes/(this-folder-is-not-in-the-url)/route-group' -import { Route as DashboardUsersRouteImport } from './routes/dashboard.users.route' -import { Route as DashboardInvoicesRouteImport } from './routes/dashboard.invoices.route' -import { Route as DashboardUsersIndexImport } from './routes/dashboard.users.index' -import { Route as DashboardInvoicesIndexImport } from './routes/dashboard.invoices.index' -import { Route as DashboardUsersUserImport } from './routes/dashboard.users.user' -import { Route as DashboardInvoicesInvoiceIdImport } from './routes/dashboard.invoices.$invoiceId' +import { Route as LoginRouteImport } from './routes/login' +import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' +import { Route as AuthRouteImport } from './routes/_auth' +import { Route as DashboardRouteRouteImport } from './routes/dashboard.route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as ExpensiveIndexRouteImport } from './routes/expensive/index' +import { Route as DashboardIndexRouteImport } from './routes/dashboard.index' +import { Route as PathlessLayoutRouteBRouteImport } from './routes/_pathlessLayout.route-b' +import { Route as PathlessLayoutRouteARouteImport } from './routes/_pathlessLayout.route-a' +import { Route as AuthProfileRouteImport } from './routes/_auth.profile' +import { Route as thisFolderIsNotInTheUrlRouteGroupRouteImport } from './routes/(this-folder-is-not-in-the-url)/route-group' +import { Route as DashboardUsersRouteRouteImport } from './routes/dashboard.users.route' +import { Route as DashboardInvoicesRouteRouteImport } from './routes/dashboard.invoices.route' +import { Route as DashboardUsersIndexRouteImport } from './routes/dashboard.users.index' +import { Route as DashboardInvoicesIndexRouteImport } from './routes/dashboard.invoices.index' +import { Route as DashboardUsersUserRouteImport } from './routes/dashboard.users.user' +import { Route as DashboardInvoicesInvoiceIdRouteImport } from './routes/dashboard.invoices.$invoiceId' // Create/Update Routes -const LoginRoute = LoginImport.update({ +const LoginRoute = LoginRouteImport.update({ id: '/login', path: '/login', getParentRoute: () => rootRoute, } as any) -const PathlessLayoutRoute = PathlessLayoutImport.update({ +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', getParentRoute: () => rootRoute, } as any) -const AuthRoute = AuthImport.update({ +const AuthRoute = AuthRouteImport.update({ id: '/_auth', getParentRoute: () => rootRoute, } as any) -const DashboardRouteRoute = DashboardRouteImport.update({ +const DashboardRouteRoute = DashboardRouteRouteImport.update({ id: '/dashboard', path: '/dashboard', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const ExpensiveIndexRoute = ExpensiveIndexImport.update({ +const ExpensiveIndexRoute = ExpensiveIndexRouteImport.update({ id: '/expensive/', path: '/expensive/', getParentRoute: () => rootRoute, } as any) -const DashboardIndexRoute = DashboardIndexImport.update({ +const DashboardIndexRoute = DashboardIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => DashboardRouteRoute, } as any) -const PathlessLayoutRouteBRoute = PathlessLayoutRouteBImport.update({ +const PathlessLayoutRouteBRoute = PathlessLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutRoute, } as any) -const PathlessLayoutRouteARoute = PathlessLayoutRouteAImport.update({ +const PathlessLayoutRouteARoute = PathlessLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutRoute, } as any) -const AuthProfileRoute = AuthProfileImport.update({ +const AuthProfileRoute = AuthProfileRouteImport.update({ id: '/profile', path: '/profile', getParentRoute: () => AuthRoute, } as any) const thisFolderIsNotInTheUrlRouteGroupRoute = - thisFolderIsNotInTheUrlRouteGroupImport.update({ + thisFolderIsNotInTheUrlRouteGroupRouteImport.update({ id: '/(this-folder-is-not-in-the-url)/route-group', path: '/route-group', getParentRoute: () => rootRoute, } as any) -const DashboardUsersRouteRoute = DashboardUsersRouteImport.update({ +const DashboardUsersRouteRoute = DashboardUsersRouteRouteImport.update({ id: '/users', path: '/users', getParentRoute: () => DashboardRouteRoute, } as any) -const DashboardInvoicesRouteRoute = DashboardInvoicesRouteImport.update({ +const DashboardInvoicesRouteRoute = DashboardInvoicesRouteRouteImport.update({ id: '/invoices', path: '/invoices', getParentRoute: () => DashboardRouteRoute, } as any) -const DashboardUsersIndexRoute = DashboardUsersIndexImport.update({ +const DashboardUsersIndexRoute = DashboardUsersIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => DashboardUsersRouteRoute, } as any) -const DashboardInvoicesIndexRoute = DashboardInvoicesIndexImport.update({ +const DashboardInvoicesIndexRoute = DashboardInvoicesIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => DashboardInvoicesRouteRoute, } as any) -const DashboardUsersUserRoute = DashboardUsersUserImport.update({ +const DashboardUsersUserRoute = DashboardUsersUserRouteImport.update({ id: '/user', path: '/user', getParentRoute: () => DashboardUsersRouteRoute, } as any) -const DashboardInvoicesInvoiceIdRoute = DashboardInvoicesInvoiceIdImport.update( - { +const DashboardInvoicesInvoiceIdRoute = + DashboardInvoicesInvoiceIdRouteImport.update({ id: '/$invoiceId', path: '/$invoiceId', getParentRoute: () => DashboardInvoicesRouteRoute, - } as any, -) + } as any) // Populate the FileRoutesByPath interface @@ -142,124 +142,280 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/dashboard': { id: '/dashboard' path: '/dashboard' fullPath: '/dashboard' - preLoaderRoute: typeof DashboardRouteImport + preLoaderRoute: typeof DashboardRouteRouteImport parentRoute: typeof rootRoute } '/_auth': { id: '/_auth' path: '' fullPath: '' - preLoaderRoute: typeof AuthImport + preLoaderRoute: typeof AuthRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout': { id: '/_pathlessLayout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteImport parentRoute: typeof rootRoute } '/login': { id: '/login' path: '/login' fullPath: '/login' - preLoaderRoute: typeof LoginImport + preLoaderRoute: typeof LoginRouteImport parentRoute: typeof rootRoute } '/dashboard/invoices': { id: '/dashboard/invoices' path: '/invoices' fullPath: '/dashboard/invoices' - preLoaderRoute: typeof DashboardInvoicesRouteImport - parentRoute: typeof DashboardRouteImport + preLoaderRoute: typeof DashboardInvoicesRouteRouteImport + parentRoute: typeof DashboardRouteRouteImport } '/dashboard/users': { id: '/dashboard/users' path: '/users' fullPath: '/dashboard/users' - preLoaderRoute: typeof DashboardUsersRouteImport - parentRoute: typeof DashboardRouteImport + preLoaderRoute: typeof DashboardUsersRouteRouteImport + parentRoute: typeof DashboardRouteRouteImport } '/(this-folder-is-not-in-the-url)/route-group': { id: '/(this-folder-is-not-in-the-url)/route-group' path: '/route-group' fullPath: '/route-group' - preLoaderRoute: typeof thisFolderIsNotInTheUrlRouteGroupImport + preLoaderRoute: typeof thisFolderIsNotInTheUrlRouteGroupRouteImport parentRoute: typeof rootRoute } '/_auth/profile': { id: '/_auth/profile' path: '/profile' fullPath: '/profile' - preLoaderRoute: typeof AuthProfileImport - parentRoute: typeof AuthImport + preLoaderRoute: typeof AuthProfileRouteImport + parentRoute: typeof AuthRouteImport } '/_pathlessLayout/route-a': { id: '/_pathlessLayout/route-a' path: '/route-a' fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutRouteAImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/_pathlessLayout/route-b': { id: '/_pathlessLayout/route-b' path: '/route-b' fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutRouteBImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/dashboard/': { id: '/dashboard/' path: '/' fullPath: '/dashboard/' - preLoaderRoute: typeof DashboardIndexImport - parentRoute: typeof DashboardRouteImport + preLoaderRoute: typeof DashboardIndexRouteImport + parentRoute: typeof DashboardRouteRouteImport } '/expensive/': { id: '/expensive/' path: '/expensive' fullPath: '/expensive' - preLoaderRoute: typeof ExpensiveIndexImport + preLoaderRoute: typeof ExpensiveIndexRouteImport parentRoute: typeof rootRoute } '/dashboard/invoices/$invoiceId': { id: '/dashboard/invoices/$invoiceId' path: '/$invoiceId' fullPath: '/dashboard/invoices/$invoiceId' - preLoaderRoute: typeof DashboardInvoicesInvoiceIdImport - parentRoute: typeof DashboardInvoicesRouteImport + preLoaderRoute: typeof DashboardInvoicesInvoiceIdRouteImport + parentRoute: typeof DashboardInvoicesRouteRouteImport } '/dashboard/users/user': { id: '/dashboard/users/user' path: '/user' fullPath: '/dashboard/users/user' - preLoaderRoute: typeof DashboardUsersUserImport - parentRoute: typeof DashboardUsersRouteImport + preLoaderRoute: typeof DashboardUsersUserRouteImport + parentRoute: typeof DashboardUsersRouteRouteImport } '/dashboard/invoices/': { id: '/dashboard/invoices/' path: '/' fullPath: '/dashboard/invoices/' - preLoaderRoute: typeof DashboardInvoicesIndexImport - parentRoute: typeof DashboardInvoicesRouteImport + preLoaderRoute: typeof DashboardInvoicesIndexRouteImport + parentRoute: typeof DashboardInvoicesRouteRouteImport } '/dashboard/users/': { id: '/dashboard/users/' path: '/' fullPath: '/dashboard/users/' - preLoaderRoute: typeof DashboardUsersIndexImport - parentRoute: typeof DashboardUsersRouteImport + preLoaderRoute: typeof DashboardUsersIndexRouteImport + parentRoute: typeof DashboardUsersRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/dashboard.route' { + const createFileRoute: CreateFileRoute< + '/dashboard', + FileRoutesByPath['/dashboard']['parentRoute'], + FileRoutesByPath['/dashboard']['id'], + FileRoutesByPath['/dashboard']['path'], + FileRoutesByPath['/dashboard']['fullPath'] + > +} +declare module './routes/_auth' { + const createFileRoute: CreateFileRoute< + '/_auth', + FileRoutesByPath['/_auth']['parentRoute'], + FileRoutesByPath['/_auth']['id'], + FileRoutesByPath['/_auth']['path'], + FileRoutesByPath['/_auth']['fullPath'] + > +} +declare module './routes/_pathlessLayout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout', + FileRoutesByPath['/_pathlessLayout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout']['id'], + FileRoutesByPath['/_pathlessLayout']['path'], + FileRoutesByPath['/_pathlessLayout']['fullPath'] + > +} +declare module './routes/login' { + const createFileRoute: CreateFileRoute< + '/login', + FileRoutesByPath['/login']['parentRoute'], + FileRoutesByPath['/login']['id'], + FileRoutesByPath['/login']['path'], + FileRoutesByPath['/login']['fullPath'] + > +} +declare module './routes/dashboard.invoices.route' { + const createFileRoute: CreateFileRoute< + '/dashboard/invoices', + FileRoutesByPath['/dashboard/invoices']['parentRoute'], + FileRoutesByPath['/dashboard/invoices']['id'], + FileRoutesByPath['/dashboard/invoices']['path'], + FileRoutesByPath['/dashboard/invoices']['fullPath'] + > +} +declare module './routes/dashboard.users.route' { + const createFileRoute: CreateFileRoute< + '/dashboard/users', + FileRoutesByPath['/dashboard/users']['parentRoute'], + FileRoutesByPath['/dashboard/users']['id'], + FileRoutesByPath['/dashboard/users']['path'], + FileRoutesByPath['/dashboard/users']['fullPath'] + > +} +declare module './routes/(this-folder-is-not-in-the-url)/route-group' { + const createFileRoute: CreateFileRoute< + '/(this-folder-is-not-in-the-url)/route-group', + FileRoutesByPath['/(this-folder-is-not-in-the-url)/route-group']['parentRoute'], + FileRoutesByPath['/(this-folder-is-not-in-the-url)/route-group']['id'], + FileRoutesByPath['/(this-folder-is-not-in-the-url)/route-group']['path'], + FileRoutesByPath['/(this-folder-is-not-in-the-url)/route-group']['fullPath'] + > +} +declare module './routes/_auth.profile' { + const createFileRoute: CreateFileRoute< + '/_auth/profile', + FileRoutesByPath['/_auth/profile']['parentRoute'], + FileRoutesByPath['/_auth/profile']['id'], + FileRoutesByPath['/_auth/profile']['path'], + FileRoutesByPath['/_auth/profile']['fullPath'] + > +} +declare module './routes/_pathlessLayout.route-a' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/route-a', + FileRoutesByPath['/_pathlessLayout/route-a']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/route-a']['id'], + FileRoutesByPath['/_pathlessLayout/route-a']['path'], + FileRoutesByPath['/_pathlessLayout/route-a']['fullPath'] + > +} +declare module './routes/_pathlessLayout.route-b' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/route-b', + FileRoutesByPath['/_pathlessLayout/route-b']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/route-b']['id'], + FileRoutesByPath['/_pathlessLayout/route-b']['path'], + FileRoutesByPath['/_pathlessLayout/route-b']['fullPath'] + > +} +declare module './routes/dashboard.index' { + const createFileRoute: CreateFileRoute< + '/dashboard/', + FileRoutesByPath['/dashboard/']['parentRoute'], + FileRoutesByPath['/dashboard/']['id'], + FileRoutesByPath['/dashboard/']['path'], + FileRoutesByPath['/dashboard/']['fullPath'] + > +} +declare module './routes/expensive/index' { + const createFileRoute: CreateFileRoute< + '/expensive/', + FileRoutesByPath['/expensive/']['parentRoute'], + FileRoutesByPath['/expensive/']['id'], + FileRoutesByPath['/expensive/']['path'], + FileRoutesByPath['/expensive/']['fullPath'] + > +} +declare module './routes/dashboard.invoices.$invoiceId' { + const createFileRoute: CreateFileRoute< + '/dashboard/invoices/$invoiceId', + FileRoutesByPath['/dashboard/invoices/$invoiceId']['parentRoute'], + FileRoutesByPath['/dashboard/invoices/$invoiceId']['id'], + FileRoutesByPath['/dashboard/invoices/$invoiceId']['path'], + FileRoutesByPath['/dashboard/invoices/$invoiceId']['fullPath'] + > +} +declare module './routes/dashboard.users.user' { + const createFileRoute: CreateFileRoute< + '/dashboard/users/user', + FileRoutesByPath['/dashboard/users/user']['parentRoute'], + FileRoutesByPath['/dashboard/users/user']['id'], + FileRoutesByPath['/dashboard/users/user']['path'], + FileRoutesByPath['/dashboard/users/user']['fullPath'] + > +} +declare module './routes/dashboard.invoices.index' { + const createFileRoute: CreateFileRoute< + '/dashboard/invoices/', + FileRoutesByPath['/dashboard/invoices/']['parentRoute'], + FileRoutesByPath['/dashboard/invoices/']['id'], + FileRoutesByPath['/dashboard/invoices/']['path'], + FileRoutesByPath['/dashboard/invoices/']['fullPath'] + > +} +declare module './routes/dashboard.users.index' { + const createFileRoute: CreateFileRoute< + '/dashboard/users/', + FileRoutesByPath['/dashboard/users/']['parentRoute'], + FileRoutesByPath['/dashboard/users/']['id'], + FileRoutesByPath['/dashboard/users/']['path'], + FileRoutesByPath['/dashboard/users/']['fullPath'] + > +} + // Create and export the route tree interface DashboardInvoicesRouteRouteChildren { @@ -468,6 +624,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/kitchen-sink-file-based/src/routes/(this-folder-is-not-in-the-url)/route-group.tsx b/examples/react/kitchen-sink-file-based/src/routes/(this-folder-is-not-in-the-url)/route-group.tsx index 4541afc8d0..c2e8814a2d 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/(this-folder-is-not-in-the-url)/route-group.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/(this-folder-is-not-in-the-url)/route-group.tsx @@ -1,9 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute( - '/(this-folder-is-not-in-the-url)/route-group', -)({ +export const Route = createFileRoute({ component: RouteGroupExample, }) diff --git a/examples/react/kitchen-sink-file-based/src/routes/_auth.profile.tsx b/examples/react/kitchen-sink-file-based/src/routes/_auth.profile.tsx index fa63df98b0..7b3d690e6e 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/_auth.profile.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/_auth.profile.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/_auth/profile')({ +export const Route = createFileRoute({ component: ProfileComponent, }) diff --git a/examples/react/kitchen-sink-file-based/src/routes/_auth.tsx b/examples/react/kitchen-sink-file-based/src/routes/_auth.tsx index f4f3876f26..60945fd245 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/_auth.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/_auth.tsx @@ -1,7 +1,7 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' import { auth } from '../utils/auth' -export const Route = createFileRoute('/_auth')({ +export const Route = createFileRoute({ // Before loading, authenticate the user via our auth context // This will also happen during prefetching (e.g. hovering over links, etc) beforeLoad: ({ context, location }) => { diff --git a/examples/react/kitchen-sink-file-based/src/routes/_pathlessLayout.route-a.tsx b/examples/react/kitchen-sink-file-based/src/routes/_pathlessLayout.route-a.tsx index ce791bcf2f..f81e516bd8 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/_pathlessLayout.route-a.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/_pathlessLayout.route-a.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout/route-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/examples/react/kitchen-sink-file-based/src/routes/_pathlessLayout.route-b.tsx b/examples/react/kitchen-sink-file-based/src/routes/_pathlessLayout.route-b.tsx index aa3010287d..c7ff7c5d74 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/_pathlessLayout.route-b.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/_pathlessLayout.route-b.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout/route-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/examples/react/kitchen-sink-file-based/src/routes/_pathlessLayout.tsx b/examples/react/kitchen-sink-file-based/src/routes/_pathlessLayout.tsx index 4884d30343..6202a8b2db 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/_pathlessLayout.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/_pathlessLayout.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: PathlessLayoutComponent, }) diff --git a/examples/react/kitchen-sink-file-based/src/routes/dashboard.index.tsx b/examples/react/kitchen-sink-file-based/src/routes/dashboard.index.tsx index 22fb1c83c6..9798188424 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/dashboard.index.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/dashboard.index.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' + import { fetchInvoices } from '../utils/mockTodos' -export const Route = createFileRoute('/dashboard/')({ +export const Route = createFileRoute({ loader: () => fetchInvoices(), component: DashboardIndexComponent, }) diff --git a/examples/react/kitchen-sink-file-based/src/routes/dashboard.invoices.$invoiceId.tsx b/examples/react/kitchen-sink-file-based/src/routes/dashboard.invoices.$invoiceId.tsx index d615c89a2c..a04c00532c 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/dashboard.invoices.$invoiceId.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/dashboard.invoices.$invoiceId.tsx @@ -1,16 +1,11 @@ import * as React from 'react' -import { - Link, - createFileRoute, - useNavigate, - useRouter, -} from '@tanstack/react-router' +import { Link, useNavigate, useRouter } from '@tanstack/react-router' import { z } from 'zod' import { InvoiceFields } from '../components/InvoiceFields' import { useMutation } from '../hooks/useMutation' import { fetchInvoiceById, patchInvoice } from '../utils/mockTodos' -export const Route = createFileRoute('/dashboard/invoices/$invoiceId')({ +export const Route = createFileRoute({ params: { parse: (params) => ({ invoiceId: z.number().int().parse(Number(params.invoiceId)), diff --git a/examples/react/kitchen-sink-file-based/src/routes/dashboard.invoices.index.tsx b/examples/react/kitchen-sink-file-based/src/routes/dashboard.invoices.index.tsx index 4df164a96e..c36ab63e2f 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/dashboard.invoices.index.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/dashboard.invoices.index.tsx @@ -1,12 +1,12 @@ import * as React from 'react' -import { createFileRoute, useRouter } from '@tanstack/react-router' +import { useRouter } from '@tanstack/react-router' import { InvoiceFields } from '../components/InvoiceFields' import { Spinner } from '../components/Spinner' import { useMutation } from '../hooks/useMutation' import { postInvoice } from '../utils/mockTodos' import type { Invoice } from '../utils/mockTodos' -export const Route = createFileRoute('/dashboard/invoices/')({ +export const Route = createFileRoute({ component: InvoicesIndexComponent, }) diff --git a/examples/react/kitchen-sink-file-based/src/routes/dashboard.invoices.route.tsx b/examples/react/kitchen-sink-file-based/src/routes/dashboard.invoices.route.tsx index e1a123946d..a784671c81 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/dashboard.invoices.route.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/dashboard.invoices.route.tsx @@ -1,14 +1,9 @@ import * as React from 'react' -import { - Link, - MatchRoute, - Outlet, - createFileRoute, -} from '@tanstack/react-router' +import { Link, MatchRoute, Outlet } from '@tanstack/react-router' import { Spinner } from '../components/Spinner' import { fetchInvoices } from '../utils/mockTodos' -export const Route = createFileRoute('/dashboard/invoices')({ +export const Route = createFileRoute({ loader: () => fetchInvoices(), component: InvoicesComponent, }) diff --git a/examples/react/kitchen-sink-file-based/src/routes/dashboard.route.tsx b/examples/react/kitchen-sink-file-based/src/routes/dashboard.route.tsx index b718b59a2d..78f697adbc 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/dashboard.route.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/dashboard.route.tsx @@ -1,12 +1,7 @@ import * as React from 'react' -import { - Link, - Outlet, - createFileRoute, - linkOptions, -} from '@tanstack/react-router' +import { Link, Outlet, linkOptions } from '@tanstack/react-router' -export const Route = createFileRoute('/dashboard')({ +export const Route = createFileRoute({ component: DashboardComponent, loader: () => ({ crumb: 'Dashboard', diff --git a/examples/react/kitchen-sink-file-based/src/routes/dashboard.users.index.tsx b/examples/react/kitchen-sink-file-based/src/routes/dashboard.users.index.tsx index 7ad9771152..2793568c42 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/dashboard.users.index.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/dashboard.users.index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/dashboard/users/')({ +export const Route = createFileRoute({ component: UsersIndexComponent, }) diff --git a/examples/react/kitchen-sink-file-based/src/routes/dashboard.users.route.tsx b/examples/react/kitchen-sink-file-based/src/routes/dashboard.users.route.tsx index 0d8886872f..31be72e784 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/dashboard.users.route.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/dashboard.users.route.tsx @@ -3,7 +3,6 @@ import { Link, MatchRoute, Outlet, - createFileRoute, retainSearchParams, useNavigate, } from '@tanstack/react-router' @@ -13,7 +12,7 @@ import { fetchUsers } from '../utils/mockTodos' type UsersViewSortBy = 'name' | 'id' | 'email' -export const Route = createFileRoute('/dashboard/users')({ +export const Route = createFileRoute({ validateSearch: z.object({ usersView: z .object({ diff --git a/examples/react/kitchen-sink-file-based/src/routes/dashboard.users.user.tsx b/examples/react/kitchen-sink-file-based/src/routes/dashboard.users.user.tsx index fb8d1cc880..08ab031105 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/dashboard.users.user.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/dashboard.users.user.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' + import { z } from 'zod' import { fetchUserById } from '../utils/mockTodos' -export const Route = createFileRoute('/dashboard/users/user')({ +export const Route = createFileRoute({ validateSearch: z.object({ userId: z.number(), }), diff --git a/examples/react/kitchen-sink-file-based/src/routes/expensive/index.tsx b/examples/react/kitchen-sink-file-based/src/routes/expensive/index.tsx index 42e1b4c0e8..5066d67ac5 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/expensive/index.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/expensive/index.tsx @@ -1,6 +1,5 @@ -import { createFileRoute } from '@tanstack/react-router' import Expensive from './-components/Expensive' -export const Route = createFileRoute('/expensive/')({ +export const Route = createFileRoute({ component: Expensive, }) diff --git a/examples/react/kitchen-sink-file-based/src/routes/index.tsx b/examples/react/kitchen-sink-file-based/src/routes/index.tsx index a99ada182b..b0d05ea341 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/index.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/index.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: IndexComponent, }) diff --git a/examples/react/kitchen-sink-file-based/src/routes/login.tsx b/examples/react/kitchen-sink-file-based/src/routes/login.tsx index 42c01d793f..4d577af794 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/login.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/login.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { createFileRoute, useRouter } from '@tanstack/react-router' +import { useRouter } from '@tanstack/react-router' import { z } from 'zod' -export const Route = createFileRoute('/login')({ +export const Route = createFileRoute({ validateSearch: z.object({ redirect: z.string().optional(), }), diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routeTree.gen.ts b/examples/react/kitchen-sink-react-query-file-based/src/routeTree.gen.ts index 0ba6d5e9a5..2f156adaf6 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routeTree.gen.ts +++ b/examples/react/kitchen-sink-react-query-file-based/src/routeTree.gen.ts @@ -10,128 +10,128 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as LoginImport } from './routes/login' -import { Route as PathlessLayoutImport } from './routes/_pathlessLayout' -import { Route as AuthImport } from './routes/_auth' -import { Route as DashboardRouteImport } from './routes/dashboard.route' -import { Route as IndexImport } from './routes/index' -import { Route as ExpensiveIndexImport } from './routes/expensive/index' -import { Route as DashboardIndexImport } from './routes/dashboard.index' -import { Route as FooBarImport } from './routes/foo/bar' -import { Route as PathlessLayoutRouteBImport } from './routes/_pathlessLayout.route-b' -import { Route as PathlessLayoutRouteAImport } from './routes/_pathlessLayout.route-a' -import { Route as AuthProfileImport } from './routes/_auth.profile' -import { Route as DashboardUsersRouteImport } from './routes/dashboard.users.route' -import { Route as DashboardInvoicesRouteImport } from './routes/dashboard.invoices.route' -import { Route as DashboardUsersIndexImport } from './routes/dashboard.users.index' -import { Route as DashboardInvoicesIndexImport } from './routes/dashboard.invoices.index' -import { Route as DashboardUsersUserImport } from './routes/dashboard.users.user' -import { Route as DashboardInvoicesInvoiceIdImport } from './routes/dashboard.invoices.$invoiceId' +import { Route as LoginRouteImport } from './routes/login' +import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' +import { Route as AuthRouteImport } from './routes/_auth' +import { Route as DashboardRouteRouteImport } from './routes/dashboard.route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as ExpensiveIndexRouteImport } from './routes/expensive/index' +import { Route as DashboardIndexRouteImport } from './routes/dashboard.index' +import { Route as FooBarRouteImport } from './routes/foo/bar' +import { Route as PathlessLayoutRouteBRouteImport } from './routes/_pathlessLayout.route-b' +import { Route as PathlessLayoutRouteARouteImport } from './routes/_pathlessLayout.route-a' +import { Route as AuthProfileRouteImport } from './routes/_auth.profile' +import { Route as DashboardUsersRouteRouteImport } from './routes/dashboard.users.route' +import { Route as DashboardInvoicesRouteRouteImport } from './routes/dashboard.invoices.route' +import { Route as DashboardUsersIndexRouteImport } from './routes/dashboard.users.index' +import { Route as DashboardInvoicesIndexRouteImport } from './routes/dashboard.invoices.index' +import { Route as DashboardUsersUserRouteImport } from './routes/dashboard.users.user' +import { Route as DashboardInvoicesInvoiceIdRouteImport } from './routes/dashboard.invoices.$invoiceId' // Create/Update Routes -const LoginRoute = LoginImport.update({ +const LoginRoute = LoginRouteImport.update({ id: '/login', path: '/login', getParentRoute: () => rootRoute, } as any) -const PathlessLayoutRoute = PathlessLayoutImport.update({ +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', getParentRoute: () => rootRoute, } as any) -const AuthRoute = AuthImport.update({ +const AuthRoute = AuthRouteImport.update({ id: '/_auth', getParentRoute: () => rootRoute, } as any) -const DashboardRouteRoute = DashboardRouteImport.update({ +const DashboardRouteRoute = DashboardRouteRouteImport.update({ id: '/dashboard', path: '/dashboard', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const ExpensiveIndexRoute = ExpensiveIndexImport.update({ +const ExpensiveIndexRoute = ExpensiveIndexRouteImport.update({ id: '/expensive/', path: '/expensive/', getParentRoute: () => rootRoute, } as any) -const DashboardIndexRoute = DashboardIndexImport.update({ +const DashboardIndexRoute = DashboardIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => DashboardRouteRoute, } as any) -const FooBarRoute = FooBarImport.update({ +const FooBarRoute = FooBarRouteImport.update({ id: '/foo/bar', path: '/foo/bar', getParentRoute: () => rootRoute, } as any) -const PathlessLayoutRouteBRoute = PathlessLayoutRouteBImport.update({ +const PathlessLayoutRouteBRoute = PathlessLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutRoute, } as any) -const PathlessLayoutRouteARoute = PathlessLayoutRouteAImport.update({ +const PathlessLayoutRouteARoute = PathlessLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutRoute, } as any) -const AuthProfileRoute = AuthProfileImport.update({ +const AuthProfileRoute = AuthProfileRouteImport.update({ id: '/profile', path: '/profile', getParentRoute: () => AuthRoute, } as any) -const DashboardUsersRouteRoute = DashboardUsersRouteImport.update({ +const DashboardUsersRouteRoute = DashboardUsersRouteRouteImport.update({ id: '/users', path: '/users', getParentRoute: () => DashboardRouteRoute, } as any) -const DashboardInvoicesRouteRoute = DashboardInvoicesRouteImport.update({ +const DashboardInvoicesRouteRoute = DashboardInvoicesRouteRouteImport.update({ id: '/invoices', path: '/invoices', getParentRoute: () => DashboardRouteRoute, } as any) -const DashboardUsersIndexRoute = DashboardUsersIndexImport.update({ +const DashboardUsersIndexRoute = DashboardUsersIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => DashboardUsersRouteRoute, } as any) -const DashboardInvoicesIndexRoute = DashboardInvoicesIndexImport.update({ +const DashboardInvoicesIndexRoute = DashboardInvoicesIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => DashboardInvoicesRouteRoute, } as any) -const DashboardUsersUserRoute = DashboardUsersUserImport.update({ +const DashboardUsersUserRoute = DashboardUsersUserRouteImport.update({ id: '/user', path: '/user', getParentRoute: () => DashboardUsersRouteRoute, } as any) -const DashboardInvoicesInvoiceIdRoute = DashboardInvoicesInvoiceIdImport.update( - { +const DashboardInvoicesInvoiceIdRoute = + DashboardInvoicesInvoiceIdRouteImport.update({ id: '/$invoiceId', path: '/$invoiceId', getParentRoute: () => DashboardInvoicesRouteRoute, - } as any, -) + } as any) // Populate the FileRoutesByPath interface @@ -141,124 +141,280 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/dashboard': { id: '/dashboard' path: '/dashboard' fullPath: '/dashboard' - preLoaderRoute: typeof DashboardRouteImport + preLoaderRoute: typeof DashboardRouteRouteImport parentRoute: typeof rootRoute } '/_auth': { id: '/_auth' path: '' fullPath: '' - preLoaderRoute: typeof AuthImport + preLoaderRoute: typeof AuthRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout': { id: '/_pathlessLayout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteImport parentRoute: typeof rootRoute } '/login': { id: '/login' path: '/login' fullPath: '/login' - preLoaderRoute: typeof LoginImport + preLoaderRoute: typeof LoginRouteImport parentRoute: typeof rootRoute } '/dashboard/invoices': { id: '/dashboard/invoices' path: '/invoices' fullPath: '/dashboard/invoices' - preLoaderRoute: typeof DashboardInvoicesRouteImport - parentRoute: typeof DashboardRouteImport + preLoaderRoute: typeof DashboardInvoicesRouteRouteImport + parentRoute: typeof DashboardRouteRouteImport } '/dashboard/users': { id: '/dashboard/users' path: '/users' fullPath: '/dashboard/users' - preLoaderRoute: typeof DashboardUsersRouteImport - parentRoute: typeof DashboardRouteImport + preLoaderRoute: typeof DashboardUsersRouteRouteImport + parentRoute: typeof DashboardRouteRouteImport } '/_auth/profile': { id: '/_auth/profile' path: '/profile' fullPath: '/profile' - preLoaderRoute: typeof AuthProfileImport - parentRoute: typeof AuthImport + preLoaderRoute: typeof AuthProfileRouteImport + parentRoute: typeof AuthRouteImport } '/_pathlessLayout/route-a': { id: '/_pathlessLayout/route-a' path: '/route-a' fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutRouteAImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/_pathlessLayout/route-b': { id: '/_pathlessLayout/route-b' path: '/route-b' fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutRouteBImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/foo/bar': { id: '/foo/bar' path: '/foo/bar' fullPath: '/foo/bar' - preLoaderRoute: typeof FooBarImport + preLoaderRoute: typeof FooBarRouteImport parentRoute: typeof rootRoute } '/dashboard/': { id: '/dashboard/' path: '/' fullPath: '/dashboard/' - preLoaderRoute: typeof DashboardIndexImport - parentRoute: typeof DashboardRouteImport + preLoaderRoute: typeof DashboardIndexRouteImport + parentRoute: typeof DashboardRouteRouteImport } '/expensive/': { id: '/expensive/' path: '/expensive' fullPath: '/expensive' - preLoaderRoute: typeof ExpensiveIndexImport + preLoaderRoute: typeof ExpensiveIndexRouteImport parentRoute: typeof rootRoute } '/dashboard/invoices/$invoiceId': { id: '/dashboard/invoices/$invoiceId' path: '/$invoiceId' fullPath: '/dashboard/invoices/$invoiceId' - preLoaderRoute: typeof DashboardInvoicesInvoiceIdImport - parentRoute: typeof DashboardInvoicesRouteImport + preLoaderRoute: typeof DashboardInvoicesInvoiceIdRouteImport + parentRoute: typeof DashboardInvoicesRouteRouteImport } '/dashboard/users/user': { id: '/dashboard/users/user' path: '/user' fullPath: '/dashboard/users/user' - preLoaderRoute: typeof DashboardUsersUserImport - parentRoute: typeof DashboardUsersRouteImport + preLoaderRoute: typeof DashboardUsersUserRouteImport + parentRoute: typeof DashboardUsersRouteRouteImport } '/dashboard/invoices/': { id: '/dashboard/invoices/' path: '/' fullPath: '/dashboard/invoices/' - preLoaderRoute: typeof DashboardInvoicesIndexImport - parentRoute: typeof DashboardInvoicesRouteImport + preLoaderRoute: typeof DashboardInvoicesIndexRouteImport + parentRoute: typeof DashboardInvoicesRouteRouteImport } '/dashboard/users/': { id: '/dashboard/users/' path: '/' fullPath: '/dashboard/users/' - preLoaderRoute: typeof DashboardUsersIndexImport - parentRoute: typeof DashboardUsersRouteImport + preLoaderRoute: typeof DashboardUsersIndexRouteImport + parentRoute: typeof DashboardUsersRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/dashboard.route' { + const createFileRoute: CreateFileRoute< + '/dashboard', + FileRoutesByPath['/dashboard']['parentRoute'], + FileRoutesByPath['/dashboard']['id'], + FileRoutesByPath['/dashboard']['path'], + FileRoutesByPath['/dashboard']['fullPath'] + > +} +declare module './routes/_auth' { + const createFileRoute: CreateFileRoute< + '/_auth', + FileRoutesByPath['/_auth']['parentRoute'], + FileRoutesByPath['/_auth']['id'], + FileRoutesByPath['/_auth']['path'], + FileRoutesByPath['/_auth']['fullPath'] + > +} +declare module './routes/_pathlessLayout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout', + FileRoutesByPath['/_pathlessLayout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout']['id'], + FileRoutesByPath['/_pathlessLayout']['path'], + FileRoutesByPath['/_pathlessLayout']['fullPath'] + > +} +declare module './routes/login' { + const createFileRoute: CreateFileRoute< + '/login', + FileRoutesByPath['/login']['parentRoute'], + FileRoutesByPath['/login']['id'], + FileRoutesByPath['/login']['path'], + FileRoutesByPath['/login']['fullPath'] + > +} +declare module './routes/dashboard.invoices.route' { + const createFileRoute: CreateFileRoute< + '/dashboard/invoices', + FileRoutesByPath['/dashboard/invoices']['parentRoute'], + FileRoutesByPath['/dashboard/invoices']['id'], + FileRoutesByPath['/dashboard/invoices']['path'], + FileRoutesByPath['/dashboard/invoices']['fullPath'] + > +} +declare module './routes/dashboard.users.route' { + const createFileRoute: CreateFileRoute< + '/dashboard/users', + FileRoutesByPath['/dashboard/users']['parentRoute'], + FileRoutesByPath['/dashboard/users']['id'], + FileRoutesByPath['/dashboard/users']['path'], + FileRoutesByPath['/dashboard/users']['fullPath'] + > +} +declare module './routes/_auth.profile' { + const createFileRoute: CreateFileRoute< + '/_auth/profile', + FileRoutesByPath['/_auth/profile']['parentRoute'], + FileRoutesByPath['/_auth/profile']['id'], + FileRoutesByPath['/_auth/profile']['path'], + FileRoutesByPath['/_auth/profile']['fullPath'] + > +} +declare module './routes/_pathlessLayout.route-a' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/route-a', + FileRoutesByPath['/_pathlessLayout/route-a']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/route-a']['id'], + FileRoutesByPath['/_pathlessLayout/route-a']['path'], + FileRoutesByPath['/_pathlessLayout/route-a']['fullPath'] + > +} +declare module './routes/_pathlessLayout.route-b' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/route-b', + FileRoutesByPath['/_pathlessLayout/route-b']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/route-b']['id'], + FileRoutesByPath['/_pathlessLayout/route-b']['path'], + FileRoutesByPath['/_pathlessLayout/route-b']['fullPath'] + > +} +declare module './routes/foo/bar' { + const createFileRoute: CreateFileRoute< + '/foo/bar', + FileRoutesByPath['/foo/bar']['parentRoute'], + FileRoutesByPath['/foo/bar']['id'], + FileRoutesByPath['/foo/bar']['path'], + FileRoutesByPath['/foo/bar']['fullPath'] + > +} +declare module './routes/dashboard.index' { + const createFileRoute: CreateFileRoute< + '/dashboard/', + FileRoutesByPath['/dashboard/']['parentRoute'], + FileRoutesByPath['/dashboard/']['id'], + FileRoutesByPath['/dashboard/']['path'], + FileRoutesByPath['/dashboard/']['fullPath'] + > +} +declare module './routes/expensive/index' { + const createFileRoute: CreateFileRoute< + '/expensive/', + FileRoutesByPath['/expensive/']['parentRoute'], + FileRoutesByPath['/expensive/']['id'], + FileRoutesByPath['/expensive/']['path'], + FileRoutesByPath['/expensive/']['fullPath'] + > +} +declare module './routes/dashboard.invoices.$invoiceId' { + const createFileRoute: CreateFileRoute< + '/dashboard/invoices/$invoiceId', + FileRoutesByPath['/dashboard/invoices/$invoiceId']['parentRoute'], + FileRoutesByPath['/dashboard/invoices/$invoiceId']['id'], + FileRoutesByPath['/dashboard/invoices/$invoiceId']['path'], + FileRoutesByPath['/dashboard/invoices/$invoiceId']['fullPath'] + > +} +declare module './routes/dashboard.users.user' { + const createFileRoute: CreateFileRoute< + '/dashboard/users/user', + FileRoutesByPath['/dashboard/users/user']['parentRoute'], + FileRoutesByPath['/dashboard/users/user']['id'], + FileRoutesByPath['/dashboard/users/user']['path'], + FileRoutesByPath['/dashboard/users/user']['fullPath'] + > +} +declare module './routes/dashboard.invoices.index' { + const createFileRoute: CreateFileRoute< + '/dashboard/invoices/', + FileRoutesByPath['/dashboard/invoices/']['parentRoute'], + FileRoutesByPath['/dashboard/invoices/']['id'], + FileRoutesByPath['/dashboard/invoices/']['path'], + FileRoutesByPath['/dashboard/invoices/']['fullPath'] + > +} +declare module './routes/dashboard.users.index' { + const createFileRoute: CreateFileRoute< + '/dashboard/users/', + FileRoutesByPath['/dashboard/users/']['parentRoute'], + FileRoutesByPath['/dashboard/users/']['id'], + FileRoutesByPath['/dashboard/users/']['path'], + FileRoutesByPath['/dashboard/users/']['fullPath'] + > +} + // Create and export the route tree interface DashboardInvoicesRouteRouteChildren { @@ -466,6 +622,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/_auth.profile.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/_auth.profile.tsx index fa63df98b0..7b3d690e6e 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/_auth.profile.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/_auth.profile.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/_auth/profile')({ +export const Route = createFileRoute({ component: ProfileComponent, }) diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/_auth.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/_auth.tsx index 30fdcf9f28..2d93a859c8 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/_auth.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/_auth.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' import { auth } from '../utils/auth' -export const Route = createFileRoute('/_auth')({ +export const Route = createFileRoute({ // Before loading, authenticate the user via our auth context // This will also happen during prefetching (e.g. hovering over links, etc) beforeLoad: ({ context, location }) => { diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/_pathlessLayout.route-a.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/_pathlessLayout.route-a.tsx index ce791bcf2f..f81e516bd8 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/_pathlessLayout.route-a.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/_pathlessLayout.route-a.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout/route-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/_pathlessLayout.route-b.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/_pathlessLayout.route-b.tsx index aa3010287d..c7ff7c5d74 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/_pathlessLayout.route-b.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/_pathlessLayout.route-b.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout/route-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/_pathlessLayout.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/_pathlessLayout.tsx index 1f13b66ee8..e596f802b0 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/_pathlessLayout.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/_pathlessLayout.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.index.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.index.tsx index 86fdaf1172..e1a97c0d00 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.index.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.index.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' + import { useSuspenseQuery } from '@tanstack/react-query' import { invoicesQueryOptions } from '../utils/queryOptions' -export const Route = createFileRoute('/dashboard/')({ +export const Route = createFileRoute({ loader: (opts) => opts.context.queryClient.ensureQueryData(invoicesQueryOptions()), component: DashboardIndexComponent, diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.invoices.$invoiceId.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.invoices.$invoiceId.tsx index 5a8a3c5308..a2df18d5ea 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.invoices.$invoiceId.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.invoices.$invoiceId.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { Link, createFileRoute, useNavigate } from '@tanstack/react-router' +import { Link, useNavigate } from '@tanstack/react-router' import { useSuspenseQuery } from '@tanstack/react-query' import { z } from 'zod' import { InvoiceFields } from '../components/InvoiceFields' @@ -8,7 +8,7 @@ import { useUpdateInvoiceMutation, } from '../utils/queryOptions' -export const Route = createFileRoute('/dashboard/invoices/$invoiceId')({ +export const Route = createFileRoute({ params: { parse: (params) => ({ invoiceId: z.number().int().parse(Number(params.invoiceId)), diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.invoices.index.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.invoices.index.tsx index 5537b15bb6..7a8978b599 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.invoices.index.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.invoices.index.tsx @@ -1,11 +1,11 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' + import { InvoiceFields } from '../components/InvoiceFields' import { Spinner } from '../components/Spinner' import { useCreateInvoiceMutation } from '../utils/queryOptions' import type { Invoice } from '../utils/mockTodos' -export const Route = createFileRoute('/dashboard/invoices/')({ +export const Route = createFileRoute({ component: InvoicesIndexComponent, }) diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.invoices.route.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.invoices.route.tsx index 4c613cb7a7..7e0dfb11b3 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.invoices.route.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.invoices.route.tsx @@ -1,15 +1,10 @@ import * as React from 'react' -import { - Link, - MatchRoute, - Outlet, - createFileRoute, -} from '@tanstack/react-router' +import { Link, MatchRoute, Outlet } from '@tanstack/react-router' import { useSuspenseQuery } from '@tanstack/react-query' import { Spinner } from '../components/Spinner' import { invoicesQueryOptions } from '../utils/queryOptions' -export const Route = createFileRoute('/dashboard/invoices')({ +export const Route = createFileRoute({ loader: (opts) => opts.context.queryClient.ensureQueryData(invoicesQueryOptions()), component: InvoicesComponent, diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.route.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.route.tsx index fc6ac0701e..25dadabf53 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.route.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.route.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/dashboard')({ +export const Route = createFileRoute({ component: DashboardComponent, }) diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.users.index.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.users.index.tsx index 7ad9771152..2793568c42 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.users.index.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.users.index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/dashboard/users/')({ +export const Route = createFileRoute({ component: UsersIndexComponent, }) diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.users.route.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.users.route.tsx index e7b2eb2316..0457ed137c 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.users.route.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.users.route.tsx @@ -4,7 +4,6 @@ import { Link, MatchRoute, Outlet, - createFileRoute, retainSearchParams, useNavigate, } from '@tanstack/react-router' @@ -15,7 +14,7 @@ import { usersQueryOptions } from '../utils/queryOptions' type UsersViewSortBy = 'name' | 'id' | 'email' -export const Route = createFileRoute('/dashboard/users')({ +export const Route = createFileRoute({ validateSearch: z.object({ usersView: z .object({ diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.users.user.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.users.user.tsx index 0dece3c32f..87eeae270c 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.users.user.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/dashboard.users.user.tsx @@ -1,10 +1,10 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' + import { useSuspenseQuery } from '@tanstack/react-query' import { z } from 'zod' import { userQueryOptions } from '../utils/queryOptions' -export const Route = createFileRoute('/dashboard/users/user')({ +export const Route = createFileRoute({ validateSearch: z.object({ userId: z.number(), }), diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/expensive/index.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/expensive/index.tsx index 42e1b4c0e8..5066d67ac5 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/expensive/index.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/expensive/index.tsx @@ -1,6 +1,5 @@ -import { createFileRoute } from '@tanstack/react-router' import Expensive from './-components/Expensive' -export const Route = createFileRoute('/expensive/')({ +export const Route = createFileRoute({ component: Expensive, }) diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/foo/bar.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/foo/bar.tsx index aa5920563e..c91111016b 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/foo/bar.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/foo/bar.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { z } from 'zod' -export const Route = createFileRoute('/foo/bar')({ +export const Route = createFileRoute({ component: () =>
{JSON.stringify(Route.useSearch())}
, validateSearch: z.object({ asdf: z.string() }), }) diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/index.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/index.tsx index a99ada182b..b0d05ea341 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/index.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/index.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: IndexComponent, }) diff --git a/examples/react/kitchen-sink-react-query-file-based/src/routes/login.tsx b/examples/react/kitchen-sink-react-query-file-based/src/routes/login.tsx index bcc606ac33..1fdb01084a 100644 --- a/examples/react/kitchen-sink-react-query-file-based/src/routes/login.tsx +++ b/examples/react/kitchen-sink-react-query-file-based/src/routes/login.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { createFileRoute, useRouter } from '@tanstack/react-router' +import { useRouter } from '@tanstack/react-router' import { z } from 'zod' -export const Route = createFileRoute('/login')({ +export const Route = createFileRoute({ validateSearch: z.object({ redirect: z.string().optional(), }), diff --git a/examples/react/kitchen-sink/src/main.tsx b/examples/react/kitchen-sink/src/main.tsx index 6c0c347284..3465637ce0 100644 --- a/examples/react/kitchen-sink/src/main.tsx +++ b/examples/react/kitchen-sink/src/main.tsx @@ -68,7 +68,7 @@ function RootComponent() { ['/route-a', 'Pathless Layout A'], ['/route-b', 'Pathless Layout B'], ['/profile', 'Profile'], - ['/login', 'Login'], + ...(auth.status === 'loggedOut' ? [['/login', 'Login']] : []), ] as const ).map(([to, label]) => { return ( @@ -642,6 +642,7 @@ const authPathlessLayoutRoute = createRoute({ beforeLoad: ({ context, location }) => { // If the user is logged out, redirect them to the login page if (context.auth.status === 'loggedOut') { + console.log(location) throw redirect({ to: loginRoute.to, search: { @@ -674,6 +675,15 @@ function ProfileComponent() {
Username:{username}
+
) } @@ -714,7 +724,10 @@ function LoginComponent() { Logged in as {auth.username}
diff --git a/examples/react/large-file-based/src/routeTree.gen.ts b/examples/react/large-file-based/src/routeTree.gen.ts index e4f3a85ab1..3e7c909d14 100644 --- a/examples/react/large-file-based/src/routeTree.gen.ts +++ b/examples/react/large-file-based/src/routeTree.gen.ts @@ -10,61 +10,62 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as RelativeImport } from './routes/relative' -import { Route as LinkPropsImport } from './routes/linkProps' -import { Route as AbsoluteImport } from './routes/absolute' -import { Route as SearchRouteImport } from './routes/search/route' -import { Route as ParamsRouteImport } from './routes/params/route' -import { Route as IndexImport } from './routes/index' -import { Route as SearchSearchPlaceholderImport } from './routes/search/searchPlaceholder' -import { Route as ParamsParamsPlaceholderImport } from './routes/params/$paramsPlaceholder' +import { Route as RelativeRouteImport } from './routes/relative' +import { Route as LinkPropsRouteImport } from './routes/linkProps' +import { Route as AbsoluteRouteImport } from './routes/absolute' +import { Route as SearchRouteRouteImport } from './routes/search/route' +import { Route as ParamsRouteRouteImport } from './routes/params/route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as SearchSearchPlaceholderRouteImport } from './routes/search/searchPlaceholder' +import { Route as ParamsParamsPlaceholderRouteImport } from './routes/params/$paramsPlaceholder' // Create/Update Routes -const RelativeRoute = RelativeImport.update({ +const RelativeRoute = RelativeRouteImport.update({ id: '/relative', path: '/relative', getParentRoute: () => rootRoute, } as any) -const LinkPropsRoute = LinkPropsImport.update({ +const LinkPropsRoute = LinkPropsRouteImport.update({ id: '/linkProps', path: '/linkProps', getParentRoute: () => rootRoute, } as any) -const AbsoluteRoute = AbsoluteImport.update({ +const AbsoluteRoute = AbsoluteRouteImport.update({ id: '/absolute', path: '/absolute', getParentRoute: () => rootRoute, } as any) -const SearchRouteRoute = SearchRouteImport.update({ +const SearchRouteRoute = SearchRouteRouteImport.update({ id: '/search', path: '/search', getParentRoute: () => rootRoute, } as any) -const ParamsRouteRoute = ParamsRouteImport.update({ +const ParamsRouteRoute = ParamsRouteRouteImport.update({ id: '/params', path: '/params', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const SearchSearchPlaceholderRoute = SearchSearchPlaceholderImport.update({ +const SearchSearchPlaceholderRoute = SearchSearchPlaceholderRouteImport.update({ id: '/searchPlaceholder', path: '/searchPlaceholder', getParentRoute: () => SearchRouteRoute, } as any) -const ParamsParamsPlaceholderRoute = ParamsParamsPlaceholderImport.update({ +const ParamsParamsPlaceholderRoute = ParamsParamsPlaceholderRouteImport.update({ id: '/$paramsPlaceholder', path: '/$paramsPlaceholder', getParentRoute: () => ParamsRouteRoute, @@ -78,61 +79,136 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/params': { id: '/params' path: '/params' fullPath: '/params' - preLoaderRoute: typeof ParamsRouteImport + preLoaderRoute: typeof ParamsRouteRouteImport parentRoute: typeof rootRoute } '/search': { id: '/search' path: '/search' fullPath: '/search' - preLoaderRoute: typeof SearchRouteImport + preLoaderRoute: typeof SearchRouteRouteImport parentRoute: typeof rootRoute } '/absolute': { id: '/absolute' path: '/absolute' fullPath: '/absolute' - preLoaderRoute: typeof AbsoluteImport + preLoaderRoute: typeof AbsoluteRouteImport parentRoute: typeof rootRoute } '/linkProps': { id: '/linkProps' path: '/linkProps' fullPath: '/linkProps' - preLoaderRoute: typeof LinkPropsImport + preLoaderRoute: typeof LinkPropsRouteImport parentRoute: typeof rootRoute } '/relative': { id: '/relative' path: '/relative' fullPath: '/relative' - preLoaderRoute: typeof RelativeImport + preLoaderRoute: typeof RelativeRouteImport parentRoute: typeof rootRoute } '/params/$paramsPlaceholder': { id: '/params/$paramsPlaceholder' path: '/$paramsPlaceholder' fullPath: '/params/$paramsPlaceholder' - preLoaderRoute: typeof ParamsParamsPlaceholderImport - parentRoute: typeof ParamsRouteImport + preLoaderRoute: typeof ParamsParamsPlaceholderRouteImport + parentRoute: typeof ParamsRouteRouteImport } '/search/searchPlaceholder': { id: '/search/searchPlaceholder' path: '/searchPlaceholder' fullPath: '/search/searchPlaceholder' - preLoaderRoute: typeof SearchSearchPlaceholderImport - parentRoute: typeof SearchRouteImport + preLoaderRoute: typeof SearchSearchPlaceholderRouteImport + parentRoute: typeof SearchRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/params/route' { + const createFileRoute: CreateFileRoute< + '/params', + FileRoutesByPath['/params']['parentRoute'], + FileRoutesByPath['/params']['id'], + FileRoutesByPath['/params']['path'], + FileRoutesByPath['/params']['fullPath'] + > +} +declare module './routes/search/route' { + const createFileRoute: CreateFileRoute< + '/search', + FileRoutesByPath['/search']['parentRoute'], + FileRoutesByPath['/search']['id'], + FileRoutesByPath['/search']['path'], + FileRoutesByPath['/search']['fullPath'] + > +} +declare module './routes/absolute' { + const createFileRoute: CreateFileRoute< + '/absolute', + FileRoutesByPath['/absolute']['parentRoute'], + FileRoutesByPath['/absolute']['id'], + FileRoutesByPath['/absolute']['path'], + FileRoutesByPath['/absolute']['fullPath'] + > +} +declare module './routes/linkProps' { + const createFileRoute: CreateFileRoute< + '/linkProps', + FileRoutesByPath['/linkProps']['parentRoute'], + FileRoutesByPath['/linkProps']['id'], + FileRoutesByPath['/linkProps']['path'], + FileRoutesByPath['/linkProps']['fullPath'] + > +} +declare module './routes/relative' { + const createFileRoute: CreateFileRoute< + '/relative', + FileRoutesByPath['/relative']['parentRoute'], + FileRoutesByPath['/relative']['id'], + FileRoutesByPath['/relative']['path'], + FileRoutesByPath['/relative']['fullPath'] + > +} +declare module './routes/params/$paramsPlaceholder' { + const createFileRoute: CreateFileRoute< + '/params/$paramsPlaceholder', + FileRoutesByPath['/params/$paramsPlaceholder']['parentRoute'], + FileRoutesByPath['/params/$paramsPlaceholder']['id'], + FileRoutesByPath['/params/$paramsPlaceholder']['path'], + FileRoutesByPath['/params/$paramsPlaceholder']['fullPath'] + > +} +declare module './routes/search/searchPlaceholder' { + const createFileRoute: CreateFileRoute< + '/search/searchPlaceholder', + FileRoutesByPath['/search/searchPlaceholder']['parentRoute'], + FileRoutesByPath['/search/searchPlaceholder']['id'], + FileRoutesByPath['/search/searchPlaceholder']['path'], + FileRoutesByPath['/search/searchPlaceholder']['fullPath'] + > +} + // Create and export the route tree interface ParamsRouteRouteChildren { @@ -249,6 +325,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/large-file-based/src/routes/absolute.tsx b/examples/react/large-file-based/src/routes/absolute.tsx index ba1f875050..857515fa10 100644 --- a/examples/react/large-file-based/src/routes/absolute.tsx +++ b/examples/react/large-file-based/src/routes/absolute.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/absolute')({ +export const Route = createFileRoute({ component: AbsoluteComponent, }) diff --git a/examples/react/large-file-based/src/routes/index.tsx b/examples/react/large-file-based/src/routes/index.tsx index eac82a9174..b23956ae17 100644 --- a/examples/react/large-file-based/src/routes/index.tsx +++ b/examples/react/large-file-based/src/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/react/large-file-based/src/routes/linkProps.tsx b/examples/react/large-file-based/src/routes/linkProps.tsx index 2811bcd5a8..83cee49160 100644 --- a/examples/react/large-file-based/src/routes/linkProps.tsx +++ b/examples/react/large-file-based/src/routes/linkProps.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, createFileRoute, linkOptions } from '@tanstack/react-router' +import { Link, linkOptions } from '@tanstack/react-router' -export const Route = createFileRoute('/linkProps')({ +export const Route = createFileRoute({ component: LinkPropsPage, }) diff --git a/examples/react/large-file-based/src/routes/params/$paramsPlaceholder.tsx b/examples/react/large-file-based/src/routes/params/$paramsPlaceholder.tsx index 35f85eab9b..8e45ed1eba 100644 --- a/examples/react/large-file-based/src/routes/params/$paramsPlaceholder.tsx +++ b/examples/react/large-file-based/src/routes/params/$paramsPlaceholder.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import { z } from 'zod' import { queryOptions } from '@tanstack/react-query' @@ -20,7 +20,7 @@ const paramsQueryOptions = queryOptions({ }, }) -export const Route = createFileRoute('/params/$paramsPlaceholder')({ +export const Route = createFileRoute({ component: ParamsComponent, loader: (opts) => opts.context.queryClient.ensureQueryData(paramsQueryOptions), diff --git a/examples/react/large-file-based/src/routes/params/route.tsx b/examples/react/large-file-based/src/routes/params/route.tsx index 32f2b82024..a37f312161 100644 --- a/examples/react/large-file-based/src/routes/params/route.tsx +++ b/examples/react/large-file-based/src/routes/params/route.tsx @@ -1,6 +1,5 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/params')({ +export const Route = createFileRoute({ component: () =>
Hello /params!
, }) diff --git a/examples/react/large-file-based/src/routes/relative.tsx b/examples/react/large-file-based/src/routes/relative.tsx index 6f6e581efd..cf25ec6f9f 100644 --- a/examples/react/large-file-based/src/routes/relative.tsx +++ b/examples/react/large-file-based/src/routes/relative.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/relative')({ +export const Route = createFileRoute({ component: RelativeComponent, }) diff --git a/examples/react/large-file-based/src/routes/search/route.tsx b/examples/react/large-file-based/src/routes/search/route.tsx index 364daefb12..13eaab8d40 100644 --- a/examples/react/large-file-based/src/routes/search/route.tsx +++ b/examples/react/large-file-based/src/routes/search/route.tsx @@ -1,12 +1,12 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' + import { z } from 'zod' const search = z.object({ rootSearch: z.number(), }) -export const Route = createFileRoute('/search')({ +export const Route = createFileRoute({ component: () =>
Hello /search!
, validateSearch: search, }) diff --git a/examples/react/large-file-based/src/routes/search/searchPlaceholder.tsx b/examples/react/large-file-based/src/routes/search/searchPlaceholder.tsx index 60372e8b98..c8249a3728 100644 --- a/examples/react/large-file-based/src/routes/search/searchPlaceholder.tsx +++ b/examples/react/large-file-based/src/routes/search/searchPlaceholder.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import { z } from 'zod' import { queryOptions } from '@tanstack/react-query' @@ -26,7 +26,7 @@ const searchQueryOptions = queryOptions({ }, }) -export const Route = createFileRoute('/search/searchPlaceholder')({ +export const Route = createFileRoute({ component: SearchComponent, validateSearch: search, loader: (opts) => diff --git a/examples/react/quickstart-file-based/src/routeTree.gen.ts b/examples/react/quickstart-file-based/src/routeTree.gen.ts index 48c183c8da..a4baf34c96 100644 --- a/examples/react/quickstart-file-based/src/routeTree.gen.ts +++ b/examples/react/quickstart-file-based/src/routeTree.gen.ts @@ -10,19 +10,20 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as AboutImport } from './routes/about' -import { Route as IndexImport } from './routes/index' +import { Route as AboutRouteImport } from './routes/about' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const AboutRoute = AboutImport.update({ +const AboutRoute = AboutRouteImport.update({ id: '/about', path: '/about', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -36,19 +37,40 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/about': { id: '/about' path: '/about' fullPath: '/about' - preLoaderRoute: typeof AboutImport + preLoaderRoute: typeof AboutRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/about' { + const createFileRoute: CreateFileRoute< + '/about', + FileRoutesByPath['/about']['parentRoute'], + FileRoutesByPath['/about']['id'], + FileRoutesByPath['/about']['path'], + FileRoutesByPath['/about']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -90,6 +112,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/quickstart-file-based/src/routes/about.tsx b/examples/react/quickstart-file-based/src/routes/about.tsx index 492e6b85c2..6ac3e560c5 100644 --- a/examples/react/quickstart-file-based/src/routes/about.tsx +++ b/examples/react/quickstart-file-based/src/routes/about.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/about')({ +export const Route = createFileRoute({ component: AboutComponent, }) diff --git a/examples/react/quickstart-file-based/src/routes/index.tsx b/examples/react/quickstart-file-based/src/routes/index.tsx index c4588fb2c9..acb0446745 100644 --- a/examples/react/quickstart-file-based/src/routes/index.tsx +++ b/examples/react/quickstart-file-based/src/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: HomeComponent, }) diff --git a/examples/react/quickstart-rspack-file-based/src/routeTree.gen.ts b/examples/react/quickstart-rspack-file-based/src/routeTree.gen.ts index 48c183c8da..a4baf34c96 100644 --- a/examples/react/quickstart-rspack-file-based/src/routeTree.gen.ts +++ b/examples/react/quickstart-rspack-file-based/src/routeTree.gen.ts @@ -10,19 +10,20 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as AboutImport } from './routes/about' -import { Route as IndexImport } from './routes/index' +import { Route as AboutRouteImport } from './routes/about' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const AboutRoute = AboutImport.update({ +const AboutRoute = AboutRouteImport.update({ id: '/about', path: '/about', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -36,19 +37,40 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/about': { id: '/about' path: '/about' fullPath: '/about' - preLoaderRoute: typeof AboutImport + preLoaderRoute: typeof AboutRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/about' { + const createFileRoute: CreateFileRoute< + '/about', + FileRoutesByPath['/about']['parentRoute'], + FileRoutesByPath['/about']['id'], + FileRoutesByPath['/about']['path'], + FileRoutesByPath['/about']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -90,6 +112,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/quickstart-rspack-file-based/src/routes/about.tsx b/examples/react/quickstart-rspack-file-based/src/routes/about.tsx index 492e6b85c2..6ac3e560c5 100644 --- a/examples/react/quickstart-rspack-file-based/src/routes/about.tsx +++ b/examples/react/quickstart-rspack-file-based/src/routes/about.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/about')({ +export const Route = createFileRoute({ component: AboutComponent, }) diff --git a/examples/react/quickstart-rspack-file-based/src/routes/index.tsx b/examples/react/quickstart-rspack-file-based/src/routes/index.tsx index c4588fb2c9..acb0446745 100644 --- a/examples/react/quickstart-rspack-file-based/src/routes/index.tsx +++ b/examples/react/quickstart-rspack-file-based/src/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: HomeComponent, }) diff --git a/examples/react/quickstart-webpack-file-based/src/routeTree.gen.ts b/examples/react/quickstart-webpack-file-based/src/routeTree.gen.ts index 48c183c8da..a4baf34c96 100644 --- a/examples/react/quickstart-webpack-file-based/src/routeTree.gen.ts +++ b/examples/react/quickstart-webpack-file-based/src/routeTree.gen.ts @@ -10,19 +10,20 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as AboutImport } from './routes/about' -import { Route as IndexImport } from './routes/index' +import { Route as AboutRouteImport } from './routes/about' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const AboutRoute = AboutImport.update({ +const AboutRoute = AboutRouteImport.update({ id: '/about', path: '/about', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -36,19 +37,40 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/about': { id: '/about' path: '/about' fullPath: '/about' - preLoaderRoute: typeof AboutImport + preLoaderRoute: typeof AboutRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/about' { + const createFileRoute: CreateFileRoute< + '/about', + FileRoutesByPath['/about']['parentRoute'], + FileRoutesByPath['/about']['id'], + FileRoutesByPath['/about']['path'], + FileRoutesByPath['/about']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -90,6 +112,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/quickstart-webpack-file-based/src/routes/about.tsx b/examples/react/quickstart-webpack-file-based/src/routes/about.tsx index 0d58b8cb0b..d57890bd6c 100644 --- a/examples/react/quickstart-webpack-file-based/src/routes/about.tsx +++ b/examples/react/quickstart-webpack-file-based/src/routes/about.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/about')({ +export const Route = createFileRoute({ component: AboutComponent, }) diff --git a/examples/react/quickstart-webpack-file-based/src/routes/index.tsx b/examples/react/quickstart-webpack-file-based/src/routes/index.tsx index c6b6b31c01..3254ca4186 100644 --- a/examples/react/quickstart-webpack-file-based/src/routes/index.tsx +++ b/examples/react/quickstart-webpack-file-based/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: HomeComponent, }) diff --git a/examples/react/router-monorepo-react-query/packages/router/src/routeTree.gen.ts b/examples/react/router-monorepo-react-query/packages/router/src/routeTree.gen.ts index 708707e98c..dbbef3c648 100644 --- a/examples/react/router-monorepo-react-query/packages/router/src/routeTree.gen.ts +++ b/examples/react/router-monorepo-react-query/packages/router/src/routeTree.gen.ts @@ -10,19 +10,20 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostIdImport } from './routes/$postId' -import { Route as IndexImport } from './routes/index' +import { Route as PostIdRouteImport } from './routes/$postId' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const PostIdRoute = PostIdImport.update({ +const PostIdRoute = PostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -36,19 +37,40 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/$postId': { id: '/$postId' path: '/$postId' fullPath: '/$postId' - preLoaderRoute: typeof PostIdImport + preLoaderRoute: typeof PostIdRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/$postId' { + const createFileRoute: CreateFileRoute< + '/$postId', + FileRoutesByPath['/$postId']['parentRoute'], + FileRoutesByPath['/$postId']['id'], + FileRoutesByPath['/$postId']['path'], + FileRoutesByPath['/$postId']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -90,6 +112,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/router-monorepo-react-query/packages/router/src/routes/$postId.ts b/examples/react/router-monorepo-react-query/packages/router/src/routes/$postId.ts index 0e85860a5b..35540eeb42 100644 --- a/examples/react/router-monorepo-react-query/packages/router/src/routes/$postId.ts +++ b/examples/react/router-monorepo-react-query/packages/router/src/routes/$postId.ts @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { postQueryOptions } from '@router-mono-react-query/post-query' -export const Route = createFileRoute('/$postId')({ +export const Route = createFileRoute({ loader: ({ context: { queryClient }, params: { postId } }) => { return queryClient.ensureQueryData(postQueryOptions(postId)) }, diff --git a/examples/react/router-monorepo-react-query/packages/router/src/routes/index.ts b/examples/react/router-monorepo-react-query/packages/router/src/routes/index.ts index 880ec469fe..b1a99aecbb 100644 --- a/examples/react/router-monorepo-react-query/packages/router/src/routes/index.ts +++ b/examples/react/router-monorepo-react-query/packages/router/src/routes/index.ts @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { postsQueryOptions } from '@router-mono-react-query/post-query' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ loader: ({ context: { queryClient } }) => { return queryClient.ensureQueryData(postsQueryOptions) }, diff --git a/examples/react/router-monorepo-simple-lazy/packages/router/src/routeTree.gen.ts b/examples/react/router-monorepo-simple-lazy/packages/router/src/routeTree.gen.ts index 708707e98c..dbbef3c648 100644 --- a/examples/react/router-monorepo-simple-lazy/packages/router/src/routeTree.gen.ts +++ b/examples/react/router-monorepo-simple-lazy/packages/router/src/routeTree.gen.ts @@ -10,19 +10,20 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostIdImport } from './routes/$postId' -import { Route as IndexImport } from './routes/index' +import { Route as PostIdRouteImport } from './routes/$postId' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const PostIdRoute = PostIdImport.update({ +const PostIdRoute = PostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -36,19 +37,40 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/$postId': { id: '/$postId' path: '/$postId' fullPath: '/$postId' - preLoaderRoute: typeof PostIdImport + preLoaderRoute: typeof PostIdRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/$postId' { + const createFileRoute: CreateFileRoute< + '/$postId', + FileRoutesByPath['/$postId']['parentRoute'], + FileRoutesByPath['/$postId']['id'], + FileRoutesByPath['/$postId']['path'], + FileRoutesByPath['/$postId']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -90,6 +112,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/router-monorepo-simple-lazy/packages/router/src/routes/$postId.ts b/examples/react/router-monorepo-simple-lazy/packages/router/src/routes/$postId.ts index 670d4cc883..14110f613f 100644 --- a/examples/react/router-monorepo-simple-lazy/packages/router/src/routes/$postId.ts +++ b/examples/react/router-monorepo-simple-lazy/packages/router/src/routes/$postId.ts @@ -1,6 +1,5 @@ -import { createFileRoute } from '@tanstack/react-router' import { fetchPost } from '../fetch/posts' -export const Route = createFileRoute('/$postId')({ +export const Route = createFileRoute({ loader: ({ params }) => fetchPost(params.postId), }) diff --git a/examples/react/router-monorepo-simple-lazy/packages/router/src/routes/index.ts b/examples/react/router-monorepo-simple-lazy/packages/router/src/routes/index.ts index 2dc2272d1f..2e8127f3f6 100644 --- a/examples/react/router-monorepo-simple-lazy/packages/router/src/routes/index.ts +++ b/examples/react/router-monorepo-simple-lazy/packages/router/src/routes/index.ts @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { fetchPosts } from '../fetch/posts' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ loader: () => { return fetchPosts() }, diff --git a/examples/react/router-monorepo-simple/packages/router/src/routeTree.gen.ts b/examples/react/router-monorepo-simple/packages/router/src/routeTree.gen.ts index 708707e98c..dbbef3c648 100644 --- a/examples/react/router-monorepo-simple/packages/router/src/routeTree.gen.ts +++ b/examples/react/router-monorepo-simple/packages/router/src/routeTree.gen.ts @@ -10,19 +10,20 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostIdImport } from './routes/$postId' -import { Route as IndexImport } from './routes/index' +import { Route as PostIdRouteImport } from './routes/$postId' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const PostIdRoute = PostIdImport.update({ +const PostIdRoute = PostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -36,19 +37,40 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/$postId': { id: '/$postId' path: '/$postId' fullPath: '/$postId' - preLoaderRoute: typeof PostIdImport + preLoaderRoute: typeof PostIdRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/$postId' { + const createFileRoute: CreateFileRoute< + '/$postId', + FileRoutesByPath['/$postId']['parentRoute'], + FileRoutesByPath['/$postId']['id'], + FileRoutesByPath['/$postId']['path'], + FileRoutesByPath['/$postId']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -90,6 +112,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/router-monorepo-simple/packages/router/src/routes/$postId.ts b/examples/react/router-monorepo-simple/packages/router/src/routes/$postId.ts index 670d4cc883..14110f613f 100644 --- a/examples/react/router-monorepo-simple/packages/router/src/routes/$postId.ts +++ b/examples/react/router-monorepo-simple/packages/router/src/routes/$postId.ts @@ -1,6 +1,5 @@ -import { createFileRoute } from '@tanstack/react-router' import { fetchPost } from '../fetch/posts' -export const Route = createFileRoute('/$postId')({ +export const Route = createFileRoute({ loader: ({ params }) => fetchPost(params.postId), }) diff --git a/examples/react/router-monorepo-simple/packages/router/src/routes/index.ts b/examples/react/router-monorepo-simple/packages/router/src/routes/index.ts index 2dc2272d1f..2e8127f3f6 100644 --- a/examples/react/router-monorepo-simple/packages/router/src/routes/index.ts +++ b/examples/react/router-monorepo-simple/packages/router/src/routes/index.ts @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { fetchPosts } from '../fetch/posts' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ loader: () => { return fetchPosts() }, diff --git a/examples/react/search-validator-adapters/src/routeTree.gen.ts b/examples/react/search-validator-adapters/src/routeTree.gen.ts index 4e8d04aa89..25183d0998 100644 --- a/examples/react/search-validator-adapters/src/routeTree.gen.ts +++ b/examples/react/search-validator-adapters/src/routeTree.gen.ts @@ -10,33 +10,34 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' -import { Route as UsersZodIndexImport } from './routes/users/zod.index' -import { Route as UsersValibotIndexImport } from './routes/users/valibot.index' -import { Route as UsersArktypeIndexImport } from './routes/users/arktype.index' +import { Route as IndexRouteImport } from './routes/index' +import { Route as UsersZodIndexRouteImport } from './routes/users/zod.index' +import { Route as UsersValibotIndexRouteImport } from './routes/users/valibot.index' +import { Route as UsersArktypeIndexRouteImport } from './routes/users/arktype.index' // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const UsersZodIndexRoute = UsersZodIndexImport.update({ +const UsersZodIndexRoute = UsersZodIndexRouteImport.update({ id: '/users/zod/', path: '/users/zod/', getParentRoute: () => rootRoute, } as any) -const UsersValibotIndexRoute = UsersValibotIndexImport.update({ +const UsersValibotIndexRoute = UsersValibotIndexRouteImport.update({ id: '/users/valibot/', path: '/users/valibot/', getParentRoute: () => rootRoute, } as any) -const UsersArktypeIndexRoute = UsersArktypeIndexImport.update({ +const UsersArktypeIndexRoute = UsersArktypeIndexRouteImport.update({ id: '/users/arktype/', path: '/users/arktype/', getParentRoute: () => rootRoute, @@ -50,33 +51,72 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/users/arktype/': { id: '/users/arktype/' path: '/users/arktype' fullPath: '/users/arktype' - preLoaderRoute: typeof UsersArktypeIndexImport + preLoaderRoute: typeof UsersArktypeIndexRouteImport parentRoute: typeof rootRoute } '/users/valibot/': { id: '/users/valibot/' path: '/users/valibot' fullPath: '/users/valibot' - preLoaderRoute: typeof UsersValibotIndexImport + preLoaderRoute: typeof UsersValibotIndexRouteImport parentRoute: typeof rootRoute } '/users/zod/': { id: '/users/zod/' path: '/users/zod' fullPath: '/users/zod' - preLoaderRoute: typeof UsersZodIndexImport + preLoaderRoute: typeof UsersZodIndexRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/users/arktype.index' { + const createFileRoute: CreateFileRoute< + '/users/arktype/', + FileRoutesByPath['/users/arktype/']['parentRoute'], + FileRoutesByPath['/users/arktype/']['id'], + FileRoutesByPath['/users/arktype/']['path'], + FileRoutesByPath['/users/arktype/']['fullPath'] + > +} +declare module './routes/users/valibot.index' { + const createFileRoute: CreateFileRoute< + '/users/valibot/', + FileRoutesByPath['/users/valibot/']['parentRoute'], + FileRoutesByPath['/users/valibot/']['id'], + FileRoutesByPath['/users/valibot/']['path'], + FileRoutesByPath['/users/valibot/']['fullPath'] + > +} +declare module './routes/users/zod.index' { + const createFileRoute: CreateFileRoute< + '/users/zod/', + FileRoutesByPath['/users/zod/']['parentRoute'], + FileRoutesByPath['/users/zod/']['id'], + FileRoutesByPath['/users/zod/']['path'], + FileRoutesByPath['/users/zod/']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -128,6 +168,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/search-validator-adapters/src/routes/index.tsx b/examples/react/search-validator-adapters/src/routes/index.tsx index c00341b613..e279d9c1e0 100644 --- a/examples/react/search-validator-adapters/src/routes/index.tsx +++ b/examples/react/search-validator-adapters/src/routes/index.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' + import { Header } from '../components/Header' import { Content } from '../components/Content' @@ -12,6 +12,6 @@ export const Index: React.FunctionComponent = () => { ) } -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Index, }) diff --git a/examples/react/search-validator-adapters/src/routes/users/arktype.index.tsx b/examples/react/search-validator-adapters/src/routes/users/arktype.index.tsx index 3595f1ef01..38af594c85 100644 --- a/examples/react/search-validator-adapters/src/routes/users/arktype.index.tsx +++ b/examples/react/search-validator-adapters/src/routes/users/arktype.index.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { createFileRoute, useNavigate } from '@tanstack/react-router' +import { useNavigate } from '@tanstack/react-router' import { type } from 'arktype' import { Header } from '../../components/Header' import { Users, usersQueryOptions } from '../../components/Users' @@ -32,7 +32,7 @@ const search = type({ search: 'string = ""', }) -export const Route = createFileRoute('/users/arktype/')({ +export const Route = createFileRoute({ validateSearch: search, loaderDeps: (opt) => ({ search: opt.search }), loader: (opt) => { diff --git a/examples/react/search-validator-adapters/src/routes/users/valibot.index.tsx b/examples/react/search-validator-adapters/src/routes/users/valibot.index.tsx index 33ff6623f0..1a8bc7dd18 100644 --- a/examples/react/search-validator-adapters/src/routes/users/valibot.index.tsx +++ b/examples/react/search-validator-adapters/src/routes/users/valibot.index.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { createFileRoute, useNavigate } from '@tanstack/react-router' +import { useNavigate } from '@tanstack/react-router' import * as v from 'valibot' import { Header } from '../../components/Header' import { Users, usersQueryOptions } from '../../components/Users' @@ -26,7 +26,7 @@ const Valibot = () => { ) } -export const Route = createFileRoute('/users/valibot/')({ +export const Route = createFileRoute({ validateSearch: v.object({ search: v.fallback(v.optional(v.string(), ''), ''), }), diff --git a/examples/react/search-validator-adapters/src/routes/users/zod.index.tsx b/examples/react/search-validator-adapters/src/routes/users/zod.index.tsx index 7a94b04d54..8f095d156f 100644 --- a/examples/react/search-validator-adapters/src/routes/users/zod.index.tsx +++ b/examples/react/search-validator-adapters/src/routes/users/zod.index.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { createFileRoute, useNavigate } from '@tanstack/react-router' +import { useNavigate } from '@tanstack/react-router' import { fallback, zodValidator } from '@tanstack/zod-adapter' import { z } from 'zod' import { Header } from '../../components/Header' @@ -29,7 +29,7 @@ const Zod = () => { ) } -export const Route = createFileRoute('/users/zod/')({ +export const Route = createFileRoute({ validateSearch: zodValidator( z.object({ search: fallback(z.string().optional(), undefined), diff --git a/examples/react/start-bare/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-bare/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/examples/react/start-bare/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-bare/app.config.ts b/examples/react/start-bare/app.config.ts deleted file mode 100644 index 775bee171b..0000000000 --- a/examples/react/start-bare/app.config.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' -import tailwindcss from '@tailwindcss/vite' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - tailwindcss(), - ], - }, -}) diff --git a/examples/react/start-bare/package.json b/examples/react/start-bare/package.json index c87ecebfde..9874aa3d3c 100644 --- a/examples/react/start-bare/package.json +++ b/examples/react/start-bare/package.json @@ -4,9 +4,9 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "dependencies": { "@tanstack/react-router": "^1.120.3", @@ -14,7 +14,6 @@ "@tanstack/react-start": "^1.120.3", "react": "^19.0.0", "react-dom": "^19.0.0", - "vinxi": "0.5.3", "zod": "^3.24.2" }, "devDependencies": { diff --git a/examples/react/start-bare/src/api.ts b/examples/react/start-bare/src/api.ts deleted file mode 100644 index 8b9fef1667..0000000000 --- a/examples/react/start-bare/src/api.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { - createStartAPIHandler, - defaultAPIFileRouteHandler, -} from '@tanstack/react-start/api' - -export default createStartAPIHandler(defaultAPIFileRouteHandler) diff --git a/examples/react/start-bare/src/client.tsx b/examples/react/start-bare/src/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/examples/react/start-bare/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/examples/react/start-bare/src/routeTree.gen.ts b/examples/react/start-bare/src/routeTree.gen.ts index 48c183c8da..a4baf34c96 100644 --- a/examples/react/start-bare/src/routeTree.gen.ts +++ b/examples/react/start-bare/src/routeTree.gen.ts @@ -10,19 +10,20 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as AboutImport } from './routes/about' -import { Route as IndexImport } from './routes/index' +import { Route as AboutRouteImport } from './routes/about' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const AboutRoute = AboutImport.update({ +const AboutRoute = AboutRouteImport.update({ id: '/about', path: '/about', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -36,19 +37,40 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/about': { id: '/about' path: '/about' fullPath: '/about' - preLoaderRoute: typeof AboutImport + preLoaderRoute: typeof AboutRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/about' { + const createFileRoute: CreateFileRoute< + '/about', + FileRoutesByPath['/about']['parentRoute'], + FileRoutesByPath['/about']['id'], + FileRoutesByPath['/about']['path'], + FileRoutesByPath['/about']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -90,6 +112,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/start-bare/src/routes/about.tsx b/examples/react/start-bare/src/routes/about.tsx index ca401c33c7..f0d5d234a0 100644 --- a/examples/react/start-bare/src/routes/about.tsx +++ b/examples/react/start-bare/src/routes/about.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/about')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/examples/react/start-bare/src/routes/index.tsx b/examples/react/start-bare/src/routes/index.tsx index e9de615dc9..bd87c0bf42 100644 --- a/examples/react/start-bare/src/routes/index.tsx +++ b/examples/react/start-bare/src/routes/index.tsx @@ -1,6 +1,5 @@ -import { createFileRoute } from '@tanstack/react-router' import Counter from '~/components/Counter' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/examples/react/start-bare/vite.config.ts b/examples/react/start-bare/vite.config.ts new file mode 100644 index 0000000000..f451c4b69c --- /dev/null +++ b/examples/react/start-bare/vite.config.ts @@ -0,0 +1,15 @@ +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/examples/react/start-basic-auth/.gitignore b/examples/react/start-basic-auth/.gitignore index b15fed94e2..2818549158 100644 --- a/examples/react/start-basic-auth/.gitignore +++ b/examples/react/start-basic-auth/.gitignore @@ -7,14 +7,10 @@ yarn.lock .cache .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ diff --git a/examples/react/start-basic-auth/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-basic-auth/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/examples/react/start-basic-auth/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-basic-auth/app.config.ts b/examples/react/start-basic-auth/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/examples/react/start-basic-auth/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/examples/react/start-basic-auth/package.json b/examples/react/start-basic-auth/package.json index 554777cc4e..a419d8845a 100644 --- a/examples/react/start-basic-auth/package.json +++ b/examples/react/start-basic-auth/package.json @@ -4,9 +4,9 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start", + "dev": "vite dev", + "build": "vite build", + "start": "vite start", "prisma-generate": "prisma generate" }, "dependencies": { @@ -18,8 +18,7 @@ "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", - "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3" + "tailwind-merge": "^2.6.0" }, "devDependencies": { "@types/node": "^22.5.4", diff --git a/examples/react/start-basic-auth/src/client.tsx b/examples/react/start-basic-auth/src/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/examples/react/start-basic-auth/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/examples/react/start-basic-auth/src/routeTree.gen.ts b/examples/react/start-basic-auth/src/routeTree.gen.ts index 8c5a37a7e8..e5b814464d 100644 --- a/examples/react/start-basic-auth/src/routeTree.gen.ts +++ b/examples/react/start-basic-auth/src/routeTree.gen.ts @@ -10,60 +10,61 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as SignupImport } from './routes/signup' -import { Route as LogoutImport } from './routes/logout' -import { Route as LoginImport } from './routes/login' -import { Route as AuthedImport } from './routes/_authed' -import { Route as IndexImport } from './routes/index' -import { Route as AuthedPostsRouteImport } from './routes/_authed/posts.route' -import { Route as AuthedPostsIndexImport } from './routes/_authed/posts.index' -import { Route as AuthedPostsPostIdImport } from './routes/_authed/posts.$postId' +import { Route as SignupRouteImport } from './routes/signup' +import { Route as LogoutRouteImport } from './routes/logout' +import { Route as LoginRouteImport } from './routes/login' +import { Route as AuthedRouteImport } from './routes/_authed' +import { Route as IndexRouteImport } from './routes/index' +import { Route as AuthedPostsRouteRouteImport } from './routes/_authed/posts.route' +import { Route as AuthedPostsIndexRouteImport } from './routes/_authed/posts.index' +import { Route as AuthedPostsPostIdRouteImport } from './routes/_authed/posts.$postId' // Create/Update Routes -const SignupRoute = SignupImport.update({ +const SignupRoute = SignupRouteImport.update({ id: '/signup', path: '/signup', getParentRoute: () => rootRoute, } as any) -const LogoutRoute = LogoutImport.update({ +const LogoutRoute = LogoutRouteImport.update({ id: '/logout', path: '/logout', getParentRoute: () => rootRoute, } as any) -const LoginRoute = LoginImport.update({ +const LoginRoute = LoginRouteImport.update({ id: '/login', path: '/login', getParentRoute: () => rootRoute, } as any) -const AuthedRoute = AuthedImport.update({ +const AuthedRoute = AuthedRouteImport.update({ id: '/_authed', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const AuthedPostsRouteRoute = AuthedPostsRouteImport.update({ +const AuthedPostsRouteRoute = AuthedPostsRouteRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => AuthedRoute, } as any) -const AuthedPostsIndexRoute = AuthedPostsIndexImport.update({ +const AuthedPostsIndexRoute = AuthedPostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => AuthedPostsRouteRoute, } as any) -const AuthedPostsPostIdRoute = AuthedPostsPostIdImport.update({ +const AuthedPostsPostIdRoute = AuthedPostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => AuthedPostsRouteRoute, @@ -77,61 +78,136 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_authed': { id: '/_authed' path: '' fullPath: '' - preLoaderRoute: typeof AuthedImport + preLoaderRoute: typeof AuthedRouteImport parentRoute: typeof rootRoute } '/login': { id: '/login' path: '/login' fullPath: '/login' - preLoaderRoute: typeof LoginImport + preLoaderRoute: typeof LoginRouteImport parentRoute: typeof rootRoute } '/logout': { id: '/logout' path: '/logout' fullPath: '/logout' - preLoaderRoute: typeof LogoutImport + preLoaderRoute: typeof LogoutRouteImport parentRoute: typeof rootRoute } '/signup': { id: '/signup' path: '/signup' fullPath: '/signup' - preLoaderRoute: typeof SignupImport + preLoaderRoute: typeof SignupRouteImport parentRoute: typeof rootRoute } '/_authed/posts': { id: '/_authed/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof AuthedPostsRouteImport - parentRoute: typeof AuthedImport + preLoaderRoute: typeof AuthedPostsRouteRouteImport + parentRoute: typeof AuthedRouteImport } '/_authed/posts/$postId': { id: '/_authed/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof AuthedPostsPostIdImport - parentRoute: typeof AuthedPostsRouteImport + preLoaderRoute: typeof AuthedPostsPostIdRouteImport + parentRoute: typeof AuthedPostsRouteRouteImport } '/_authed/posts/': { id: '/_authed/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof AuthedPostsIndexImport - parentRoute: typeof AuthedPostsRouteImport + preLoaderRoute: typeof AuthedPostsIndexRouteImport + parentRoute: typeof AuthedPostsRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_authed' { + const createFileRoute: CreateFileRoute< + '/_authed', + FileRoutesByPath['/_authed']['parentRoute'], + FileRoutesByPath['/_authed']['id'], + FileRoutesByPath['/_authed']['path'], + FileRoutesByPath['/_authed']['fullPath'] + > +} +declare module './routes/login' { + const createFileRoute: CreateFileRoute< + '/login', + FileRoutesByPath['/login']['parentRoute'], + FileRoutesByPath['/login']['id'], + FileRoutesByPath['/login']['path'], + FileRoutesByPath['/login']['fullPath'] + > +} +declare module './routes/logout' { + const createFileRoute: CreateFileRoute< + '/logout', + FileRoutesByPath['/logout']['parentRoute'], + FileRoutesByPath['/logout']['id'], + FileRoutesByPath['/logout']['path'], + FileRoutesByPath['/logout']['fullPath'] + > +} +declare module './routes/signup' { + const createFileRoute: CreateFileRoute< + '/signup', + FileRoutesByPath['/signup']['parentRoute'], + FileRoutesByPath['/signup']['id'], + FileRoutesByPath['/signup']['path'], + FileRoutesByPath['/signup']['fullPath'] + > +} +declare module './routes/_authed/posts.route' { + const createFileRoute: CreateFileRoute< + '/_authed/posts', + FileRoutesByPath['/_authed/posts']['parentRoute'], + FileRoutesByPath['/_authed/posts']['id'], + FileRoutesByPath['/_authed/posts']['path'], + FileRoutesByPath['/_authed/posts']['fullPath'] + > +} +declare module './routes/_authed/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/_authed/posts/$postId', + FileRoutesByPath['/_authed/posts/$postId']['parentRoute'], + FileRoutesByPath['/_authed/posts/$postId']['id'], + FileRoutesByPath['/_authed/posts/$postId']['path'], + FileRoutesByPath['/_authed/posts/$postId']['fullPath'] + > +} +declare module './routes/_authed/posts.index' { + const createFileRoute: CreateFileRoute< + '/_authed/posts/', + FileRoutesByPath['/_authed/posts/']['parentRoute'], + FileRoutesByPath['/_authed/posts/']['id'], + FileRoutesByPath['/_authed/posts/']['path'], + FileRoutesByPath['/_authed/posts/']['fullPath'] + > +} + // Create and export the route tree interface AuthedPostsRouteRouteChildren { @@ -237,6 +313,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/start-basic-auth/src/routes/_authed.tsx b/examples/react/start-basic-auth/src/routes/_authed.tsx index 3944e590f9..f1049611a4 100644 --- a/examples/react/start-basic-auth/src/routes/_authed.tsx +++ b/examples/react/start-basic-auth/src/routes/_authed.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' import { hashPassword, prismaClient } from '~/utils/prisma' import { Login } from '~/components/Login' @@ -42,7 +41,7 @@ export const loginFn = createServerFn({ method: 'POST' }) }) }) -export const Route = createFileRoute('/_authed')({ +export const Route = createFileRoute({ beforeLoad: ({ context }) => { if (!context.user) { throw new Error('Not authenticated') diff --git a/examples/react/start-basic-auth/src/routes/_authed/posts.$postId.tsx b/examples/react/start-basic-auth/src/routes/_authed/posts.$postId.tsx index 039271bb89..c6c36f3ea4 100644 --- a/examples/react/start-basic-auth/src/routes/_authed/posts.$postId.tsx +++ b/examples/react/start-basic-auth/src/routes/_authed/posts.$postId.tsx @@ -1,9 +1,9 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import type { ErrorComponentProps } from '@tanstack/react-router' import { NotFound } from '~/components/NotFound.js' import { fetchPost } from '~/utils/posts.js' -export const Route = createFileRoute('/_authed/posts/$postId')({ +export const Route = createFileRoute({ loader: ({ params: { postId } }) => fetchPost({ data: postId }), errorComponent: PostErrorComponent, component: PostComponent, diff --git a/examples/react/start-basic-auth/src/routes/_authed/posts.index.tsx b/examples/react/start-basic-auth/src/routes/_authed/posts.index.tsx index ea9e667e54..13529228bb 100644 --- a/examples/react/start-basic-auth/src/routes/_authed/posts.index.tsx +++ b/examples/react/start-basic-auth/src/routes/_authed/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_authed/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/react/start-basic-auth/src/routes/_authed/posts.route.tsx b/examples/react/start-basic-auth/src/routes/_authed/posts.route.tsx index 86c8ef4138..f9b50197cf 100644 --- a/examples/react/start-basic-auth/src/routes/_authed/posts.route.tsx +++ b/examples/react/start-basic-auth/src/routes/_authed/posts.route.tsx @@ -1,7 +1,7 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '~/utils/posts.js' -export const Route = createFileRoute('/_authed/posts')({ +export const Route = createFileRoute({ loader: () => fetchPosts(), component: PostsComponent, }) diff --git a/examples/react/start-basic-auth/src/routes/index.tsx b/examples/react/start-basic-auth/src/routes/index.tsx index 09a907cb18..f6c5b98b02 100644 --- a/examples/react/start-basic-auth/src/routes/index.tsx +++ b/examples/react/start-basic-auth/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/react/start-basic-auth/src/routes/login.tsx b/examples/react/start-basic-auth/src/routes/login.tsx index 03ced20832..269ca5e816 100644 --- a/examples/react/start-basic-auth/src/routes/login.tsx +++ b/examples/react/start-basic-auth/src/routes/login.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { Login } from '~/components/Login' -export const Route = createFileRoute('/login')({ +export const Route = createFileRoute({ component: LoginComp, }) diff --git a/examples/react/start-basic-auth/src/routes/logout.tsx b/examples/react/start-basic-auth/src/routes/logout.tsx index d072c25008..a7023a1793 100644 --- a/examples/react/start-basic-auth/src/routes/logout.tsx +++ b/examples/react/start-basic-auth/src/routes/logout.tsx @@ -1,4 +1,4 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' import { useAppSession } from '~/utils/session' @@ -12,7 +12,7 @@ const logoutFn = createServerFn().handler(async () => { }) }) -export const Route = createFileRoute('/logout')({ +export const Route = createFileRoute({ preload: false, loader: () => logoutFn(), }) diff --git a/examples/react/start-basic-auth/src/routes/signup.tsx b/examples/react/start-basic-auth/src/routes/signup.tsx index 8f052d3629..a8dbef283b 100644 --- a/examples/react/start-basic-auth/src/routes/signup.tsx +++ b/examples/react/start-basic-auth/src/routes/signup.tsx @@ -1,4 +1,4 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' import { createServerFn, useServerFn } from '@tanstack/react-start' import { hashPassword, prismaClient } from '~/utils/prisma' import { useMutation } from '~/hooks/useMutation' @@ -62,7 +62,7 @@ export const signupFn = createServerFn({ method: 'POST' }) }) }) -export const Route = createFileRoute('/signup')({ +export const Route = createFileRoute({ component: SignupComp, }) diff --git a/e2e/react-start/basic-auth/src/ssr.tsx b/examples/react/start-basic-auth/src/server.ts similarity index 100% rename from e2e/react-start/basic-auth/src/ssr.tsx rename to examples/react/start-basic-auth/src/server.ts diff --git a/examples/react/start-basic-auth/src/ssr.tsx b/examples/react/start-basic-auth/src/ssr.tsx deleted file mode 100644 index 8981a9a338..0000000000 --- a/examples/react/start-basic-auth/src/ssr.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/examples/react/start-basic-auth/vite.config.ts b/examples/react/start-basic-auth/vite.config.ts new file mode 100644 index 0000000000..f451c4b69c --- /dev/null +++ b/examples/react/start-basic-auth/vite.config.ts @@ -0,0 +1,15 @@ +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/examples/react/start-basic-react-query/.gitignore b/examples/react/start-basic-react-query/.gitignore index be342025da..ca63f49885 100644 --- a/examples/react/start-basic-react-query/.gitignore +++ b/examples/react/start-basic-react-query/.gitignore @@ -7,14 +7,10 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ diff --git a/examples/react/start-basic-react-query/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-basic-react-query/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/examples/react/start-basic-react-query/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-basic-react-query/app.config.ts b/examples/react/start-basic-react-query/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/examples/react/start-basic-react-query/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/examples/react/start-basic-react-query/package.json b/examples/react/start-basic-react-query/package.json index 9c27d1a42d..0330ad793b 100644 --- a/examples/react/start-basic-react-query/package.json +++ b/examples/react/start-basic-react-query/package.json @@ -4,9 +4,9 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "dependencies": { "@tanstack/react-query": "^5.66.0", @@ -18,8 +18,7 @@ "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", - "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3" + "tailwind-merge": "^2.6.0" }, "devDependencies": { "@types/node": "^22.5.4", diff --git a/examples/react/start-basic-react-query/src/client.tsx b/examples/react/start-basic-react-query/src/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/examples/react/start-basic-react-query/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/examples/react/start-basic-react-query/src/routeTree.gen.ts b/examples/react/start-basic-react-query/src/routeTree.gen.ts index 4dca20ee9c..6bae8ee83c 100644 --- a/examples/react/start-basic-react-query/src/routeTree.gen.ts +++ b/examples/react/start-basic-react-query/src/routeTree.gen.ts @@ -10,105 +10,105 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as RedirectImport } from './routes/redirect' -import { Route as DeferredImport } from './routes/deferred' -import { Route as PathlessLayoutImport } from './routes/_pathlessLayout' -import { Route as UsersRouteImport } from './routes/users.route' -import { Route as PostsRouteImport } from './routes/posts.route' -import { Route as IndexImport } from './routes/index' -import { Route as UsersIndexImport } from './routes/users.index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as UsersUserIdImport } from './routes/users.$userId' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as PathlessLayoutNestedLayoutImport } from './routes/_pathlessLayout/_nested-layout' -import { Route as PostsPostIdDeepImport } from './routes/posts_.$postId.deep' -import { Route as PathlessLayoutNestedLayoutRouteBImport } from './routes/_pathlessLayout/_nested-layout/route-b' -import { Route as PathlessLayoutNestedLayoutRouteAImport } from './routes/_pathlessLayout/_nested-layout/route-a' +import { Route as RedirectRouteImport } from './routes/redirect' +import { Route as DeferredRouteImport } from './routes/deferred' +import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' +import { Route as UsersRouteRouteImport } from './routes/users.route' +import { Route as PostsRouteRouteImport } from './routes/posts.route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as UsersIndexRouteImport } from './routes/users.index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as UsersUserIdRouteImport } from './routes/users.$userId' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as PathlessLayoutNestedLayoutRouteImport } from './routes/_pathlessLayout/_nested-layout' +import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep' +import { Route as PathlessLayoutNestedLayoutRouteBRouteImport } from './routes/_pathlessLayout/_nested-layout/route-b' +import { Route as PathlessLayoutNestedLayoutRouteARouteImport } from './routes/_pathlessLayout/_nested-layout/route-a' // Create/Update Routes -const RedirectRoute = RedirectImport.update({ +const RedirectRoute = RedirectRouteImport.update({ id: '/redirect', path: '/redirect', getParentRoute: () => rootRoute, } as any) -const DeferredRoute = DeferredImport.update({ +const DeferredRoute = DeferredRouteImport.update({ id: '/deferred', path: '/deferred', getParentRoute: () => rootRoute, } as any) -const PathlessLayoutRoute = PathlessLayoutImport.update({ +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', getParentRoute: () => rootRoute, } as any) -const UsersRouteRoute = UsersRouteImport.update({ +const UsersRouteRoute = UsersRouteRouteImport.update({ id: '/users', path: '/users', getParentRoute: () => rootRoute, } as any) -const PostsRouteRoute = PostsRouteImport.update({ +const PostsRouteRoute = PostsRouteRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const UsersIndexRoute = UsersIndexImport.update({ +const UsersIndexRoute = UsersIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => UsersRouteRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRouteRoute, } as any) -const UsersUserIdRoute = UsersUserIdImport.update({ +const UsersUserIdRoute = UsersUserIdRouteImport.update({ id: '/$userId', path: '/$userId', getParentRoute: () => UsersRouteRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRouteRoute, } as any) -const PathlessLayoutNestedLayoutRoute = PathlessLayoutNestedLayoutImport.update( - { +const PathlessLayoutNestedLayoutRoute = + PathlessLayoutNestedLayoutRouteImport.update({ id: '/_nested-layout', getParentRoute: () => PathlessLayoutRoute, - } as any, -) + } as any) -const PostsPostIdDeepRoute = PostsPostIdDeepImport.update({ +const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ id: '/posts_/$postId/deep', path: '/posts/$postId/deep', getParentRoute: () => rootRoute, } as any) const PathlessLayoutNestedLayoutRouteBRoute = - PathlessLayoutNestedLayoutRouteBImport.update({ + PathlessLayoutNestedLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutNestedLayoutRoute, } as any) const PathlessLayoutNestedLayoutRouteARoute = - PathlessLayoutNestedLayoutRouteAImport.update({ + PathlessLayoutNestedLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutNestedLayoutRoute, @@ -122,103 +122,232 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsRouteRouteImport parentRoute: typeof rootRoute } '/users': { id: '/users' path: '/users' fullPath: '/users' - preLoaderRoute: typeof UsersRouteImport + preLoaderRoute: typeof UsersRouteRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout': { id: '/_pathlessLayout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteImport parentRoute: typeof rootRoute } '/deferred': { id: '/deferred' path: '/deferred' fullPath: '/deferred' - preLoaderRoute: typeof DeferredImport + preLoaderRoute: typeof DeferredRouteImport parentRoute: typeof rootRoute } '/redirect': { id: '/redirect' path: '/redirect' fullPath: '/redirect' - preLoaderRoute: typeof RedirectImport + preLoaderRoute: typeof RedirectRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout/_nested-layout': { id: '/_pathlessLayout/_nested-layout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutNestedLayoutImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteRouteImport } '/users/$userId': { id: '/users/$userId' path: '/$userId' fullPath: '/users/$userId' - preLoaderRoute: typeof UsersUserIdImport - parentRoute: typeof UsersRouteImport + preLoaderRoute: typeof UsersUserIdRouteImport + parentRoute: typeof UsersRouteRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteRouteImport } '/users/': { id: '/users/' path: '/' fullPath: '/users/' - preLoaderRoute: typeof UsersIndexImport - parentRoute: typeof UsersRouteImport + preLoaderRoute: typeof UsersIndexRouteImport + parentRoute: typeof UsersRouteRouteImport } '/_pathlessLayout/_nested-layout/route-a': { id: '/_pathlessLayout/_nested-layout/route-a' path: '/route-a' fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteAImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/_pathlessLayout/_nested-layout/route-b': { id: '/_pathlessLayout/_nested-layout/route-b' path: '/route-b' fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/posts_/$postId/deep': { id: '/posts_/$postId/deep' path: '/posts/$postId/deep' fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepImport + preLoaderRoute: typeof PostsPostIdDeepRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/posts.route' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/users.route' { + const createFileRoute: CreateFileRoute< + '/users', + FileRoutesByPath['/users']['parentRoute'], + FileRoutesByPath['/users']['id'], + FileRoutesByPath['/users']['path'], + FileRoutesByPath['/users']['fullPath'] + > +} +declare module './routes/_pathlessLayout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout', + FileRoutesByPath['/_pathlessLayout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout']['id'], + FileRoutesByPath['/_pathlessLayout']['path'], + FileRoutesByPath['/_pathlessLayout']['fullPath'] + > +} +declare module './routes/deferred' { + const createFileRoute: CreateFileRoute< + '/deferred', + FileRoutesByPath['/deferred']['parentRoute'], + FileRoutesByPath['/deferred']['id'], + FileRoutesByPath['/deferred']['path'], + FileRoutesByPath['/deferred']['fullPath'] + > +} +declare module './routes/redirect' { + const createFileRoute: CreateFileRoute< + '/redirect', + FileRoutesByPath['/redirect']['parentRoute'], + FileRoutesByPath['/redirect']['id'], + FileRoutesByPath['/redirect']['path'], + FileRoutesByPath['/redirect']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout', + FileRoutesByPath['/_pathlessLayout/_nested-layout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/users.$userId' { + const createFileRoute: CreateFileRoute< + '/users/$userId', + FileRoutesByPath['/users/$userId']['parentRoute'], + FileRoutesByPath['/users/$userId']['id'], + FileRoutesByPath['/users/$userId']['path'], + FileRoutesByPath['/users/$userId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/users.index' { + const createFileRoute: CreateFileRoute< + '/users/', + FileRoutesByPath['/users/']['parentRoute'], + FileRoutesByPath['/users/']['id'], + FileRoutesByPath['/users/']['path'], + FileRoutesByPath['/users/']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-a' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-a', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-b' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-b', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['fullPath'] + > +} +declare module './routes/posts_.$postId.deep' { + const createFileRoute: CreateFileRoute< + '/posts_/$postId/deep', + FileRoutesByPath['/posts_/$postId/deep']['parentRoute'], + FileRoutesByPath['/posts_/$postId/deep']['id'], + FileRoutesByPath['/posts_/$postId/deep']['path'], + FileRoutesByPath['/posts_/$postId/deep']['fullPath'] + > +} + // Create and export the route tree interface PostsRouteRouteChildren { @@ -399,6 +528,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/start-basic-react-query/src/routes/_pathlessLayout.tsx b/examples/react/start-basic-react-query/src/routes/_pathlessLayout.tsx index 3353841595..209e478e44 100644 --- a/examples/react/start-basic-react-query/src/routes/_pathlessLayout.tsx +++ b/examples/react/start-basic-react-query/src/routes/_pathlessLayout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: PathlessLayoutComponent, }) diff --git a/examples/react/start-basic-react-query/src/routes/_pathlessLayout/_nested-layout.tsx b/examples/react/start-basic-react-query/src/routes/_pathlessLayout/_nested-layout.tsx index 0dcb1270ad..97f5dc3ea3 100644 --- a/examples/react/start-basic-react-query/src/routes/_pathlessLayout/_nested-layout.tsx +++ b/examples/react/start-basic-react-query/src/routes/_pathlessLayout/_nested-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout/_nested-layout')({ +export const Route = createFileRoute({ component: PathlessLayoutComponent, }) diff --git a/examples/react/start-basic-react-query/src/routes/_pathlessLayout/_nested-layout/route-a.tsx b/examples/react/start-basic-react-query/src/routes/_pathlessLayout/_nested-layout/route-a.tsx index 426a8fe486..a0bd5240b7 100644 --- a/examples/react/start-basic-react-query/src/routes/_pathlessLayout/_nested-layout/route-a.tsx +++ b/examples/react/start-basic-react-query/src/routes/_pathlessLayout/_nested-layout/route-a.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-a')( - { - component: LayoutAComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutAComponent, +}) function LayoutAComponent() { return
I'm A!
diff --git a/examples/react/start-basic-react-query/src/routes/_pathlessLayout/_nested-layout/route-b.tsx b/examples/react/start-basic-react-query/src/routes/_pathlessLayout/_nested-layout/route-b.tsx index 20facf2daf..2864ec1f28 100644 --- a/examples/react/start-basic-react-query/src/routes/_pathlessLayout/_nested-layout/route-b.tsx +++ b/examples/react/start-basic-react-query/src/routes/_pathlessLayout/_nested-layout/route-b.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-b')( - { - component: LayoutBComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutBComponent, +}) function LayoutBComponent() { return
I'm B!
diff --git a/examples/react/start-basic-react-query/src/routes/deferred.tsx b/examples/react/start-basic-react-query/src/routes/deferred.tsx index 666ae26e49..16a9f72593 100644 --- a/examples/react/start-basic-react-query/src/routes/deferred.tsx +++ b/examples/react/start-basic-react-query/src/routes/deferred.tsx @@ -1,5 +1,5 @@ import { queryOptions, useSuspenseQuery } from '@tanstack/react-query' -import { createFileRoute } from '@tanstack/react-router' +import {} from '@tanstack/react-router' import { Suspense, useState } from 'react' const deferredQueryOptions = () => @@ -15,7 +15,7 @@ const deferredQueryOptions = () => }, }) -export const Route = createFileRoute('/deferred')({ +export const Route = createFileRoute({ loader: ({ context }) => { // Kick off loading as early as possible! context.queryClient.prefetchQuery(deferredQueryOptions()) diff --git a/examples/react/start-basic-react-query/src/routes/index.tsx b/examples/react/start-basic-react-query/src/routes/index.tsx index 09a907cb18..f6c5b98b02 100644 --- a/examples/react/start-basic-react-query/src/routes/index.tsx +++ b/examples/react/start-basic-react-query/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/react/start-basic-react-query/src/routes/posts.$postId.tsx b/examples/react/start-basic-react-query/src/routes/posts.$postId.tsx index 542a12a9f6..e8098c4a2f 100644 --- a/examples/react/start-basic-react-query/src/routes/posts.$postId.tsx +++ b/examples/react/start-basic-react-query/src/routes/posts.$postId.tsx @@ -1,10 +1,10 @@ -import { ErrorComponent, Link, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent, Link } from '@tanstack/react-router' import { useSuspenseQuery } from '@tanstack/react-query' import { postQueryOptions } from '../utils/posts' import type { ErrorComponentProps } from '@tanstack/react-router' import { NotFound } from '~/components/NotFound' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId }, context }) => { const data = await context.queryClient.ensureQueryData( postQueryOptions(postId), @@ -42,7 +42,7 @@ function PostComponent() { postId: postQuery.data.id, }} activeProps={{ className: 'text-black font-bold' }} - className="block py-1 text-blue-800 hover:text-blue-600" + className="inline-block py-1 text-blue-800 hover:text-blue-600" > Deep View diff --git a/examples/react/start-basic-react-query/src/routes/posts.index.tsx b/examples/react/start-basic-react-query/src/routes/posts.index.tsx index 5b5f08f95b..13529228bb 100644 --- a/examples/react/start-basic-react-query/src/routes/posts.index.tsx +++ b/examples/react/start-basic-react-query/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/react/start-basic-react-query/src/routes/posts.route.tsx b/examples/react/start-basic-react-query/src/routes/posts.route.tsx index b545663be2..4fbfb471c1 100644 --- a/examples/react/start-basic-react-query/src/routes/posts.route.tsx +++ b/examples/react/start-basic-react-query/src/routes/posts.route.tsx @@ -1,8 +1,8 @@ import { useSuspenseQuery } from '@tanstack/react-query' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { postsQueryOptions } from '../utils/posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: async ({ context }) => { await context.queryClient.ensureQueryData(postsQueryOptions()) }, diff --git a/examples/react/start-basic-react-query/src/routes/posts_.$postId.deep.tsx b/examples/react/start-basic-react-query/src/routes/posts_.$postId.deep.tsx index 33f6475a55..4d91776273 100644 --- a/examples/react/start-basic-react-query/src/routes/posts_.$postId.deep.tsx +++ b/examples/react/start-basic-react-query/src/routes/posts_.$postId.deep.tsx @@ -1,9 +1,9 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import { useSuspenseQuery } from '@tanstack/react-query' import { postQueryOptions } from '../utils/posts' import { PostErrorComponent } from './posts.$postId' -export const Route = createFileRoute('/posts_/$postId/deep')({ +export const Route = createFileRoute({ loader: async ({ params: { postId }, context }) => { const data = await context.queryClient.ensureQueryData( postQueryOptions(postId), diff --git a/examples/react/start-basic-react-query/src/routes/redirect.tsx b/examples/react/start-basic-react-query/src/routes/redirect.tsx index c9286de13d..68a98d5683 100644 --- a/examples/react/start-basic-react-query/src/routes/redirect.tsx +++ b/examples/react/start-basic-react-query/src/routes/redirect.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' -export const Route = createFileRoute('/redirect')({ +export const Route = createFileRoute({ beforeLoad: async () => { throw redirect({ to: '/posts', diff --git a/examples/react/start-basic-react-query/src/routes/users.$userId.tsx b/examples/react/start-basic-react-query/src/routes/users.$userId.tsx index 0750a01568..176be186e0 100644 --- a/examples/react/start-basic-react-query/src/routes/users.$userId.tsx +++ b/examples/react/start-basic-react-query/src/routes/users.$userId.tsx @@ -1,10 +1,10 @@ import { useSuspenseQuery } from '@tanstack/react-query' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import type { ErrorComponentProps } from '@tanstack/react-router' import { NotFound } from '~/components/NotFound' import { userQueryOptions } from '~/utils/users' -export const Route = createFileRoute('/users/$userId')({ +export const Route = createFileRoute({ loader: async ({ context, params: { userId } }) => { await context.queryClient.ensureQueryData(userQueryOptions(userId)) }, diff --git a/examples/react/start-basic-react-query/src/routes/users.index.tsx b/examples/react/start-basic-react-query/src/routes/users.index.tsx index b6b0ee67fb..662e8b6c68 100644 --- a/examples/react/start-basic-react-query/src/routes/users.index.tsx +++ b/examples/react/start-basic-react-query/src/routes/users.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/users/')({ +export const Route = createFileRoute({ component: UsersIndexComponent, }) diff --git a/examples/react/start-basic-react-query/src/routes/users.route.tsx b/examples/react/start-basic-react-query/src/routes/users.route.tsx index 2f3c72cb7b..80ce468130 100644 --- a/examples/react/start-basic-react-query/src/routes/users.route.tsx +++ b/examples/react/start-basic-react-query/src/routes/users.route.tsx @@ -1,8 +1,8 @@ import { useSuspenseQuery } from '@tanstack/react-query' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { usersQueryOptions } from '../utils/users' -export const Route = createFileRoute('/users')({ +export const Route = createFileRoute({ loader: async ({ context }) => { await context.queryClient.ensureQueryData(usersQueryOptions()) }, diff --git a/e2e/react-start/basic-react-query/src/ssr.tsx b/examples/react/start-basic-react-query/src/server.ts similarity index 100% rename from e2e/react-start/basic-react-query/src/ssr.tsx rename to examples/react/start-basic-react-query/src/server.ts diff --git a/examples/react/start-basic-react-query/src/ssr.tsx b/examples/react/start-basic-react-query/src/ssr.tsx deleted file mode 100644 index 8981a9a338..0000000000 --- a/examples/react/start-basic-react-query/src/ssr.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/examples/react/start-basic-react-query/vite.config.ts b/examples/react/start-basic-react-query/vite.config.ts new file mode 100644 index 0000000000..f451c4b69c --- /dev/null +++ b/examples/react/start-basic-react-query/vite.config.ts @@ -0,0 +1,15 @@ +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/examples/react/start-basic-rsc/.gitignore b/examples/react/start-basic-rsc/.gitignore index d3387e00cd..3c8e6870b3 100644 --- a/examples/react/start-basic-rsc/.gitignore +++ b/examples/react/start-basic-rsc/.gitignore @@ -7,12 +7,8 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin diff --git a/examples/react/start-basic-rsc/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-basic-rsc/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/examples/react/start-basic-rsc/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-basic-rsc/app.config.ts b/examples/react/start-basic-rsc/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/examples/react/start-basic-rsc/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/examples/react/start-basic-rsc/package.json b/examples/react/start-basic-rsc/package.json index e526759a5b..48e4b6b5b8 100644 --- a/examples/react/start-basic-rsc/package.json +++ b/examples/react/start-basic-rsc/package.json @@ -4,9 +4,9 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "dependencies": { "@babel/plugin-syntax-typescript": "^7.25.9", @@ -16,8 +16,7 @@ "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", - "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3" + "tailwind-merge": "^2.6.0" }, "devDependencies": { "@types/react": "^19.0.8", diff --git a/examples/react/start-basic-rsc/src/client.tsx b/examples/react/start-basic-rsc/src/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/examples/react/start-basic-rsc/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/examples/react/start-basic-rsc/src/routeTree.gen.ts b/examples/react/start-basic-rsc/src/routeTree.gen.ts index 1465b03fd1..d8a5ca6b14 100644 --- a/examples/react/start-basic-rsc/src/routeTree.gen.ts +++ b/examples/react/start-basic-rsc/src/routeTree.gen.ts @@ -10,70 +10,70 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostsImport } from './routes/posts' -import { Route as PathlessLayoutImport } from './routes/_pathlessLayout' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as PathlessLayoutNestedLayoutImport } from './routes/_pathlessLayout/_nested-layout' -import { Route as PostsPostIdDeepImport } from './routes/posts_.$postId.deep' -import { Route as PathlessLayoutNestedLayoutRouteBImport } from './routes/_pathlessLayout/_nested-layout/route-b' -import { Route as PathlessLayoutNestedLayoutRouteAImport } from './routes/_pathlessLayout/_nested-layout/route-a' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as PathlessLayoutNestedLayoutRouteImport } from './routes/_pathlessLayout/_nested-layout' +import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep' +import { Route as PathlessLayoutNestedLayoutRouteBRouteImport } from './routes/_pathlessLayout/_nested-layout/route-b' +import { Route as PathlessLayoutNestedLayoutRouteARouteImport } from './routes/_pathlessLayout/_nested-layout/route-a' // Create/Update Routes -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const PathlessLayoutRoute = PathlessLayoutImport.update({ +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const PathlessLayoutNestedLayoutRoute = PathlessLayoutNestedLayoutImport.update( - { +const PathlessLayoutNestedLayoutRoute = + PathlessLayoutNestedLayoutRouteImport.update({ id: '/_nested-layout', getParentRoute: () => PathlessLayoutRoute, - } as any, -) + } as any) -const PostsPostIdDeepRoute = PostsPostIdDeepImport.update({ +const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ id: '/posts_/$postId/deep', path: '/posts/$postId/deep', getParentRoute: () => rootRoute, } as any) const PathlessLayoutNestedLayoutRouteBRoute = - PathlessLayoutNestedLayoutRouteBImport.update({ + PathlessLayoutNestedLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutNestedLayoutRoute, } as any) const PathlessLayoutNestedLayoutRouteARoute = - PathlessLayoutNestedLayoutRouteAImport.update({ + PathlessLayoutNestedLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutNestedLayoutRoute, @@ -87,68 +87,152 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout': { id: '/_pathlessLayout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout/_nested-layout': { id: '/_pathlessLayout/_nested-layout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutNestedLayoutImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/_pathlessLayout/_nested-layout/route-a': { id: '/_pathlessLayout/_nested-layout/route-a' path: '/route-a' fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteAImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/_pathlessLayout/_nested-layout/route-b': { id: '/_pathlessLayout/_nested-layout/route-b' path: '/route-b' fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/posts_/$postId/deep': { id: '/posts_/$postId/deep' path: '/posts/$postId/deep' fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepImport + preLoaderRoute: typeof PostsPostIdDeepRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_pathlessLayout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout', + FileRoutesByPath['/_pathlessLayout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout']['id'], + FileRoutesByPath['/_pathlessLayout']['path'], + FileRoutesByPath['/_pathlessLayout']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout', + FileRoutesByPath['/_pathlessLayout/_nested-layout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-a' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-a', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-b' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-b', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['fullPath'] + > +} +declare module './routes/posts_.$postId.deep' { + const createFileRoute: CreateFileRoute< + '/posts_/$postId/deep', + FileRoutesByPath['/posts_/$postId/deep']['parentRoute'], + FileRoutesByPath['/posts_/$postId/deep']['id'], + FileRoutesByPath['/posts_/$postId/deep']['path'], + FileRoutesByPath['/posts_/$postId/deep']['fullPath'] + > +} + // Create and export the route tree interface PathlessLayoutNestedLayoutRouteChildren { @@ -279,6 +363,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/start-basic-rsc/src/routes/_pathlessLayout.tsx b/examples/react/start-basic-rsc/src/routes/_pathlessLayout.tsx index c3b12442b8..5c4a461d8d 100644 --- a/examples/react/start-basic-rsc/src/routes/_pathlessLayout.tsx +++ b/examples/react/start-basic-rsc/src/routes/_pathlessLayout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/start-basic-rsc/src/routes/_pathlessLayout/_nested-layout.tsx b/examples/react/start-basic-rsc/src/routes/_pathlessLayout/_nested-layout.tsx index c5bcffd5a4..abd82a2bf6 100644 --- a/examples/react/start-basic-rsc/src/routes/_pathlessLayout/_nested-layout.tsx +++ b/examples/react/start-basic-rsc/src/routes/_pathlessLayout/_nested-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout/_nested-layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/start-basic-rsc/src/routes/_pathlessLayout/_nested-layout/route-a.tsx b/examples/react/start-basic-rsc/src/routes/_pathlessLayout/_nested-layout/route-a.tsx index 426a8fe486..a0bd5240b7 100644 --- a/examples/react/start-basic-rsc/src/routes/_pathlessLayout/_nested-layout/route-a.tsx +++ b/examples/react/start-basic-rsc/src/routes/_pathlessLayout/_nested-layout/route-a.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-a')( - { - component: LayoutAComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutAComponent, +}) function LayoutAComponent() { return
I'm A!
diff --git a/examples/react/start-basic-rsc/src/routes/_pathlessLayout/_nested-layout/route-b.tsx b/examples/react/start-basic-rsc/src/routes/_pathlessLayout/_nested-layout/route-b.tsx index 20facf2daf..2864ec1f28 100644 --- a/examples/react/start-basic-rsc/src/routes/_pathlessLayout/_nested-layout/route-b.tsx +++ b/examples/react/start-basic-rsc/src/routes/_pathlessLayout/_nested-layout/route-b.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-b')( - { - component: LayoutBComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutBComponent, +}) function LayoutBComponent() { return
I'm B!
diff --git a/examples/react/start-basic-rsc/src/routes/index.tsx b/examples/react/start-basic-rsc/src/routes/index.tsx index b7b6138529..a693dcbf14 100644 --- a/examples/react/start-basic-rsc/src/routes/index.tsx +++ b/examples/react/start-basic-rsc/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/react/start-basic-rsc/src/routes/posts.$postId.tsx b/examples/react/start-basic-rsc/src/routes/posts.$postId.tsx index 5404a690a0..736bb2499d 100644 --- a/examples/react/start-basic-rsc/src/routes/posts.$postId.tsx +++ b/examples/react/start-basic-rsc/src/routes/posts.$postId.tsx @@ -1,4 +1,4 @@ -import { ErrorComponent, Link, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent, Link } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' import { fetchPost } from '../utils/posts' import type { ErrorComponentProps } from '@tanstack/react-router' @@ -27,7 +27,7 @@ const renderPost = createServerFn({ method: 'GET' }) ) }) -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => renderPost({ data: postId }), errorComponent: PostErrorComponent, component: PostComponent, diff --git a/examples/react/start-basic-rsc/src/routes/posts.index.tsx b/examples/react/start-basic-rsc/src/routes/posts.index.tsx index 5b5f08f95b..13529228bb 100644 --- a/examples/react/start-basic-rsc/src/routes/posts.index.tsx +++ b/examples/react/start-basic-rsc/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/react/start-basic-rsc/src/routes/posts.tsx b/examples/react/start-basic-rsc/src/routes/posts.tsx index a3ef2a2e20..131cec4b9b 100644 --- a/examples/react/start-basic-rsc/src/routes/posts.tsx +++ b/examples/react/start-basic-rsc/src/routes/posts.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' import { createServerFn, renderRsc } from '@tanstack/react-start' import { renderPosts } from '~/utils/renderPosts' @@ -6,7 +5,7 @@ export const serverRenderPosts = createServerFn({ method: 'GET' }).handler( renderPosts, ) -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: async () => serverRenderPosts(), component: PostsComponent, }) diff --git a/examples/react/start-basic-rsc/src/routes/posts_.$postId.deep.tsx b/examples/react/start-basic-rsc/src/routes/posts_.$postId.deep.tsx index 13d368cf9c..bf2edef3c9 100644 --- a/examples/react/start-basic-rsc/src/routes/posts_.$postId.deep.tsx +++ b/examples/react/start-basic-rsc/src/routes/posts_.$postId.deep.tsx @@ -1,8 +1,8 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import { fetchPost } from '../utils/posts' import { PostErrorComponent } from './posts.$postId' -export const Route = createFileRoute('/posts_/$postId/deep')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent, component: PostDeepComponent, diff --git a/e2e/react-start/basic-rsc/src/ssr.tsx b/examples/react/start-basic-rsc/src/server.ts similarity index 100% rename from e2e/react-start/basic-rsc/src/ssr.tsx rename to examples/react/start-basic-rsc/src/server.ts diff --git a/examples/react/start-basic-rsc/src/ssr.tsx b/examples/react/start-basic-rsc/src/ssr.tsx deleted file mode 100644 index 8981a9a338..0000000000 --- a/examples/react/start-basic-rsc/src/ssr.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/examples/react/start-basic-rsc/vite.config.ts b/examples/react/start-basic-rsc/vite.config.ts new file mode 100644 index 0000000000..f451c4b69c --- /dev/null +++ b/examples/react/start-basic-rsc/vite.config.ts @@ -0,0 +1,15 @@ +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/examples/react/start-basic-static/.gitignore b/examples/react/start-basic-static/.gitignore index be342025da..ca63f49885 100644 --- a/examples/react/start-basic-static/.gitignore +++ b/examples/react/start-basic-static/.gitignore @@ -7,14 +7,10 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ diff --git a/examples/react/start-basic-static/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-basic-static/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/examples/react/start-basic-static/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-basic-static/app.config.ts b/examples/react/start-basic-static/app.config.ts deleted file mode 100644 index e6854562f8..0000000000 --- a/examples/react/start-basic-static/app.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, - server: { - preset: 'netlify', - prerender: { - routes: ['/'], - crawlLinks: true, - }, - }, -}) diff --git a/examples/react/start-basic-static/package.json b/examples/react/start-basic-static/package.json index 5481062895..52b94fa281 100644 --- a/examples/react/start-basic-static/package.json +++ b/examples/react/start-basic-static/package.json @@ -4,9 +4,9 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "dependencies": { "@tanstack/react-router": "^1.120.3", @@ -15,8 +15,7 @@ "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", - "tailwind-merge": "^2.5.5", - "vinxi": "0.5.1" + "tailwind-merge": "^2.5.5" }, "devDependencies": { "@types/node": "^22.5.4", diff --git a/examples/react/start-basic-static/src/client.tsx b/examples/react/start-basic-static/src/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/examples/react/start-basic-static/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/examples/react/start-basic-static/src/routeTree.gen.ts b/examples/react/start-basic-static/src/routeTree.gen.ts index 762ce1516f..6a5cb97e5e 100644 --- a/examples/react/start-basic-static/src/routeTree.gen.ts +++ b/examples/react/start-basic-static/src/routeTree.gen.ts @@ -10,105 +10,105 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as UsersImport } from './routes/users' -import { Route as RedirectImport } from './routes/redirect' -import { Route as PostsImport } from './routes/posts' -import { Route as DeferredImport } from './routes/deferred' -import { Route as PathlessLayoutImport } from './routes/_pathlessLayout' -import { Route as IndexImport } from './routes/index' -import { Route as UsersIndexImport } from './routes/users.index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as UsersUserIdImport } from './routes/users.$userId' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as PathlessLayoutNestedLayoutImport } from './routes/_pathlessLayout/_nested-layout' -import { Route as PostsPostIdDeepImport } from './routes/posts_.$postId.deep' -import { Route as PathlessLayoutNestedLayoutRouteBImport } from './routes/_pathlessLayout/_nested-layout/route-b' -import { Route as PathlessLayoutNestedLayoutRouteAImport } from './routes/_pathlessLayout/_nested-layout/route-a' +import { Route as UsersRouteImport } from './routes/users' +import { Route as RedirectRouteImport } from './routes/redirect' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as DeferredRouteImport } from './routes/deferred' +import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as UsersIndexRouteImport } from './routes/users.index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as UsersUserIdRouteImport } from './routes/users.$userId' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as PathlessLayoutNestedLayoutRouteImport } from './routes/_pathlessLayout/_nested-layout' +import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep' +import { Route as PathlessLayoutNestedLayoutRouteBRouteImport } from './routes/_pathlessLayout/_nested-layout/route-b' +import { Route as PathlessLayoutNestedLayoutRouteARouteImport } from './routes/_pathlessLayout/_nested-layout/route-a' // Create/Update Routes -const UsersRoute = UsersImport.update({ +const UsersRoute = UsersRouteImport.update({ id: '/users', path: '/users', getParentRoute: () => rootRoute, } as any) -const RedirectRoute = RedirectImport.update({ +const RedirectRoute = RedirectRouteImport.update({ id: '/redirect', path: '/redirect', getParentRoute: () => rootRoute, } as any) -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const DeferredRoute = DeferredImport.update({ +const DeferredRoute = DeferredRouteImport.update({ id: '/deferred', path: '/deferred', getParentRoute: () => rootRoute, } as any) -const PathlessLayoutRoute = PathlessLayoutImport.update({ +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const UsersIndexRoute = UsersIndexImport.update({ +const UsersIndexRoute = UsersIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => UsersRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const UsersUserIdRoute = UsersUserIdImport.update({ +const UsersUserIdRoute = UsersUserIdRouteImport.update({ id: '/$userId', path: '/$userId', getParentRoute: () => UsersRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const PathlessLayoutNestedLayoutRoute = PathlessLayoutNestedLayoutImport.update( - { +const PathlessLayoutNestedLayoutRoute = + PathlessLayoutNestedLayoutRouteImport.update({ id: '/_nested-layout', getParentRoute: () => PathlessLayoutRoute, - } as any, -) + } as any) -const PostsPostIdDeepRoute = PostsPostIdDeepImport.update({ +const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ id: '/posts_/$postId/deep', path: '/posts/$postId/deep', getParentRoute: () => rootRoute, } as any) const PathlessLayoutNestedLayoutRouteBRoute = - PathlessLayoutNestedLayoutRouteBImport.update({ + PathlessLayoutNestedLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutNestedLayoutRoute, } as any) const PathlessLayoutNestedLayoutRouteARoute = - PathlessLayoutNestedLayoutRouteAImport.update({ + PathlessLayoutNestedLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutNestedLayoutRoute, @@ -122,103 +122,232 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout': { id: '/_pathlessLayout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteImport parentRoute: typeof rootRoute } '/deferred': { id: '/deferred' path: '/deferred' fullPath: '/deferred' - preLoaderRoute: typeof DeferredImport + preLoaderRoute: typeof DeferredRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/redirect': { id: '/redirect' path: '/redirect' fullPath: '/redirect' - preLoaderRoute: typeof RedirectImport + preLoaderRoute: typeof RedirectRouteImport parentRoute: typeof rootRoute } '/users': { id: '/users' path: '/users' fullPath: '/users' - preLoaderRoute: typeof UsersImport + preLoaderRoute: typeof UsersRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout/_nested-layout': { id: '/_pathlessLayout/_nested-layout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutNestedLayoutImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/users/$userId': { id: '/users/$userId' path: '/$userId' fullPath: '/users/$userId' - preLoaderRoute: typeof UsersUserIdImport - parentRoute: typeof UsersImport + preLoaderRoute: typeof UsersUserIdRouteImport + parentRoute: typeof UsersRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/users/': { id: '/users/' path: '/' fullPath: '/users/' - preLoaderRoute: typeof UsersIndexImport - parentRoute: typeof UsersImport + preLoaderRoute: typeof UsersIndexRouteImport + parentRoute: typeof UsersRouteImport } '/_pathlessLayout/_nested-layout/route-a': { id: '/_pathlessLayout/_nested-layout/route-a' path: '/route-a' fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteAImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/_pathlessLayout/_nested-layout/route-b': { id: '/_pathlessLayout/_nested-layout/route-b' path: '/route-b' fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/posts_/$postId/deep': { id: '/posts_/$postId/deep' path: '/posts/$postId/deep' fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepImport + preLoaderRoute: typeof PostsPostIdDeepRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_pathlessLayout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout', + FileRoutesByPath['/_pathlessLayout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout']['id'], + FileRoutesByPath['/_pathlessLayout']['path'], + FileRoutesByPath['/_pathlessLayout']['fullPath'] + > +} +declare module './routes/deferred' { + const createFileRoute: CreateFileRoute< + '/deferred', + FileRoutesByPath['/deferred']['parentRoute'], + FileRoutesByPath['/deferred']['id'], + FileRoutesByPath['/deferred']['path'], + FileRoutesByPath['/deferred']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/redirect' { + const createFileRoute: CreateFileRoute< + '/redirect', + FileRoutesByPath['/redirect']['parentRoute'], + FileRoutesByPath['/redirect']['id'], + FileRoutesByPath['/redirect']['path'], + FileRoutesByPath['/redirect']['fullPath'] + > +} +declare module './routes/users' { + const createFileRoute: CreateFileRoute< + '/users', + FileRoutesByPath['/users']['parentRoute'], + FileRoutesByPath['/users']['id'], + FileRoutesByPath['/users']['path'], + FileRoutesByPath['/users']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout', + FileRoutesByPath['/_pathlessLayout/_nested-layout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/users.$userId' { + const createFileRoute: CreateFileRoute< + '/users/$userId', + FileRoutesByPath['/users/$userId']['parentRoute'], + FileRoutesByPath['/users/$userId']['id'], + FileRoutesByPath['/users/$userId']['path'], + FileRoutesByPath['/users/$userId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/users.index' { + const createFileRoute: CreateFileRoute< + '/users/', + FileRoutesByPath['/users/']['parentRoute'], + FileRoutesByPath['/users/']['id'], + FileRoutesByPath['/users/']['path'], + FileRoutesByPath['/users/']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-a' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-a', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-b' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-b', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['fullPath'] + > +} +declare module './routes/posts_.$postId.deep' { + const createFileRoute: CreateFileRoute< + '/posts_/$postId/deep', + FileRoutesByPath['/posts_/$postId/deep']['parentRoute'], + FileRoutesByPath['/posts_/$postId/deep']['id'], + FileRoutesByPath['/posts_/$postId/deep']['path'], + FileRoutesByPath['/posts_/$postId/deep']['fullPath'] + > +} + // Create and export the route tree interface PathlessLayoutNestedLayoutRouteChildren { @@ -395,6 +524,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/start-basic-static/src/routes/_pathlessLayout.tsx b/examples/react/start-basic-static/src/routes/_pathlessLayout.tsx index 29d3477145..ed5b364c94 100644 --- a/examples/react/start-basic-static/src/routes/_pathlessLayout.tsx +++ b/examples/react/start-basic-static/src/routes/_pathlessLayout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: PathlessLayoutComponent, }) diff --git a/examples/react/start-basic-static/src/routes/_pathlessLayout/_nested-layout.tsx b/examples/react/start-basic-static/src/routes/_pathlessLayout/_nested-layout.tsx index 9a48b73a46..1e1400f5a7 100644 --- a/examples/react/start-basic-static/src/routes/_pathlessLayout/_nested-layout.tsx +++ b/examples/react/start-basic-static/src/routes/_pathlessLayout/_nested-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout/_nested-layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/start-basic-static/src/routes/_pathlessLayout/_nested-layout/route-a.tsx b/examples/react/start-basic-static/src/routes/_pathlessLayout/_nested-layout/route-a.tsx index 426a8fe486..a0bd5240b7 100644 --- a/examples/react/start-basic-static/src/routes/_pathlessLayout/_nested-layout/route-a.tsx +++ b/examples/react/start-basic-static/src/routes/_pathlessLayout/_nested-layout/route-a.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-a')( - { - component: LayoutAComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutAComponent, +}) function LayoutAComponent() { return
I'm A!
diff --git a/examples/react/start-basic-static/src/routes/_pathlessLayout/_nested-layout/route-b.tsx b/examples/react/start-basic-static/src/routes/_pathlessLayout/_nested-layout/route-b.tsx index 20facf2daf..2864ec1f28 100644 --- a/examples/react/start-basic-static/src/routes/_pathlessLayout/_nested-layout/route-b.tsx +++ b/examples/react/start-basic-static/src/routes/_pathlessLayout/_nested-layout/route-b.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-b')( - { - component: LayoutBComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutBComponent, +}) function LayoutBComponent() { return
I'm B!
diff --git a/examples/react/start-basic-static/src/routes/deferred.tsx b/examples/react/start-basic-static/src/routes/deferred.tsx index e59a871e7b..f99f2236fb 100644 --- a/examples/react/start-basic-static/src/routes/deferred.tsx +++ b/examples/react/start-basic-static/src/routes/deferred.tsx @@ -1,4 +1,4 @@ -import { Await, createFileRoute } from '@tanstack/react-router' +import { Await } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' import { Suspense, useState } from 'react' @@ -15,7 +15,7 @@ const slowServerFn = createServerFn({ method: 'GET', type: 'static' }) return { name, randomNumber: Math.floor(Math.random() * 100) } }) -export const Route = createFileRoute('/deferred')({ +export const Route = createFileRoute({ loader: async () => { return { deferredStuff: new Promise((r) => diff --git a/examples/react/start-basic-static/src/routes/index.tsx b/examples/react/start-basic-static/src/routes/index.tsx index 09a907cb18..f6c5b98b02 100644 --- a/examples/react/start-basic-static/src/routes/index.tsx +++ b/examples/react/start-basic-static/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/react/start-basic-static/src/routes/posts.$postId.tsx b/examples/react/start-basic-static/src/routes/posts.$postId.tsx index 0d4d2de8eb..821c8b5fa9 100644 --- a/examples/react/start-basic-static/src/routes/posts.$postId.tsx +++ b/examples/react/start-basic-static/src/routes/posts.$postId.tsx @@ -1,9 +1,9 @@ -import { ErrorComponent, Link, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent, Link } from '@tanstack/react-router' import { fetchPost } from '../utils/posts' import type { ErrorComponentProps } from '@tanstack/react-router' import { NotFound } from '~/components/NotFound' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: ({ params: { postId } }) => fetchPost({ data: postId }), errorComponent: PostErrorComponent, component: PostComponent, @@ -29,7 +29,7 @@ function PostComponent() { postId: post.id, }} activeProps={{ className: 'text-black font-bold' }} - className="block py-1 text-blue-800 hover:text-blue-600" + className="inline-block py-1 text-blue-800 hover:text-blue-600" > Deep View diff --git a/examples/react/start-basic-static/src/routes/posts.index.tsx b/examples/react/start-basic-static/src/routes/posts.index.tsx index 5b5f08f95b..13529228bb 100644 --- a/examples/react/start-basic-static/src/routes/posts.index.tsx +++ b/examples/react/start-basic-static/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/react/start-basic-static/src/routes/posts.tsx b/examples/react/start-basic-static/src/routes/posts.tsx index ae49032459..5bcd320911 100644 --- a/examples/react/start-basic-static/src/routes/posts.tsx +++ b/examples/react/start-basic-static/src/routes/posts.tsx @@ -1,7 +1,7 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../utils/posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: async () => fetchPosts(), component: PostsComponent, }) diff --git a/examples/react/start-basic-static/src/routes/posts_.$postId.deep.tsx b/examples/react/start-basic-static/src/routes/posts_.$postId.deep.tsx index a82d2e3211..a26a03b7b8 100644 --- a/examples/react/start-basic-static/src/routes/posts_.$postId.deep.tsx +++ b/examples/react/start-basic-static/src/routes/posts_.$postId.deep.tsx @@ -1,8 +1,8 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import { fetchPost } from '../utils/posts' import { PostErrorComponent } from './posts.$postId' -export const Route = createFileRoute('/posts_/$postId/deep')({ +export const Route = createFileRoute({ loader: ({ params: { postId } }) => fetchPost({ data: postId, diff --git a/examples/react/start-basic-static/src/routes/redirect.tsx b/examples/react/start-basic-static/src/routes/redirect.tsx index c9286de13d..68a98d5683 100644 --- a/examples/react/start-basic-static/src/routes/redirect.tsx +++ b/examples/react/start-basic-static/src/routes/redirect.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' -export const Route = createFileRoute('/redirect')({ +export const Route = createFileRoute({ beforeLoad: async () => { throw redirect({ to: '/posts', diff --git a/examples/react/start-basic-static/src/routes/users.$userId.tsx b/examples/react/start-basic-static/src/routes/users.$userId.tsx index d166885e29..b7066bd00d 100644 --- a/examples/react/start-basic-static/src/routes/users.$userId.tsx +++ b/examples/react/start-basic-static/src/routes/users.$userId.tsx @@ -1,4 +1,4 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import axios from 'redaxios' import { createServerFn } from '@tanstack/react-start' import type { ErrorComponentProps } from '@tanstack/react-router' @@ -20,7 +20,7 @@ const fetchUser = createServerFn({ method: 'GET', type: 'static' }) }) }) -export const Route = createFileRoute('/users/$userId')({ +export const Route = createFileRoute({ loader: ({ params: { userId } }) => fetchUser({ data: userId }), errorComponent: UserErrorComponent, component: UserComponent, diff --git a/examples/react/start-basic-static/src/routes/users.index.tsx b/examples/react/start-basic-static/src/routes/users.index.tsx index b6b0ee67fb..662e8b6c68 100644 --- a/examples/react/start-basic-static/src/routes/users.index.tsx +++ b/examples/react/start-basic-static/src/routes/users.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/users/')({ +export const Route = createFileRoute({ component: UsersIndexComponent, }) diff --git a/examples/react/start-basic-static/src/routes/users.tsx b/examples/react/start-basic-static/src/routes/users.tsx index 95eeacaf63..8799830d36 100644 --- a/examples/react/start-basic-static/src/routes/users.tsx +++ b/examples/react/start-basic-static/src/routes/users.tsx @@ -1,4 +1,4 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import axios from 'redaxios' import { createServerFn } from '@tanstack/react-start' import type { User } from '../utils/users' @@ -16,7 +16,7 @@ const fetchUsers = createServerFn({ method: 'GET', type: 'static' }).handler( }, ) -export const Route = createFileRoute('/users')({ +export const Route = createFileRoute({ loader: async () => fetchUsers(), component: UsersComponent, }) diff --git a/e2e/react-start/scroll-restoration/src/ssr.tsx b/examples/react/start-basic-static/src/server.ts similarity index 100% rename from e2e/react-start/scroll-restoration/src/ssr.tsx rename to examples/react/start-basic-static/src/server.ts diff --git a/examples/react/start-basic-static/src/ssr.tsx b/examples/react/start-basic-static/src/ssr.tsx deleted file mode 100644 index 8981a9a338..0000000000 --- a/examples/react/start-basic-static/src/ssr.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/examples/react/start-basic-static/src/utils/loggingMiddleware.tsx b/examples/react/start-basic-static/src/utils/loggingMiddleware.tsx index e64b1516da..80ef49b306 100644 --- a/examples/react/start-basic-static/src/utils/loggingMiddleware.tsx +++ b/examples/react/start-basic-static/src/utils/loggingMiddleware.tsx @@ -1,8 +1,8 @@ import { createMiddleware } from '@tanstack/react-start' -export const logMiddleware = createMiddleware() +export const logMiddleware = createMiddleware({ type: 'function' }) .middleware([ - createMiddleware() + createMiddleware({ type: 'function' }) .client(async (ctx) => { const clientTime = new Date() diff --git a/examples/react/start-basic-static/vite.config.ts b/examples/react/start-basic-static/vite.config.ts new file mode 100644 index 0000000000..570d9aa204 --- /dev/null +++ b/examples/react/start-basic-static/vite.config.ts @@ -0,0 +1,19 @@ +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin({ + prerender: { + enabled: true, + }, + }), + ], +}) diff --git a/examples/react/start-basic/.gitignore b/examples/react/start-basic/.gitignore index be342025da..0bb5a583db 100644 --- a/examples/react/start-basic/.gitignore +++ b/examples/react/start-basic/.gitignore @@ -7,16 +7,14 @@ yarn.lock .env .vercel .output -.vinxi - +.nitro /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ /blob-report/ /playwright/.cache/ +.tanstack-start/build \ No newline at end of file diff --git a/examples/react/start-basic/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-basic/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..7972e1ecfd --- /dev/null +++ b/examples/react/start-basic/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,187 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +import { ServerRoute as CustomScriptDotjsRouteImport } from './../../src/routes/customScript[.]js' +import { ServerRoute as ApiUsersRouteImport } from './../../src/routes/api/users' +import { ServerRoute as ApiUsersUserIdRouteImport } from './../../src/routes/api/users.$userId' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +const CustomScriptDotjsRoute = CustomScriptDotjsRouteImport.update({ + id: '/customScript.js', + path: '/customScript.js', + getParentRoute: () => rootRoute, +} as any) + +const ApiUsersRoute = ApiUsersRouteImport.update({ + id: '/api/users', + path: '/api/users', + getParentRoute: () => rootRoute, +} as any) + +const ApiUsersUserIdRoute = ApiUsersUserIdRouteImport.update({ + id: '/$userId', + path: '/$userId', + getParentRoute: () => ApiUsersRoute, +} as any) + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath { + '/customScript.js': { + id: '/customScript.js' + path: '/customScript.js' + fullPath: '/customScript.js' + preLoaderRoute: typeof CustomScriptDotjsRouteImport + parentRoute: typeof rootRoute + } + '/api/users': { + id: '/api/users' + path: '/api/users' + fullPath: '/api/users' + preLoaderRoute: typeof ApiUsersRouteImport + parentRoute: typeof rootRoute + } + '/api/users/$userId': { + id: '/api/users/$userId' + path: '/$userId' + fullPath: '/api/users/$userId' + preLoaderRoute: typeof ApiUsersUserIdRouteImport + parentRoute: typeof ApiUsersRouteImport + } + } +} + +// Add type-safety to the createFileRoute function across the route tree + +declare module './../../src/routes/customScript[.]js' { + const createServerFileRoute: CreateServerFileRoute< + FileRoutesByPath['/customScript.js']['parentRoute'], + FileRoutesByPath['/customScript.js']['id'], + FileRoutesByPath['/customScript.js']['path'], + FileRoutesByPath['/customScript.js']['fullPath'], + unknown + > +} +declare module './../../src/routes/api/users' { + const createServerFileRoute: CreateServerFileRoute< + FileRoutesByPath['/api/users']['parentRoute'], + FileRoutesByPath['/api/users']['id'], + FileRoutesByPath['/api/users']['path'], + FileRoutesByPath['/api/users']['fullPath'], + ApiUsersRouteChildren + > +} +declare module './../../src/routes/api/users.$userId' { + const createServerFileRoute: CreateServerFileRoute< + FileRoutesByPath['/api/users/$userId']['parentRoute'], + FileRoutesByPath['/api/users/$userId']['id'], + FileRoutesByPath['/api/users/$userId']['path'], + FileRoutesByPath['/api/users/$userId']['fullPath'], + unknown + > +} + +// Create and export the route tree + +interface ApiUsersRouteChildren { + ApiUsersUserIdRoute: typeof ApiUsersUserIdRoute +} + +const ApiUsersRouteChildren: ApiUsersRouteChildren = { + ApiUsersUserIdRoute: ApiUsersUserIdRoute, +} + +const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren( + ApiUsersRouteChildren, +) + +export interface FileRoutesByFullPath { + '/customScript.js': typeof CustomScriptDotjsRoute + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$userId': typeof ApiUsersUserIdRoute +} + +export interface FileRoutesByTo { + '/customScript.js': typeof CustomScriptDotjsRoute + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$userId': typeof ApiUsersUserIdRoute +} + +export interface FileRoutesById { + __root__: typeof rootRoute + '/customScript.js': typeof CustomScriptDotjsRoute + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$userId': typeof ApiUsersUserIdRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: '/customScript.js' | '/api/users' | '/api/users/$userId' + fileRoutesByTo: FileRoutesByTo + to: '/customScript.js' | '/api/users' | '/api/users/$userId' + id: '__root__' | '/customScript.js' | '/api/users' | '/api/users/$userId' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren { + CustomScriptDotjsRoute: typeof CustomScriptDotjsRoute + ApiUsersRoute: typeof ApiUsersRouteWithChildren +} + +const rootRouteChildren: RootRouteChildren = { + CustomScriptDotjsRoute: CustomScriptDotjsRoute, + ApiUsersRoute: ApiUsersRouteWithChildren, +} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [ + "/customScript.js", + "/api/users" + ] + }, + "/customScript.js": { + "filePath": "customScript[.]js.ts" + }, + "/api/users": { + "filePath": "api/users.ts", + "children": [ + "/api/users/$userId" + ] + }, + "/api/users/$userId": { + "filePath": "api/users.$userId.ts", + "parent": "/api/users" + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-basic/app.config.ts b/examples/react/start-basic/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/examples/react/start-basic/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/examples/react/start-basic/package.json b/examples/react/start-basic/package.json index b7475e12c3..ee8b44b416 100644 --- a/examples/react/start-basic/package.json +++ b/examples/react/start-basic/package.json @@ -4,9 +4,9 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "node .output/server/index.mjs" }, "dependencies": { "@tanstack/react-router": "^1.120.3", @@ -15,7 +15,8 @@ "react": "^19.0.0", "react-dom": "^19.0.0", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3" + "vite": "6.1.0", + "zod": "^3.24.2" }, "devDependencies": { "@types/node": "^22.5.4", diff --git a/examples/react/start-basic/src/api.ts b/examples/react/start-basic/src/api.ts deleted file mode 100644 index 8b9fef1667..0000000000 --- a/examples/react/start-basic/src/api.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { - createStartAPIHandler, - defaultAPIFileRouteHandler, -} from '@tanstack/react-start/api' - -export default createStartAPIHandler(defaultAPIFileRouteHandler) diff --git a/examples/react/start-basic/src/client.tsx b/examples/react/start-basic/src/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/examples/react/start-basic/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/examples/react/start-basic/src/global-middleware.ts b/examples/react/start-basic/src/global-middleware.ts deleted file mode 100644 index c7e7af599f..0000000000 --- a/examples/react/start-basic/src/global-middleware.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerGlobalMiddleware } from '@tanstack/react-start' -import { logMiddleware } from './utils/loggingMiddleware' - -registerGlobalMiddleware({ - middleware: [logMiddleware], -}) diff --git a/examples/react/start-basic/src/routeTree.gen.ts b/examples/react/start-basic/src/routeTree.gen.ts index 4dca20ee9c..6a5cb97e5e 100644 --- a/examples/react/start-basic/src/routeTree.gen.ts +++ b/examples/react/start-basic/src/routeTree.gen.ts @@ -10,105 +10,105 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as RedirectImport } from './routes/redirect' -import { Route as DeferredImport } from './routes/deferred' -import { Route as PathlessLayoutImport } from './routes/_pathlessLayout' -import { Route as UsersRouteImport } from './routes/users.route' -import { Route as PostsRouteImport } from './routes/posts.route' -import { Route as IndexImport } from './routes/index' -import { Route as UsersIndexImport } from './routes/users.index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as UsersUserIdImport } from './routes/users.$userId' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as PathlessLayoutNestedLayoutImport } from './routes/_pathlessLayout/_nested-layout' -import { Route as PostsPostIdDeepImport } from './routes/posts_.$postId.deep' -import { Route as PathlessLayoutNestedLayoutRouteBImport } from './routes/_pathlessLayout/_nested-layout/route-b' -import { Route as PathlessLayoutNestedLayoutRouteAImport } from './routes/_pathlessLayout/_nested-layout/route-a' +import { Route as UsersRouteImport } from './routes/users' +import { Route as RedirectRouteImport } from './routes/redirect' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as DeferredRouteImport } from './routes/deferred' +import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as UsersIndexRouteImport } from './routes/users.index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as UsersUserIdRouteImport } from './routes/users.$userId' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as PathlessLayoutNestedLayoutRouteImport } from './routes/_pathlessLayout/_nested-layout' +import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep' +import { Route as PathlessLayoutNestedLayoutRouteBRouteImport } from './routes/_pathlessLayout/_nested-layout/route-b' +import { Route as PathlessLayoutNestedLayoutRouteARouteImport } from './routes/_pathlessLayout/_nested-layout/route-a' // Create/Update Routes -const RedirectRoute = RedirectImport.update({ - id: '/redirect', - path: '/redirect', - getParentRoute: () => rootRoute, -} as any) - -const DeferredRoute = DeferredImport.update({ - id: '/deferred', - path: '/deferred', - getParentRoute: () => rootRoute, -} as any) - -const PathlessLayoutRoute = PathlessLayoutImport.update({ - id: '/_pathlessLayout', - getParentRoute: () => rootRoute, -} as any) - -const UsersRouteRoute = UsersRouteImport.update({ +const UsersRoute = UsersRouteImport.update({ id: '/users', path: '/users', getParentRoute: () => rootRoute, } as any) -const PostsRouteRoute = PostsRouteImport.update({ +const RedirectRoute = RedirectRouteImport.update({ + id: '/redirect', + path: '/redirect', + getParentRoute: () => rootRoute, +} as any) + +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const DeferredRoute = DeferredRouteImport.update({ + id: '/deferred', + path: '/deferred', + getParentRoute: () => rootRoute, +} as any) + +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ + id: '/_pathlessLayout', + getParentRoute: () => rootRoute, +} as any) + +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const UsersIndexRoute = UsersIndexImport.update({ +const UsersIndexRoute = UsersIndexRouteImport.update({ id: '/', path: '/', - getParentRoute: () => UsersRouteRoute, + getParentRoute: () => UsersRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', - getParentRoute: () => PostsRouteRoute, + getParentRoute: () => PostsRoute, } as any) -const UsersUserIdRoute = UsersUserIdImport.update({ +const UsersUserIdRoute = UsersUserIdRouteImport.update({ id: '/$userId', path: '/$userId', - getParentRoute: () => UsersRouteRoute, + getParentRoute: () => UsersRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', - getParentRoute: () => PostsRouteRoute, + getParentRoute: () => PostsRoute, } as any) -const PathlessLayoutNestedLayoutRoute = PathlessLayoutNestedLayoutImport.update( - { +const PathlessLayoutNestedLayoutRoute = + PathlessLayoutNestedLayoutRouteImport.update({ id: '/_nested-layout', getParentRoute: () => PathlessLayoutRoute, - } as any, -) + } as any) -const PostsPostIdDeepRoute = PostsPostIdDeepImport.update({ +const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ id: '/posts_/$postId/deep', path: '/posts/$postId/deep', getParentRoute: () => rootRoute, } as any) const PathlessLayoutNestedLayoutRouteBRoute = - PathlessLayoutNestedLayoutRouteBImport.update({ + PathlessLayoutNestedLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutNestedLayoutRoute, } as any) const PathlessLayoutNestedLayoutRouteARoute = - PathlessLayoutNestedLayoutRouteAImport.update({ + PathlessLayoutNestedLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutNestedLayoutRoute, @@ -122,7 +122,21 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport + parentRoute: typeof rootRoute + } + '/_pathlessLayout': { + id: '/_pathlessLayout' + path: '' + fullPath: '' + preLoaderRoute: typeof PathlessLayoutRouteImport + parentRoute: typeof rootRoute + } + '/deferred': { + id: '/deferred' + path: '/deferred' + fullPath: '/deferred' + preLoaderRoute: typeof DeferredRouteImport parentRoute: typeof rootRoute } '/posts': { @@ -132,6 +146,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } + '/redirect': { + id: '/redirect' + path: '/redirect' + fullPath: '/redirect' + preLoaderRoute: typeof RedirectRouteImport + parentRoute: typeof rootRoute + } '/users': { id: '/users' path: '/users' @@ -139,116 +160,196 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof UsersRouteImport parentRoute: typeof rootRoute } - '/_pathlessLayout': { - id: '/_pathlessLayout' - path: '' - fullPath: '' - preLoaderRoute: typeof PathlessLayoutImport - parentRoute: typeof rootRoute - } - '/deferred': { - id: '/deferred' - path: '/deferred' - fullPath: '/deferred' - preLoaderRoute: typeof DeferredImport - parentRoute: typeof rootRoute - } - '/redirect': { - id: '/redirect' - path: '/redirect' - fullPath: '/redirect' - preLoaderRoute: typeof RedirectImport - parentRoute: typeof rootRoute - } '/_pathlessLayout/_nested-layout': { id: '/_pathlessLayout/_nested-layout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutNestedLayoutImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport + preLoaderRoute: typeof PostsPostIdRouteImport parentRoute: typeof PostsRouteImport } '/users/$userId': { id: '/users/$userId' path: '/$userId' fullPath: '/users/$userId' - preLoaderRoute: typeof UsersUserIdImport + preLoaderRoute: typeof UsersUserIdRouteImport parentRoute: typeof UsersRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport + preLoaderRoute: typeof PostsIndexRouteImport parentRoute: typeof PostsRouteImport } '/users/': { id: '/users/' path: '/' fullPath: '/users/' - preLoaderRoute: typeof UsersIndexImport + preLoaderRoute: typeof UsersIndexRouteImport parentRoute: typeof UsersRouteImport } '/_pathlessLayout/_nested-layout/route-a': { id: '/_pathlessLayout/_nested-layout/route-a' path: '/route-a' fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteAImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/_pathlessLayout/_nested-layout/route-b': { id: '/_pathlessLayout/_nested-layout/route-b' path: '/route-b' fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/posts_/$postId/deep': { id: '/posts_/$postId/deep' path: '/posts/$postId/deep' fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepImport + preLoaderRoute: typeof PostsPostIdDeepRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_pathlessLayout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout', + FileRoutesByPath['/_pathlessLayout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout']['id'], + FileRoutesByPath['/_pathlessLayout']['path'], + FileRoutesByPath['/_pathlessLayout']['fullPath'] + > +} +declare module './routes/deferred' { + const createFileRoute: CreateFileRoute< + '/deferred', + FileRoutesByPath['/deferred']['parentRoute'], + FileRoutesByPath['/deferred']['id'], + FileRoutesByPath['/deferred']['path'], + FileRoutesByPath['/deferred']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/redirect' { + const createFileRoute: CreateFileRoute< + '/redirect', + FileRoutesByPath['/redirect']['parentRoute'], + FileRoutesByPath['/redirect']['id'], + FileRoutesByPath['/redirect']['path'], + FileRoutesByPath['/redirect']['fullPath'] + > +} +declare module './routes/users' { + const createFileRoute: CreateFileRoute< + '/users', + FileRoutesByPath['/users']['parentRoute'], + FileRoutesByPath['/users']['id'], + FileRoutesByPath['/users']['path'], + FileRoutesByPath['/users']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout', + FileRoutesByPath['/_pathlessLayout/_nested-layout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/users.$userId' { + const createFileRoute: CreateFileRoute< + '/users/$userId', + FileRoutesByPath['/users/$userId']['parentRoute'], + FileRoutesByPath['/users/$userId']['id'], + FileRoutesByPath['/users/$userId']['path'], + FileRoutesByPath['/users/$userId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/users.index' { + const createFileRoute: CreateFileRoute< + '/users/', + FileRoutesByPath['/users/']['parentRoute'], + FileRoutesByPath['/users/']['id'], + FileRoutesByPath['/users/']['path'], + FileRoutesByPath['/users/']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-a' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-a', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-b' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-b', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['fullPath'] + > +} +declare module './routes/posts_.$postId.deep' { + const createFileRoute: CreateFileRoute< + '/posts_/$postId/deep', + FileRoutesByPath['/posts_/$postId/deep']['parentRoute'], + FileRoutesByPath['/posts_/$postId/deep']['id'], + FileRoutesByPath['/posts_/$postId/deep']['path'], + FileRoutesByPath['/posts_/$postId/deep']['fullPath'] + > +} + // Create and export the route tree -interface PostsRouteRouteChildren { - PostsPostIdRoute: typeof PostsPostIdRoute - PostsIndexRoute: typeof PostsIndexRoute -} - -const PostsRouteRouteChildren: PostsRouteRouteChildren = { - PostsPostIdRoute: PostsPostIdRoute, - PostsIndexRoute: PostsIndexRoute, -} - -const PostsRouteRouteWithChildren = PostsRouteRoute._addFileChildren( - PostsRouteRouteChildren, -) - -interface UsersRouteRouteChildren { - UsersUserIdRoute: typeof UsersUserIdRoute - UsersIndexRoute: typeof UsersIndexRoute -} - -const UsersRouteRouteChildren: UsersRouteRouteChildren = { - UsersUserIdRoute: UsersUserIdRoute, - UsersIndexRoute: UsersIndexRoute, -} - -const UsersRouteRouteWithChildren = UsersRouteRoute._addFileChildren( - UsersRouteRouteChildren, -) - interface PathlessLayoutNestedLayoutRouteChildren { PathlessLayoutNestedLayoutRouteARoute: typeof PathlessLayoutNestedLayoutRouteARoute PathlessLayoutNestedLayoutRouteBRoute: typeof PathlessLayoutNestedLayoutRouteBRoute @@ -279,13 +380,37 @@ const PathlessLayoutRouteWithChildren = PathlessLayoutRoute._addFileChildren( PathlessLayoutRouteChildren, ) +interface PostsRouteChildren { + PostsPostIdRoute: typeof PostsPostIdRoute + PostsIndexRoute: typeof PostsIndexRoute +} + +const PostsRouteChildren: PostsRouteChildren = { + PostsPostIdRoute: PostsPostIdRoute, + PostsIndexRoute: PostsIndexRoute, +} + +const PostsRouteWithChildren = PostsRoute._addFileChildren(PostsRouteChildren) + +interface UsersRouteChildren { + UsersUserIdRoute: typeof UsersUserIdRoute + UsersIndexRoute: typeof UsersIndexRoute +} + +const UsersRouteChildren: UsersRouteChildren = { + UsersUserIdRoute: UsersUserIdRoute, + UsersIndexRoute: UsersIndexRoute, +} + +const UsersRouteWithChildren = UsersRoute._addFileChildren(UsersRouteChildren) + export interface FileRoutesByFullPath { '/': typeof IndexRoute - '/posts': typeof PostsRouteRouteWithChildren - '/users': typeof UsersRouteRouteWithChildren '': typeof PathlessLayoutNestedLayoutRouteWithChildren '/deferred': typeof DeferredRoute + '/posts': typeof PostsRouteWithChildren '/redirect': typeof RedirectRoute + '/users': typeof UsersRouteWithChildren '/posts/$postId': typeof PostsPostIdRoute '/users/$userId': typeof UsersUserIdRoute '/posts/': typeof PostsIndexRoute @@ -312,11 +437,11 @@ export interface FileRoutesByTo { export interface FileRoutesById { __root__: typeof rootRoute '/': typeof IndexRoute - '/posts': typeof PostsRouteRouteWithChildren - '/users': typeof UsersRouteRouteWithChildren '/_pathlessLayout': typeof PathlessLayoutRouteWithChildren '/deferred': typeof DeferredRoute + '/posts': typeof PostsRouteWithChildren '/redirect': typeof RedirectRoute + '/users': typeof UsersRouteWithChildren '/_pathlessLayout/_nested-layout': typeof PathlessLayoutNestedLayoutRouteWithChildren '/posts/$postId': typeof PostsPostIdRoute '/users/$userId': typeof UsersUserIdRoute @@ -331,11 +456,11 @@ export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath fullPaths: | '/' - | '/posts' - | '/users' | '' | '/deferred' + | '/posts' | '/redirect' + | '/users' | '/posts/$postId' | '/users/$userId' | '/posts/' @@ -359,11 +484,11 @@ export interface FileRouteTypes { id: | '__root__' | '/' - | '/posts' - | '/users' | '/_pathlessLayout' | '/deferred' + | '/posts' | '/redirect' + | '/users' | '/_pathlessLayout/_nested-layout' | '/posts/$postId' | '/users/$userId' @@ -377,21 +502,21 @@ export interface FileRouteTypes { export interface RootRouteChildren { IndexRoute: typeof IndexRoute - PostsRouteRoute: typeof PostsRouteRouteWithChildren - UsersRouteRoute: typeof UsersRouteRouteWithChildren PathlessLayoutRoute: typeof PathlessLayoutRouteWithChildren DeferredRoute: typeof DeferredRoute + PostsRoute: typeof PostsRouteWithChildren RedirectRoute: typeof RedirectRoute + UsersRoute: typeof UsersRouteWithChildren PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute } const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, - PostsRouteRoute: PostsRouteRouteWithChildren, - UsersRouteRoute: UsersRouteRouteWithChildren, PathlessLayoutRoute: PathlessLayoutRouteWithChildren, DeferredRoute: DeferredRoute, + PostsRoute: PostsRouteWithChildren, RedirectRoute: RedirectRoute, + UsersRoute: UsersRouteWithChildren, PostsPostIdDeepRoute: PostsPostIdDeepRoute, } @@ -399,6 +524,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { @@ -406,31 +534,17 @@ export const routeTree = rootRoute "filePath": "__root.tsx", "children": [ "/", - "/posts", - "/users", "/_pathlessLayout", "/deferred", + "/posts", "/redirect", + "/users", "/posts_/$postId/deep" ] }, "/": { "filePath": "index.tsx" }, - "/posts": { - "filePath": "posts.route.tsx", - "children": [ - "/posts/$postId", - "/posts/" - ] - }, - "/users": { - "filePath": "users.route.tsx", - "children": [ - "/users/$userId", - "/users/" - ] - }, "/_pathlessLayout": { "filePath": "_pathlessLayout.tsx", "children": [ @@ -440,9 +554,23 @@ export const routeTree = rootRoute "/deferred": { "filePath": "deferred.tsx" }, + "/posts": { + "filePath": "posts.tsx", + "children": [ + "/posts/$postId", + "/posts/" + ] + }, "/redirect": { "filePath": "redirect.tsx" }, + "/users": { + "filePath": "users.tsx", + "children": [ + "/users/$userId", + "/users/" + ] + }, "/_pathlessLayout/_nested-layout": { "filePath": "_pathlessLayout/_nested-layout.tsx", "parent": "/_pathlessLayout", diff --git a/examples/react/start-basic/src/routes/__root.tsx b/examples/react/start-basic/src/routes/__root.tsx index 70140f2306..407f04b58a 100644 --- a/examples/react/start-basic/src/routes/__root.tsx +++ b/examples/react/start-basic/src/routes/__root.tsx @@ -50,6 +50,12 @@ export const Route = createRootRoute({ { rel: 'manifest', href: '/site.webmanifest', color: '#fffff' }, { rel: 'icon', href: '/favicon.ico' }, ], + scripts: [ + { + src: '/customScript.js', + type: 'text/javascript', + }, + ], }), errorComponent: (props) => { return ( diff --git a/examples/react/start-basic/src/routes/_pathlessLayout.tsx b/examples/react/start-basic/src/routes/_pathlessLayout.tsx index c3b12442b8..5c4a461d8d 100644 --- a/examples/react/start-basic/src/routes/_pathlessLayout.tsx +++ b/examples/react/start-basic/src/routes/_pathlessLayout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/react-router' +import { Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/start-basic/src/routes/_pathlessLayout/_nested-layout.tsx b/examples/react/start-basic/src/routes/_pathlessLayout/_nested-layout.tsx index 9a48b73a46..1e1400f5a7 100644 --- a/examples/react/start-basic/src/routes/_pathlessLayout/_nested-layout.tsx +++ b/examples/react/start-basic/src/routes/_pathlessLayout/_nested-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' -export const Route = createFileRoute('/_pathlessLayout/_nested-layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/react/start-basic/src/routes/_pathlessLayout/_nested-layout/route-a.tsx b/examples/react/start-basic/src/routes/_pathlessLayout/_nested-layout/route-a.tsx index 426a8fe486..a0bd5240b7 100644 --- a/examples/react/start-basic/src/routes/_pathlessLayout/_nested-layout/route-a.tsx +++ b/examples/react/start-basic/src/routes/_pathlessLayout/_nested-layout/route-a.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-a')( - { - component: LayoutAComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutAComponent, +}) function LayoutAComponent() { return
I'm A!
diff --git a/examples/react/start-basic/src/routes/_pathlessLayout/_nested-layout/route-b.tsx b/examples/react/start-basic/src/routes/_pathlessLayout/_nested-layout/route-b.tsx index 20facf2daf..2864ec1f28 100644 --- a/examples/react/start-basic/src/routes/_pathlessLayout/_nested-layout/route-b.tsx +++ b/examples/react/start-basic/src/routes/_pathlessLayout/_nested-layout/route-b.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-b')( - { - component: LayoutBComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutBComponent, +}) function LayoutBComponent() { return
I'm B!
diff --git a/examples/react/start-basic/src/routes/api/users.$id.ts b/examples/react/start-basic/src/routes/api/users.$userId.ts similarity index 55% rename from examples/react/start-basic/src/routes/api/users.$id.ts rename to examples/react/start-basic/src/routes/api/users.$userId.ts index 1332a2cd07..f0575c881c 100644 --- a/examples/react/start-basic/src/routes/api/users.$id.ts +++ b/examples/react/start-basic/src/routes/api/users.$userId.ts @@ -1,13 +1,12 @@ import { json } from '@tanstack/react-start' -import { createAPIFileRoute } from '@tanstack/react-start/api' -import type { User } from '../../utils/users' +import type { User } from '~/utils/users' -export const APIRoute = createAPIFileRoute('/api/users/$id')({ - GET: async ({ request, params }) => { - console.info(`Fetching users by id=${params.id}... @`, request.url) +export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ params, request }) => { + console.info(`Fetching users by id=${params.userId}... @`, request.url) try { const res = await fetch( - 'https://jsonplaceholder.typicode.com/users/' + params.id, + 'https://jsonplaceholder.typicode.com/users/' + params.userId, ) if (!res.ok) { throw new Error('Failed to fetch user') diff --git a/examples/react/start-basic/src/routes/api/users.ts b/examples/react/start-basic/src/routes/api/users.ts index 61ad3e5bf4..dd8e36bfab 100644 --- a/examples/react/start-basic/src/routes/api/users.ts +++ b/examples/react/start-basic/src/routes/api/users.ts @@ -1,19 +1,58 @@ -import { json } from '@tanstack/react-start' -import { createAPIFileRoute } from '@tanstack/react-start/api' -import type { User } from '../../utils/users' +import { createMiddleware, json } from '@tanstack/react-start' +import type { User } from '~/utils/users' -export const APIRoute = createAPIFileRoute('/api/users')({ - GET: async ({ request }) => { - console.info('Fetching users... @', request.url) - const res = await fetch('https://jsonplaceholder.typicode.com/users') - if (!res.ok) { - throw new Error('Failed to fetch users') - } - - const data = (await res.json()) as Array - - const list = data.slice(0, 10) - - return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email }))) +const userLoggerMiddleware = createMiddleware({ type: 'request' }).server( + async ({ next, request }) => { + console.info('In: /users') + const result = await next() + result.response.headers.set('x-users', 'true') + console.info('Out: /users') + return result }, -}) +) + +const testParentMiddleware = createMiddleware({ type: 'request' }).server( + async ({ next, request }) => { + console.info('In: testParentMiddleware') + const result = await next() + result.response.headers.set('x-test-parent', 'true') + console.info('Out: testParentMiddleware') + return result + }, +) + +const testMiddleware = createMiddleware({ type: 'request' }) + .middleware([testParentMiddleware]) + .server(async ({ next, request }) => { + console.info('In: testMiddleware') + const result = await next() + result.response.headers.set('x-test', 'true') + + // if (Math.random() > 0.5) { + // throw new Response(null, { + // status: 302, + // headers: { Location: 'https://www.google.com' }, + // }) + // } + + console.info('Out: testMiddleware') + return result + }) + +export const ServerRoute = createServerFileRoute() + .middleware([testMiddleware, userLoggerMiddleware, testParentMiddleware]) + .methods({ + GET: async ({ request }) => { + console.info('Fetching users... @', request.url) + const res = await fetch('https://jsonplaceholder.typicode.com/users') + if (!res.ok) { + throw new Error('Failed to fetch users') + } + + const data = (await res.json()) as Array + + const list = data.slice(0, 10) + + return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email }))) + }, + }) diff --git a/examples/react/start-basic/src/routes/customScript[.]js.ts b/examples/react/start-basic/src/routes/customScript[.]js.ts new file mode 100644 index 0000000000..6966a3379d --- /dev/null +++ b/examples/react/start-basic/src/routes/customScript[.]js.ts @@ -0,0 +1,9 @@ +export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ request }) => { + return new Response('console.log("Hello from customScript.js!")', { + headers: { + 'Content-Type': 'application/javascript', + }, + }) + }, +}) diff --git a/examples/react/start-basic/src/routes/deferred.tsx b/examples/react/start-basic/src/routes/deferred.tsx index f3e09d1d4e..da895081df 100644 --- a/examples/react/start-basic/src/routes/deferred.tsx +++ b/examples/react/start-basic/src/routes/deferred.tsx @@ -1,4 +1,4 @@ -import { Await, createFileRoute } from '@tanstack/react-router' +import { Await } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' import { Suspense, useState } from 'react' @@ -15,7 +15,7 @@ const slowServerFn = createServerFn({ method: 'GET' }) return { name, randomNumber: Math.floor(Math.random() * 100) } }) -export const Route = createFileRoute('/deferred')({ +export const Route = createFileRoute({ loader: async () => { return { deferredStuff: new Promise((r) => diff --git a/examples/react/start-basic/src/routes/index.tsx b/examples/react/start-basic/src/routes/index.tsx index 09a907cb18..f6c5b98b02 100644 --- a/examples/react/start-basic/src/routes/index.tsx +++ b/examples/react/start-basic/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/react/start-basic/src/routes/posts.$postId.tsx b/examples/react/start-basic/src/routes/posts.$postId.tsx index d6de7c9dc3..f4184852e0 100644 --- a/examples/react/start-basic/src/routes/posts.$postId.tsx +++ b/examples/react/start-basic/src/routes/posts.$postId.tsx @@ -1,9 +1,9 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import { fetchPost } from '../utils/posts' import { NotFound } from '~/components/NotFound' import { PostErrorComponent } from '~/components/PostError' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: ({ params: { postId } }) => fetchPost({ data: postId }), errorComponent: PostErrorComponent, component: PostComponent, @@ -25,7 +25,7 @@ function PostComponent() { postId: post.id, }} activeProps={{ className: 'text-black font-bold' }} - className="block py-1 text-blue-800 hover:text-blue-600" + className="inline-block py-1 text-blue-800 hover:text-blue-600" > Deep View diff --git a/examples/react/start-basic/src/routes/posts.index.tsx b/examples/react/start-basic/src/routes/posts.index.tsx index 5b5f08f95b..13529228bb 100644 --- a/examples/react/start-basic/src/routes/posts.index.tsx +++ b/examples/react/start-basic/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/react/start-basic/src/routes/posts.route.tsx b/examples/react/start-basic/src/routes/posts.tsx similarity index 82% rename from examples/react/start-basic/src/routes/posts.route.tsx rename to examples/react/start-basic/src/routes/posts.tsx index f29619363e..5bcd320911 100644 --- a/examples/react/start-basic/src/routes/posts.route.tsx +++ b/examples/react/start-basic/src/routes/posts.tsx @@ -1,12 +1,12 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../utils/posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: async () => fetchPosts(), - component: PostsLayoutComponent, + component: PostsComponent, }) -function PostsLayoutComponent() { +function PostsComponent() { const posts = Route.useLoaderData() return ( diff --git a/examples/react/start-basic/src/routes/posts_.$postId.deep.tsx b/examples/react/start-basic/src/routes/posts_.$postId.deep.tsx index 29e6c39b5a..624b76a6c1 100644 --- a/examples/react/start-basic/src/routes/posts_.$postId.deep.tsx +++ b/examples/react/start-basic/src/routes/posts_.$postId.deep.tsx @@ -1,8 +1,8 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import { fetchPost } from '../utils/posts' import { PostErrorComponent } from '~/components/PostError' -export const Route = createFileRoute('/posts_/$postId/deep')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost({ data: postId, diff --git a/examples/react/start-basic/src/routes/redirect.tsx b/examples/react/start-basic/src/routes/redirect.tsx index c9286de13d..68a98d5683 100644 --- a/examples/react/start-basic/src/routes/redirect.tsx +++ b/examples/react/start-basic/src/routes/redirect.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' -export const Route = createFileRoute('/redirect')({ +export const Route = createFileRoute({ beforeLoad: async () => { throw redirect({ to: '/posts', diff --git a/examples/react/start-basic/src/routes/users.$userId.tsx b/examples/react/start-basic/src/routes/users.$userId.tsx index 186b1c64e7..1f493d2945 100644 --- a/examples/react/start-basic/src/routes/users.$userId.tsx +++ b/examples/react/start-basic/src/routes/users.$userId.tsx @@ -1,18 +1,15 @@ -import { createFileRoute } from '@tanstack/react-router' -import type { User } from '~/utils/users' -import { DEPLOY_URL } from '~/utils/users' -import { NotFound } from '~/components/NotFound' -import { UserErrorComponent } from '~/components/UserError' +import { NotFound } from 'src/components/NotFound' +import { UserErrorComponent } from 'src/components/UserError' -export const Route = createFileRoute('/users/$userId')({ +export const Route = createFileRoute({ loader: async ({ params: { userId } }) => { try { - const res = await fetch(DEPLOY_URL + '/api/users/' + userId) + const res = await fetch('/api/users/' + userId) if (!res.ok) { throw new Error('Unexpected status code') } - const data = (await res.json()) as User + const data = await res.json() return data } catch { @@ -33,6 +30,14 @@ function UserComponent() {

{user.name}

{user.email}
+
) } diff --git a/examples/react/start-basic/src/routes/users.index.tsx b/examples/react/start-basic/src/routes/users.index.tsx index b6b0ee67fb..31d070db1f 100644 --- a/examples/react/start-basic/src/routes/users.index.tsx +++ b/examples/react/start-basic/src/routes/users.index.tsx @@ -1,9 +1,17 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/users/')({ +export const Route = createFileRoute({ component: UsersIndexComponent, }) function UsersIndexComponent() { - return
Select a user.
+ return ( +
+ Select a user or{' '} + + view as JSON + +
+ ) } diff --git a/examples/react/start-basic/src/routes/users.route.tsx b/examples/react/start-basic/src/routes/users.tsx similarity index 63% rename from examples/react/start-basic/src/routes/users.route.tsx rename to examples/react/start-basic/src/routes/users.tsx index ebc930e4da..9d1548980a 100644 --- a/examples/react/start-basic/src/routes/users.route.tsx +++ b/examples/react/start-basic/src/routes/users.tsx @@ -1,26 +1,22 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' -import { DEPLOY_URL } from '../utils/users' +import { Link, Outlet } from '@tanstack/react-router' import type { User } from '../utils/users' -export const Route = createFileRoute('/users')({ +export const Route = createFileRoute({ loader: async () => { - try { - const res = await fetch(DEPLOY_URL + '/api/users') - if (!res.ok) { - throw new Error('Unexpected status code') - } + const res = await fetch('/api/users') - const data = (await res.json()) as Array - - return data - } catch { - throw new Error('Failed to fetch users') + if (!res.ok) { + throw new Error('Unexpected status code') } + + const data = (await res.json()) as Array + + return data }, - component: UsersLayoutComponent, + component: UsersComponent, }) -function UsersLayoutComponent() { +function UsersComponent() { const users = Route.useLoaderData() return ( diff --git a/examples/react/start-basic/src/ssr.tsx b/examples/react/start-basic/src/ssr.tsx deleted file mode 100644 index 8981a9a338..0000000000 --- a/examples/react/start-basic/src/ssr.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/examples/react/start-basic/src/utils/loggingMiddleware.tsx b/examples/react/start-basic/src/utils/loggingMiddleware.tsx index 3944490725..3ea9a06439 100644 --- a/examples/react/start-basic/src/utils/loggingMiddleware.tsx +++ b/examples/react/start-basic/src/utils/loggingMiddleware.tsx @@ -1,6 +1,6 @@ import { createMiddleware } from '@tanstack/react-start' -const preLogMiddleware = createMiddleware() +const preLogMiddleware = createMiddleware({ type: 'function' }) .client(async (ctx) => { const clientTime = new Date() @@ -25,14 +25,14 @@ const preLogMiddleware = createMiddleware() }) }) -export const logMiddleware = createMiddleware() +export const logMiddleware = createMiddleware({ type: 'function' }) .middleware([preLogMiddleware]) .client(async (ctx) => { const res = await ctx.next() const now = new Date() console.log('Client Req/Res:', { - duration: res.context.clientTime.getTime() - now.getTime(), + duration: now.getTime() - res.context.clientTime.getTime(), durationToServer: res.context.durationToServer, durationFromServer: now.getTime() - res.context.serverTime.getTime(), }) diff --git a/examples/react/start-basic/src/utils/posts.tsx b/examples/react/start-basic/src/utils/posts.tsx index d12abb30ab..52877be68c 100644 --- a/examples/react/start-basic/src/utils/posts.tsx +++ b/examples/react/start-basic/src/utils/posts.tsx @@ -7,7 +7,7 @@ export type PostType = { body: string } -export const fetchPost = createServerFn({ method: 'GET' }) +export const fetchPost = createServerFn() .validator((d: string) => d) .handler(async ({ data }) => { console.info(`Fetching post with id ${data}...`) @@ -27,16 +27,14 @@ export const fetchPost = createServerFn({ method: 'GET' }) return post }) -export const fetchPosts = createServerFn({ method: 'GET' }).handler( - async () => { - console.info('Fetching posts...') - const res = await fetch('https://jsonplaceholder.typicode.com/posts') - if (!res.ok) { - throw new Error('Failed to fetch posts') - } +export const fetchPosts = createServerFn().handler(async () => { + console.info('Fetching posts...') + const res = await fetch('https://jsonplaceholder.typicode.com/posts') + if (!res.ok) { + throw new Error('Failed to fetch posts') + } - const posts = (await res.json()) as Array + const posts = (await res.json()) as Array - return posts - }, -) + return posts.slice(0, 10) +}) diff --git a/examples/react/start-basic/src/utils/users.tsx b/examples/react/start-basic/src/utils/users.tsx index b810f455fe..7ba645b383 100644 --- a/examples/react/start-basic/src/utils/users.tsx +++ b/examples/react/start-basic/src/utils/users.tsx @@ -3,5 +3,3 @@ export type User = { name: string email: string } - -export const DEPLOY_URL = 'http://localhost:3000' diff --git a/examples/react/start-basic/vite.config.ts b/examples/react/start-basic/vite.config.ts new file mode 100644 index 0000000000..f451c4b69c --- /dev/null +++ b/examples/react/start-basic/vite.config.ts @@ -0,0 +1,15 @@ +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/examples/react/start-clerk-basic/.gitignore b/examples/react/start-clerk-basic/.gitignore index b15fed94e2..2818549158 100644 --- a/examples/react/start-clerk-basic/.gitignore +++ b/examples/react/start-clerk-basic/.gitignore @@ -7,14 +7,10 @@ yarn.lock .cache .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ diff --git a/examples/react/start-clerk-basic/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-clerk-basic/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/examples/react/start-clerk-basic/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-clerk-basic/app.config.ts b/examples/react/start-clerk-basic/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/examples/react/start-clerk-basic/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/examples/react/start-clerk-basic/package.json b/examples/react/start-clerk-basic/package.json index 81c2bb8456..c3a9a49fa5 100644 --- a/examples/react/start-clerk-basic/package.json +++ b/examples/react/start-clerk-basic/package.json @@ -4,9 +4,9 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "dependencies": { "@clerk/tanstack-react-start": "0.12.0", @@ -16,8 +16,7 @@ "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", - "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3" + "tailwind-merge": "^2.6.0" }, "devDependencies": { "@types/node": "^22.5.4", diff --git a/examples/react/start-clerk-basic/src/client.tsx b/examples/react/start-clerk-basic/src/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/examples/react/start-clerk-basic/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/examples/react/start-clerk-basic/src/routeTree.gen.ts b/examples/react/start-clerk-basic/src/routeTree.gen.ts index b4b4f459a8..c485ac113c 100644 --- a/examples/react/start-clerk-basic/src/routeTree.gen.ts +++ b/examples/react/start-clerk-basic/src/routeTree.gen.ts @@ -10,46 +10,47 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as AuthedImport } from './routes/_authed' -import { Route as IndexImport } from './routes/index' -import { Route as AuthedPostsImport } from './routes/_authed/posts' -import { Route as AuthedPostsIndexImport } from './routes/_authed/posts.index' -import { Route as AuthedProfileSplatImport } from './routes/_authed/profile.$' -import { Route as AuthedPostsPostIdImport } from './routes/_authed/posts.$postId' +import { Route as AuthedRouteImport } from './routes/_authed' +import { Route as IndexRouteImport } from './routes/index' +import { Route as AuthedPostsRouteImport } from './routes/_authed/posts' +import { Route as AuthedPostsIndexRouteImport } from './routes/_authed/posts.index' +import { Route as AuthedProfileSplatRouteImport } from './routes/_authed/profile.$' +import { Route as AuthedPostsPostIdRouteImport } from './routes/_authed/posts.$postId' // Create/Update Routes -const AuthedRoute = AuthedImport.update({ +const AuthedRoute = AuthedRouteImport.update({ id: '/_authed', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const AuthedPostsRoute = AuthedPostsImport.update({ +const AuthedPostsRoute = AuthedPostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => AuthedRoute, } as any) -const AuthedPostsIndexRoute = AuthedPostsIndexImport.update({ +const AuthedPostsIndexRoute = AuthedPostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => AuthedPostsRoute, } as any) -const AuthedProfileSplatRoute = AuthedProfileSplatImport.update({ +const AuthedProfileSplatRoute = AuthedProfileSplatRouteImport.update({ id: '/profile/$', path: '/profile/$', getParentRoute: () => AuthedRoute, } as any) -const AuthedPostsPostIdRoute = AuthedPostsPostIdImport.update({ +const AuthedPostsPostIdRoute = AuthedPostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => AuthedPostsRoute, @@ -63,47 +64,104 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_authed': { id: '/_authed' path: '' fullPath: '' - preLoaderRoute: typeof AuthedImport + preLoaderRoute: typeof AuthedRouteImport parentRoute: typeof rootRoute } '/_authed/posts': { id: '/_authed/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof AuthedPostsImport - parentRoute: typeof AuthedImport + preLoaderRoute: typeof AuthedPostsRouteImport + parentRoute: typeof AuthedRouteImport } '/_authed/posts/$postId': { id: '/_authed/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof AuthedPostsPostIdImport - parentRoute: typeof AuthedPostsImport + preLoaderRoute: typeof AuthedPostsPostIdRouteImport + parentRoute: typeof AuthedPostsRouteImport } '/_authed/profile/$': { id: '/_authed/profile/$' path: '/profile/$' fullPath: '/profile/$' - preLoaderRoute: typeof AuthedProfileSplatImport - parentRoute: typeof AuthedImport + preLoaderRoute: typeof AuthedProfileSplatRouteImport + parentRoute: typeof AuthedRouteImport } '/_authed/posts/': { id: '/_authed/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof AuthedPostsIndexImport - parentRoute: typeof AuthedPostsImport + preLoaderRoute: typeof AuthedPostsIndexRouteImport + parentRoute: typeof AuthedPostsRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_authed' { + const createFileRoute: CreateFileRoute< + '/_authed', + FileRoutesByPath['/_authed']['parentRoute'], + FileRoutesByPath['/_authed']['id'], + FileRoutesByPath['/_authed']['path'], + FileRoutesByPath['/_authed']['fullPath'] + > +} +declare module './routes/_authed/posts' { + const createFileRoute: CreateFileRoute< + '/_authed/posts', + FileRoutesByPath['/_authed/posts']['parentRoute'], + FileRoutesByPath['/_authed/posts']['id'], + FileRoutesByPath['/_authed/posts']['path'], + FileRoutesByPath['/_authed/posts']['fullPath'] + > +} +declare module './routes/_authed/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/_authed/posts/$postId', + FileRoutesByPath['/_authed/posts/$postId']['parentRoute'], + FileRoutesByPath['/_authed/posts/$postId']['id'], + FileRoutesByPath['/_authed/posts/$postId']['path'], + FileRoutesByPath['/_authed/posts/$postId']['fullPath'] + > +} +declare module './routes/_authed/profile.$' { + const createFileRoute: CreateFileRoute< + '/_authed/profile/$', + FileRoutesByPath['/_authed/profile/$']['parentRoute'], + FileRoutesByPath['/_authed/profile/$']['id'], + FileRoutesByPath['/_authed/profile/$']['path'], + FileRoutesByPath['/_authed/profile/$']['fullPath'] + > +} +declare module './routes/_authed/posts.index' { + const createFileRoute: CreateFileRoute< + '/_authed/posts/', + FileRoutesByPath['/_authed/posts/']['parentRoute'], + FileRoutesByPath['/_authed/posts/']['id'], + FileRoutesByPath['/_authed/posts/']['path'], + FileRoutesByPath['/_authed/posts/']['fullPath'] + > +} + // Create and export the route tree interface AuthedPostsRouteChildren { @@ -190,6 +248,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/start-clerk-basic/src/routes/_authed.tsx b/examples/react/start-clerk-basic/src/routes/_authed.tsx index 1f68471a91..7e56fea09b 100644 --- a/examples/react/start-clerk-basic/src/routes/_authed.tsx +++ b/examples/react/start-clerk-basic/src/routes/_authed.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { SignIn } from '@clerk/tanstack-react-start' -export const Route = createFileRoute('/_authed')({ +export const Route = createFileRoute({ beforeLoad: ({ context }) => { if (!context.userId) { throw new Error('Not authenticated') diff --git a/examples/react/start-clerk-basic/src/routes/_authed/posts.$postId.tsx b/examples/react/start-clerk-basic/src/routes/_authed/posts.$postId.tsx index 039271bb89..c6c36f3ea4 100644 --- a/examples/react/start-clerk-basic/src/routes/_authed/posts.$postId.tsx +++ b/examples/react/start-clerk-basic/src/routes/_authed/posts.$postId.tsx @@ -1,9 +1,9 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import type { ErrorComponentProps } from '@tanstack/react-router' import { NotFound } from '~/components/NotFound.js' import { fetchPost } from '~/utils/posts.js' -export const Route = createFileRoute('/_authed/posts/$postId')({ +export const Route = createFileRoute({ loader: ({ params: { postId } }) => fetchPost({ data: postId }), errorComponent: PostErrorComponent, component: PostComponent, diff --git a/examples/react/start-clerk-basic/src/routes/_authed/posts.index.tsx b/examples/react/start-clerk-basic/src/routes/_authed/posts.index.tsx index ea9e667e54..13529228bb 100644 --- a/examples/react/start-clerk-basic/src/routes/_authed/posts.index.tsx +++ b/examples/react/start-clerk-basic/src/routes/_authed/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_authed/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/react/start-clerk-basic/src/routes/_authed/posts.tsx b/examples/react/start-clerk-basic/src/routes/_authed/posts.tsx index 86c8ef4138..f9b50197cf 100644 --- a/examples/react/start-clerk-basic/src/routes/_authed/posts.tsx +++ b/examples/react/start-clerk-basic/src/routes/_authed/posts.tsx @@ -1,7 +1,7 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '~/utils/posts.js' -export const Route = createFileRoute('/_authed/posts')({ +export const Route = createFileRoute({ loader: () => fetchPosts(), component: PostsComponent, }) diff --git a/examples/react/start-clerk-basic/src/routes/_authed/profile.$.tsx b/examples/react/start-clerk-basic/src/routes/_authed/profile.$.tsx index 208a38e230..f9b50197cf 100644 --- a/examples/react/start-clerk-basic/src/routes/_authed/profile.$.tsx +++ b/examples/react/start-clerk-basic/src/routes/_authed/profile.$.tsx @@ -1,7 +1,7 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '~/utils/posts.js' -export const Route = createFileRoute('/_authed/profile/$')({ +export const Route = createFileRoute({ loader: () => fetchPosts(), component: PostsComponent, }) diff --git a/examples/react/start-clerk-basic/src/routes/index.tsx b/examples/react/start-clerk-basic/src/routes/index.tsx index 6ae388a178..66baf1e9f1 100644 --- a/examples/react/start-clerk-basic/src/routes/index.tsx +++ b/examples/react/start-clerk-basic/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/e2e/react-start/clerk-basic/src/ssr.tsx b/examples/react/start-clerk-basic/src/server.ts similarity index 100% rename from e2e/react-start/clerk-basic/src/ssr.tsx rename to examples/react/start-clerk-basic/src/server.ts diff --git a/examples/react/start-clerk-basic/src/ssr.tsx b/examples/react/start-clerk-basic/src/ssr.tsx deleted file mode 100644 index 060cd4816b..0000000000 --- a/examples/react/start-clerk-basic/src/ssr.tsx +++ /dev/null @@ -1,17 +0,0 @@ -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' -import { createClerkHandler } from '@clerk/tanstack-react-start/server' -import { createRouter } from './router' - -const handler = createStartHandler({ - createRouter, - getRouterManifest, -}) - -const clerkHandler = createClerkHandler(handler) - -export default clerkHandler(defaultStreamHandler) diff --git a/examples/react/start-clerk-basic/vite.config.ts b/examples/react/start-clerk-basic/vite.config.ts new file mode 100644 index 0000000000..f451c4b69c --- /dev/null +++ b/examples/react/start-clerk-basic/vite.config.ts @@ -0,0 +1,15 @@ +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/examples/react/start-convex-trellaux/.gitignore b/examples/react/start-convex-trellaux/.gitignore index 30518e7416..ba7dbddfbe 100644 --- a/examples/react/start-convex-trellaux/.gitignore +++ b/examples/react/start-convex-trellaux/.gitignore @@ -7,14 +7,10 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin .env.local diff --git a/examples/react/start-convex-trellaux/.stackblitzrc b/examples/react/start-convex-trellaux/.stackblitzrc index 2f76846e62..e616ee3a78 100644 --- a/examples/react/start-convex-trellaux/.stackblitzrc +++ b/examples/react/start-convex-trellaux/.stackblitzrc @@ -1,3 +1,3 @@ { - "startCommand": "cp .env.local.example .env.local && npx vinxi dev" + "startCommand": "cp .env.local.example .env.local && npx vite dev" } diff --git a/examples/react/start-convex-trellaux/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-convex-trellaux/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/examples/react/start-convex-trellaux/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-convex-trellaux/app.config.ts b/examples/react/start-convex-trellaux/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/examples/react/start-convex-trellaux/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/examples/react/start-convex-trellaux/package.json b/examples/react/start-convex-trellaux/package.json index ab54a780df..57539d28f8 100644 --- a/examples/react/start-convex-trellaux/package.json +++ b/examples/react/start-convex-trellaux/package.json @@ -5,10 +5,10 @@ "type": "module", "scripts": { "dev": "npx convex dev --once && concurrently -r npm:dev:web npm:dev:db", - "dev:web": "vinxi dev", + "dev:web": "vite dev", "dev:db": "convex dev --run board:seed", - "build": "vinxi build", - "start": "vinxi start" + "build": "vite build", + "start": "vite start" }, "dependencies": { "@convex-dev/react-query": "0.0.0-alpha.8", @@ -28,7 +28,6 @@ "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", "tiny-invariant": "^1.3.3", - "vinxi": "0.5.3", "zod": "^3.24.2" }, "devDependencies": { diff --git a/examples/react/start-convex-trellaux/src/client.tsx b/examples/react/start-convex-trellaux/src/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/examples/react/start-convex-trellaux/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/examples/react/start-convex-trellaux/src/routeTree.gen.ts b/examples/react/start-convex-trellaux/src/routeTree.gen.ts index 7ee57387dc..81d9d390e4 100644 --- a/examples/react/start-convex-trellaux/src/routeTree.gen.ts +++ b/examples/react/start-convex-trellaux/src/routeTree.gen.ts @@ -10,19 +10,20 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' -import { Route as BoardsBoardIdImport } from './routes/boards.$boardId' +import { Route as IndexRouteImport } from './routes/index' +import { Route as BoardsBoardIdRouteImport } from './routes/boards.$boardId' // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const BoardsBoardIdRoute = BoardsBoardIdImport.update({ +const BoardsBoardIdRoute = BoardsBoardIdRouteImport.update({ id: '/boards/$boardId', path: '/boards/$boardId', getParentRoute: () => rootRoute, @@ -36,19 +37,40 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/boards/$boardId': { id: '/boards/$boardId' path: '/boards/$boardId' fullPath: '/boards/$boardId' - preLoaderRoute: typeof BoardsBoardIdImport + preLoaderRoute: typeof BoardsBoardIdRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/boards.$boardId' { + const createFileRoute: CreateFileRoute< + '/boards/$boardId', + FileRoutesByPath['/boards/$boardId']['parentRoute'], + FileRoutesByPath['/boards/$boardId']['id'], + FileRoutesByPath['/boards/$boardId']['path'], + FileRoutesByPath['/boards/$boardId']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -90,6 +112,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/start-convex-trellaux/src/routes/boards.$boardId.tsx b/examples/react/start-convex-trellaux/src/routes/boards.$boardId.tsx index 36896cbb02..19400b89f6 100644 --- a/examples/react/start-convex-trellaux/src/routes/boards.$boardId.tsx +++ b/examples/react/start-convex-trellaux/src/routes/boards.$boardId.tsx @@ -1,9 +1,8 @@ -import { createFileRoute } from '@tanstack/react-router' import { Board } from '~/components/Board' import { Loader } from '~/components/Loader' import { boardQueries } from '~/queries' -export const Route = createFileRoute('/boards/$boardId')({ +export const Route = createFileRoute({ component: Home, pendingComponent: () => , loader: async ({ params, context: { queryClient } }) => { diff --git a/examples/react/start-convex-trellaux/src/routes/index.tsx b/examples/react/start-convex-trellaux/src/routes/index.tsx index 154fc22e70..212bf2f5f8 100644 --- a/examples/react/start-convex-trellaux/src/routes/index.tsx +++ b/examples/react/start-convex-trellaux/src/routes/index.tsx @@ -1,10 +1,10 @@ import { useSuspenseQuery } from '@tanstack/react-query' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import { convexQuery } from '@convex-dev/react-query' import { api } from 'convex/_generated/api' import { Loader } from '~/components/Loader' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, pendingComponent: () => , }) diff --git a/e2e/react-start/server-functions/src/ssr.tsx b/examples/react/start-convex-trellaux/src/server.ts similarity index 100% rename from e2e/react-start/server-functions/src/ssr.tsx rename to examples/react/start-convex-trellaux/src/server.ts diff --git a/examples/react/start-convex-trellaux/src/ssr.tsx b/examples/react/start-convex-trellaux/src/ssr.tsx deleted file mode 100644 index 8981a9a338..0000000000 --- a/examples/react/start-convex-trellaux/src/ssr.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/examples/react/start-convex-trellaux/vite.config.ts b/examples/react/start-convex-trellaux/vite.config.ts new file mode 100644 index 0000000000..f451c4b69c --- /dev/null +++ b/examples/react/start-convex-trellaux/vite.config.ts @@ -0,0 +1,15 @@ +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/examples/react/start-counter/.gitignore b/examples/react/start-counter/.gitignore index 2b76174be5..08eba9e706 100644 --- a/examples/react/start-counter/.gitignore +++ b/examples/react/start-counter/.gitignore @@ -7,14 +7,10 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ diff --git a/examples/react/start-counter/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-counter/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/examples/react/start-counter/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-counter/app.config.ts b/examples/react/start-counter/app.config.ts deleted file mode 100644 index 83ec1302eb..0000000000 --- a/examples/react/start-counter/app.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -// app.config.ts -import { defineConfig } from '@tanstack/react-start/config' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, -}) diff --git a/examples/react/start-counter/package.json b/examples/react/start-counter/package.json index 5597354b06..cd7bbbb50b 100644 --- a/examples/react/start-counter/package.json +++ b/examples/react/start-counter/package.json @@ -4,17 +4,16 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "dependencies": { "@tanstack/react-router": "^1.120.3", "@tanstack/react-router-devtools": "^1.120.3", "@tanstack/react-start": "^1.120.3", "react": "^19.0.0", - "react-dom": "^19.0.0", - "vinxi": "0.5.3" + "react-dom": "^19.0.0" }, "devDependencies": { "@types/node": "^22.5.4", diff --git a/examples/react/start-counter/src/client.tsx b/examples/react/start-counter/src/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/examples/react/start-counter/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/examples/react/start-counter/src/routeTree.gen.ts b/examples/react/start-counter/src/routeTree.gen.ts index 5e682936ba..2a5dae4dd7 100644 --- a/examples/react/start-counter/src/routeTree.gen.ts +++ b/examples/react/start-counter/src/routeTree.gen.ts @@ -10,12 +10,13 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -29,12 +30,24 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -71,6 +84,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/start-counter/src/routes/index.tsx b/examples/react/start-counter/src/routes/index.tsx index 5a02f33eba..04431b1329 100644 --- a/examples/react/start-counter/src/routes/index.tsx +++ b/examples/react/start-counter/src/routes/index.tsx @@ -1,5 +1,5 @@ import * as fs from 'node:fs' -import { createFileRoute, useRouter } from '@tanstack/react-router' +import { useRouter } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' const filePath = 'count.txt' @@ -21,7 +21,7 @@ const updateCount = createServerFn({ method: 'POST' }) await fs.promises.writeFile(filePath, `${count + data}`) }) -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, loader: async () => await getCount(), }) diff --git a/examples/react/start-bare/src/ssr.tsx b/examples/react/start-counter/src/server.ts similarity index 100% rename from examples/react/start-bare/src/ssr.tsx rename to examples/react/start-counter/src/server.ts diff --git a/examples/react/start-counter/src/ssr.tsx b/examples/react/start-counter/src/ssr.tsx deleted file mode 100644 index 8981a9a338..0000000000 --- a/examples/react/start-counter/src/ssr.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/examples/react/start-counter/vite.config.ts b/examples/react/start-counter/vite.config.ts new file mode 100644 index 0000000000..abe66bc161 --- /dev/null +++ b/examples/react/start-counter/vite.config.ts @@ -0,0 +1,9 @@ +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' +import { defineConfig } from 'vite' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [TanStackStartVitePlugin()], +}) diff --git a/examples/react/start-large/.gitignore b/examples/react/start-large/.gitignore index cb9991202d..ca4ef70bc0 100644 --- a/examples/react/start-large/.gitignore +++ b/examples/react/start-large/.gitignore @@ -13,10 +13,7 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi \ No newline at end of file +/public/build \ No newline at end of file diff --git a/examples/react/start-large/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-large/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..75f8bd4d20 --- /dev/null +++ b/examples/react/start-large/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,110 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +import { ServerRoute as SearchSearchPlaceholderRouteImport } from './../../src/routes/search/searchPlaceholder' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +const SearchSearchPlaceholderRoute = SearchSearchPlaceholderRouteImport.update({ + id: '/search/searchPlaceholder', + path: '/search/searchPlaceholder', + getParentRoute: () => rootRoute, +} as any) + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath { + '/search/searchPlaceholder': { + id: '/search/searchPlaceholder' + path: '/search/searchPlaceholder' + fullPath: '/search/searchPlaceholder' + preLoaderRoute: typeof SearchSearchPlaceholderRouteImport + parentRoute: typeof rootRoute + } + } +} + +// Add type-safety to the createFileRoute function across the route tree + +declare module './../../src/routes/search/searchPlaceholder' { + const createServerFileRoute: CreateServerFileRoute< + FileRoutesByPath['/search/searchPlaceholder']['parentRoute'], + FileRoutesByPath['/search/searchPlaceholder']['id'], + FileRoutesByPath['/search/searchPlaceholder']['path'], + FileRoutesByPath['/search/searchPlaceholder']['fullPath'], + unknown + > +} + +// Create and export the route tree + +export interface FileRoutesByFullPath { + '/search/searchPlaceholder': typeof SearchSearchPlaceholderRoute +} + +export interface FileRoutesByTo { + '/search/searchPlaceholder': typeof SearchSearchPlaceholderRoute +} + +export interface FileRoutesById { + __root__: typeof rootRoute + '/search/searchPlaceholder': typeof SearchSearchPlaceholderRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: '/search/searchPlaceholder' + fileRoutesByTo: FileRoutesByTo + to: '/search/searchPlaceholder' + id: '__root__' | '/search/searchPlaceholder' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren { + SearchSearchPlaceholderRoute: typeof SearchSearchPlaceholderRoute +} + +const rootRouteChildren: RootRouteChildren = { + SearchSearchPlaceholderRoute: SearchSearchPlaceholderRoute, +} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [ + "/search/searchPlaceholder" + ] + }, + "/search/searchPlaceholder": { + "filePath": "search/searchPlaceholder.tsx" + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-large/app.config.ts b/examples/react/start-large/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/examples/react/start-large/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/examples/react/start-large/package.json b/examples/react/start-large/package.json index a9c4ced79d..fc01526099 100644 --- a/examples/react/start-large/package.json +++ b/examples/react/start-large/package.json @@ -4,9 +4,9 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start", + "dev": "vite dev", + "build": "vite build", + "start": "vite start", "gen": "node ./src/createRoutes.mjs", "test:types": "tsc --extendedDiagnostics" }, @@ -19,8 +19,7 @@ "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "valibot": "^1.0.0-beta.15", - "vinxi": "0.5.3" + "valibot": "^1.0.0-beta.15" }, "devDependencies": { "@types/node": "^22.5.4", diff --git a/examples/react/start-large/src/client.tsx b/examples/react/start-large/src/client.tsx deleted file mode 100644 index 4d4c49a500..0000000000 --- a/examples/react/start-large/src/client.tsx +++ /dev/null @@ -1,9 +0,0 @@ -// src/client.tsx -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/examples/react/start-large/src/routeTree.gen.ts b/examples/react/start-large/src/routeTree.gen.ts index e4f3a85ab1..3e7c909d14 100644 --- a/examples/react/start-large/src/routeTree.gen.ts +++ b/examples/react/start-large/src/routeTree.gen.ts @@ -10,61 +10,62 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as RelativeImport } from './routes/relative' -import { Route as LinkPropsImport } from './routes/linkProps' -import { Route as AbsoluteImport } from './routes/absolute' -import { Route as SearchRouteImport } from './routes/search/route' -import { Route as ParamsRouteImport } from './routes/params/route' -import { Route as IndexImport } from './routes/index' -import { Route as SearchSearchPlaceholderImport } from './routes/search/searchPlaceholder' -import { Route as ParamsParamsPlaceholderImport } from './routes/params/$paramsPlaceholder' +import { Route as RelativeRouteImport } from './routes/relative' +import { Route as LinkPropsRouteImport } from './routes/linkProps' +import { Route as AbsoluteRouteImport } from './routes/absolute' +import { Route as SearchRouteRouteImport } from './routes/search/route' +import { Route as ParamsRouteRouteImport } from './routes/params/route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as SearchSearchPlaceholderRouteImport } from './routes/search/searchPlaceholder' +import { Route as ParamsParamsPlaceholderRouteImport } from './routes/params/$paramsPlaceholder' // Create/Update Routes -const RelativeRoute = RelativeImport.update({ +const RelativeRoute = RelativeRouteImport.update({ id: '/relative', path: '/relative', getParentRoute: () => rootRoute, } as any) -const LinkPropsRoute = LinkPropsImport.update({ +const LinkPropsRoute = LinkPropsRouteImport.update({ id: '/linkProps', path: '/linkProps', getParentRoute: () => rootRoute, } as any) -const AbsoluteRoute = AbsoluteImport.update({ +const AbsoluteRoute = AbsoluteRouteImport.update({ id: '/absolute', path: '/absolute', getParentRoute: () => rootRoute, } as any) -const SearchRouteRoute = SearchRouteImport.update({ +const SearchRouteRoute = SearchRouteRouteImport.update({ id: '/search', path: '/search', getParentRoute: () => rootRoute, } as any) -const ParamsRouteRoute = ParamsRouteImport.update({ +const ParamsRouteRoute = ParamsRouteRouteImport.update({ id: '/params', path: '/params', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const SearchSearchPlaceholderRoute = SearchSearchPlaceholderImport.update({ +const SearchSearchPlaceholderRoute = SearchSearchPlaceholderRouteImport.update({ id: '/searchPlaceholder', path: '/searchPlaceholder', getParentRoute: () => SearchRouteRoute, } as any) -const ParamsParamsPlaceholderRoute = ParamsParamsPlaceholderImport.update({ +const ParamsParamsPlaceholderRoute = ParamsParamsPlaceholderRouteImport.update({ id: '/$paramsPlaceholder', path: '/$paramsPlaceholder', getParentRoute: () => ParamsRouteRoute, @@ -78,61 +79,136 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/params': { id: '/params' path: '/params' fullPath: '/params' - preLoaderRoute: typeof ParamsRouteImport + preLoaderRoute: typeof ParamsRouteRouteImport parentRoute: typeof rootRoute } '/search': { id: '/search' path: '/search' fullPath: '/search' - preLoaderRoute: typeof SearchRouteImport + preLoaderRoute: typeof SearchRouteRouteImport parentRoute: typeof rootRoute } '/absolute': { id: '/absolute' path: '/absolute' fullPath: '/absolute' - preLoaderRoute: typeof AbsoluteImport + preLoaderRoute: typeof AbsoluteRouteImport parentRoute: typeof rootRoute } '/linkProps': { id: '/linkProps' path: '/linkProps' fullPath: '/linkProps' - preLoaderRoute: typeof LinkPropsImport + preLoaderRoute: typeof LinkPropsRouteImport parentRoute: typeof rootRoute } '/relative': { id: '/relative' path: '/relative' fullPath: '/relative' - preLoaderRoute: typeof RelativeImport + preLoaderRoute: typeof RelativeRouteImport parentRoute: typeof rootRoute } '/params/$paramsPlaceholder': { id: '/params/$paramsPlaceholder' path: '/$paramsPlaceholder' fullPath: '/params/$paramsPlaceholder' - preLoaderRoute: typeof ParamsParamsPlaceholderImport - parentRoute: typeof ParamsRouteImport + preLoaderRoute: typeof ParamsParamsPlaceholderRouteImport + parentRoute: typeof ParamsRouteRouteImport } '/search/searchPlaceholder': { id: '/search/searchPlaceholder' path: '/searchPlaceholder' fullPath: '/search/searchPlaceholder' - preLoaderRoute: typeof SearchSearchPlaceholderImport - parentRoute: typeof SearchRouteImport + preLoaderRoute: typeof SearchSearchPlaceholderRouteImport + parentRoute: typeof SearchRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/params/route' { + const createFileRoute: CreateFileRoute< + '/params', + FileRoutesByPath['/params']['parentRoute'], + FileRoutesByPath['/params']['id'], + FileRoutesByPath['/params']['path'], + FileRoutesByPath['/params']['fullPath'] + > +} +declare module './routes/search/route' { + const createFileRoute: CreateFileRoute< + '/search', + FileRoutesByPath['/search']['parentRoute'], + FileRoutesByPath['/search']['id'], + FileRoutesByPath['/search']['path'], + FileRoutesByPath['/search']['fullPath'] + > +} +declare module './routes/absolute' { + const createFileRoute: CreateFileRoute< + '/absolute', + FileRoutesByPath['/absolute']['parentRoute'], + FileRoutesByPath['/absolute']['id'], + FileRoutesByPath['/absolute']['path'], + FileRoutesByPath['/absolute']['fullPath'] + > +} +declare module './routes/linkProps' { + const createFileRoute: CreateFileRoute< + '/linkProps', + FileRoutesByPath['/linkProps']['parentRoute'], + FileRoutesByPath['/linkProps']['id'], + FileRoutesByPath['/linkProps']['path'], + FileRoutesByPath['/linkProps']['fullPath'] + > +} +declare module './routes/relative' { + const createFileRoute: CreateFileRoute< + '/relative', + FileRoutesByPath['/relative']['parentRoute'], + FileRoutesByPath['/relative']['id'], + FileRoutesByPath['/relative']['path'], + FileRoutesByPath['/relative']['fullPath'] + > +} +declare module './routes/params/$paramsPlaceholder' { + const createFileRoute: CreateFileRoute< + '/params/$paramsPlaceholder', + FileRoutesByPath['/params/$paramsPlaceholder']['parentRoute'], + FileRoutesByPath['/params/$paramsPlaceholder']['id'], + FileRoutesByPath['/params/$paramsPlaceholder']['path'], + FileRoutesByPath['/params/$paramsPlaceholder']['fullPath'] + > +} +declare module './routes/search/searchPlaceholder' { + const createFileRoute: CreateFileRoute< + '/search/searchPlaceholder', + FileRoutesByPath['/search/searchPlaceholder']['parentRoute'], + FileRoutesByPath['/search/searchPlaceholder']['id'], + FileRoutesByPath['/search/searchPlaceholder']['path'], + FileRoutesByPath['/search/searchPlaceholder']['fullPath'] + > +} + // Create and export the route tree interface ParamsRouteRouteChildren { @@ -249,6 +325,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/start-large/src/routes/__root.tsx b/examples/react/start-large/src/routes/__root.tsx index 789c85c351..b52ca36ae8 100644 --- a/examples/react/start-large/src/routes/__root.tsx +++ b/examples/react/start-large/src/routes/__root.tsx @@ -7,7 +7,6 @@ import { } from '@tanstack/react-router' import type { QueryClient } from '@tanstack/react-query' import type { ReactNode } from 'react' -import appCss from '~/styles.css?url' import { TanStackRouterDevtools } from '@tanstack/react-router-devtools' export interface Context { queryClient: QueryClient @@ -15,7 +14,7 @@ export interface Context { export const Route = createRootRouteWithContext()({ head: () => ({ - links: [{ rel: 'stylesheet', href: appCss }], + links: [{ rel: 'stylesheet' }], meta: [ { charSet: 'utf-8', diff --git a/examples/react/start-large/src/routes/absolute.tsx b/examples/react/start-large/src/routes/absolute.tsx index ba1f875050..857515fa10 100644 --- a/examples/react/start-large/src/routes/absolute.tsx +++ b/examples/react/start-large/src/routes/absolute.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/absolute')({ +export const Route = createFileRoute({ component: AbsoluteComponent, }) diff --git a/examples/react/start-large/src/routes/index.tsx b/examples/react/start-large/src/routes/index.tsx index eac82a9174..b23956ae17 100644 --- a/examples/react/start-large/src/routes/index.tsx +++ b/examples/react/start-large/src/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/react/start-large/src/routes/linkProps.tsx b/examples/react/start-large/src/routes/linkProps.tsx index 4804161ccf..89ef1c2a36 100644 --- a/examples/react/start-large/src/routes/linkProps.tsx +++ b/examples/react/start-large/src/routes/linkProps.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { Link, createFileRoute, linkOptions } from '@tanstack/react-router' +import { Link, linkOptions } from '@tanstack/react-router' import { customRedirect, ListItems, @@ -7,7 +7,7 @@ import { useCustomNavigate, } from '~/typePrimitives' -export const Route = createFileRoute('/linkProps')({ +export const Route = createFileRoute({ component: LinkPropsPage, loader: () => { throw customRedirect({ diff --git a/examples/react/start-large/src/routes/params/$paramsPlaceholder.tsx b/examples/react/start-large/src/routes/params/$paramsPlaceholder.tsx index 45c00d1837..99486e6380 100644 --- a/examples/react/start-large/src/routes/params/$paramsPlaceholder.tsx +++ b/examples/react/start-large/src/routes/params/$paramsPlaceholder.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import * as v from 'valibot' import { queryOptions } from '@tanstack/react-query' import { createMiddleware, createServerFn } from '@tanstack/react-start' @@ -14,7 +14,7 @@ const loaderResult = v.object({ params, }) -const middleware = createMiddleware() +const middleware = createMiddleware({ type: 'function' }) .validator(params) .client(({ next }) => { const context = { client: { paramsPlaceholder: 'paramsPlaceholder' } } @@ -44,7 +44,7 @@ const paramsQueryOptions = queryOptions({ }, }) -export const Route = createFileRoute('/params/$paramsPlaceholder')({ +export const Route = createFileRoute({ component: ParamsComponent, context: () => ({ paramsQueryOptions: queryOptions({ diff --git a/examples/react/start-large/src/routes/params/route.tsx b/examples/react/start-large/src/routes/params/route.tsx index 32f2b82024..a37f312161 100644 --- a/examples/react/start-large/src/routes/params/route.tsx +++ b/examples/react/start-large/src/routes/params/route.tsx @@ -1,6 +1,5 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/params')({ +export const Route = createFileRoute({ component: () =>
Hello /params!
, }) diff --git a/examples/react/start-large/src/routes/relative.tsx b/examples/react/start-large/src/routes/relative.tsx index 6f6e581efd..cf25ec6f9f 100644 --- a/examples/react/start-large/src/routes/relative.tsx +++ b/examples/react/start-large/src/routes/relative.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/relative')({ +export const Route = createFileRoute({ component: RelativeComponent, }) diff --git a/examples/react/start-large/src/routes/search/route.tsx b/examples/react/start-large/src/routes/search/route.tsx index 3bcbe420e1..9829854586 100644 --- a/examples/react/start-large/src/routes/search/route.tsx +++ b/examples/react/start-large/src/routes/search/route.tsx @@ -1,11 +1,10 @@ -import { createFileRoute } from '@tanstack/react-router' import * as v from 'valibot' const search = v.object({ rootSearch: v.number(), }) -export const Route = createFileRoute('/search')({ +export const Route = createFileRoute({ component: () =>
Hello /search!
, validateSearch: search, }) diff --git a/examples/react/start-large/src/routes/search/searchPlaceholder.tsx b/examples/react/start-large/src/routes/search/searchPlaceholder.tsx index 56dc0a2931..1071a38cb7 100644 --- a/examples/react/start-large/src/routes/search/searchPlaceholder.tsx +++ b/examples/react/start-large/src/routes/search/searchPlaceholder.tsx @@ -1,4 +1,4 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import * as v from 'valibot' import { queryOptions } from '@tanstack/react-query' @@ -15,7 +15,7 @@ const loaderResult = v.object({ searchPlaceholder: v.number(), }) -const middleware = createMiddleware() +const middleware = createMiddleware({ type: 'function' }) .validator(search) .client(({ next }) => { const context = { client: { searchPlaceholder: 'searchPlaceholder' } } @@ -42,7 +42,13 @@ const fn = createServerFn() return result }) -export const Route = createFileRoute('/search/searchPlaceholder')({ +export const ServerRoute = createServerFileRoute().methods((api) => ({ + GET: api.handler(() => { + return 'searchPlaceholder' + }), +})) + +export const Route = createFileRoute({ component: SearchComponent, validateSearch: search, loaderDeps: ({ search }) => ({ search }), @@ -52,8 +58,16 @@ export const Route = createFileRoute('/search/searchPlaceholder')({ queryFn: () => fn({ data: ctx.deps.search }), }), }), - loader: (opts) => - opts.context.queryClient.ensureQueryData(opts.context.searchQueryOptions), + loader: async (opts) => { + const search = await opts.context.queryClient.ensureQueryData( + opts.context.searchQueryOptions, + ) + + return { + search, + external, + } + }, }) function SearchComponent() { diff --git a/examples/react/start-large/src/ssr.tsx b/examples/react/start-large/src/ssr.tsx deleted file mode 100644 index a24fb32843..0000000000 --- a/examples/react/start-large/src/ssr.tsx +++ /dev/null @@ -1,14 +0,0 @@ -// src/ssr.tsx -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/examples/react/start-large/vite.config.ts b/examples/react/start-large/vite.config.ts new file mode 100644 index 0000000000..f451c4b69c --- /dev/null +++ b/examples/react/start-large/vite.config.ts @@ -0,0 +1,15 @@ +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/examples/react/start-material-ui/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-material-ui/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/examples/react/start-material-ui/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-material-ui/app.config.ts b/examples/react/start-material-ui/app.config.ts deleted file mode 100644 index 659f799bb9..0000000000 --- a/examples/react/start-material-ui/app.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - ssr: { - noExternal: ['@mui/*'], - }, - - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/examples/react/start-material-ui/package.json b/examples/react/start-material-ui/package.json index e327c367b7..ac52782139 100644 --- a/examples/react/start-material-ui/package.json +++ b/examples/react/start-material-ui/package.json @@ -4,9 +4,9 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "dependencies": { "@emotion/cache": "11.14.0", @@ -19,7 +19,6 @@ "@tanstack/react-router-devtools": "^1.120.3", "react": "^19.0.0", "react-dom": "^19.0.0", - "vinxi": "0.5.3", "zod": "^3.24.2" }, "devDependencies": { diff --git a/examples/react/start-material-ui/src/routeTree.gen.ts b/examples/react/start-material-ui/src/routeTree.gen.ts index 48c183c8da..a4baf34c96 100644 --- a/examples/react/start-material-ui/src/routeTree.gen.ts +++ b/examples/react/start-material-ui/src/routeTree.gen.ts @@ -10,19 +10,20 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as AboutImport } from './routes/about' -import { Route as IndexImport } from './routes/index' +import { Route as AboutRouteImport } from './routes/about' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const AboutRoute = AboutImport.update({ +const AboutRoute = AboutRouteImport.update({ id: '/about', path: '/about', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -36,19 +37,40 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/about': { id: '/about' path: '/about' fullPath: '/about' - preLoaderRoute: typeof AboutImport + preLoaderRoute: typeof AboutRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/about' { + const createFileRoute: CreateFileRoute< + '/about', + FileRoutesByPath['/about']['parentRoute'], + FileRoutesByPath['/about']['id'], + FileRoutesByPath['/about']['path'], + FileRoutesByPath['/about']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -90,6 +112,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/start-material-ui/src/routes/about.tsx b/examples/react/start-material-ui/src/routes/about.tsx index 39492e85d7..1a9b347084 100644 --- a/examples/react/start-material-ui/src/routes/about.tsx +++ b/examples/react/start-material-ui/src/routes/about.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { Typography } from '@mui/material' -export const Route = createFileRoute('/about')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/examples/react/start-material-ui/src/routes/index.tsx b/examples/react/start-material-ui/src/routes/index.tsx index 75f5d14de4..f52a53f5ad 100644 --- a/examples/react/start-material-ui/src/routes/index.tsx +++ b/examples/react/start-material-ui/src/routes/index.tsx @@ -1,9 +1,8 @@ -import { createFileRoute } from '@tanstack/react-router' import { Stack, Typography } from '@mui/material' import z from 'zod' import { Counter } from '~/components/Counter' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ validateSearch: z.object({ count: z.number().optional(), }), diff --git a/examples/react/start-material-ui/vite.config.ts b/examples/react/start-material-ui/vite.config.ts new file mode 100644 index 0000000000..f451c4b69c --- /dev/null +++ b/examples/react/start-material-ui/vite.config.ts @@ -0,0 +1,15 @@ +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/examples/react/start-supabase-basic/.gitignore b/examples/react/start-supabase-basic/.gitignore index 5578fb7487..8293849e8d 100644 --- a/examples/react/start-supabase-basic/.gitignore +++ b/examples/react/start-supabase-basic/.gitignore @@ -9,14 +9,10 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ diff --git a/examples/react/start-supabase-basic/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-supabase-basic/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/examples/react/start-supabase-basic/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-supabase-basic/app.config.ts b/examples/react/start-supabase-basic/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/examples/react/start-supabase-basic/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/examples/react/start-supabase-basic/package.json b/examples/react/start-supabase-basic/package.json index 45d347e083..89e81f46c0 100644 --- a/examples/react/start-supabase-basic/package.json +++ b/examples/react/start-supabase-basic/package.json @@ -5,9 +5,9 @@ "main": "index.js", "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "keywords": [], "author": "", @@ -19,8 +19,7 @@ "@tanstack/react-router-devtools": "^1.120.3", "@tanstack/react-start": "^1.120.3", "react": "^19.0.0", - "react-dom": "^19.0.0", - "vinxi": "0.5.3" + "react-dom": "^19.0.0" }, "devDependencies": { "@types/react": "^19.0.8", diff --git a/examples/react/start-supabase-basic/src/client.tsx b/examples/react/start-supabase-basic/src/client.tsx deleted file mode 100644 index 4d4c49a500..0000000000 --- a/examples/react/start-supabase-basic/src/client.tsx +++ /dev/null @@ -1,9 +0,0 @@ -// src/client.tsx -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/examples/react/start-supabase-basic/src/routeTree.gen.ts b/examples/react/start-supabase-basic/src/routeTree.gen.ts index a37809fd07..73917eb528 100644 --- a/examples/react/start-supabase-basic/src/routeTree.gen.ts +++ b/examples/react/start-supabase-basic/src/routeTree.gen.ts @@ -10,60 +10,61 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as SignupImport } from './routes/signup' -import { Route as LogoutImport } from './routes/logout' -import { Route as LoginImport } from './routes/login' -import { Route as AuthedImport } from './routes/_authed' -import { Route as IndexImport } from './routes/index' -import { Route as AuthedPostsImport } from './routes/_authed/posts' -import { Route as AuthedPostsIndexImport } from './routes/_authed/posts.index' -import { Route as AuthedPostsPostIdImport } from './routes/_authed/posts.$postId' +import { Route as SignupRouteImport } from './routes/signup' +import { Route as LogoutRouteImport } from './routes/logout' +import { Route as LoginRouteImport } from './routes/login' +import { Route as AuthedRouteImport } from './routes/_authed' +import { Route as IndexRouteImport } from './routes/index' +import { Route as AuthedPostsRouteImport } from './routes/_authed/posts' +import { Route as AuthedPostsIndexRouteImport } from './routes/_authed/posts.index' +import { Route as AuthedPostsPostIdRouteImport } from './routes/_authed/posts.$postId' // Create/Update Routes -const SignupRoute = SignupImport.update({ +const SignupRoute = SignupRouteImport.update({ id: '/signup', path: '/signup', getParentRoute: () => rootRoute, } as any) -const LogoutRoute = LogoutImport.update({ +const LogoutRoute = LogoutRouteImport.update({ id: '/logout', path: '/logout', getParentRoute: () => rootRoute, } as any) -const LoginRoute = LoginImport.update({ +const LoginRoute = LoginRouteImport.update({ id: '/login', path: '/login', getParentRoute: () => rootRoute, } as any) -const AuthedRoute = AuthedImport.update({ +const AuthedRoute = AuthedRouteImport.update({ id: '/_authed', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const AuthedPostsRoute = AuthedPostsImport.update({ +const AuthedPostsRoute = AuthedPostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => AuthedRoute, } as any) -const AuthedPostsIndexRoute = AuthedPostsIndexImport.update({ +const AuthedPostsIndexRoute = AuthedPostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => AuthedPostsRoute, } as any) -const AuthedPostsPostIdRoute = AuthedPostsPostIdImport.update({ +const AuthedPostsPostIdRoute = AuthedPostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => AuthedPostsRoute, @@ -77,61 +78,136 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_authed': { id: '/_authed' path: '' fullPath: '' - preLoaderRoute: typeof AuthedImport + preLoaderRoute: typeof AuthedRouteImport parentRoute: typeof rootRoute } '/login': { id: '/login' path: '/login' fullPath: '/login' - preLoaderRoute: typeof LoginImport + preLoaderRoute: typeof LoginRouteImport parentRoute: typeof rootRoute } '/logout': { id: '/logout' path: '/logout' fullPath: '/logout' - preLoaderRoute: typeof LogoutImport + preLoaderRoute: typeof LogoutRouteImport parentRoute: typeof rootRoute } '/signup': { id: '/signup' path: '/signup' fullPath: '/signup' - preLoaderRoute: typeof SignupImport + preLoaderRoute: typeof SignupRouteImport parentRoute: typeof rootRoute } '/_authed/posts': { id: '/_authed/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof AuthedPostsImport - parentRoute: typeof AuthedImport + preLoaderRoute: typeof AuthedPostsRouteImport + parentRoute: typeof AuthedRouteImport } '/_authed/posts/$postId': { id: '/_authed/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof AuthedPostsPostIdImport - parentRoute: typeof AuthedPostsImport + preLoaderRoute: typeof AuthedPostsPostIdRouteImport + parentRoute: typeof AuthedPostsRouteImport } '/_authed/posts/': { id: '/_authed/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof AuthedPostsIndexImport - parentRoute: typeof AuthedPostsImport + preLoaderRoute: typeof AuthedPostsIndexRouteImport + parentRoute: typeof AuthedPostsRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_authed' { + const createFileRoute: CreateFileRoute< + '/_authed', + FileRoutesByPath['/_authed']['parentRoute'], + FileRoutesByPath['/_authed']['id'], + FileRoutesByPath['/_authed']['path'], + FileRoutesByPath['/_authed']['fullPath'] + > +} +declare module './routes/login' { + const createFileRoute: CreateFileRoute< + '/login', + FileRoutesByPath['/login']['parentRoute'], + FileRoutesByPath['/login']['id'], + FileRoutesByPath['/login']['path'], + FileRoutesByPath['/login']['fullPath'] + > +} +declare module './routes/logout' { + const createFileRoute: CreateFileRoute< + '/logout', + FileRoutesByPath['/logout']['parentRoute'], + FileRoutesByPath['/logout']['id'], + FileRoutesByPath['/logout']['path'], + FileRoutesByPath['/logout']['fullPath'] + > +} +declare module './routes/signup' { + const createFileRoute: CreateFileRoute< + '/signup', + FileRoutesByPath['/signup']['parentRoute'], + FileRoutesByPath['/signup']['id'], + FileRoutesByPath['/signup']['path'], + FileRoutesByPath['/signup']['fullPath'] + > +} +declare module './routes/_authed/posts' { + const createFileRoute: CreateFileRoute< + '/_authed/posts', + FileRoutesByPath['/_authed/posts']['parentRoute'], + FileRoutesByPath['/_authed/posts']['id'], + FileRoutesByPath['/_authed/posts']['path'], + FileRoutesByPath['/_authed/posts']['fullPath'] + > +} +declare module './routes/_authed/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/_authed/posts/$postId', + FileRoutesByPath['/_authed/posts/$postId']['parentRoute'], + FileRoutesByPath['/_authed/posts/$postId']['id'], + FileRoutesByPath['/_authed/posts/$postId']['path'], + FileRoutesByPath['/_authed/posts/$postId']['fullPath'] + > +} +declare module './routes/_authed/posts.index' { + const createFileRoute: CreateFileRoute< + '/_authed/posts/', + FileRoutesByPath['/_authed/posts/']['parentRoute'], + FileRoutesByPath['/_authed/posts/']['id'], + FileRoutesByPath['/_authed/posts/']['path'], + FileRoutesByPath['/_authed/posts/']['fullPath'] + > +} + // Create and export the route tree interface AuthedPostsRouteChildren { @@ -238,6 +314,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/start-supabase-basic/src/routes/_authed.tsx b/examples/react/start-supabase-basic/src/routes/_authed.tsx index 91b9ca133f..4ecd57cb86 100644 --- a/examples/react/start-supabase-basic/src/routes/_authed.tsx +++ b/examples/react/start-supabase-basic/src/routes/_authed.tsx @@ -1,4 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' import { Login } from '../components/Login' import { getSupabaseServerClient } from '../utils/supabase' @@ -20,7 +19,7 @@ export const loginFn = createServerFn({ method: 'POST' }) } }) -export const Route = createFileRoute('/_authed')({ +export const Route = createFileRoute({ beforeLoad: ({ context }) => { if (!context.user) { throw new Error('Not authenticated') diff --git a/examples/react/start-supabase-basic/src/routes/_authed/posts.$postId.tsx b/examples/react/start-supabase-basic/src/routes/_authed/posts.$postId.tsx index 4dd11756a8..0c58d7839f 100644 --- a/examples/react/start-supabase-basic/src/routes/_authed/posts.$postId.tsx +++ b/examples/react/start-supabase-basic/src/routes/_authed/posts.$postId.tsx @@ -1,9 +1,9 @@ -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import type { ErrorComponentProps } from '@tanstack/react-router' import { NotFound } from '~/components/NotFound' import { fetchPost } from '~/utils/posts' -export const Route = createFileRoute('/_authed/posts/$postId')({ +export const Route = createFileRoute({ loader: ({ params: { postId } }) => fetchPost({ data: postId }), errorComponent: PostErrorComponent, component: PostComponent, diff --git a/examples/react/start-supabase-basic/src/routes/_authed/posts.index.tsx b/examples/react/start-supabase-basic/src/routes/_authed/posts.index.tsx index ea9e667e54..13529228bb 100644 --- a/examples/react/start-supabase-basic/src/routes/_authed/posts.index.tsx +++ b/examples/react/start-supabase-basic/src/routes/_authed/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_authed/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/react/start-supabase-basic/src/routes/_authed/posts.tsx b/examples/react/start-supabase-basic/src/routes/_authed/posts.tsx index f7d863b8b9..fbcf599a08 100644 --- a/examples/react/start-supabase-basic/src/routes/_authed/posts.tsx +++ b/examples/react/start-supabase-basic/src/routes/_authed/posts.tsx @@ -1,7 +1,7 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../../utils/posts' -export const Route = createFileRoute('/_authed/posts')({ +export const Route = createFileRoute({ loader: () => fetchPosts(), component: PostsComponent, }) diff --git a/examples/react/start-supabase-basic/src/routes/index.tsx b/examples/react/start-supabase-basic/src/routes/index.tsx index 09a907cb18..f6c5b98b02 100644 --- a/examples/react/start-supabase-basic/src/routes/index.tsx +++ b/examples/react/start-supabase-basic/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/react/start-supabase-basic/src/routes/login.tsx b/examples/react/start-supabase-basic/src/routes/login.tsx index 64b539d819..9d7bd16865 100644 --- a/examples/react/start-supabase-basic/src/routes/login.tsx +++ b/examples/react/start-supabase-basic/src/routes/login.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router' import { Login } from '../components/Login' -export const Route = createFileRoute('/login')({ +export const Route = createFileRoute({ component: LoginComp, }) diff --git a/examples/react/start-supabase-basic/src/routes/logout.tsx b/examples/react/start-supabase-basic/src/routes/logout.tsx index a2f495c7fb..4b170c9bdd 100644 --- a/examples/react/start-supabase-basic/src/routes/logout.tsx +++ b/examples/react/start-supabase-basic/src/routes/logout.tsx @@ -1,4 +1,4 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' import { createServerFn } from '@tanstack/react-start' import { getSupabaseServerClient } from '../utils/supabase' @@ -18,7 +18,7 @@ const logoutFn = createServerFn().handler(async () => { }) }) -export const Route = createFileRoute('/logout')({ +export const Route = createFileRoute({ preload: false, loader: () => logoutFn(), }) diff --git a/examples/react/start-supabase-basic/src/routes/signup.tsx b/examples/react/start-supabase-basic/src/routes/signup.tsx index f37a2fa6a8..5896510b23 100644 --- a/examples/react/start-supabase-basic/src/routes/signup.tsx +++ b/examples/react/start-supabase-basic/src/routes/signup.tsx @@ -1,4 +1,4 @@ -import { createFileRoute, redirect } from '@tanstack/react-router' +import { redirect } from '@tanstack/react-router' import { createServerFn, useServerFn } from '@tanstack/react-start' import { useMutation } from '../hooks/useMutation' import { Auth } from '../components/Auth' @@ -27,7 +27,7 @@ export const signupFn = createServerFn({ method: 'POST' }) }) }) -export const Route = createFileRoute('/signup')({ +export const Route = createFileRoute({ component: SignupComp, }) diff --git a/examples/react/start-supabase-basic/src/ssr.tsx b/examples/react/start-supabase-basic/src/ssr.tsx deleted file mode 100644 index a24fb32843..0000000000 --- a/examples/react/start-supabase-basic/src/ssr.tsx +++ /dev/null @@ -1,14 +0,0 @@ -// src/ssr.tsx -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/examples/react/start-supabase-basic/vite.config.ts b/examples/react/start-supabase-basic/vite.config.ts new file mode 100644 index 0000000000..f451c4b69c --- /dev/null +++ b/examples/react/start-supabase-basic/vite.config.ts @@ -0,0 +1,15 @@ +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/examples/react/start-trellaux/.gitignore b/examples/react/start-trellaux/.gitignore index d3387e00cd..3c8e6870b3 100644 --- a/examples/react/start-trellaux/.gitignore +++ b/examples/react/start-trellaux/.gitignore @@ -7,12 +7,8 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin diff --git a/examples/react/start-trellaux/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-trellaux/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..52adc3a6f3 --- /dev/null +++ b/examples/react/start-trellaux/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/react-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/react-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-trellaux/app.config.ts b/examples/react/start-trellaux/app.config.ts deleted file mode 100644 index 90c7c8cba8..0000000000 --- a/examples/react/start-trellaux/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/examples/react/start-trellaux/package.json b/examples/react/start-trellaux/package.json index 8e30f6062d..d3db08d319 100644 --- a/examples/react/start-trellaux/package.json +++ b/examples/react/start-trellaux/package.json @@ -4,9 +4,9 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "dependencies": { "@tanstack/react-query": "^5.66.0", @@ -23,7 +23,6 @@ "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", "tiny-invariant": "^1.3.3", - "vinxi": "0.5.3", "zod": "^3.24.2" }, "devDependencies": { diff --git a/examples/react/start-trellaux/src/client.tsx b/examples/react/start-trellaux/src/client.tsx deleted file mode 100644 index 1593d1b3c7..0000000000 --- a/examples/react/start-trellaux/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document, ) diff --git a/examples/react/start-trellaux/src/routeTree.gen.ts b/examples/react/start-trellaux/src/routeTree.gen.ts index 7ee57387dc..81d9d390e4 100644 --- a/examples/react/start-trellaux/src/routeTree.gen.ts +++ b/examples/react/start-trellaux/src/routeTree.gen.ts @@ -10,19 +10,20 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' -import { Route as BoardsBoardIdImport } from './routes/boards.$boardId' +import { Route as IndexRouteImport } from './routes/index' +import { Route as BoardsBoardIdRouteImport } from './routes/boards.$boardId' // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const BoardsBoardIdRoute = BoardsBoardIdImport.update({ +const BoardsBoardIdRoute = BoardsBoardIdRouteImport.update({ id: '/boards/$boardId', path: '/boards/$boardId', getParentRoute: () => rootRoute, @@ -36,19 +37,40 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/boards/$boardId': { id: '/boards/$boardId' path: '/boards/$boardId' fullPath: '/boards/$boardId' - preLoaderRoute: typeof BoardsBoardIdImport + preLoaderRoute: typeof BoardsBoardIdRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/boards.$boardId' { + const createFileRoute: CreateFileRoute< + '/boards/$boardId', + FileRoutesByPath['/boards/$boardId']['parentRoute'], + FileRoutesByPath['/boards/$boardId']['id'], + FileRoutesByPath['/boards/$boardId']['path'], + FileRoutesByPath['/boards/$boardId']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -90,6 +112,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/start-trellaux/src/routes/boards.$boardId.tsx b/examples/react/start-trellaux/src/routes/boards.$boardId.tsx index 36896cbb02..19400b89f6 100644 --- a/examples/react/start-trellaux/src/routes/boards.$boardId.tsx +++ b/examples/react/start-trellaux/src/routes/boards.$boardId.tsx @@ -1,9 +1,8 @@ -import { createFileRoute } from '@tanstack/react-router' import { Board } from '~/components/Board' import { Loader } from '~/components/Loader' import { boardQueries } from '~/queries' -export const Route = createFileRoute('/boards/$boardId')({ +export const Route = createFileRoute({ component: Home, pendingComponent: () => , loader: async ({ params, context: { queryClient } }) => { diff --git a/examples/react/start-trellaux/src/routes/index.tsx b/examples/react/start-trellaux/src/routes/index.tsx index 3b9e1a5fac..85baed6c0b 100644 --- a/examples/react/start-trellaux/src/routes/index.tsx +++ b/examples/react/start-trellaux/src/routes/index.tsx @@ -1,9 +1,9 @@ import { useSuspenseQuery } from '@tanstack/react-query' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' import { Loader } from '~/components/Loader' import { boardQueries } from '~/queries' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, pendingComponent: () => , }) diff --git a/e2e/react-start/basic-tsr-config/src/app/ssr.tsx b/examples/react/start-trellaux/src/server.ts similarity index 87% rename from e2e/react-start/basic-tsr-config/src/app/ssr.tsx rename to examples/react/start-trellaux/src/server.ts index 8981a9a338..65a580f25e 100644 --- a/e2e/react-start/basic-tsr-config/src/app/ssr.tsx +++ b/examples/react/start-trellaux/src/server.ts @@ -1,4 +1,3 @@ -/// import { createStartHandler, defaultStreamHandler, diff --git a/examples/react/start-trellaux/src/ssr.tsx b/examples/react/start-trellaux/src/ssr.tsx deleted file mode 100644 index 8981a9a338..0000000000 --- a/examples/react/start-trellaux/src/ssr.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/// -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/examples/react/start-trellaux/vite.config.ts b/examples/react/start-trellaux/vite.config.ts new file mode 100644 index 0000000000..f451c4b69c --- /dev/null +++ b/examples/react/start-trellaux/vite.config.ts @@ -0,0 +1,15 @@ +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}) diff --git a/examples/react/start-workos/.gitignore b/examples/react/start-workos/.gitignore index c274dbb056..51e00c0d4a 100644 --- a/examples/react/start-workos/.gitignore +++ b/examples/react/start-workos/.gitignore @@ -7,10 +7,8 @@ yarn.lock .env .vercel .output -.vinxi /build/ /api/ /server/build /public/build -.vinxi diff --git a/examples/react/start-workos/.tanstack-start/server-routes/routeTree.gen.ts b/examples/react/start-workos/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..e4a8044a28 --- /dev/null +++ b/examples/react/start-workos/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,62 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { FileRoutesByPath, CreateServerFileRoute } from '@tanstack/react-start/server'; +import { createServerRoute, createServerFileRoute } from '@tanstack/react-start/server'; + +// Create/Update Routes + +const rootRoute = createServerRoute(); + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute; +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath; + fullPaths: never; + fileRoutesByTo: FileRoutesByTo; + to: never; + id: '__root__'; + fileRoutesById: FileRoutesById; +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {}; + +export const routeTree = rootRoute._addFileChildren(rootRouteChildren)._addFileTypes(); + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/react/start-workos/app.config.ts b/examples/react/start-workos/app.config.ts deleted file mode 100644 index 3096b30089..0000000000 --- a/examples/react/start-workos/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config'; -import tsConfigPaths from 'vite-tsconfig-paths'; - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}); diff --git a/examples/react/start-workos/package.json b/examples/react/start-workos/package.json index 9b4f6be98b..97f0798993 100644 --- a/examples/react/start-workos/package.json +++ b/examples/react/start-workos/package.json @@ -5,13 +5,13 @@ "main": "index.js", "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "keywords": [], "author": "", - "license": "ISC", + "license": "MIT", "dependencies": { "@radix-ui/themes": "^3.2.1", "@tanstack/react-router": "^1.120.3", @@ -22,7 +22,7 @@ "jose": "^6.0.10", "react": "^19.0.0", "react-dom": "^19.0.0", - "vinxi": "0.5.3" + "vite": "6.1.0" }, "devDependencies": { "@types/react": "^19.0.8", diff --git a/examples/react/start-workos/src/routeTree.gen.ts b/examples/react/start-workos/src/routeTree.gen.ts index f7cb0a82d5..a8296b28cd 100644 --- a/examples/react/start-workos/src/routeTree.gen.ts +++ b/examples/react/start-workos/src/routeTree.gen.ts @@ -10,32 +10,33 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router'; import { Route as rootRoute } from './routes/__root'; -import { Route as LogoutImport } from './routes/logout'; -import { Route as AuthenticatedImport } from './routes/_authenticated'; -import { Route as IndexImport } from './routes/index'; -import { Route as AuthenticatedAccountImport } from './routes/_authenticated/account'; +import { Route as LogoutRouteImport } from './routes/logout'; +import { Route as AuthenticatedRouteImport } from './routes/_authenticated'; +import { Route as IndexRouteImport } from './routes/index'; +import { Route as AuthenticatedAccountRouteImport } from './routes/_authenticated/account'; // Create/Update Routes -const LogoutRoute = LogoutImport.update({ +const LogoutRoute = LogoutRouteImport.update({ id: '/logout', path: '/logout', getParentRoute: () => rootRoute, } as any); -const AuthenticatedRoute = AuthenticatedImport.update({ +const AuthenticatedRoute = AuthenticatedRouteImport.update({ id: '/_authenticated', getParentRoute: () => rootRoute, } as any); -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any); -const AuthenticatedAccountRoute = AuthenticatedAccountImport.update({ +const AuthenticatedAccountRoute = AuthenticatedAccountRouteImport.update({ id: '/account', path: '/account', getParentRoute: () => AuthenticatedRoute, @@ -49,33 +50,72 @@ declare module '@tanstack/react-router' { id: '/'; path: '/'; fullPath: '/'; - preLoaderRoute: typeof IndexImport; + preLoaderRoute: typeof IndexRouteImport; parentRoute: typeof rootRoute; }; '/_authenticated': { id: '/_authenticated'; path: ''; fullPath: ''; - preLoaderRoute: typeof AuthenticatedImport; + preLoaderRoute: typeof AuthenticatedRouteImport; parentRoute: typeof rootRoute; }; '/logout': { id: '/logout'; path: '/logout'; fullPath: '/logout'; - preLoaderRoute: typeof LogoutImport; + preLoaderRoute: typeof LogoutRouteImport; parentRoute: typeof rootRoute; }; '/_authenticated/account': { id: '/_authenticated/account'; path: '/account'; fullPath: '/account'; - preLoaderRoute: typeof AuthenticatedAccountImport; - parentRoute: typeof AuthenticatedImport; + preLoaderRoute: typeof AuthenticatedAccountRouteImport; + parentRoute: typeof AuthenticatedRouteImport; }; } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + >; +} +declare module './routes/_authenticated' { + const createFileRoute: CreateFileRoute< + '/_authenticated', + FileRoutesByPath['/_authenticated']['parentRoute'], + FileRoutesByPath['/_authenticated']['id'], + FileRoutesByPath['/_authenticated']['path'], + FileRoutesByPath['/_authenticated']['fullPath'] + >; +} +declare module './routes/logout' { + const createFileRoute: CreateFileRoute< + '/logout', + FileRoutesByPath['/logout']['parentRoute'], + FileRoutesByPath['/logout']['id'], + FileRoutesByPath['/logout']['path'], + FileRoutesByPath['/logout']['fullPath'] + >; +} +declare module './routes/_authenticated/account' { + const createFileRoute: CreateFileRoute< + '/_authenticated/account', + FileRoutesByPath['/_authenticated/account']['parentRoute'], + FileRoutesByPath['/_authenticated/account']['id'], + FileRoutesByPath['/_authenticated/account']['path'], + FileRoutesByPath['/_authenticated/account']['fullPath'] + >; +} + // Create and export the route tree interface AuthenticatedRouteChildren { @@ -133,6 +173,9 @@ const rootRouteChildren: RootRouteChildren = { export const routeTree = rootRoute._addFileChildren(rootRouteChildren)._addFileTypes(); +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts'; + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/start-workos/src/routes/_authenticated.tsx b/examples/react/start-workos/src/routes/_authenticated.tsx index 2533014a27..a44930eaa1 100644 --- a/examples/react/start-workos/src/routes/_authenticated.tsx +++ b/examples/react/start-workos/src/routes/_authenticated.tsx @@ -1,7 +1,7 @@ -import { createFileRoute, redirect } from '@tanstack/react-router'; +import { redirect } from '@tanstack/react-router'; import { getSignInUrl } from '../authkit/serverFunctions'; -export const Route = createFileRoute('/_authenticated')({ +export const Route = createFileRoute({ beforeLoad: async ({ context, location }) => { if (!context.user) { const path = location.pathname; diff --git a/examples/react/start-workos/src/routes/_authenticated/account.tsx b/examples/react/start-workos/src/routes/_authenticated/account.tsx index b5a8a660a1..7776e66e53 100644 --- a/examples/react/start-workos/src/routes/_authenticated/account.tsx +++ b/examples/react/start-workos/src/routes/_authenticated/account.tsx @@ -1,8 +1,8 @@ import { Box, Flex, Heading, Text, TextField } from '@radix-ui/themes'; -import { createFileRoute } from '@tanstack/react-router'; +import {} from '@tanstack/react-router'; import { getAuth } from '../../authkit/serverFunctions'; -export const Route = createFileRoute('/_authenticated/account')({ +export const Route = createFileRoute({ component: RouteComponent, loader: async ({ context }) => { const { user } = context; diff --git a/examples/react/start-workos/src/routes/index.tsx b/examples/react/start-workos/src/routes/index.tsx index 6f2c64415b..f6ecd09981 100644 --- a/examples/react/start-workos/src/routes/index.tsx +++ b/examples/react/start-workos/src/routes/index.tsx @@ -1,9 +1,9 @@ import { Button, Flex, Heading, Text } from '@radix-ui/themes'; -import { Link, createFileRoute } from '@tanstack/react-router'; +import { Link } from '@tanstack/react-router'; import { getSignInUrl } from '../authkit/serverFunctions'; import SignInButton from '../components/sign-in-button'; -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, loader: async ({ context }) => { const { user } = context; diff --git a/examples/react/start-workos/src/routes/logout.tsx b/examples/react/start-workos/src/routes/logout.tsx index 41e8bc0b88..dc61380a45 100644 --- a/examples/react/start-workos/src/routes/logout.tsx +++ b/examples/react/start-workos/src/routes/logout.tsx @@ -1,7 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router'; import { signOut } from '../authkit/serverFunctions'; -export const Route = createFileRoute('/logout')({ +export const Route = createFileRoute({ preload: false, loader: () => signOut(), }); diff --git a/examples/react/start-workos/vite.config.ts b/examples/react/start-workos/vite.config.ts new file mode 100644 index 0000000000..94ce863f6e --- /dev/null +++ b/examples/react/start-workos/vite.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'vite'; +import tsConfigPaths from 'vite-tsconfig-paths'; +import { TanStackStartVitePlugin } from '@tanstack/react-start/plugin'; + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin(), + ], +}); diff --git a/examples/react/view-transitions/src/routeTree.gen.ts b/examples/react/view-transitions/src/routeTree.gen.ts index 7dc7f740d9..16f6bb007d 100644 --- a/examples/react/view-transitions/src/routeTree.gen.ts +++ b/examples/react/view-transitions/src/routeTree.gen.ts @@ -10,47 +10,48 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as HowItWorksImport } from './routes/how-it-works' -import { Route as ExploreImport } from './routes/explore' -import { Route as PostsRouteImport } from './routes/posts.route' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as PostsPostIdImport } from './routes/posts.$postId' +import { Route as HowItWorksRouteImport } from './routes/how-it-works' +import { Route as ExploreRouteImport } from './routes/explore' +import { Route as PostsRouteRouteImport } from './routes/posts.route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' // Create/Update Routes -const HowItWorksRoute = HowItWorksImport.update({ +const HowItWorksRoute = HowItWorksRouteImport.update({ id: '/how-it-works', path: '/how-it-works', getParentRoute: () => rootRoute, } as any) -const ExploreRoute = ExploreImport.update({ +const ExploreRoute = ExploreRouteImport.update({ id: '/explore', path: '/explore', getParentRoute: () => rootRoute, } as any) -const PostsRouteRoute = PostsRouteImport.update({ +const PostsRouteRoute = PostsRouteRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRouteRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRouteRoute, @@ -64,47 +65,104 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsRouteRouteImport parentRoute: typeof rootRoute } '/explore': { id: '/explore' path: '/explore' fullPath: '/explore' - preLoaderRoute: typeof ExploreImport + preLoaderRoute: typeof ExploreRouteImport parentRoute: typeof rootRoute } '/how-it-works': { id: '/how-it-works' path: '/how-it-works' fullPath: '/how-it-works' - preLoaderRoute: typeof HowItWorksImport + preLoaderRoute: typeof HowItWorksRouteImport parentRoute: typeof rootRoute } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/posts.route' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/explore' { + const createFileRoute: CreateFileRoute< + '/explore', + FileRoutesByPath['/explore']['parentRoute'], + FileRoutesByPath['/explore']['id'], + FileRoutesByPath['/explore']['path'], + FileRoutesByPath['/explore']['fullPath'] + > +} +declare module './routes/how-it-works' { + const createFileRoute: CreateFileRoute< + '/how-it-works', + FileRoutesByPath['/how-it-works']['parentRoute'], + FileRoutesByPath['/how-it-works']['id'], + FileRoutesByPath['/how-it-works']['path'], + FileRoutesByPath['/how-it-works']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} + // Create and export the route tree interface PostsRouteRouteChildren { @@ -188,6 +246,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/react/view-transitions/src/routes/explore.tsx b/examples/react/view-transitions/src/routes/explore.tsx index b70a6f3bd5..6728fd4ad8 100644 --- a/examples/react/view-transitions/src/routes/explore.tsx +++ b/examples/react/view-transitions/src/routes/explore.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/explore')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/examples/react/view-transitions/src/routes/how-it-works.tsx b/examples/react/view-transitions/src/routes/how-it-works.tsx index ab4dd4c714..bf2c1b4287 100644 --- a/examples/react/view-transitions/src/routes/how-it-works.tsx +++ b/examples/react/view-transitions/src/routes/how-it-works.tsx @@ -1,6 +1,6 @@ -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/how-it-works')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/examples/react/view-transitions/src/routes/index.tsx b/examples/react/view-transitions/src/routes/index.tsx index 132ba18dbb..d62a1aff95 100644 --- a/examples/react/view-transitions/src/routes/index.tsx +++ b/examples/react/view-transitions/src/routes/index.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import { Link, createFileRoute } from '@tanstack/react-router' +import { Link } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/react/view-transitions/src/routes/posts.$postId.tsx b/examples/react/view-transitions/src/routes/posts.$postId.tsx index cded91ef96..0578182ecb 100644 --- a/examples/react/view-transitions/src/routes/posts.$postId.tsx +++ b/examples/react/view-transitions/src/routes/posts.$postId.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import { ErrorComponent } from '@tanstack/react-router' import { fetchPost } from '../posts' import type { ErrorComponentProps } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent, notFoundComponent: () => { diff --git a/examples/react/view-transitions/src/routes/posts.index.tsx b/examples/react/view-transitions/src/routes/posts.index.tsx index 056433ca0a..fdbe5865e5 100644 --- a/examples/react/view-transitions/src/routes/posts.index.tsx +++ b/examples/react/view-transitions/src/routes/posts.index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/react/view-transitions/src/routes/posts.route.tsx b/examples/react/view-transitions/src/routes/posts.route.tsx index c63dc78ff2..41c034c7ee 100644 --- a/examples/react/view-transitions/src/routes/posts.route.tsx +++ b/examples/react/view-transitions/src/routes/posts.route.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { Link, Outlet } from '@tanstack/react-router' import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsLayoutComponent, }) diff --git a/examples/react/with-trpc-react-query/.gitignore b/examples/react/with-trpc-react-query/.gitignore index be342025da..ca63f49885 100644 --- a/examples/react/with-trpc-react-query/.gitignore +++ b/examples/react/with-trpc-react-query/.gitignore @@ -7,14 +7,10 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ diff --git a/examples/react/with-trpc-react-query/app.config.js b/examples/react/with-trpc-react-query/app.config.js index ef4eb87c7b..0f15246c33 100644 --- a/examples/react/with-trpc-react-query/app.config.js +++ b/examples/react/with-trpc-react-query/app.config.js @@ -1,8 +1,10 @@ -import { createApp } from 'vinxi' +import { defineConfig } from 'vite' import reactRefresh from '@vitejs/plugin-react' import { TanStackRouterVite } from '@tanstack/router-plugin/vite' -export default createApp({ +// TODO: Need to migrate this to vite and the new TanStack Start plugin + +export default defineConfig({ server: { preset: 'node-server', // change to 'netlify' or 'bun' or anyof the supported presets for nitro (nitro.unjs.io) experimental: { diff --git a/examples/react/with-trpc-react-query/package.json b/examples/react/with-trpc-react-query/package.json index bc9b26032a..4900f5621d 100644 --- a/examples/react/with-trpc-react-query/package.json +++ b/examples/react/with-trpc-react-query/package.json @@ -3,9 +3,9 @@ "private": true, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "dependencies": { "@tanstack/react-query": "^5.66.0", @@ -23,7 +23,6 @@ "postcss": "^8.5.1", "autoprefixer": "^10.4.20", "tailwindcss": "^3.4.17", - "vinxi": "0.5.3", "zod": "^3.24.2" }, "devDependencies": { diff --git a/examples/react/with-trpc-react-query/src/main.tsx b/examples/react/with-trpc-react-query/src/main.tsx index 4cc69baaac..bda5f47256 100644 --- a/examples/react/with-trpc-react-query/src/main.tsx +++ b/examples/react/with-trpc-react-query/src/main.tsx @@ -1,5 +1,3 @@ -/// - import React from 'react' import ReactDOM from 'react-dom/client' import { RouterProvider } from '@tanstack/react-router' diff --git a/examples/react/with-trpc-react-query/src/router.tsx b/examples/react/with-trpc-react-query/src/router.tsx index 1dfd9c4131..0d9dd5c4e4 100644 --- a/examples/react/with-trpc-react-query/src/router.tsx +++ b/examples/react/with-trpc-react-query/src/router.tsx @@ -15,7 +15,7 @@ export const trpc = createTRPCOptionsProxy({ client: createTRPCClient({ links: [ httpBatchLink({ - // since we are using Vinxi, the server is running on the same port, + // since we are using Vite, the server is running on the same port, // this means in dev the url is `http://localhost:3000/trpc` // and since its from the same origin, we don't need to explicitly set the full URL url: '/trpc', diff --git a/examples/react/with-trpc/.gitignore b/examples/react/with-trpc/.gitignore index be342025da..ca63f49885 100644 --- a/examples/react/with-trpc/.gitignore +++ b/examples/react/with-trpc/.gitignore @@ -7,14 +7,10 @@ yarn.lock .env .vercel .output -.vinxi - /build/ /api/ /server/build -/public/build -.vinxi -# Sentry Config File +/public/build# Sentry Config File .env.sentry-build-plugin /test-results/ /playwright-report/ diff --git a/examples/react/with-trpc/app.config.js b/examples/react/with-trpc/app.config.js index ef4eb87c7b..0f15246c33 100644 --- a/examples/react/with-trpc/app.config.js +++ b/examples/react/with-trpc/app.config.js @@ -1,8 +1,10 @@ -import { createApp } from 'vinxi' +import { defineConfig } from 'vite' import reactRefresh from '@vitejs/plugin-react' import { TanStackRouterVite } from '@tanstack/router-plugin/vite' -export default createApp({ +// TODO: Need to migrate this to vite and the new TanStack Start plugin + +export default defineConfig({ server: { preset: 'node-server', // change to 'netlify' or 'bun' or anyof the supported presets for nitro (nitro.unjs.io) experimental: { diff --git a/examples/react/with-trpc/package.json b/examples/react/with-trpc/package.json index 2414353240..708a214c3b 100644 --- a/examples/react/with-trpc/package.json +++ b/examples/react/with-trpc/package.json @@ -3,9 +3,9 @@ "private": true, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "dependencies": { "@tanstack/react-router": "^1.120.3", @@ -20,7 +20,6 @@ "postcss": "^8.5.1", "autoprefixer": "^10.4.20", "tailwindcss": "^3.4.17", - "vinxi": "0.5.3", "zod": "^3.24.2" }, "devDependencies": { diff --git a/examples/react/with-trpc/src/main.tsx b/examples/react/with-trpc/src/main.tsx index 3cff783e4b..ff5d7de693 100644 --- a/examples/react/with-trpc/src/main.tsx +++ b/examples/react/with-trpc/src/main.tsx @@ -1,5 +1,3 @@ -/// - import React from 'react' import ReactDOM from 'react-dom/client' import { RouterProvider, createRouter } from '@tanstack/react-router' diff --git a/examples/react/with-trpc/src/trpc.ts b/examples/react/with-trpc/src/trpc.ts index 243e4a6f5e..2320dcdfb6 100644 --- a/examples/react/with-trpc/src/trpc.ts +++ b/examples/react/with-trpc/src/trpc.ts @@ -4,7 +4,7 @@ import type { AppRouter } from '../trpc-server.handler' export const trpc = createTRPCClient({ links: [ httpBatchLink({ - // since we are using Vinxi, the server is running on the same port, + // since we are using Vite, the server is running on the same port, // this means in dev the url is `http://localhost:3000/trpc` // and since its from the same origin, we don't need to explicitly set the full URL url: '/trpc', diff --git a/examples/solid/basic-file-based/src/routeTree.gen.ts b/examples/solid/basic-file-based/src/routeTree.gen.ts index 1f53fb23d7..2479160c34 100644 --- a/examples/solid/basic-file-based/src/routeTree.gen.ts +++ b/examples/solid/basic-file-based/src/routeTree.gen.ts @@ -10,63 +10,63 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostsImport } from './routes/posts' -import { Route as PathlessLayoutImport } from './routes/_pathlessLayout' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as PathlessLayoutNestedLayoutImport } from './routes/_pathlessLayout/_nested-layout' -import { Route as PathlessLayoutNestedLayoutRouteBImport } from './routes/_pathlessLayout/_nested-layout/route-b' -import { Route as PathlessLayoutNestedLayoutRouteAImport } from './routes/_pathlessLayout/_nested-layout/route-a' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as PathlessLayoutNestedLayoutRouteImport } from './routes/_pathlessLayout/_nested-layout' +import { Route as PathlessLayoutNestedLayoutRouteBRouteImport } from './routes/_pathlessLayout/_nested-layout/route-b' +import { Route as PathlessLayoutNestedLayoutRouteARouteImport } from './routes/_pathlessLayout/_nested-layout/route-a' // Create/Update Routes -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const PathlessLayoutRoute = PathlessLayoutImport.update({ +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const PathlessLayoutNestedLayoutRoute = PathlessLayoutNestedLayoutImport.update( - { +const PathlessLayoutNestedLayoutRoute = + PathlessLayoutNestedLayoutRouteImport.update({ id: '/_nested-layout', getParentRoute: () => PathlessLayoutRoute, - } as any, -) + } as any) const PathlessLayoutNestedLayoutRouteBRoute = - PathlessLayoutNestedLayoutRouteBImport.update({ + PathlessLayoutNestedLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutNestedLayoutRoute, } as any) const PathlessLayoutNestedLayoutRouteARoute = - PathlessLayoutNestedLayoutRouteAImport.update({ + PathlessLayoutNestedLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutNestedLayoutRoute, @@ -80,61 +80,136 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout': { id: '/_pathlessLayout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout/_nested-layout': { id: '/_pathlessLayout/_nested-layout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutNestedLayoutImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/_pathlessLayout/_nested-layout/route-a': { id: '/_pathlessLayout/_nested-layout/route-a' path: '/route-a' fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteAImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/_pathlessLayout/_nested-layout/route-b': { id: '/_pathlessLayout/_nested-layout/route-b' path: '/route-b' fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_pathlessLayout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout', + FileRoutesByPath['/_pathlessLayout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout']['id'], + FileRoutesByPath['/_pathlessLayout']['path'], + FileRoutesByPath['/_pathlessLayout']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout', + FileRoutesByPath['/_pathlessLayout/_nested-layout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-a' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-a', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-b' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-b', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['fullPath'] + > +} + // Create and export the route tree interface PathlessLayoutNestedLayoutRouteChildren { @@ -251,6 +326,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/solid/basic-file-based/src/routes/_pathlessLayout.tsx b/examples/solid/basic-file-based/src/routes/_pathlessLayout.tsx index af197bc038..c549175638 100644 --- a/examples/solid/basic-file-based/src/routes/_pathlessLayout.tsx +++ b/examples/solid/basic-file-based/src/routes/_pathlessLayout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/solid/basic-file-based/src/routes/_pathlessLayout/_nested-layout.tsx b/examples/solid/basic-file-based/src/routes/_pathlessLayout/_nested-layout.tsx index f54a42abb4..dd2e04ea2b 100644 --- a/examples/solid/basic-file-based/src/routes/_pathlessLayout/_nested-layout.tsx +++ b/examples/solid/basic-file-based/src/routes/_pathlessLayout/_nested-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_pathlessLayout/_nested-layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/solid/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx b/examples/solid/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx index a22902a271..a0bd5240b7 100644 --- a/examples/solid/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx +++ b/examples/solid/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-a')( - { - component: LayoutAComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutAComponent, +}) function LayoutAComponent() { return
I'm A!
diff --git a/examples/solid/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx b/examples/solid/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx index 36231d2153..2864ec1f28 100644 --- a/examples/solid/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx +++ b/examples/solid/basic-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-b')( - { - component: LayoutBComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutBComponent, +}) function LayoutBComponent() { return
I'm B!
diff --git a/examples/solid/basic-file-based/src/routes/index.tsx b/examples/solid/basic-file-based/src/routes/index.tsx index bdfb4c7676..510db79b73 100644 --- a/examples/solid/basic-file-based/src/routes/index.tsx +++ b/examples/solid/basic-file-based/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/solid/basic-file-based/src/routes/posts.$postId.tsx b/examples/solid/basic-file-based/src/routes/posts.$postId.tsx index c673d45fa6..e06a7e1f38 100644 --- a/examples/solid/basic-file-based/src/routes/posts.$postId.tsx +++ b/examples/solid/basic-file-based/src/routes/posts.$postId.tsx @@ -1,8 +1,7 @@ -import { createFileRoute } from '@tanstack/solid-router' import { fetchPost } from '../posts' import { PostErrorComponent } from './-components/PostErrorComponent' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost(postId), errorComponent: PostErrorComponent, notFoundComponent: () => { diff --git a/examples/solid/basic-file-based/src/routes/posts.index.tsx b/examples/solid/basic-file-based/src/routes/posts.index.tsx index 33d0386c19..13529228bb 100644 --- a/examples/solid/basic-file-based/src/routes/posts.index.tsx +++ b/examples/solid/basic-file-based/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/solid/basic-file-based/src/routes/posts.tsx b/examples/solid/basic-file-based/src/routes/posts.tsx index 11a999f50a..2e28f9beb3 100644 --- a/examples/solid/basic-file-based/src/routes/posts.tsx +++ b/examples/solid/basic-file-based/src/routes/posts.tsx @@ -1,7 +1,7 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: fetchPosts, component: PostsComponent, }) diff --git a/examples/solid/basic-solid-query-file-based/src/routeTree.gen.ts b/examples/solid/basic-solid-query-file-based/src/routeTree.gen.ts index 1f53fb23d7..2479160c34 100644 --- a/examples/solid/basic-solid-query-file-based/src/routeTree.gen.ts +++ b/examples/solid/basic-solid-query-file-based/src/routeTree.gen.ts @@ -10,63 +10,63 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostsImport } from './routes/posts' -import { Route as PathlessLayoutImport } from './routes/_pathlessLayout' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as PostsPostIdImport } from './routes/posts.$postId' -import { Route as PathlessLayoutNestedLayoutImport } from './routes/_pathlessLayout/_nested-layout' -import { Route as PathlessLayoutNestedLayoutRouteBImport } from './routes/_pathlessLayout/_nested-layout/route-b' -import { Route as PathlessLayoutNestedLayoutRouteAImport } from './routes/_pathlessLayout/_nested-layout/route-a' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' +import { Route as PathlessLayoutNestedLayoutRouteImport } from './routes/_pathlessLayout/_nested-layout' +import { Route as PathlessLayoutNestedLayoutRouteBRouteImport } from './routes/_pathlessLayout/_nested-layout/route-b' +import { Route as PathlessLayoutNestedLayoutRouteARouteImport } from './routes/_pathlessLayout/_nested-layout/route-a' // Create/Update Routes -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const PathlessLayoutRoute = PathlessLayoutImport.update({ +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const PathlessLayoutNestedLayoutRoute = PathlessLayoutNestedLayoutImport.update( - { +const PathlessLayoutNestedLayoutRoute = + PathlessLayoutNestedLayoutRouteImport.update({ id: '/_nested-layout', getParentRoute: () => PathlessLayoutRoute, - } as any, -) + } as any) const PathlessLayoutNestedLayoutRouteBRoute = - PathlessLayoutNestedLayoutRouteBImport.update({ + PathlessLayoutNestedLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutNestedLayoutRoute, } as any) const PathlessLayoutNestedLayoutRouteARoute = - PathlessLayoutNestedLayoutRouteAImport.update({ + PathlessLayoutNestedLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutNestedLayoutRoute, @@ -80,61 +80,136 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout': { id: '/_pathlessLayout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout/_nested-layout': { id: '/_pathlessLayout/_nested-layout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutNestedLayoutImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/_pathlessLayout/_nested-layout/route-a': { id: '/_pathlessLayout/_nested-layout/route-a' path: '/route-a' fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteAImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/_pathlessLayout/_nested-layout/route-b': { id: '/_pathlessLayout/_nested-layout/route-b' path: '/route-b' fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_pathlessLayout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout', + FileRoutesByPath['/_pathlessLayout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout']['id'], + FileRoutesByPath['/_pathlessLayout']['path'], + FileRoutesByPath['/_pathlessLayout']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout', + FileRoutesByPath['/_pathlessLayout/_nested-layout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-a' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-a', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-b' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-b', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['fullPath'] + > +} + // Create and export the route tree interface PathlessLayoutNestedLayoutRouteChildren { @@ -251,6 +326,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout.tsx b/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout.tsx index b52af5379b..53068bc1bb 100644 --- a/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout.tsx +++ b/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout/_nested-layout.tsx b/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout/_nested-layout.tsx index f9a1b90b23..584515d8ec 100644 --- a/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout/_nested-layout.tsx +++ b/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout/_nested-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_pathlessLayout/_nested-layout')({ +export const Route = createFileRoute({ component: PathlessLayoutComponent, }) diff --git a/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx b/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx index a22902a271..a0bd5240b7 100644 --- a/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx +++ b/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-a.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-a')( - { - component: LayoutAComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutAComponent, +}) function LayoutAComponent() { return
I'm A!
diff --git a/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx b/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx index 36231d2153..2864ec1f28 100644 --- a/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx +++ b/examples/solid/basic-solid-query-file-based/src/routes/_pathlessLayout/_nested-layout/route-b.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-b')( - { - component: LayoutBComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutBComponent, +}) function LayoutBComponent() { return
I'm B!
diff --git a/examples/solid/basic-solid-query-file-based/src/routes/index.tsx b/examples/solid/basic-solid-query-file-based/src/routes/index.tsx index bdfb4c7676..510db79b73 100644 --- a/examples/solid/basic-solid-query-file-based/src/routes/index.tsx +++ b/examples/solid/basic-solid-query-file-based/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/solid/basic-solid-query-file-based/src/routes/posts.$postId.tsx b/examples/solid/basic-solid-query-file-based/src/routes/posts.$postId.tsx index 619428c4b5..38ae2af8bd 100644 --- a/examples/solid/basic-solid-query-file-based/src/routes/posts.$postId.tsx +++ b/examples/solid/basic-solid-query-file-based/src/routes/posts.$postId.tsx @@ -1,8 +1,4 @@ -import { - ErrorComponent, - createFileRoute, - useRouter, -} from '@tanstack/solid-router' +import { ErrorComponent, useRouter } from '@tanstack/solid-router' import { useQuery } from '@tanstack/solid-query' import { createEffect, createMemo } from 'solid-js' import { PostNotFoundError } from '../posts' @@ -35,7 +31,7 @@ export function PostErrorComponent({ error, reset }: ErrorComponentProps) { ) } -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: ({ context: { queryClient }, params: { postId } }) => { return queryClient.ensureQueryData(postQueryOptions(postId)) }, diff --git a/examples/solid/basic-solid-query-file-based/src/routes/posts.index.tsx b/examples/solid/basic-solid-query-file-based/src/routes/posts.index.tsx index 33d0386c19..13529228bb 100644 --- a/examples/solid/basic-solid-query-file-based/src/routes/posts.index.tsx +++ b/examples/solid/basic-solid-query-file-based/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/solid/basic-solid-query-file-based/src/routes/posts.tsx b/examples/solid/basic-solid-query-file-based/src/routes/posts.tsx index b0af26be32..a41ebe0dd7 100644 --- a/examples/solid/basic-solid-query-file-based/src/routes/posts.tsx +++ b/examples/solid/basic-solid-query-file-based/src/routes/posts.tsx @@ -1,9 +1,9 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' import { useQuery } from '@tanstack/solid-query' import { postsQueryOptions } from '../postsQueryOptions' import { createMemo } from 'solid-js' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: ({ context: { queryClient } }) => queryClient.ensureQueryData(postsQueryOptions), component: PostsComponent, diff --git a/examples/solid/kitchen-sink-file-based/src/routeTree.gen.ts b/examples/solid/kitchen-sink-file-based/src/routeTree.gen.ts index 0deb820043..2dcd3d7d64 100644 --- a/examples/solid/kitchen-sink-file-based/src/routeTree.gen.ts +++ b/examples/solid/kitchen-sink-file-based/src/routeTree.gen.ts @@ -10,129 +10,129 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as LoginImport } from './routes/login' -import { Route as PathlessLayoutImport } from './routes/_pathlessLayout' -import { Route as AuthImport } from './routes/_auth' -import { Route as DashboardRouteImport } from './routes/dashboard.route' -import { Route as IndexImport } from './routes/index' -import { Route as ExpensiveIndexImport } from './routes/expensive/index' -import { Route as DashboardIndexImport } from './routes/dashboard.index' -import { Route as PathlessLayoutRouteBImport } from './routes/_pathlessLayout.route-b' -import { Route as PathlessLayoutRouteAImport } from './routes/_pathlessLayout.route-a' -import { Route as AuthProfileImport } from './routes/_auth.profile' -import { Route as thisFolderIsNotInTheUrlRouteGroupImport } from './routes/(this-folder-is-not-in-the-url)/route-group' -import { Route as DashboardUsersRouteImport } from './routes/dashboard.users.route' -import { Route as DashboardInvoicesRouteImport } from './routes/dashboard.invoices.route' -import { Route as DashboardUsersIndexImport } from './routes/dashboard.users.index' -import { Route as DashboardInvoicesIndexImport } from './routes/dashboard.invoices.index' -import { Route as DashboardUsersUserImport } from './routes/dashboard.users.user' -import { Route as DashboardInvoicesInvoiceIdImport } from './routes/dashboard.invoices.$invoiceId' +import { Route as LoginRouteImport } from './routes/login' +import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' +import { Route as AuthRouteImport } from './routes/_auth' +import { Route as DashboardRouteRouteImport } from './routes/dashboard.route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as ExpensiveIndexRouteImport } from './routes/expensive/index' +import { Route as DashboardIndexRouteImport } from './routes/dashboard.index' +import { Route as PathlessLayoutRouteBRouteImport } from './routes/_pathlessLayout.route-b' +import { Route as PathlessLayoutRouteARouteImport } from './routes/_pathlessLayout.route-a' +import { Route as AuthProfileRouteImport } from './routes/_auth.profile' +import { Route as thisFolderIsNotInTheUrlRouteGroupRouteImport } from './routes/(this-folder-is-not-in-the-url)/route-group' +import { Route as DashboardUsersRouteRouteImport } from './routes/dashboard.users.route' +import { Route as DashboardInvoicesRouteRouteImport } from './routes/dashboard.invoices.route' +import { Route as DashboardUsersIndexRouteImport } from './routes/dashboard.users.index' +import { Route as DashboardInvoicesIndexRouteImport } from './routes/dashboard.invoices.index' +import { Route as DashboardUsersUserRouteImport } from './routes/dashboard.users.user' +import { Route as DashboardInvoicesInvoiceIdRouteImport } from './routes/dashboard.invoices.$invoiceId' // Create/Update Routes -const LoginRoute = LoginImport.update({ +const LoginRoute = LoginRouteImport.update({ id: '/login', path: '/login', getParentRoute: () => rootRoute, } as any) -const PathlessLayoutRoute = PathlessLayoutImport.update({ +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', getParentRoute: () => rootRoute, } as any) -const AuthRoute = AuthImport.update({ +const AuthRoute = AuthRouteImport.update({ id: '/_auth', getParentRoute: () => rootRoute, } as any) -const DashboardRouteRoute = DashboardRouteImport.update({ +const DashboardRouteRoute = DashboardRouteRouteImport.update({ id: '/dashboard', path: '/dashboard', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const ExpensiveIndexRoute = ExpensiveIndexImport.update({ +const ExpensiveIndexRoute = ExpensiveIndexRouteImport.update({ id: '/expensive/', path: '/expensive/', getParentRoute: () => rootRoute, } as any) -const DashboardIndexRoute = DashboardIndexImport.update({ +const DashboardIndexRoute = DashboardIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => DashboardRouteRoute, } as any) -const PathlessLayoutRouteBRoute = PathlessLayoutRouteBImport.update({ +const PathlessLayoutRouteBRoute = PathlessLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutRoute, } as any) -const PathlessLayoutRouteARoute = PathlessLayoutRouteAImport.update({ +const PathlessLayoutRouteARoute = PathlessLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutRoute, } as any) -const AuthProfileRoute = AuthProfileImport.update({ +const AuthProfileRoute = AuthProfileRouteImport.update({ id: '/profile', path: '/profile', getParentRoute: () => AuthRoute, } as any) const thisFolderIsNotInTheUrlRouteGroupRoute = - thisFolderIsNotInTheUrlRouteGroupImport.update({ + thisFolderIsNotInTheUrlRouteGroupRouteImport.update({ id: '/(this-folder-is-not-in-the-url)/route-group', path: '/route-group', getParentRoute: () => rootRoute, } as any) -const DashboardUsersRouteRoute = DashboardUsersRouteImport.update({ +const DashboardUsersRouteRoute = DashboardUsersRouteRouteImport.update({ id: '/users', path: '/users', getParentRoute: () => DashboardRouteRoute, } as any) -const DashboardInvoicesRouteRoute = DashboardInvoicesRouteImport.update({ +const DashboardInvoicesRouteRoute = DashboardInvoicesRouteRouteImport.update({ id: '/invoices', path: '/invoices', getParentRoute: () => DashboardRouteRoute, } as any) -const DashboardUsersIndexRoute = DashboardUsersIndexImport.update({ +const DashboardUsersIndexRoute = DashboardUsersIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => DashboardUsersRouteRoute, } as any) -const DashboardInvoicesIndexRoute = DashboardInvoicesIndexImport.update({ +const DashboardInvoicesIndexRoute = DashboardInvoicesIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => DashboardInvoicesRouteRoute, } as any) -const DashboardUsersUserRoute = DashboardUsersUserImport.update({ +const DashboardUsersUserRoute = DashboardUsersUserRouteImport.update({ id: '/user', path: '/user', getParentRoute: () => DashboardUsersRouteRoute, } as any) -const DashboardInvoicesInvoiceIdRoute = DashboardInvoicesInvoiceIdImport.update( - { +const DashboardInvoicesInvoiceIdRoute = + DashboardInvoicesInvoiceIdRouteImport.update({ id: '/$invoiceId', path: '/$invoiceId', getParentRoute: () => DashboardInvoicesRouteRoute, - } as any, -) + } as any) // Populate the FileRoutesByPath interface @@ -142,124 +142,280 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/dashboard': { id: '/dashboard' path: '/dashboard' fullPath: '/dashboard' - preLoaderRoute: typeof DashboardRouteImport + preLoaderRoute: typeof DashboardRouteRouteImport parentRoute: typeof rootRoute } '/_auth': { id: '/_auth' path: '' fullPath: '' - preLoaderRoute: typeof AuthImport + preLoaderRoute: typeof AuthRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout': { id: '/_pathlessLayout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteImport parentRoute: typeof rootRoute } '/login': { id: '/login' path: '/login' fullPath: '/login' - preLoaderRoute: typeof LoginImport + preLoaderRoute: typeof LoginRouteImport parentRoute: typeof rootRoute } '/dashboard/invoices': { id: '/dashboard/invoices' path: '/invoices' fullPath: '/dashboard/invoices' - preLoaderRoute: typeof DashboardInvoicesRouteImport - parentRoute: typeof DashboardRouteImport + preLoaderRoute: typeof DashboardInvoicesRouteRouteImport + parentRoute: typeof DashboardRouteRouteImport } '/dashboard/users': { id: '/dashboard/users' path: '/users' fullPath: '/dashboard/users' - preLoaderRoute: typeof DashboardUsersRouteImport - parentRoute: typeof DashboardRouteImport + preLoaderRoute: typeof DashboardUsersRouteRouteImport + parentRoute: typeof DashboardRouteRouteImport } '/(this-folder-is-not-in-the-url)/route-group': { id: '/(this-folder-is-not-in-the-url)/route-group' path: '/route-group' fullPath: '/route-group' - preLoaderRoute: typeof thisFolderIsNotInTheUrlRouteGroupImport + preLoaderRoute: typeof thisFolderIsNotInTheUrlRouteGroupRouteImport parentRoute: typeof rootRoute } '/_auth/profile': { id: '/_auth/profile' path: '/profile' fullPath: '/profile' - preLoaderRoute: typeof AuthProfileImport - parentRoute: typeof AuthImport + preLoaderRoute: typeof AuthProfileRouteImport + parentRoute: typeof AuthRouteImport } '/_pathlessLayout/route-a': { id: '/_pathlessLayout/route-a' path: '/route-a' fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutRouteAImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/_pathlessLayout/route-b': { id: '/_pathlessLayout/route-b' path: '/route-b' fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutRouteBImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/dashboard/': { id: '/dashboard/' path: '/' fullPath: '/dashboard/' - preLoaderRoute: typeof DashboardIndexImport - parentRoute: typeof DashboardRouteImport + preLoaderRoute: typeof DashboardIndexRouteImport + parentRoute: typeof DashboardRouteRouteImport } '/expensive/': { id: '/expensive/' path: '/expensive' fullPath: '/expensive' - preLoaderRoute: typeof ExpensiveIndexImport + preLoaderRoute: typeof ExpensiveIndexRouteImport parentRoute: typeof rootRoute } '/dashboard/invoices/$invoiceId': { id: '/dashboard/invoices/$invoiceId' path: '/$invoiceId' fullPath: '/dashboard/invoices/$invoiceId' - preLoaderRoute: typeof DashboardInvoicesInvoiceIdImport - parentRoute: typeof DashboardInvoicesRouteImport + preLoaderRoute: typeof DashboardInvoicesInvoiceIdRouteImport + parentRoute: typeof DashboardInvoicesRouteRouteImport } '/dashboard/users/user': { id: '/dashboard/users/user' path: '/user' fullPath: '/dashboard/users/user' - preLoaderRoute: typeof DashboardUsersUserImport - parentRoute: typeof DashboardUsersRouteImport + preLoaderRoute: typeof DashboardUsersUserRouteImport + parentRoute: typeof DashboardUsersRouteRouteImport } '/dashboard/invoices/': { id: '/dashboard/invoices/' path: '/' fullPath: '/dashboard/invoices/' - preLoaderRoute: typeof DashboardInvoicesIndexImport - parentRoute: typeof DashboardInvoicesRouteImport + preLoaderRoute: typeof DashboardInvoicesIndexRouteImport + parentRoute: typeof DashboardInvoicesRouteRouteImport } '/dashboard/users/': { id: '/dashboard/users/' path: '/' fullPath: '/dashboard/users/' - preLoaderRoute: typeof DashboardUsersIndexImport - parentRoute: typeof DashboardUsersRouteImport + preLoaderRoute: typeof DashboardUsersIndexRouteImport + parentRoute: typeof DashboardUsersRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/dashboard.route' { + const createFileRoute: CreateFileRoute< + '/dashboard', + FileRoutesByPath['/dashboard']['parentRoute'], + FileRoutesByPath['/dashboard']['id'], + FileRoutesByPath['/dashboard']['path'], + FileRoutesByPath['/dashboard']['fullPath'] + > +} +declare module './routes/_auth' { + const createFileRoute: CreateFileRoute< + '/_auth', + FileRoutesByPath['/_auth']['parentRoute'], + FileRoutesByPath['/_auth']['id'], + FileRoutesByPath['/_auth']['path'], + FileRoutesByPath['/_auth']['fullPath'] + > +} +declare module './routes/_pathlessLayout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout', + FileRoutesByPath['/_pathlessLayout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout']['id'], + FileRoutesByPath['/_pathlessLayout']['path'], + FileRoutesByPath['/_pathlessLayout']['fullPath'] + > +} +declare module './routes/login' { + const createFileRoute: CreateFileRoute< + '/login', + FileRoutesByPath['/login']['parentRoute'], + FileRoutesByPath['/login']['id'], + FileRoutesByPath['/login']['path'], + FileRoutesByPath['/login']['fullPath'] + > +} +declare module './routes/dashboard.invoices.route' { + const createFileRoute: CreateFileRoute< + '/dashboard/invoices', + FileRoutesByPath['/dashboard/invoices']['parentRoute'], + FileRoutesByPath['/dashboard/invoices']['id'], + FileRoutesByPath['/dashboard/invoices']['path'], + FileRoutesByPath['/dashboard/invoices']['fullPath'] + > +} +declare module './routes/dashboard.users.route' { + const createFileRoute: CreateFileRoute< + '/dashboard/users', + FileRoutesByPath['/dashboard/users']['parentRoute'], + FileRoutesByPath['/dashboard/users']['id'], + FileRoutesByPath['/dashboard/users']['path'], + FileRoutesByPath['/dashboard/users']['fullPath'] + > +} +declare module './routes/(this-folder-is-not-in-the-url)/route-group' { + const createFileRoute: CreateFileRoute< + '/(this-folder-is-not-in-the-url)/route-group', + FileRoutesByPath['/(this-folder-is-not-in-the-url)/route-group']['parentRoute'], + FileRoutesByPath['/(this-folder-is-not-in-the-url)/route-group']['id'], + FileRoutesByPath['/(this-folder-is-not-in-the-url)/route-group']['path'], + FileRoutesByPath['/(this-folder-is-not-in-the-url)/route-group']['fullPath'] + > +} +declare module './routes/_auth.profile' { + const createFileRoute: CreateFileRoute< + '/_auth/profile', + FileRoutesByPath['/_auth/profile']['parentRoute'], + FileRoutesByPath['/_auth/profile']['id'], + FileRoutesByPath['/_auth/profile']['path'], + FileRoutesByPath['/_auth/profile']['fullPath'] + > +} +declare module './routes/_pathlessLayout.route-a' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/route-a', + FileRoutesByPath['/_pathlessLayout/route-a']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/route-a']['id'], + FileRoutesByPath['/_pathlessLayout/route-a']['path'], + FileRoutesByPath['/_pathlessLayout/route-a']['fullPath'] + > +} +declare module './routes/_pathlessLayout.route-b' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/route-b', + FileRoutesByPath['/_pathlessLayout/route-b']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/route-b']['id'], + FileRoutesByPath['/_pathlessLayout/route-b']['path'], + FileRoutesByPath['/_pathlessLayout/route-b']['fullPath'] + > +} +declare module './routes/dashboard.index' { + const createFileRoute: CreateFileRoute< + '/dashboard/', + FileRoutesByPath['/dashboard/']['parentRoute'], + FileRoutesByPath['/dashboard/']['id'], + FileRoutesByPath['/dashboard/']['path'], + FileRoutesByPath['/dashboard/']['fullPath'] + > +} +declare module './routes/expensive/index' { + const createFileRoute: CreateFileRoute< + '/expensive/', + FileRoutesByPath['/expensive/']['parentRoute'], + FileRoutesByPath['/expensive/']['id'], + FileRoutesByPath['/expensive/']['path'], + FileRoutesByPath['/expensive/']['fullPath'] + > +} +declare module './routes/dashboard.invoices.$invoiceId' { + const createFileRoute: CreateFileRoute< + '/dashboard/invoices/$invoiceId', + FileRoutesByPath['/dashboard/invoices/$invoiceId']['parentRoute'], + FileRoutesByPath['/dashboard/invoices/$invoiceId']['id'], + FileRoutesByPath['/dashboard/invoices/$invoiceId']['path'], + FileRoutesByPath['/dashboard/invoices/$invoiceId']['fullPath'] + > +} +declare module './routes/dashboard.users.user' { + const createFileRoute: CreateFileRoute< + '/dashboard/users/user', + FileRoutesByPath['/dashboard/users/user']['parentRoute'], + FileRoutesByPath['/dashboard/users/user']['id'], + FileRoutesByPath['/dashboard/users/user']['path'], + FileRoutesByPath['/dashboard/users/user']['fullPath'] + > +} +declare module './routes/dashboard.invoices.index' { + const createFileRoute: CreateFileRoute< + '/dashboard/invoices/', + FileRoutesByPath['/dashboard/invoices/']['parentRoute'], + FileRoutesByPath['/dashboard/invoices/']['id'], + FileRoutesByPath['/dashboard/invoices/']['path'], + FileRoutesByPath['/dashboard/invoices/']['fullPath'] + > +} +declare module './routes/dashboard.users.index' { + const createFileRoute: CreateFileRoute< + '/dashboard/users/', + FileRoutesByPath['/dashboard/users/']['parentRoute'], + FileRoutesByPath['/dashboard/users/']['id'], + FileRoutesByPath['/dashboard/users/']['path'], + FileRoutesByPath['/dashboard/users/']['fullPath'] + > +} + // Create and export the route tree interface DashboardInvoicesRouteRouteChildren { @@ -468,6 +624,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/solid/kitchen-sink-file-based/src/routes/(this-folder-is-not-in-the-url)/route-group.tsx b/examples/solid/kitchen-sink-file-based/src/routes/(this-folder-is-not-in-the-url)/route-group.tsx index c06e439a1b..3b34f15613 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/(this-folder-is-not-in-the-url)/route-group.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/(this-folder-is-not-in-the-url)/route-group.tsx @@ -1,9 +1,6 @@ import * as Solid from 'solid-js' -import { createFileRoute } from '@tanstack/solid-router' -export const Route = createFileRoute( - '/(this-folder-is-not-in-the-url)/route-group', -)({ +export const Route = createFileRoute({ component: RouteGroupExample, }) diff --git a/examples/solid/kitchen-sink-file-based/src/routes/_auth.profile.tsx b/examples/solid/kitchen-sink-file-based/src/routes/_auth.profile.tsx index f67d367ee1..389d0f3477 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/_auth.profile.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/_auth.profile.tsx @@ -1,7 +1,6 @@ import * as Solid from 'solid-js' -import { createFileRoute } from '@tanstack/solid-router' -export const Route = createFileRoute('/_auth/profile')({ +export const Route = createFileRoute({ component: ProfileComponent, }) diff --git a/examples/solid/kitchen-sink-file-based/src/routes/_auth.tsx b/examples/solid/kitchen-sink-file-based/src/routes/_auth.tsx index a5b98f8631..6936f9e0ff 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/_auth.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/_auth.tsx @@ -1,7 +1,7 @@ -import { createFileRoute, redirect } from '@tanstack/solid-router' +import { redirect } from '@tanstack/solid-router' import { auth } from '../utils/auth' -export const Route = createFileRoute('/_auth')({ +export const Route = createFileRoute({ // Before loading, authenticate the user via our auth context // This will also happen during prefetching (e.g. hovering over links, etc) beforeLoad: ({ context, location }) => { diff --git a/examples/solid/kitchen-sink-file-based/src/routes/_pathlessLayout.route-a.tsx b/examples/solid/kitchen-sink-file-based/src/routes/_pathlessLayout.route-a.tsx index c1c392cbad..a0bd5240b7 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/_pathlessLayout.route-a.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/_pathlessLayout.route-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_pathlessLayout/route-a')({ +export const Route = createFileRoute({ component: LayoutAComponent, }) diff --git a/examples/solid/kitchen-sink-file-based/src/routes/_pathlessLayout.route-b.tsx b/examples/solid/kitchen-sink-file-based/src/routes/_pathlessLayout.route-b.tsx index 30dd035c93..2864ec1f28 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/_pathlessLayout.route-b.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/_pathlessLayout.route-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_pathlessLayout/route-b')({ +export const Route = createFileRoute({ component: LayoutBComponent, }) diff --git a/examples/solid/kitchen-sink-file-based/src/routes/_pathlessLayout.tsx b/examples/solid/kitchen-sink-file-based/src/routes/_pathlessLayout.tsx index 9e090b1166..ebfb59943c 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/_pathlessLayout.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/_pathlessLayout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: PathlessLayoutComponent, }) diff --git a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.index.tsx b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.index.tsx index f967ed4f4b..d046fd363b 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.index.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.index.tsx @@ -1,8 +1,8 @@ import * as Solid from 'solid-js' -import { createFileRoute } from '@tanstack/solid-router' + import { fetchInvoices } from '../utils/mockTodos' -export const Route = createFileRoute('/dashboard/')({ +export const Route = createFileRoute({ loader: () => fetchInvoices(), component: DashboardIndexComponent, }) diff --git a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.invoices.$invoiceId.tsx b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.invoices.$invoiceId.tsx index c5c35e15b9..5f520989a7 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.invoices.$invoiceId.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.invoices.$invoiceId.tsx @@ -1,16 +1,11 @@ import * as Solid from 'solid-js' -import { - Link, - createFileRoute, - useNavigate, - useRouter, -} from '@tanstack/solid-router' +import { Link, useNavigate, useRouter } from '@tanstack/solid-router' import { z } from 'zod' import { InvoiceFields } from '../components/InvoiceFields' import { useMutation } from '../hooks/useMutation' import { fetchInvoiceById, patchInvoice } from '../utils/mockTodos' -export const Route = createFileRoute('/dashboard/invoices/$invoiceId')({ +export const Route = createFileRoute({ params: { parse: (params) => ({ invoiceId: z.number().int().parse(Number(params.invoiceId)), diff --git a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.invoices.index.tsx b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.invoices.index.tsx index 936a2b01b3..591a53b7cb 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.invoices.index.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.invoices.index.tsx @@ -1,12 +1,12 @@ import * as Solid from 'solid-js' -import { createFileRoute, useRouter } from '@tanstack/solid-router' +import { useRouter } from '@tanstack/solid-router' import { InvoiceFields } from '../components/InvoiceFields' import { Spinner } from '../components/Spinner' import { useMutation } from '../hooks/useMutation' import { postInvoice } from '../utils/mockTodos' import type { Invoice } from '../utils/mockTodos' -export const Route = createFileRoute('/dashboard/invoices/')({ +export const Route = createFileRoute({ component: InvoicesIndexComponent, }) diff --git a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.invoices.route.tsx b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.invoices.route.tsx index 11668cac8e..817a493f75 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.invoices.route.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.invoices.route.tsx @@ -1,14 +1,9 @@ import * as Solid from 'solid-js' -import { - Link, - MatchRoute, - Outlet, - createFileRoute, -} from '@tanstack/solid-router' +import { Link, MatchRoute, Outlet } from '@tanstack/solid-router' import { Spinner } from '../components/Spinner' import { fetchInvoices } from '../utils/mockTodos' -export const Route = createFileRoute('/dashboard/invoices')({ +export const Route = createFileRoute({ loader: () => fetchInvoices(), component: InvoicesComponent, }) diff --git a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.route.tsx b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.route.tsx index c10209e841..fe88331414 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.route.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.route.tsx @@ -1,12 +1,7 @@ import * as Solid from 'solid-js' -import { - Link, - Outlet, - createFileRoute, - linkOptions, -} from '@tanstack/solid-router' +import { Link, Outlet, linkOptions } from '@tanstack/solid-router' -export const Route = createFileRoute('/dashboard')({ +export const Route = createFileRoute({ component: DashboardComponent, loader: () => ({ crumb: 'Dashboard', diff --git a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.users.index.tsx b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.users.index.tsx index 268107589d..b6f431fbdf 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.users.index.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.users.index.tsx @@ -1,7 +1,6 @@ import * as Solid from 'solid-js' -import { createFileRoute } from '@tanstack/solid-router' -export const Route = createFileRoute('/dashboard/users/')({ +export const Route = createFileRoute({ component: UsersIndexComponent, }) diff --git a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.users.route.tsx b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.users.route.tsx index dee3a070ec..32213eacb2 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.users.route.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.users.route.tsx @@ -3,7 +3,6 @@ import { Link, MatchRoute, Outlet, - createFileRoute, retainSearchParams, useNavigate, useRouterState, @@ -15,7 +14,7 @@ import { fetchUsers } from '../utils/mockTodos' type UsersViewSortBy = 'name' | 'id' | 'email' -export const Route = createFileRoute('/dashboard/users')({ +export const Route = createFileRoute({ validateSearch: z.object({ usersView: z .object({ diff --git a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.users.user.tsx b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.users.user.tsx index 84cecbe1c0..962d1e27cb 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/dashboard.users.user.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/dashboard.users.user.tsx @@ -1,9 +1,9 @@ import * as Solid from 'solid-js' -import { createFileRoute } from '@tanstack/solid-router' + import { z } from 'zod' import { fetchUserById } from '../utils/mockTodos' -export const Route = createFileRoute('/dashboard/users/user')({ +export const Route = createFileRoute({ validateSearch: z.object({ userId: z.number(), }), diff --git a/examples/solid/kitchen-sink-file-based/src/routes/expensive/index.tsx b/examples/solid/kitchen-sink-file-based/src/routes/expensive/index.tsx index f1ae88b32b..5066d67ac5 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/expensive/index.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/expensive/index.tsx @@ -1,6 +1,5 @@ -import { createFileRoute } from '@tanstack/solid-router' import Expensive from './-components/Expensive' -export const Route = createFileRoute('/expensive/')({ +export const Route = createFileRoute({ component: Expensive, }) diff --git a/examples/solid/kitchen-sink-file-based/src/routes/index.tsx b/examples/solid/kitchen-sink-file-based/src/routes/index.tsx index 3301318ef3..d0f309f8b5 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/index.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/index.tsx @@ -1,7 +1,7 @@ import * as Solid from 'solid-js' -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: IndexComponent, }) diff --git a/examples/solid/kitchen-sink-file-based/src/routes/login.tsx b/examples/solid/kitchen-sink-file-based/src/routes/login.tsx index 1a4bed3e9c..823555d813 100644 --- a/examples/solid/kitchen-sink-file-based/src/routes/login.tsx +++ b/examples/solid/kitchen-sink-file-based/src/routes/login.tsx @@ -1,8 +1,8 @@ import * as Solid from 'solid-js' -import { createFileRoute, useRouter } from '@tanstack/solid-router' +import { useRouter } from '@tanstack/solid-router' import { z } from 'zod' -export const Route = createFileRoute('/login')({ +export const Route = createFileRoute({ validateSearch: z.object({ redirect: z.string().optional(), }), diff --git a/examples/solid/quickstart-file-based/src/routeTree.gen.ts b/examples/solid/quickstart-file-based/src/routeTree.gen.ts index cb367c516c..990f81106d 100644 --- a/examples/solid/quickstart-file-based/src/routeTree.gen.ts +++ b/examples/solid/quickstart-file-based/src/routeTree.gen.ts @@ -10,19 +10,20 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as AboutImport } from './routes/about' -import { Route as IndexImport } from './routes/index' +import { Route as AboutRouteImport } from './routes/about' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const AboutRoute = AboutImport.update({ +const AboutRoute = AboutRouteImport.update({ id: '/about', path: '/about', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -36,19 +37,40 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/about': { id: '/about' path: '/about' fullPath: '/about' - preLoaderRoute: typeof AboutImport + preLoaderRoute: typeof AboutRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/about' { + const createFileRoute: CreateFileRoute< + '/about', + FileRoutesByPath['/about']['parentRoute'], + FileRoutesByPath['/about']['id'], + FileRoutesByPath['/about']['path'], + FileRoutesByPath['/about']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -90,6 +112,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/solid/quickstart-file-based/src/routes/about.tsx b/examples/solid/quickstart-file-based/src/routes/about.tsx index 4596223513..5cc1a89442 100644 --- a/examples/solid/quickstart-file-based/src/routes/about.tsx +++ b/examples/solid/quickstart-file-based/src/routes/about.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/about')({ +export const Route = createFileRoute({ component: AboutComponent, }) diff --git a/examples/solid/quickstart-file-based/src/routes/index.tsx b/examples/solid/quickstart-file-based/src/routes/index.tsx index c71b5d33f2..e64f9b04f0 100644 --- a/examples/solid/quickstart-file-based/src/routes/index.tsx +++ b/examples/solid/quickstart-file-based/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: HomeComponent, }) diff --git a/examples/solid/start-bare/.tanstack-start/server-routes/routeTree.gen.ts b/examples/solid/start-bare/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..2dc6bfc4bd --- /dev/null +++ b/examples/solid/start-bare/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/solid-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/solid-start/server' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/solid-start/server' { + interface FileRoutesByPath {} +} + +// Add type-safety to the createFileRoute function across the route tree + +// Create and export the route tree + +export interface FileRoutesByFullPath {} + +export interface FileRoutesByTo {} + +export interface FileRoutesById { + __root__: typeof rootRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren {} + +const rootRouteChildren: RootRouteChildren = {} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [] + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/solid/start-bare/app.config.ts b/examples/solid/start-bare/app.config.ts deleted file mode 100644 index 19c03a0458..0000000000 --- a/examples/solid/start-bare/app.config.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { defineConfig } from '@tanstack/solid-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' -import tailwindcss from '@tailwindcss/vite' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - tailwindcss(), - ], - }, -}) diff --git a/examples/solid/start-bare/package.json b/examples/solid/start-bare/package.json index 2a94ab0a76..d5b05f1bed 100644 --- a/examples/solid/start-bare/package.json +++ b/examples/solid/start-bare/package.json @@ -4,9 +4,9 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "dependencies": { "@tanstack/solid-router": "^1.120.3", @@ -15,7 +15,7 @@ "solid-js": "^1.9.5", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vinxi": "0.5.3", + "vite": "6.1.0", "zod": "^3.24.2" }, "devDependencies": { diff --git a/examples/solid/start-bare/src/client.tsx b/examples/solid/start-bare/src/client.tsx deleted file mode 100644 index ba0f02fac0..0000000000 --- a/examples/solid/start-bare/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrate } from 'solid-js/web' -import { StartClient } from '@tanstack/solid-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrate(() => , document.body) diff --git a/examples/solid/start-bare/src/routeTree.gen.ts b/examples/solid/start-bare/src/routeTree.gen.ts index cb367c516c..990f81106d 100644 --- a/examples/solid/start-bare/src/routeTree.gen.ts +++ b/examples/solid/start-bare/src/routeTree.gen.ts @@ -10,19 +10,20 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/solid-router' import { Route as rootRoute } from './routes/__root' -import { Route as AboutImport } from './routes/about' -import { Route as IndexImport } from './routes/index' +import { Route as AboutRouteImport } from './routes/about' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const AboutRoute = AboutImport.update({ +const AboutRoute = AboutRouteImport.update({ id: '/about', path: '/about', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -36,19 +37,40 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/about': { id: '/about' path: '/about' fullPath: '/about' - preLoaderRoute: typeof AboutImport + preLoaderRoute: typeof AboutRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/about' { + const createFileRoute: CreateFileRoute< + '/about', + FileRoutesByPath['/about']['parentRoute'], + FileRoutesByPath['/about']['id'], + FileRoutesByPath['/about']['path'], + FileRoutesByPath['/about']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -90,6 +112,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/solid/start-bare/src/routes/about.tsx b/examples/solid/start-bare/src/routes/about.tsx index d66c7db828..f0d5d234a0 100644 --- a/examples/solid/start-bare/src/routes/about.tsx +++ b/examples/solid/start-bare/src/routes/about.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/about')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/examples/solid/start-bare/src/routes/index.tsx b/examples/solid/start-bare/src/routes/index.tsx index 6a91bd1999..2f6c3c11e9 100644 --- a/examples/solid/start-bare/src/routes/index.tsx +++ b/examples/solid/start-bare/src/routes/index.tsx @@ -1,6 +1,5 @@ -import { createFileRoute } from '@tanstack/solid-router' import Counter from '~/components/Counter' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/examples/solid/start-bare/src/ssr.tsx b/examples/solid/start-bare/src/ssr.tsx deleted file mode 100644 index 6d10bea05f..0000000000 --- a/examples/solid/start-bare/src/ssr.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/solid-start/server' -import { getRouterManifest } from '@tanstack/solid-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/examples/solid/start-bare/vite.config.ts b/examples/solid/start-bare/vite.config.ts new file mode 100644 index 0000000000..4c05ddd1ef --- /dev/null +++ b/examples/solid/start-bare/vite.config.ts @@ -0,0 +1,17 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/solid-start/plugin' +import tailwindcss from '@tailwindcss/vite' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin({}), + tailwindcss(), + ], +}) diff --git a/examples/solid/start-basic/.tanstack-start/server-routes/routeTree.gen.ts b/examples/solid/start-basic/.tanstack-start/server-routes/routeTree.gen.ts new file mode 100644 index 0000000000..e36fccb479 --- /dev/null +++ b/examples/solid/start-basic/.tanstack-start/server-routes/routeTree.gen.ts @@ -0,0 +1,155 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { + FileRoutesByPath, + CreateServerFileRoute, +} from '@tanstack/solid-start/server' +import { + createServerRoute, + createServerFileRoute, +} from '@tanstack/solid-start/server' + +import { ServerRoute as ApiUsersRouteImport } from './../../src/routes/api/users' +import { ServerRoute as ApiUsersUserIdRouteImport } from './../../src/routes/api/users.$userId' + +// Create/Update Routes + +const rootRoute = createServerRoute() + +const ApiUsersRoute = ApiUsersRouteImport.update({ + id: '/api/users', + path: '/api/users', + getParentRoute: () => rootRoute, +} as any) + +const ApiUsersUserIdRoute = ApiUsersUserIdRouteImport.update({ + id: '/$userId', + path: '/$userId', + getParentRoute: () => ApiUsersRoute, +} as any) + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/solid-start/server' { + interface FileRoutesByPath { + '/api/users': { + id: '/api/users' + path: '/api/users' + fullPath: '/api/users' + preLoaderRoute: typeof ApiUsersRouteImport + parentRoute: typeof rootRoute + } + '/api/users/$userId': { + id: '/api/users/$userId' + path: '/$userId' + fullPath: '/api/users/$userId' + preLoaderRoute: typeof ApiUsersUserIdRouteImport + parentRoute: typeof ApiUsersRouteImport + } + } +} + +// Add type-safety to the createFileRoute function across the route tree + +declare module './../../src/routes/api/users' { + const createServerFileRoute: CreateServerFileRoute< + FileRoutesByPath['/api/users']['parentRoute'], + FileRoutesByPath['/api/users']['id'], + FileRoutesByPath['/api/users']['path'], + FileRoutesByPath['/api/users']['fullPath'], + ApiUsersRouteChildren + > +} +declare module './../../src/routes/api/users.$userId' { + const createServerFileRoute: CreateServerFileRoute< + FileRoutesByPath['/api/users/$userId']['parentRoute'], + FileRoutesByPath['/api/users/$userId']['id'], + FileRoutesByPath['/api/users/$userId']['path'], + FileRoutesByPath['/api/users/$userId']['fullPath'], + unknown + > +} + +// Create and export the route tree + +interface ApiUsersRouteChildren { + ApiUsersUserIdRoute: typeof ApiUsersUserIdRoute +} + +const ApiUsersRouteChildren: ApiUsersRouteChildren = { + ApiUsersUserIdRoute: ApiUsersUserIdRoute, +} + +const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren( + ApiUsersRouteChildren, +) + +export interface FileRoutesByFullPath { + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$userId': typeof ApiUsersUserIdRoute +} + +export interface FileRoutesByTo { + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$userId': typeof ApiUsersUserIdRoute +} + +export interface FileRoutesById { + __root__: typeof rootRoute + '/api/users': typeof ApiUsersRouteWithChildren + '/api/users/$userId': typeof ApiUsersUserIdRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: '/api/users' | '/api/users/$userId' + fileRoutesByTo: FileRoutesByTo + to: '/api/users' | '/api/users/$userId' + id: '__root__' | '/api/users' | '/api/users/$userId' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren { + ApiUsersRoute: typeof ApiUsersRouteWithChildren +} + +const rootRouteChildren: RootRouteChildren = { + ApiUsersRoute: ApiUsersRouteWithChildren, +} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [ + "/api/users" + ] + }, + "/api/users": { + "filePath": "api/users.ts", + "children": [ + "/api/users/$userId" + ] + }, + "/api/users/$userId": { + "filePath": "api/users.$userId.ts", + "parent": "/api/users" + } + } +} +ROUTE_MANIFEST_END */ diff --git a/examples/solid/start-basic/app.config.ts b/examples/solid/start-basic/app.config.ts deleted file mode 100644 index 2a06e3d3f0..0000000000 --- a/examples/solid/start-basic/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from '@tanstack/solid-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - tsr: { - appDirectory: 'src', - }, - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/examples/solid/start-basic/package.json b/examples/solid/start-basic/package.json index 9503c2499a..eb253dfe8d 100644 --- a/examples/solid/start-basic/package.json +++ b/examples/solid/start-basic/package.json @@ -4,9 +4,9 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start" + "dev": "vite dev", + "build": "vite build", + "start": "vite start" }, "dependencies": { "@tanstack/solid-router": "^1.120.3", @@ -15,8 +15,7 @@ "solid-js": "^1.9.5", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vite": "6.1.4", - "vinxi": "0.5.3" + "vite": "6.1.4" }, "devDependencies": { "@types/node": "^22.5.4", diff --git a/examples/solid/start-basic/src/api.ts b/examples/solid/start-basic/src/api.ts deleted file mode 100644 index ed511bcd26..0000000000 --- a/examples/solid/start-basic/src/api.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { - createStartAPIHandler, - defaultAPIFileRouteHandler, -} from '@tanstack/solid-start/api' - -export default createStartAPIHandler(defaultAPIFileRouteHandler) diff --git a/examples/solid/start-basic/src/client.tsx b/examples/solid/start-basic/src/client.tsx deleted file mode 100644 index ba0f02fac0..0000000000 --- a/examples/solid/start-basic/src/client.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/// -import { hydrate } from 'solid-js/web' -import { StartClient } from '@tanstack/solid-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrate(() => , document.body) diff --git a/examples/solid/start-basic/src/components/DefaultCatchBoundary.tsx b/examples/solid/start-basic/src/components/DefaultCatchBoundary.tsx index 0dff3919fd..bf759681a4 100644 --- a/examples/solid/start-basic/src/components/DefaultCatchBoundary.tsx +++ b/examples/solid/start-basic/src/components/DefaultCatchBoundary.tsx @@ -28,7 +28,7 @@ export function DefaultCatchBoundary({ error }: ErrorComponentProps) { > Try Again - {isRoot() ? ( + {isRoot ? ( rootRoute, } as any) -const RedirectRoute = RedirectImport.update({ +const RedirectRoute = RedirectRouteImport.update({ id: '/redirect', path: '/redirect', getParentRoute: () => rootRoute, } as any) -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const DeferredRoute = DeferredImport.update({ +const DeferredRoute = DeferredRouteImport.update({ id: '/deferred', path: '/deferred', getParentRoute: () => rootRoute, } as any) -const PathlessLayoutRoute = PathlessLayoutImport.update({ +const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const UsersIndexRoute = UsersIndexImport.update({ +const UsersIndexRoute = UsersIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => UsersRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRoute, } as any) -const UsersUserIdRoute = UsersUserIdImport.update({ +const UsersUserIdRoute = UsersUserIdRouteImport.update({ id: '/$userId', path: '/$userId', getParentRoute: () => UsersRoute, } as any) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, } as any) -const PathlessLayoutNestedLayoutRoute = PathlessLayoutNestedLayoutImport.update( - { +const PathlessLayoutNestedLayoutRoute = + PathlessLayoutNestedLayoutRouteImport.update({ id: '/_nested-layout', getParentRoute: () => PathlessLayoutRoute, - } as any, -) + } as any) -const PostsPostIdDeepRoute = PostsPostIdDeepImport.update({ +const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ id: '/posts_/$postId/deep', path: '/posts/$postId/deep', getParentRoute: () => rootRoute, } as any) const PathlessLayoutNestedLayoutRouteBRoute = - PathlessLayoutNestedLayoutRouteBImport.update({ + PathlessLayoutNestedLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutNestedLayoutRoute, } as any) const PathlessLayoutNestedLayoutRouteARoute = - PathlessLayoutNestedLayoutRouteAImport.update({ + PathlessLayoutNestedLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutNestedLayoutRoute, @@ -122,103 +122,232 @@ declare module '@tanstack/solid-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout': { id: '/_pathlessLayout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutRouteImport parentRoute: typeof rootRoute } '/deferred': { id: '/deferred' path: '/deferred' fullPath: '/deferred' - preLoaderRoute: typeof DeferredImport + preLoaderRoute: typeof DeferredRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } '/redirect': { id: '/redirect' path: '/redirect' fullPath: '/redirect' - preLoaderRoute: typeof RedirectImport + preLoaderRoute: typeof RedirectRouteImport parentRoute: typeof rootRoute } '/users': { id: '/users' path: '/users' fullPath: '/users' - preLoaderRoute: typeof UsersImport + preLoaderRoute: typeof UsersRouteImport parentRoute: typeof rootRoute } '/_pathlessLayout/_nested-layout': { id: '/_pathlessLayout/_nested-layout' path: '' fullPath: '' - preLoaderRoute: typeof PathlessLayoutNestedLayoutImport - parentRoute: typeof PathlessLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteImport + parentRoute: typeof PathlessLayoutRouteImport } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsPostIdRouteImport + parentRoute: typeof PostsRouteImport } '/users/$userId': { id: '/users/$userId' path: '/$userId' fullPath: '/users/$userId' - preLoaderRoute: typeof UsersUserIdImport - parentRoute: typeof UsersImport + preLoaderRoute: typeof UsersUserIdRouteImport + parentRoute: typeof UsersRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteImport } '/users/': { id: '/users/' path: '/' fullPath: '/users/' - preLoaderRoute: typeof UsersIndexImport - parentRoute: typeof UsersImport + preLoaderRoute: typeof UsersIndexRouteImport + parentRoute: typeof UsersRouteImport } '/_pathlessLayout/_nested-layout/route-a': { id: '/_pathlessLayout/_nested-layout/route-a' path: '/route-a' fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteAImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/_pathlessLayout/_nested-layout/route-b': { id: '/_pathlessLayout/_nested-layout/route-b' path: '/route-b' fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBImport - parentRoute: typeof PathlessLayoutNestedLayoutImport + preLoaderRoute: typeof PathlessLayoutNestedLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutNestedLayoutRouteImport } '/posts_/$postId/deep': { id: '/posts_/$postId/deep' path: '/posts/$postId/deep' fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepImport + preLoaderRoute: typeof PostsPostIdDeepRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/_pathlessLayout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout', + FileRoutesByPath['/_pathlessLayout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout']['id'], + FileRoutesByPath['/_pathlessLayout']['path'], + FileRoutesByPath['/_pathlessLayout']['fullPath'] + > +} +declare module './routes/deferred' { + const createFileRoute: CreateFileRoute< + '/deferred', + FileRoutesByPath['/deferred']['parentRoute'], + FileRoutesByPath['/deferred']['id'], + FileRoutesByPath['/deferred']['path'], + FileRoutesByPath['/deferred']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/redirect' { + const createFileRoute: CreateFileRoute< + '/redirect', + FileRoutesByPath['/redirect']['parentRoute'], + FileRoutesByPath['/redirect']['id'], + FileRoutesByPath['/redirect']['path'], + FileRoutesByPath['/redirect']['fullPath'] + > +} +declare module './routes/users' { + const createFileRoute: CreateFileRoute< + '/users', + FileRoutesByPath['/users']['parentRoute'], + FileRoutesByPath['/users']['id'], + FileRoutesByPath['/users']['path'], + FileRoutesByPath['/users']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout', + FileRoutesByPath['/_pathlessLayout/_nested-layout']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout']['fullPath'] + > +} +declare module './routes/posts.$postId' { + const createFileRoute: CreateFileRoute< + '/posts/$postId', + FileRoutesByPath['/posts/$postId']['parentRoute'], + FileRoutesByPath['/posts/$postId']['id'], + FileRoutesByPath['/posts/$postId']['path'], + FileRoutesByPath['/posts/$postId']['fullPath'] + > +} +declare module './routes/users.$userId' { + const createFileRoute: CreateFileRoute< + '/users/$userId', + FileRoutesByPath['/users/$userId']['parentRoute'], + FileRoutesByPath['/users/$userId']['id'], + FileRoutesByPath['/users/$userId']['path'], + FileRoutesByPath['/users/$userId']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/users.index' { + const createFileRoute: CreateFileRoute< + '/users/', + FileRoutesByPath['/users/']['parentRoute'], + FileRoutesByPath['/users/']['id'], + FileRoutesByPath['/users/']['path'], + FileRoutesByPath['/users/']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-a' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-a', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-a']['fullPath'] + > +} +declare module './routes/_pathlessLayout/_nested-layout/route-b' { + const createFileRoute: CreateFileRoute< + '/_pathlessLayout/_nested-layout/route-b', + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['parentRoute'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['id'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['path'], + FileRoutesByPath['/_pathlessLayout/_nested-layout/route-b']['fullPath'] + > +} +declare module './routes/posts_.$postId.deep' { + const createFileRoute: CreateFileRoute< + '/posts_/$postId/deep', + FileRoutesByPath['/posts_/$postId/deep']['parentRoute'], + FileRoutesByPath['/posts_/$postId/deep']['id'], + FileRoutesByPath['/posts_/$postId/deep']['path'], + FileRoutesByPath['/posts_/$postId/deep']['fullPath'] + > +} + // Create and export the route tree interface PathlessLayoutNestedLayoutRouteChildren { @@ -395,6 +524,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '../.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/examples/solid/start-basic/src/routes/__root.tsx b/examples/solid/start-basic/src/routes/__root.tsx index a9380d3209..374a4fb944 100644 --- a/examples/solid/start-basic/src/routes/__root.tsx +++ b/examples/solid/start-basic/src/routes/__root.tsx @@ -1,6 +1,13 @@ -import { Link, Outlet, createRootRoute } from '@tanstack/solid-router' - -import { TanStackRouterDevtoolsInProd } from '@tanstack/solid-router-devtools' +import { + HeadContent, + Link, + Outlet, + Scripts, + createRootRoute, +} from '@tanstack/solid-router' +import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools' +import type * as Solid from 'solid-js' +import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary' import { NotFound } from '~/components/NotFound' import appCss from '~/styles/app.css?url' import { seo } from '~/utils/seo' @@ -8,6 +15,9 @@ import { seo } from '~/utils/seo' export const Route = createRootRoute({ head: () => ({ meta: [ + { + charset: 'utf-8', + }, { name: 'viewport', content: 'width=device-width, initial-scale=1', @@ -41,14 +51,29 @@ export const Route = createRootRoute({ { rel: 'icon', href: '/favicon.ico' }, ], }), - errorComponent: (props) =>

{props.error.stack}

, + errorComponent: (props) => { + return ( + + + + ) + }, notFoundComponent: () => , component: RootComponent, }) function RootComponent() { + return ( + + + + ) +} + +function RootDocument({ children }: { children: Solid.JSX.Element }) { return ( <> +
Users {' '} + + Pathless Layout + {' '} Deferred {' '} - - redirect - {' '}
- - +
+ {children} + + ) } diff --git a/examples/solid/start-basic/src/routes/_pathlessLayout.tsx b/examples/solid/start-basic/src/routes/_pathlessLayout.tsx index af197bc038..c549175638 100644 --- a/examples/solid/start-basic/src/routes/_pathlessLayout.tsx +++ b/examples/solid/start-basic/src/routes/_pathlessLayout.tsx @@ -1,6 +1,6 @@ -import { Outlet, createFileRoute } from '@tanstack/solid-router' +import { Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_pathlessLayout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/solid/start-basic/src/routes/_pathlessLayout/_nested-layout.tsx b/examples/solid/start-basic/src/routes/_pathlessLayout/_nested-layout.tsx index 24e4b2545b..03bcac9d47 100644 --- a/examples/solid/start-basic/src/routes/_pathlessLayout/_nested-layout.tsx +++ b/examples/solid/start-basic/src/routes/_pathlessLayout/_nested-layout.tsx @@ -1,6 +1,6 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' -export const Route = createFileRoute('/_pathlessLayout/_nested-layout')({ +export const Route = createFileRoute({ component: LayoutComponent, }) diff --git a/examples/solid/start-basic/src/routes/_pathlessLayout/_nested-layout/route-a.tsx b/examples/solid/start-basic/src/routes/_pathlessLayout/_nested-layout/route-a.tsx index a22902a271..a0bd5240b7 100644 --- a/examples/solid/start-basic/src/routes/_pathlessLayout/_nested-layout/route-a.tsx +++ b/examples/solid/start-basic/src/routes/_pathlessLayout/_nested-layout/route-a.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-a')( - { - component: LayoutAComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutAComponent, +}) function LayoutAComponent() { return
I'm A!
diff --git a/examples/solid/start-basic/src/routes/_pathlessLayout/_nested-layout/route-b.tsx b/examples/solid/start-basic/src/routes/_pathlessLayout/_nested-layout/route-b.tsx index 36231d2153..2864ec1f28 100644 --- a/examples/solid/start-basic/src/routes/_pathlessLayout/_nested-layout/route-b.tsx +++ b/examples/solid/start-basic/src/routes/_pathlessLayout/_nested-layout/route-b.tsx @@ -1,10 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/_pathlessLayout/_nested-layout/route-b')( - { - component: LayoutBComponent, - }, -) +export const Route = createFileRoute({ + component: LayoutBComponent, +}) function LayoutBComponent() { return
I'm B!
diff --git a/examples/solid/start-basic/src/routes/api/users.$id.ts b/examples/solid/start-basic/src/routes/api/users.$id.ts deleted file mode 100644 index b1786f6a30..0000000000 --- a/examples/solid/start-basic/src/routes/api/users.$id.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { json } from '@tanstack/solid-start' -import { createAPIFileRoute } from '@tanstack/solid-start/api' -import axios from 'redaxios' -import type { User } from '../../utils/users' - -export const APIRoute = createAPIFileRoute('/api/users/$id')({ - GET: async ({ request, params }) => { - console.info(`Fetching users by id=${params.id}... @`, request.url) - try { - const res = await axios.get( - 'https://jsonplaceholder.typicode.com/users/' + params.id, - ) - - return json({ - id: res.data.id, - name: res.data.name, - email: res.data.email, - }) - } catch (e) { - console.error(e) - return json({ error: 'User not found' }, { status: 404 }) - } - }, -}) diff --git a/examples/solid/start-basic/src/routes/api/users.$userId.ts b/examples/solid/start-basic/src/routes/api/users.$userId.ts new file mode 100644 index 0000000000..69d966d982 --- /dev/null +++ b/examples/solid/start-basic/src/routes/api/users.$userId.ts @@ -0,0 +1,27 @@ +import { json } from '@tanstack/solid-start' +import type { User } from '~/utils/users' + +export const ServerRoute = createServerFileRoute().methods({ + GET: async ({ params, request }) => { + console.info(`Fetching users by id=${params.userId}... @`, request.url) + try { + const res = await fetch( + 'https://jsonplaceholder.typicode.com/users/' + params.userId, + ) + if (!res.ok) { + throw new Error('Failed to fetch user') + } + + const user = (await res.json()) as User + + return json({ + id: user.id, + name: user.name, + email: user.email, + }) + } catch (e) { + console.error(e) + return json({ error: 'User not found' }, { status: 404 }) + } + }, +}) diff --git a/examples/solid/start-basic/src/routes/api/users.ts b/examples/solid/start-basic/src/routes/api/users.ts index c10bcfc94a..c0a6a1a6a2 100644 --- a/examples/solid/start-basic/src/routes/api/users.ts +++ b/examples/solid/start-basic/src/routes/api/users.ts @@ -1,17 +1,58 @@ -import { json } from '@tanstack/solid-start' -import { createAPIFileRoute } from '@tanstack/solid-start/api' -import axios from 'redaxios' -import type { User } from '../../utils/users' +import { createMiddleware, json } from '@tanstack/solid-start' +import type { User } from '~/utils/users' -export const APIRoute = createAPIFileRoute('/api/users')({ - GET: async ({ request }) => { - console.info('Fetching users... @', request.url) - const res = await axios.get>( - 'https://jsonplaceholder.typicode.com/users', - ) - - const list = res.data.slice(0, 10) - - return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email }))) +const userLoggerMiddleware = createMiddleware({ type: 'request' }).server( + async ({ next, request }) => { + console.info('In: /users') + const result = await next() + result.response.headers.set('x-users', 'true') + console.info('Out: /users') + return result }, -}) +) + +const testParentMiddleware = createMiddleware({ type: 'request' }).server( + async ({ next, request }) => { + console.info('In: testParentMiddleware') + const result = await next() + result.response.headers.set('x-test-parent', 'true') + console.info('Out: testParentMiddleware') + return result + }, +) + +const testMiddleware = createMiddleware({ type: 'request' }) + .middleware([testParentMiddleware]) + .server(async ({ next, request }) => { + console.info('In: testMiddleware') + const result = await next() + result.response.headers.set('x-test', 'true') + + // if (Math.random() > 0.5) { + // throw new Response(null, { + // status: 302, + // headers: { Location: 'https://www.google.com' }, + // }) + // } + + console.info('Out: testMiddleware') + return result + }) + +export const ServerRoute = createServerFileRoute() + .middleware([testMiddleware, userLoggerMiddleware, testParentMiddleware]) + .methods({ + GET: async ({ request }) => { + console.info('Fetching users... @', request.url) + const res = await fetch('https://jsonplaceholder.typicode.com/users') + if (!res.ok) { + throw new Error('Failed to fetch users') + } + + const data = (await res.json()) as Array + + const list = data.slice(0, 10) + + return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email }))) + }, + }) diff --git a/examples/solid/start-basic/src/routes/deferred.tsx b/examples/solid/start-basic/src/routes/deferred.tsx index 1860f3af9a..c510571e5d 100644 --- a/examples/solid/start-basic/src/routes/deferred.tsx +++ b/examples/solid/start-basic/src/routes/deferred.tsx @@ -1,6 +1,6 @@ -import { Await, createFileRoute } from '@tanstack/solid-router' +import { Await } from '@tanstack/solid-router' import { createServerFn } from '@tanstack/solid-start' -import { createSignal, Suspense } from 'solid-js' +import { Suspense, createSignal } from 'solid-js' const personServerFn = createServerFn({ method: 'GET' }) .validator((d: string) => d) @@ -15,7 +15,7 @@ const slowServerFn = createServerFn({ method: 'GET' }) return { name, randomNumber: Math.floor(Math.random() * 100) } }) -export const Route = createFileRoute('/deferred')({ +export const Route = createFileRoute({ loader: async () => { return { deferredStuff: new Promise((r) => diff --git a/examples/solid/start-basic/src/routes/index.tsx b/examples/solid/start-basic/src/routes/index.tsx index a128aeca0e..2f35891abb 100644 --- a/examples/solid/start-basic/src/routes/index.tsx +++ b/examples/solid/start-basic/src/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, }) diff --git a/examples/solid/start-basic/src/routes/posts.$postId.tsx b/examples/solid/start-basic/src/routes/posts.$postId.tsx index d13735a4db..7d06791adb 100644 --- a/examples/solid/start-basic/src/routes/posts.$postId.tsx +++ b/examples/solid/start-basic/src/routes/posts.$postId.tsx @@ -1,9 +1,9 @@ -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' import { fetchPost } from '../utils/posts' import { NotFound } from '~/components/NotFound' import { PostErrorComponent } from '~/components/PostError' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: ({ params: { postId } }) => fetchPost({ data: postId }), errorComponent: PostErrorComponent, component: PostComponent, diff --git a/examples/solid/start-basic/src/routes/posts.index.tsx b/examples/solid/start-basic/src/routes/posts.index.tsx index 33d0386c19..13529228bb 100644 --- a/examples/solid/start-basic/src/routes/posts.index.tsx +++ b/examples/solid/start-basic/src/routes/posts.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: PostsIndexComponent, }) diff --git a/examples/solid/start-basic/src/routes/posts.tsx b/examples/solid/start-basic/src/routes/posts.tsx index 326372478f..4f0b47fa08 100644 --- a/examples/solid/start-basic/src/routes/posts.tsx +++ b/examples/solid/start-basic/src/routes/posts.tsx @@ -1,7 +1,7 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { Link, Outlet } from '@tanstack/solid-router' import { fetchPosts } from '../utils/posts' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ loader: async () => fetchPosts(), component: PostsComponent, }) diff --git a/examples/solid/start-basic/src/routes/posts_.$postId.deep.tsx b/examples/solid/start-basic/src/routes/posts_.$postId.deep.tsx index 7c52bc19eb..b71b51e8cc 100644 --- a/examples/solid/start-basic/src/routes/posts_.$postId.deep.tsx +++ b/examples/solid/start-basic/src/routes/posts_.$postId.deep.tsx @@ -1,8 +1,8 @@ -import { Link, createFileRoute } from '@tanstack/solid-router' +import { Link } from '@tanstack/solid-router' import { fetchPost } from '../utils/posts' import { PostErrorComponent } from '~/components/PostError' -export const Route = createFileRoute('/posts_/$postId/deep')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => fetchPost({ data: postId, diff --git a/examples/solid/start-basic/src/routes/redirect.tsx b/examples/solid/start-basic/src/routes/redirect.tsx index ca017f0635..d80d290638 100644 --- a/examples/solid/start-basic/src/routes/redirect.tsx +++ b/examples/solid/start-basic/src/routes/redirect.tsx @@ -1,6 +1,6 @@ -import { createFileRoute, redirect } from '@tanstack/solid-router' +import { redirect } from '@tanstack/solid-router' -export const Route = createFileRoute('/redirect')({ +export const Route = createFileRoute({ beforeLoad: async () => { throw redirect({ to: '/posts', diff --git a/examples/solid/start-basic/src/routes/users.$userId.tsx b/examples/solid/start-basic/src/routes/users.$userId.tsx index a2d99fbf6b..9bdb09d835 100644 --- a/examples/solid/start-basic/src/routes/users.$userId.tsx +++ b/examples/solid/start-basic/src/routes/users.$userId.tsx @@ -1,18 +1,20 @@ -import { createFileRoute } from '@tanstack/solid-router' -import axios from 'redaxios' -import type { User } from '~/utils/users' -import { DEPLOY_URL } from '~/utils/users' -import { NotFound } from '~/components/NotFound' -import { UserErrorComponent } from '~/components/UserError' +import { NotFound } from 'src/components/NotFound' +import { UserErrorComponent } from 'src/components/UserError' -export const Route = createFileRoute('/users/$userId')({ +export const Route = createFileRoute({ loader: async ({ params: { userId } }) => { - return await axios - .get(DEPLOY_URL + '/api/users/' + userId) - .then((r) => r.data) - .catch(() => { - throw new Error('Failed to fetch user') - }) + try { + const res = await fetch('/api/users/' + userId) + if (!res.ok) { + throw new Error('Unexpected status code') + } + + const data = await res.json() + + return data + } catch { + throw new Error('Failed to fetch user') + } }, errorComponent: UserErrorComponent, component: UserComponent, @@ -28,6 +30,14 @@ function UserComponent() {

{user().name}

{user().email}
+
) } diff --git a/examples/solid/start-basic/src/routes/users.index.tsx b/examples/solid/start-basic/src/routes/users.index.tsx index bbc96801a9..f30b0712b9 100644 --- a/examples/solid/start-basic/src/routes/users.index.tsx +++ b/examples/solid/start-basic/src/routes/users.index.tsx @@ -1,9 +1,14 @@ -import { createFileRoute } from '@tanstack/solid-router' - -export const Route = createFileRoute('/users/')({ +export const Route = createFileRoute({ component: UsersIndexComponent, }) function UsersIndexComponent() { - return
Select a user.
+ return ( +
+ Select a user or{' '} + + view as JSON + +
+ ) } diff --git a/examples/solid/start-basic/src/routes/users.tsx b/examples/solid/start-basic/src/routes/users.tsx index 2caca046e0..c3a2a1fe15 100644 --- a/examples/solid/start-basic/src/routes/users.tsx +++ b/examples/solid/start-basic/src/routes/users.tsx @@ -1,16 +1,17 @@ -import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' -import axios from 'redaxios' -import { DEPLOY_URL } from '../utils/users' +import { Link, Outlet } from '@tanstack/solid-router' import type { User } from '../utils/users' -export const Route = createFileRoute('/users')({ +export const Route = createFileRoute({ loader: async () => { - return await axios - .get>(DEPLOY_URL + '/api/users') - .then((r) => r.data) - .catch(() => { - throw new Error('Failed to fetch users') - }) + const res = await fetch('/api/users') + + if (!res.ok) { + throw new Error('Unexpected status code') + } + + const data = (await res.json()) as Array + + return data }, component: UsersComponent, }) diff --git a/examples/solid/start-basic/src/ssr.tsx b/examples/solid/start-basic/src/ssr.tsx deleted file mode 100644 index 6d10bea05f..0000000000 --- a/examples/solid/start-basic/src/ssr.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { - createStartHandler, - defaultStreamHandler, -} from '@tanstack/solid-start/server' -import { getRouterManifest } from '@tanstack/solid-start/router-manifest' - -import { createRouter } from './router' - -export default createStartHandler({ - createRouter, - getRouterManifest, -})(defaultStreamHandler) diff --git a/examples/solid/start-basic/src/utils/loggingMiddleware.tsx b/examples/solid/start-basic/src/utils/loggingMiddleware.tsx index 928fedfd25..fae87c5965 100644 --- a/examples/solid/start-basic/src/utils/loggingMiddleware.tsx +++ b/examples/solid/start-basic/src/utils/loggingMiddleware.tsx @@ -1,6 +1,6 @@ import { createMiddleware } from '@tanstack/solid-start' -const preLogMiddleware = createMiddleware() +const preLogMiddleware = createMiddleware({ type: 'function' }) .client(async (ctx) => { const clientTime = new Date() @@ -25,7 +25,7 @@ const preLogMiddleware = createMiddleware() }) }) -export const logMiddleware = createMiddleware() +export const logMiddleware = createMiddleware({ type: 'function' }) .middleware([preLogMiddleware]) .client(async (ctx) => { const res = await ctx.next() diff --git a/examples/solid/start-basic/src/utils/posts.tsx b/examples/solid/start-basic/src/utils/posts.tsx index 96eaa78afc..e29706d38c 100644 --- a/examples/solid/start-basic/src/utils/posts.tsx +++ b/examples/solid/start-basic/src/utils/posts.tsx @@ -8,7 +8,7 @@ export type PostType = { body: string } -export const fetchPost = createServerFn({ method: 'GET' }) +export const fetchPost = createServerFn({ method: 'GET', type: 'static' }) .validator((d: string) => d) .handler(async ({ data }) => { console.info(`Fetching post with id ${data}...`) @@ -26,11 +26,12 @@ export const fetchPost = createServerFn({ method: 'GET' }) return post }) -export const fetchPosts = createServerFn({ method: 'GET' }).handler( - async () => { - console.info('Fetching posts...') - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) - }, -) +export const fetchPosts = createServerFn({ + method: 'GET', + type: 'static', +}).handler(async () => { + console.info('Fetching posts...') + return axios + .get>('https://jsonplaceholder.typicode.com/posts') + .then((r) => r.data.slice(0, 10)) +}) diff --git a/examples/solid/start-basic/src/utils/users.tsx b/examples/solid/start-basic/src/utils/users.tsx index b810f455fe..7ba645b383 100644 --- a/examples/solid/start-basic/src/utils/users.tsx +++ b/examples/solid/start-basic/src/utils/users.tsx @@ -3,5 +3,3 @@ export type User = { name: string email: string } - -export const DEPLOY_URL = 'http://localhost:3000' diff --git a/examples/solid/start-basic/vite.config.ts b/examples/solid/start-basic/vite.config.ts new file mode 100644 index 0000000000..f6a9e52322 --- /dev/null +++ b/examples/solid/start-basic/vite.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import { TanStackStartVitePlugin } from '@tanstack/solid-start/plugin' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + TanStackStartVitePlugin({}), + ], +}) diff --git a/package.json b/package.json index 9ac5606a3a..c74f5974b4 100644 --- a/package.json +++ b/package.json @@ -107,12 +107,10 @@ "@tanstack/solid-start-plugin": "workspace:*", "@tanstack/solid-start-router-manifest": "workspace:*", "@tanstack/solid-start-server": "workspace:*", - "@tanstack/start-api-routes": "workspace:*", "@tanstack/start-server-functions-fetcher": "workspace:*", - "@tanstack/start-server-functions-handler": "workspace:*", "@tanstack/start-server-functions-client": "workspace:*", - "@tanstack/start-server-functions-ssr": "workspace:*", "@tanstack/start-server-functions-server": "workspace:*", + "@tanstack/start-plugin-core": "workspace:*", "@tanstack/start-client-core": "workspace:*", "@tanstack/start-server-core": "workspace:*", "@tanstack/eslint-plugin-router": "workspace:*", diff --git a/packages/directive-functions-plugin/src/compilers.ts b/packages/directive-functions-plugin/src/compilers.ts index 463f5e879e..43830231b9 100644 --- a/packages/directive-functions-plugin/src/compilers.ts +++ b/packages/directive-functions-plugin/src/compilers.ts @@ -40,6 +40,8 @@ export type CompileDirectivesOpts = ParseAstOptions & { }) => string replacer: ReplacerFn // devSplitImporter: string + filename: string + root: string } function buildDirectiveSplitParam(opts: CompileDirectivesOpts) { @@ -230,6 +232,8 @@ export function findDirectives( directiveLabel: string replacer?: ReplacerFn directiveSplitParam: string + filename: string + root: string }, ): Record { const directiveFnsById: Record = {} diff --git a/packages/directive-functions-plugin/src/index.ts b/packages/directive-functions-plugin/src/index.ts index 25ed1df746..d0fd8aee06 100644 --- a/packages/directive-functions-plugin/src/index.ts +++ b/packages/directive-functions-plugin/src/index.ts @@ -15,23 +15,28 @@ export type { ReplacerFn, } from './compilers' -export type DirectiveFunctionsViteOptions = Pick< +export type DirectiveFunctionsViteEnvOptions = Pick< CompileDirectivesOpts, - 'directive' | 'directiveLabel' | 'getRuntimeCode' | 'replacer' - // | 'devSplitImporter' + 'getRuntimeCode' | 'replacer' > & { envLabel: string } +export type DirectiveFunctionsViteOptions = Pick< + CompileDirectivesOpts, + 'directive' | 'directiveLabel' +> & + DirectiveFunctionsViteEnvOptions & { + onDirectiveFnsById?: (directiveFnsById: Record) => void + } + const createDirectiveRx = (directive: string) => new RegExp(`"${directive}"|'${directive}'`, 'gm') export function TanStackDirectiveFunctionsPlugin( - opts: DirectiveFunctionsViteOptions & { - onDirectiveFnsById?: (directiveFnsById: Record) => void - }, + opts: DirectiveFunctionsViteOptions, ): Plugin { - let ROOT: string = process.cwd() + let root: string = process.cwd() const directiveRx = createDirectiveRx(opts.directive) @@ -39,36 +44,123 @@ export function TanStackDirectiveFunctionsPlugin( name: 'tanstack-start-directive-vite-plugin', enforce: 'pre', configResolved: (config) => { - ROOT = config.root + root = config.root }, transform(code, id) { - const url = pathToFileURL(id) - url.searchParams.delete('v') - id = fileURLToPath(url).replace(/\\/g, '/') - - if (!code.match(directiveRx)) { - return null - } - - if (debug) console.info(`${opts.envLabel}: Compiling Directives: `, id) - - const { compiledResult, directiveFnsById } = compileDirectives({ - ...opts, - code, - root: ROOT, - filename: id, - // globalThis.app currently refers to Vinxi's app instance. In the future, it can just be the - // vite dev server instance we get from Nitro. - }) - - opts.onDirectiveFnsById?.(directiveFnsById) - - if (debug) { - logDiff(code, compiledResult.code) - console.log('Output:\n', compiledResult.code + '\n\n') - } - - return compiledResult + return transformCode({ ...opts, code, id, directiveRx, root }) }, } } + +export type DirectiveFunctionsVitePluginEnvOptions = Pick< + CompileDirectivesOpts, + 'directive' | 'directiveLabel' +> & { + environments: { + client: DirectiveFunctionsViteEnvOptions & { envName?: string } + server: DirectiveFunctionsViteEnvOptions & { envName?: string } + } + onDirectiveFnsById?: (directiveFnsById: Record) => void +} + +export function TanStackDirectiveFunctionsPluginEnv( + opts: DirectiveFunctionsVitePluginEnvOptions, +): Plugin { + opts = { + ...opts, + environments: { + client: { + envName: 'client', + ...opts.environments.client, + }, + server: { + envName: 'server', + ...opts.environments.server, + }, + }, + } + + let root: string = process.cwd() + + const directiveRx = createDirectiveRx(opts.directive) + + return { + name: 'tanstack-start-directive-vite-plugin', + enforce: 'pre', + buildStart() { + root = this.environment.config.root + }, + // applyToEnvironment(env) { + // return [ + // opts.environments.client.envName, + // opts.environments.server.envName, + // ].includes(env.name) + // }, + transform(code, id) { + const envOptions = [ + opts.environments.client, + opts.environments.server, + ].find((e) => e.envName === this.environment.name) + + if (!envOptions) { + throw new Error(`Environment ${this.environment.name} not found`) + } + + return transformCode({ + ...opts, + ...envOptions, + code, + id, + directiveRx, + root, + }) + }, + } +} + +function transformCode({ + code, + id, + directiveRx, + envLabel, + directive, + directiveLabel, + getRuntimeCode, + replacer, + onDirectiveFnsById, + root, +}: DirectiveFunctionsViteOptions & { + code: string + id: string + directiveRx: RegExp + root: string +}) { + const url = pathToFileURL(id) + url.searchParams.delete('v') + id = fileURLToPath(url).replace(/\\/g, '/') + + if (!code.match(directiveRx)) { + return null + } + + if (debug) console.info(`${envLabel}: Compiling Directives: `, id) + + const { compiledResult, directiveFnsById } = compileDirectives({ + directive, + directiveLabel, + getRuntimeCode, + replacer, + code, + root, + filename: id, + }) + + onDirectiveFnsById?.(directiveFnsById) + + if (debug) { + logDiff(code, compiledResult.code) + console.log('Output:\n', compiledResult.code + '\n\n') + } + + return compiledResult +} diff --git a/packages/directive-functions-plugin/tests/compiler.test.ts b/packages/directive-functions-plugin/tests/compiler.test.ts index a2c7fd3fc5..e405a7411e 100644 --- a/packages/directive-functions-plugin/tests/compiler.test.ts +++ b/packages/directive-functions-plugin/tests/compiler.test.ts @@ -713,8 +713,6 @@ describe('server function compilation', () => { .extractedFilename, }) - console.log(ssr.directiveFnsById) - expect(client.compiledResult.code).toMatchInlineSnapshot(` "'use server'; diff --git a/packages/react-router-with-query/src/index.tsx b/packages/react-router-with-query/src/index.tsx index e26bcf2975..7858816513 100644 --- a/packages/react-router-with-query/src/index.tsx +++ b/packages/react-router-with-query/src/index.tsx @@ -117,12 +117,8 @@ export function routerWithQueryClient( ...ogMutationCacheConfig, onError: (error, _variables, _context, _mutation) => { if (isRedirect(error)) { - return router.navigate( - router.resolveRedirect({ - ...error, - _fromLocation: router.state.location, - }), - ) + error.options._fromLocation = router.state.location + return router.navigate(router.resolveRedirect(error).options) } return ogMutationCacheConfig.onError?.( @@ -139,12 +135,8 @@ export function routerWithQueryClient( ...ogQueryCacheConfig, onError: (error, _query) => { if (isRedirect(error)) { - return router.navigate( - router.resolveRedirect({ - ...error, - _fromLocation: router.state.location, - }), - ) + error.options._fromLocation = router.state.location + return router.navigate(router.resolveRedirect(error).options) } return ogQueryCacheConfig.onError?.(error, _query) diff --git a/packages/react-router/src/HeadContent.tsx b/packages/react-router/src/HeadContent.tsx index 638dee8acc..b0856e5d49 100644 --- a/packages/react-router/src/HeadContent.tsx +++ b/packages/react-router/src/HeadContent.tsx @@ -58,8 +58,8 @@ export const useTags = () => { }, [routeMeta]) const links = useRouterState({ - select: (state) => - state.matches + select: (state) => { + const constructed = state.matches .map((match) => match.links!) .filter(Boolean) .flat(1) @@ -68,7 +68,30 @@ export const useTags = () => { attrs: { ...link, }, - })) as Array, + })) satisfies Array + + const manifest = router.ssr?.manifest + + // These are the assets extracted from the ViteManifest + // using the `startManifestPlugin` + const assets = state.matches + .map((match) => manifest?.routes[match.routeId]?.assets ?? []) + .filter(Boolean) + .flat(1) + .filter((asset) => asset.tag === 'link') + .map( + (asset) => + ({ + tag: 'link', + attrs: { + ...asset.attrs, + suppressHydrationWarning: true, + }, + }) satisfies RouterManagedTag, + ) + + return [...constructed, ...assets] + }, structuralSharing: true as any, }) diff --git a/packages/react-router/src/fileRoute.ts b/packages/react-router/src/fileRoute.ts index d645cc840d..31234f50fc 100644 --- a/packages/react-router/src/fileRoute.ts +++ b/packages/react-router/src/fileRoute.ts @@ -41,8 +41,13 @@ export function createFileRoute< TFullPath extends RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'], >( - path: TFilePath, + path?: TFilePath, ): FileRoute['createRoute'] { + if (typeof path === 'object') { + return new FileRoute(path, { + silent: true, + }).createRoute(path) as any + } return new FileRoute(path, { silent: true, }).createRoute @@ -63,7 +68,7 @@ export class FileRoute< silent?: boolean constructor( - public path: TFilePath, + public path?: TFilePath, _opts?: { silent: boolean }, ) { this.silent = _opts?.silent diff --git a/packages/react-router/src/index.tsx b/packages/react-router/src/index.tsx index b848fc7210..c1b610d04b 100644 --- a/packages/react-router/src/index.tsx +++ b/packages/react-router/src/index.tsx @@ -48,7 +48,6 @@ export type { DeferredPromiseState, DeferredPromise, ParsedLocation, - ParsePathParams, RemoveTrailingSlashes, RemoveLeadingSlashes, ActiveOptions, @@ -78,8 +77,6 @@ export type { TrimPath, TrimPathLeft, TrimPathRight, - ParseSplatParams, - SplatParams, StringifyParamsFn, ParamsOptions, InferAllParams, @@ -126,6 +123,7 @@ export type { RouteById, RootRouteOptions, SerializerExtensions, + CreateFileRoute, } from '@tanstack/router-core' export type * from './serializer' diff --git a/packages/react-router/src/link.tsx b/packages/react-router/src/link.tsx index 3023a10288..b8103d4152 100644 --- a/packages/react-router/src/link.tsx +++ b/packages/react-router/src/link.tsx @@ -20,7 +20,6 @@ import { useMatches } from './Matches' import type { AnyRouter, Constrain, - LinkCurrentTargetElement, LinkOptions, RegisteredRouter, RoutePaths, @@ -54,6 +53,7 @@ export function useLinkProps< to, preload: userPreload, preloadDelay: userPreloadDelay, + preloadIntentProximity: userPreloadIntentProximity, hashScrollIntoView, replace, startTransition, @@ -119,12 +119,24 @@ export function useLinkProps< [router, _options, currentSearch], ) - const preload = React.useMemo(() => { + const [preload, preloadIntentProximity] = React.useMemo(() => { if (_options.reloadDocument) { - return false + return [false, 0] } - return userPreload ?? router.options.defaultPreload - }, [router.options.defaultPreload, userPreload, _options.reloadDocument]) + return [ + userPreload ?? router.options.defaultPreload, + userPreloadIntentProximity ?? + router.options.defaultPreloadIntentProximity ?? + 0, + ] as const + }, [ + router.options.defaultPreload, + userPreload, + _options.reloadDocument, + router.options.defaultPreloadIntentProximity, + userPreloadIntentProximity, + ]) + const preloadDelay = userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0 @@ -179,22 +191,63 @@ export function useLinkProps< console.warn(err) console.warn(preloadWarning) }) + // NOTE: Use this to debug preloading! + // .then(() => { + // // @ts-expect-error + // innerRef.current.style.boxShadow = '0 0 10px 0 rgba(255, 0, 0, 0.5)' + // }) }, [_options, router]) + const timeoutIdRef = React.useRef | null>(null) + const hasPreloadedRef = React.useRef(false) + + const tryPreload = React.useCallback(() => { + if (hasPreloadedRef.current || timeoutIdRef.current) { + return + } + + timeoutIdRef.current = setTimeout(() => { + doPreload() + hasPreloadedRef.current = true + timeoutIdRef.current = null + }, preloadDelay) + }, [preloadDelay, doPreload]) + + const cancelPreload = React.useCallback(() => { + if (timeoutIdRef.current) { + clearTimeout(timeoutIdRef.current) + timeoutIdRef.current = null + } + }, []) + + const isIntersectingRef = React.useRef(false) + + const shouldUseIntersectionObserver = React.useMemo(() => { + return ( + !disabled && + (preload === 'viewport' || + (preload === 'intent' && preloadIntentProximity > 0)) + ) + }, [preload, preloadIntentProximity, disabled]) + const preloadViewportIoCallback = React.useCallback( (entry: IntersectionObserverEntry | undefined) => { - if (entry?.isIntersecting) { + isIntersectingRef.current = entry?.isIntersecting ?? false + + if (isIntersectingRef.current && preload === 'viewport') { doPreload() } }, - [doPreload], + [doPreload, preload], ) useIntersectionObserver( innerRef, preloadViewportIoCallback, { rootMargin: '100px' }, - { disabled: !!disabled || !(preload === 'viewport') }, + { + disabled: !shouldUseIntersectionObserver, + }, ) useLayoutEffect(() => { @@ -207,6 +260,112 @@ export function useLinkProps< } }, [disabled, doPreload, preload]) + const rectRef = React.useRef(null) + + useLayoutEffect(() => { + if ( + type === 'internal' && + preload === 'intent' && + preloadIntentProximity > 0 && + disabled && + !innerRef.current + ) { + return + } + + let lastMousePosition: { + x: number + y: number + } | null = null + + let frameId: number | null = null + + const handleMousePos = (pairs: Array<{ x: number; y: number }>) => { + if (!isIntersectingRef.current || frameId) return + + frameId = requestAnimationFrame(() => { + // If one of pairs is within the preloadIntentProximity + // stop the loop + pairs.some(({ x, y }, i) => { + if (!rectRef.current) return + + // Calculate the distance to the nearest edge of the bounding box + const dx = Math.max( + rectRef.current.left - x, + 0, + x - rectRef.current.right, + ) + const dy = Math.max( + rectRef.current.top - y, + 0, + y - rectRef.current.bottom, + ) + + const distance = Math.sqrt(dx * dx + dy * dy) + + if (distance <= preloadIntentProximity) { + tryPreload() + return true + } else { + return false + } + }) + + frameId = null + }) + } + + const handleScroll = () => { + if (!lastMousePosition) return + handleMousePos([{ x: lastMousePosition.x, y: lastMousePosition.y }]) + } + + const handlePointerMove = (e: PointerEvent) => { + lastMousePosition = { + x: e.clientX, + y: e.clientY, + } + if ((e as any).getPredictedEvents) { + const events = e.getPredictedEvents() + handleMousePos([ + { + x: e.clientX, + y: e.clientY, + }, + ...events.map((event) => ({ + x: event.clientX, + y: event.clientY, + })), + ]) + } + } + + document.addEventListener('pointermove', handlePointerMove) + document.addEventListener('scroll', handleScroll, { passive: true }) + + return () => { + document.removeEventListener('pointermove', handlePointerMove) + document.removeEventListener('scroll', handleScroll) + cancelPreload() + } + }, [ + disabled, + doPreload, + preload, + preloadDelay, + preloadIntentProximity, + cancelPreload, + innerRef, + tryPreload, + type, + ]) + + useRectCallback(innerRef, (rect) => { + rectRef.current = rect + }) + + const pointerDownRef = React.useRef(false) + if (type === 'external') { return { ...propsSafeToSpread, @@ -260,42 +419,36 @@ export function useLinkProps< } } + const onPointerDown = (e: PointerEvent) => { + pointerDownRef.current = true + } + + const onPointerUp = (e: PointerEvent) => { + pointerDownRef.current = false + } + // The click handler const handleFocus = (_: MouseEvent) => { - if (disabled) return + if (disabled || pointerDownRef.current) return if (preload) { doPreload() } } + const handleMouseEnter = () => { + if (preload === 'intent' && preloadIntentProximity <= 0) { + tryPreload() + } + } + + const handleMouseLeave = () => { + if (preload === 'intent' && preloadIntentProximity <= 0) { + cancelPreload() + } + } + const handleTouchStart = handleFocus - const handleEnter = (e: MouseEvent) => { - if (disabled) return - const eventTarget = (e.target || {}) as LinkCurrentTargetElement - - if (preload) { - if (eventTarget.preloadTimeout) { - return - } - - eventTarget.preloadTimeout = setTimeout(() => { - eventTarget.preloadTimeout = null - doPreload() - }, preloadDelay) - } - } - - const handleLeave = (e: MouseEvent) => { - if (disabled) return - const eventTarget = (e.target || {}) as LinkCurrentTargetElement - - if (eventTarget.preloadTimeout) { - clearTimeout(eventTarget.preloadTimeout) - eventTarget.preloadTimeout = null - } - } - const composeHandlers = (handlers: Array void)>) => (e: { persist?: () => void; defaultPrevented: boolean }) => { @@ -341,9 +494,11 @@ export function useLinkProps< ref: innerRef as React.ComponentPropsWithRef<'a'>['ref'], onClick: composeHandlers([onClick, handleClick]), onFocus: composeHandlers([onFocus, handleFocus]), - onMouseEnter: composeHandlers([onMouseEnter, handleEnter]), - onMouseLeave: composeHandlers([onMouseLeave, handleLeave]), + onMouseEnter: composeHandlers([onMouseEnter, handleMouseEnter]), + onMouseLeave: composeHandlers([onMouseLeave, handleMouseLeave]), onTouchStart: composeHandlers([onTouchStart, handleTouchStart]), + onPointerDown: composeHandlers([onPointerDown]), + onPointerUp: composeHandlers([onPointerUp]), disabled: !!disabled, target, ...(Object.keys(resolvedStyle).length && { style: resolvedStyle }), @@ -549,3 +704,67 @@ export type LinkOptionsFn = < export const linkOptions: LinkOptionsFn<'a'> = (options) => { return options as any } + +export const useRectCallback = ( + ref: React.RefObject, + onSizeChange: (rect: Rect) => void, +) => { + const handleResize = React.useCallback(() => { + if (!ref.current) { + return + } + + // Update client rect + const newRect = getRect(ref.current) + onSizeChange(newRect) + }, [ref, onSizeChange]) + + useLayoutEffect(() => { + const element = ref.current + if (!element) { + return + } + + handleResize() + + if (typeof ResizeObserver === 'function') { + const resizeObserver = new ResizeObserver(() => handleResize()) + resizeObserver.observe(element) + + return () => { + resizeObserver.disconnect() + } + } else { + // Browser support, remove freely + window.addEventListener('resize', handleResize) + + return () => { + window.removeEventListener('resize', handleResize) + } + } + }, [ref, handleResize]) +} + +type Rect = { + bottom: number + height: number + left: number + right: number + top: number + width: number +} + +function getRect(element: Element | null): Rect { + if (!element) { + return { + bottom: 0, + height: 0, + left: 0, + right: 0, + top: 0, + width: 0, + } + } + + return element.getBoundingClientRect() +} diff --git a/packages/react-router/src/router.ts b/packages/react-router/src/router.ts index 16b25cdcc9..1cfd74c757 100644 --- a/packages/react-router/src/router.ts +++ b/packages/react-router/src/router.ts @@ -1,4 +1,5 @@ import { RouterCore } from '@tanstack/router-core' +import { createFileRoute } from './fileRoute' import type { RouterHistory } from '@tanstack/history' import type { AnyRoute, @@ -105,3 +106,9 @@ export class Router< super(options) } } + +if (typeof globalThis !== 'undefined') { + ;(globalThis as any).createFileRoute = createFileRoute +} else if (typeof window !== 'undefined') { + ;(window as any).createFileRoute = createFileRoute +} diff --git a/packages/react-router/src/useBlocker.tsx b/packages/react-router/src/useBlocker.tsx index 1757dee80d..84a8eba9db 100644 --- a/packages/react-router/src/useBlocker.tsx +++ b/packages/react-router/src/useBlocker.tsx @@ -177,7 +177,10 @@ export function useBlocker( location: HistoryLocation, ): AnyShouldBlockFnLocation { const parsedLocation = router.parseLocation(undefined, location) - const matchedRoutes = router.getMatchedRoutes(parsedLocation) + const matchedRoutes = router.getMatchedRoutes( + parsedLocation.pathname, + undefined, + ) if (matchedRoutes.foundRoute === undefined) { throw new Error(`No route found for location ${location.href}`) } diff --git a/packages/react-router/tests/redirect.test.tsx b/packages/react-router/tests/redirect.test.tsx index 91f0196841..5f36c62631 100644 --- a/packages/react-router/tests/redirect.test.tsx +++ b/packages/react-router/tests/redirect.test.tsx @@ -8,6 +8,8 @@ import { import { afterEach, describe, expect, test, vi } from 'vitest' +import invariant from 'tiny-invariant' +import { getRedirectOptions } from '@tanstack/router-core' import { Link, RouterProvider, @@ -284,7 +286,11 @@ describe('redirect', () => { await router.load() - expect(router.state.redirect).toEqual({ + expect(router.state.redirect).toBeDefined() + expect(router.state.redirect).toBeInstanceOf(Response) + invariant(router.state.redirect) + + expect(getRedirectOptions(router.state.redirect)).toEqual({ _fromLocation: expect.objectContaining({ hash: '', href: '/', @@ -293,13 +299,8 @@ describe('redirect', () => { searchStr: '', }), to: '/about', - headers: {}, - reloadDocument: false, href: '/about', isRedirect: true, - routeId: '/', - routerCode: 'BEFORE_LOAD', - statusCode: 307, }) }) @@ -336,21 +337,28 @@ describe('redirect', () => { await router.load() - expect(router.state.redirect).toEqual({ - _fromLocation: expect.objectContaining({ + const currentRedirect = router.state.redirect + + expect(currentRedirect).toBeDefined() + expect(currentRedirect).toBeInstanceOf(Response) + invariant(currentRedirect) + expect(currentRedirect.status).toEqual(307) + expect(currentRedirect.headers.get('Location')).toEqual('/about') + expect(getRedirectOptions(currentRedirect)).toEqual({ + _fromLocation: { hash: '', href: '/', pathname: '/', search: {}, searchStr: '', - }), - to: '/about', - headers: {}, + state: { + __TSR_index: 0, + key: getRedirectOptions(currentRedirect)._fromLocation!.state.key, + }, + }, href: '/about', isRedirect: true, - reloadDocument: false, - routeId: '/', - statusCode: 307, + to: '/about', }) }) }) diff --git a/packages/react-router/tests/route.test-d.tsx b/packages/react-router/tests/route.test-d.tsx index 2183cf4af7..dea396ec6f 100644 --- a/packages/react-router/tests/route.test-d.tsx +++ b/packages/react-router/tests/route.test-d.tsx @@ -643,6 +643,8 @@ test('when creating a child route with a param and splat param from the root rou routeTree: rootRoute.addChildren([invoicesRoute]), }) + const params = invoicesRoute.useParams() + expectTypeOf(invoicesRoute.useParams()).toEqualTypeOf<{ invoiceId: string _splat?: string @@ -1776,3 +1778,114 @@ test('when creating a child route with an explicit search input', () => { .parameter(0) .toEqualTypeOf<{ page: string }>() }) + +test('when creating a route with a prefix and suffix', () => { + const rootRoute = createRootRoute() + + const prefixSuffixRoute = createRoute({ + getParentRoute: () => rootRoute, + path: 'prefix{$postId}suffix', + }) + + const routeTree = rootRoute.addChildren([prefixSuffixRoute]) + + const router = createRouter({ routeTree }) + + expectTypeOf(prefixSuffixRoute.useParams()).toEqualTypeOf<{ + postId: string + }>() +}) + +test('when creating a route with a optional prefix and suffix', () => { + const rootRoute = createRootRoute() + + const prefixSuffixRoute = createRoute({ + getParentRoute: () => rootRoute, + path: 'prefix{-$postId}suffix', + }) + + const routeTree = rootRoute.addChildren([prefixSuffixRoute]) + + const router = createRouter({ routeTree }) + + expectTypeOf(prefixSuffixRoute.useParams()).toEqualTypeOf<{ + postId?: string + }>() +}) + +test('when creating a route with a splat prefix and suffix', () => { + const rootRoute = createRootRoute() + + const prefixSuffixRoute = createRoute({ + getParentRoute: () => rootRoute, + path: 'prefix{$}suffix', + }) + + const routeTree = rootRoute.addChildren([prefixSuffixRoute]) + + const router = createRouter({ routeTree }) + + expectTypeOf(prefixSuffixRoute.useParams()).toEqualTypeOf<{ + _splat?: string + }>() +}) + +test('when creating a route with a splat, optional param and required param', () => { + const rootRoute = createRootRoute() + + const prefixSuffixRoute = createRoute({ + getParentRoute: () => rootRoute, + path: 'docs/$docId/$/{-$detailId}/{$myFile}.pdf', + }) + + const routeTree = rootRoute.addChildren([prefixSuffixRoute]) + + const router = createRouter({ routeTree }) + + expectTypeOf(prefixSuffixRoute.useParams()).toEqualTypeOf<{ + docId: string + _splat?: string + myFile: string + detailId?: string + }>() +}) + +test('when creating a route with a boundary splat, optional param and required param', () => { + const rootRoute = createRootRoute() + + const prefixSuffixRoute = createRoute({ + getParentRoute: () => rootRoute, + path: 'docs/$docId/before{$}after/detail{-$detailId}/file-{$myFile}.pdf', + }) + + const routeTree = rootRoute.addChildren([prefixSuffixRoute]) + + const router = createRouter({ routeTree }) + + expectTypeOf(prefixSuffixRoute.useParams()).toEqualTypeOf<{ + docId: string + _splat?: string + myFile: string + detailId?: string + }>() +}) + +test('when creating a route with a nested boundary splat, optional param and required param', () => { + const rootRoute = createRootRoute() + + const prefixSuffixRoute = createRoute({ + getParentRoute: () => rootRoute, + path: 'docs/$docId/before{$}after/{-detail{$detailId}suffix}/file-{$myFile}.pdf', + }) + + const routeTree = rootRoute.addChildren([prefixSuffixRoute]) + + const router = createRouter({ routeTree }) + + expectTypeOf(prefixSuffixRoute.useParams()).toEqualTypeOf<{ + docId: string + _splat?: string + myFile: string + detailId?: string + }>() +}) diff --git a/packages/react-router/vite.config.ts b/packages/react-router/vite.config.ts index b53262bcf2..4fe28b540a 100644 --- a/packages/react-router/vite.config.ts +++ b/packages/react-router/vite.config.ts @@ -21,5 +21,14 @@ export default mergeConfig( tanstackViteConfig({ entry: './src/index.tsx', srcDir: './src', + beforeWriteDeclarationFile: (filePath, content) => { + if (filePath.includes('index.d.ts')) { + return content.replace( + `createFileRouteImpl as createFileRoute`, + `createFileRouteGlobal as createFileRoute`, + ) + } + return content + }, }), ) diff --git a/packages/react-start-client/README.md b/packages/react-start-client/README.md index bb009b0c87..ba94d88108 100644 --- a/packages/react-start-client/README.md +++ b/packages/react-start-client/README.md @@ -1,33 +1,9 @@ -> 🤫 we're cooking up something special! - -# TanStack Start +# TanStack React Start - Client -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) +This package is not meant to be used directly. It is a dependency of [`@tanstack/react-start`](https://www.npmjs.com/package/@tanstack/react-start). -🤖 Type-safe router w/ built-in caching & URL state management for React! +TanStack React Start is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router). - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - - -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! +Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started. diff --git a/packages/react-start-client/package.json b/packages/react-start-client/package.json index a83ed07e55..c242f42005 100644 --- a/packages/react-start-client/package.json +++ b/packages/react-start-client/package.json @@ -69,8 +69,7 @@ "cookie-es": "^1.2.2", "jsesc": "^3.1.0", "tiny-invariant": "^1.3.3", - "tiny-warning": "^1.0.3", - "vinxi": "^0.5.3" + "tiny-warning": "^1.0.3" }, "devDependencies": { "@testing-library/react": "^16.2.0", diff --git a/packages/react-start-client/src/index.tsx b/packages/react-start-client/src/index.tsx index 6b9c30ee8f..3aebc26282 100644 --- a/packages/react-start-client/src/index.tsx +++ b/packages/react-start-client/src/index.tsx @@ -1,6 +1,15 @@ -/// -export { mergeHeaders } from '@tanstack/start-client-core' -export { startSerializer } from '@tanstack/start-client-core' +export { + mergeHeaders, + startSerializer, + createIsomorphicFn, + createServerFn, + createMiddleware, + registerGlobalMiddleware, + globalMiddleware, + serverOnly, + clientOnly, + json, +} from '@tanstack/start-client-core' export { type DehydratedRouter, type ClientExtractedBaseEntry, @@ -10,16 +19,10 @@ export { type ClientExtractedPromise, type ClientExtractedStream, type ResolvePromiseState, -} from '@tanstack/start-client-core' -export { - createIsomorphicFn, type IsomorphicFn, type ServerOnlyFn, type ClientOnlyFn, type IsomorphicFnBase, -} from '@tanstack/start-client-core' -export { createServerFn } from '@tanstack/start-client-core' -export { type ServerFn as FetchFn, type ServerFnCtx as FetchFnCtx, type CompiledFetcherFnOptions, @@ -31,43 +34,33 @@ export { type ServerFn, type ServerFnCtx, type ServerFnResponseType, -} from '@tanstack/start-client-core' -export { type JsonResponse } from '@tanstack/start-client-core' -export { - createMiddleware, + type JsonResponse, type IntersectAllValidatorInputs, type IntersectAllValidatorOutputs, - type MiddlewareServerFn, - type AnyMiddleware, - type MiddlewareOptions, - type MiddlewareWithTypes, - type MiddlewareValidator, - type MiddlewareServer, - type MiddlewareAfterClient, - type MiddlewareAfterMiddleware, - type MiddlewareAfterServer, - type Middleware, - type MiddlewareClientFnOptions, - type MiddlewareClientFnResult, - type MiddlewareClientNextFn, - type ClientResultWithContext, + type FunctionMiddlewareServerFn, + type AnyFunctionMiddleware, + type FunctionMiddlewareOptions, + type FunctionMiddlewareWithTypes, + type FunctionMiddlewareValidator, + type FunctionMiddlewareServer, + type FunctionMiddlewareAfterClient, + type FunctionMiddlewareAfterServer, + type FunctionMiddleware, + type FunctionMiddlewareClientFnOptions, + type FunctionMiddlewareClientFnResult, + type FunctionMiddlewareClientNextFn, + type FunctionClientResultWithContext, type AssignAllClientContextBeforeNext, type AssignAllMiddleware, type AssignAllServerContext, - type MiddlewareAfterValidator, - type MiddlewareClientFn, - type MiddlewareServerFnResult, - type MiddlewareClient, - type MiddlewareServerFnOptions, - type MiddlewareServerNextFn, - type ServerResultWithContext, + type FunctionMiddlewareAfterValidator, + type FunctionMiddlewareClientFn, + type FunctionMiddlewareServerFnResult, + type FunctionMiddlewareClient, + type FunctionMiddlewareServerFnOptions, + type FunctionMiddlewareServerNextFn, + type FunctionServerResultWithContext, } from '@tanstack/start-client-core' -export { - registerGlobalMiddleware, - globalMiddleware, -} from '@tanstack/start-client-core' -export { serverOnly, clientOnly } from '@tanstack/start-client-core' -export { json } from '@tanstack/start-client-core' export { Meta } from './Meta' export { Scripts } from './Scripts' export { StartClient } from './StartClient' diff --git a/packages/react-start-client/src/renderRSC.tsx b/packages/react-start-client/src/renderRSC.tsx index 6201bfa476..4832f074b6 100644 --- a/packages/react-start-client/src/renderRSC.tsx +++ b/packages/react-start-client/src/renderRSC.tsx @@ -1,6 +1,4 @@ // TODO: RSCs -// // @ts-expect-error -// import * as reactDom from '@vinxi/react-server-dom/client' import { isValidElement } from 'react' import invariant from 'tiny-invariant' import type React from 'react' diff --git a/packages/react-start-client/src/useServerFn.ts b/packages/react-start-client/src/useServerFn.ts index c046bcb9ed..971b3a6685 100644 --- a/packages/react-start-client/src/useServerFn.ts +++ b/packages/react-start-client/src/useServerFn.ts @@ -17,12 +17,8 @@ export function useServerFn) => Promise>( return res } catch (err) { if (isRedirect(err)) { - const resolvedRedirect = router.resolveRedirect({ - ...err, - _fromLocation: router.state.location, - }) - - return router.navigate(resolvedRedirect) + err.options._fromLocation = router.state.location + return router.navigate(router.resolveRedirect(err).options) } throw err diff --git a/packages/react-start-config/README.md b/packages/react-start-config/README.md deleted file mode 100644 index bb009b0c87..0000000000 --- a/packages/react-start-config/README.md +++ /dev/null @@ -1,33 +0,0 @@ -> 🤫 we're cooking up something special! - - - -# TanStack Start - -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) - -🤖 Type-safe router w/ built-in caching & URL state management for React! - - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - - -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! diff --git a/packages/react-start-config/eslint.config.js b/packages/react-start-config/eslint.config.js deleted file mode 100644 index 931f0ec774..0000000000 --- a/packages/react-start-config/eslint.config.js +++ /dev/null @@ -1,31 +0,0 @@ -// @ts-check - -import pluginReact from '@eslint-react/eslint-plugin' -import pluginReactHooks from 'eslint-plugin-react-hooks' -import rootConfig from '../../eslint.config.js' - -export default [ - ...rootConfig, - { - ...pluginReact.configs.recommended, - files: ['**/*.{ts,tsx}'], - }, - { - plugins: { - 'react-hooks': pluginReactHooks, - }, - rules: { - '@eslint-react/no-unstable-context-value': 'off', - '@eslint-react/no-unstable-default-props': 'off', - '@eslint-react/dom/no-missing-button-type': 'off', - 'react-hooks/exhaustive-deps': 'error', - 'react-hooks/rules-of-hooks': 'error', - }, - }, - { - files: ['**/__tests__/**'], - rules: { - '@typescript-eslint/no-unnecessary-condition': 'off', - }, - }, -] diff --git a/packages/react-start-config/package.json b/packages/react-start-config/package.json deleted file mode 100644 index 23efef7bfd..0000000000 --- a/packages/react-start-config/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@tanstack/react-start-config", - "version": "1.120.3", - "description": "Modern and scalable routing for React applications", - "author": "Tanner Linsley", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/TanStack/router.git", - "directory": "packages/react-start-config" - }, - "homepage": "https://tanstack.com/start", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/tannerlinsley" - }, - "keywords": [ - "react", - "location", - "router", - "routing", - "async", - "async router", - "typescript" - ], - "scripts": { - "clean": "rimraf ./dist && rimraf ./coverage", - "build": "tsc", - "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit", - "test:unit": "exit 0;vitest", - "test:eslint": "eslint ./src", - "test:types": "exit 0; vitest" - }, - "type": "module", - "types": "dist/esm/index.d.ts", - "exports": { - ".": { - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - } - }, - "./package.json": "./package.json" - }, - "sideEffects": false, - "files": [ - "dist", - "src" - ], - "engines": { - "node": ">=12" - }, - "dependencies": { - "@tanstack/router-core": "workspace:^", - "@tanstack/router-generator": "workspace:^", - "@tanstack/router-plugin": "workspace:^", - "@tanstack/server-functions-plugin": "workspace:^", - "@tanstack/react-start-plugin": "workspace:^", - "@tanstack/start-server-functions-handler": "workspace:^", - "@vitejs/plugin-react": "^4.3.4", - "import-meta-resolve": "^4.1.0", - "nitropack": "^2.10.4", - "ofetch": "^1.4.1", - "vite": "^6.1.0", - "vinxi": "0.5.3", - "zod": "^3.24.2" - }, - "peerDependencies": { - "react": ">=18.0.0 || >=19.0.0", - "react-dom": ">=18.0.0 || >=19.0.0", - "vite": "^6.0.0" - } -} diff --git a/packages/react-start-config/src/index.ts b/packages/react-start-config/src/index.ts deleted file mode 100644 index ac30bf2140..0000000000 --- a/packages/react-start-config/src/index.ts +++ /dev/null @@ -1,663 +0,0 @@ -import path from 'node:path' -import { existsSync, readFileSync } from 'node:fs' -import { readFile } from 'node:fs/promises' -import { fileURLToPath } from 'node:url' -import viteReact from '@vitejs/plugin-react' -import { resolve } from 'import-meta-resolve' -import { TanStackRouterVite } from '@tanstack/router-plugin/vite' -import { getConfig } from '@tanstack/router-generator' -import { createApp } from 'vinxi' -import { config } from 'vinxi/plugins/config' -// // @ts-expect-error -// import { serverComponents } from '@vinxi/server-components/plugin' -import { createTanStackServerFnPlugin } from '@tanstack/server-functions-plugin' -import { createTanStackStartPlugin } from '@tanstack/react-start-plugin' -import { createFetch } from 'ofetch' -import { createNitro } from 'nitropack' -import { tanstackStartVinxiFileRouter } from './vinxi-file-router.js' -import { - checkDeploymentPresetInput, - getUserViteConfig, - inlineConfigSchema, - serverSchema, -} from './schema.js' -import type { configSchema } from '@tanstack/router-generator' -import type { z } from 'zod' -import type { - TanStackStartInputConfig, - TanStackStartOutputConfig, -} from './schema.js' -import type { App as VinxiApp } from 'vinxi' -import type { Manifest } from '@tanstack/router-core' -import type * as vite from 'vite' - -export type { - TanStackStartInputConfig, - TanStackStartOutputConfig, -} from './schema.js' - -function setTsrDefaults(config: TanStackStartOutputConfig['tsr']) { - // Normally these are `./src/___`, but we're using `./app/___` for Start stuff - const appDirectory = config?.appDirectory ?? './app' - return { - ...config, - appDirectory: config?.appDirectory ?? appDirectory, - routesDirectory: - config?.routesDirectory ?? path.join(appDirectory, 'routes'), - generatedRouteTree: - config?.generatedRouteTree ?? path.join(appDirectory, 'routeTree.gen.ts'), - } -} - -function mergeSsrOptions(options: Array) { - let ssrOptions: vite.SSROptions = {} - let noExternal: vite.SSROptions['noExternal'] = [] - for (const option of options) { - if (!option) { - continue - } - - if (option.noExternal) { - if (option.noExternal === true) { - noExternal = true - } else if (noExternal !== true) { - if (Array.isArray(option.noExternal)) { - noExternal.push(...option.noExternal) - } else { - noExternal.push(option.noExternal) - } - } - } - - ssrOptions = { - ...ssrOptions, - ...option, - noExternal, - } - } - - return ssrOptions -} - -export async function defineConfig( - inlineConfig: TanStackStartInputConfig = {}, -): Promise { - const opts = inlineConfigSchema.parse(inlineConfig) - - const { preset: configDeploymentPreset, ...serverOptions } = - serverSchema.parse(opts.server || {}) - - const deploymentPreset = checkDeploymentPresetInput(configDeploymentPreset) - const tsr = setTsrDefaults(opts.tsr) - const tsrConfig = getConfig(tsr) - - const appDirectory = tsr.appDirectory - const publicDir = opts.routers?.public?.dir || './public' - - const publicBase = opts.routers?.public?.base || '/' - const clientBase = opts.routers?.client?.base || '/_build' - const apiBase = opts.tsr?.apiBase || '/api' - const serverBase = opts.routers?.server?.base || '/_server' - - const apiMiddleware = opts.routers?.api?.middleware || undefined - const serverMiddleware = opts.routers?.server?.middleware || undefined - const ssrMiddleware = opts.routers?.ssr?.middleware || undefined - - const clientEntry = - opts.routers?.client?.entry || path.join(appDirectory, 'client.tsx') - const ssrEntry = - opts.routers?.ssr?.entry || path.join(appDirectory, 'ssr.tsx') - const apiEntry = opts.routers?.api?.entry || path.join(appDirectory, 'api.ts') - const globalMiddlewareEntry = - opts.routers?.server?.globalMiddlewareEntry || - path.join(appDirectory, 'global-middleware.ts') - const apiEntryExists = existsSync(apiEntry) - - const viteConfig = getUserViteConfig(opts.vite) - - const TanStackServerFnsPlugin = createTanStackServerFnPlugin({ - // This is the ID that will be available to look up and import - // our server function manifest and resolve its module - manifestVirtualImportId: 'tsr:server-fn-manifest', - client: { - getRuntimeCode: () => - `import { createClientRpc } from '@tanstack/react-start/server-functions-client'`, - replacer: (opts) => - `createClientRpc('${opts.functionId}', '${serverBase}')`, - }, - ssr: { - getRuntimeCode: () => - `import { createSsrRpc } from '@tanstack/react-start/server-functions-ssr'`, - replacer: (opts) => `createSsrRpc('${opts.functionId}', '${serverBase}')`, - }, - server: { - getRuntimeCode: () => - `import { createServerRpc } from '@tanstack/react-start/server-functions-server'`, - replacer: (opts) => - `createServerRpc('${opts.functionId}', '${serverBase}', ${opts.fn})`, - }, - }) - - const TanStackStartPlugin = createTanStackStartPlugin({ - globalMiddlewareEntry, - }) - - // Create a dummy nitro app to get the resolved public output path - const dummyNitroApp = await createNitro({ - preset: deploymentPreset, - compatibilityDate: '2024-12-01', - }) - - const nitroOutputPublicDir = dummyNitroApp.options.output.publicDir - await dummyNitroApp.close() - - let vinxiApp = createApp({ - server: { - ...serverOptions, - preset: deploymentPreset, - experimental: { - ...serverOptions.experimental, - asyncContext: true, - }, - }, - routers: [ - { - name: 'public', - type: 'static', - dir: publicDir, - base: publicBase, - }, - { - name: 'client', - type: 'client', - target: 'browser', - handler: clientEntry, - base: clientBase, - // @ts-expect-error - build: { - sourcemap: true, - }, - plugins: () => { - const routerType = 'client' - const clientViteConfig = getUserViteConfig( - opts.routers?.[routerType]?.vite, - ) - - return [ - config('tss-vite-config-client', { - ...viteConfig.userConfig, - ...clientViteConfig.userConfig, - define: { - ...(viteConfig.userConfig.define || {}), - ...(clientViteConfig.userConfig.define || {}), - ...injectDefineEnv('TSS_PUBLIC_BASE', publicBase), - ...injectDefineEnv('TSS_CLIENT_BASE', clientBase), - ...injectDefineEnv('TSS_API_BASE', apiBase), - ...injectDefineEnv( - 'TSS_OUTPUT_PUBLIC_DIR', - nitroOutputPublicDir, - ), - }, - ssr: mergeSsrOptions([ - viteConfig.userConfig.ssr, - clientViteConfig.userConfig.ssr, - { - noExternal, - }, - ]), - optimizeDeps: { - entries: [], - ...(viteConfig.userConfig.optimizeDeps || {}), - ...(clientViteConfig.userConfig.optimizeDeps || {}), - }, - }), - TanStackRouterVite({ - ...tsrConfig, - enableRouteGeneration: true, - autoCodeSplitting: true, - __enableAPIRoutesGeneration: true, - experimental: { - ...tsrConfig.experimental, - }, - }), - TanStackStartPlugin.client, - TanStackServerFnsPlugin.client, - ...(viteConfig.plugins || []), - ...(clientViteConfig.plugins || []), - viteReact(opts.react), - // TODO: RSCS - enable this - // serverComponents.client(), - ] - }, - }, - { - name: 'ssr', - type: 'http', - target: 'server', - handler: ssrEntry, - middleware: ssrMiddleware, - // @ts-expect-error - link: { - client: 'client', - }, - plugins: () => { - const routerType = 'ssr' - const ssrViteConfig = getUserViteConfig( - opts.routers?.[routerType]?.vite, - ) - - return [ - config('tss-vite-config-ssr', { - ...viteConfig.userConfig, - ...ssrViteConfig.userConfig, - define: { - ...(viteConfig.userConfig.define || {}), - ...(ssrViteConfig.userConfig.define || {}), - ...injectDefineEnv('TSS_PUBLIC_BASE', publicBase), - ...injectDefineEnv('TSS_CLIENT_BASE', clientBase), - ...injectDefineEnv('TSS_API_BASE', apiBase), - ...injectDefineEnv( - 'TSS_OUTPUT_PUBLIC_DIR', - nitroOutputPublicDir, - ), - }, - ssr: mergeSsrOptions([ - viteConfig.userConfig.ssr, - ssrViteConfig.userConfig.ssr, - { - noExternal, - external: ['@vinxi/react-server-dom/client'], - }, - ]), - optimizeDeps: { - entries: [], - ...(viteConfig.userConfig.optimizeDeps || {}), - ...(ssrViteConfig.userConfig.optimizeDeps || {}), - }, - }), - TanStackRouterVite({ - ...tsrConfig, - enableRouteGeneration: false, - autoCodeSplitting: true, - __enableAPIRoutesGeneration: true, - experimental: { - ...tsrConfig.experimental, - }, - }), - TanStackStartPlugin.ssr, - TanStackServerFnsPlugin.ssr, - tsrRoutesManifest({ - tsrConfig, - clientBase, - }), - ...(getUserViteConfig(opts.vite).plugins || []), - ...(getUserViteConfig(opts.routers?.ssr?.vite).plugins || []), - viteReact(opts.react), - ] - }, - }, - { - name: 'server', - type: 'http', - target: 'server', - base: serverBase, - middleware: serverMiddleware, - // TODO: RSCS - enable this - // worker: true, - handler: importToProjectRelative( - '@tanstack/start-server-functions-handler', - ), - plugins: () => { - const routerType = 'server' - const serverViteConfig = getUserViteConfig( - opts.routers?.[routerType]?.vite, - ) - - return [ - config('tss-vite-config-server', { - ...viteConfig.userConfig, - ...serverViteConfig.userConfig, - define: { - ...(viteConfig.userConfig.define || {}), - ...(serverViteConfig.userConfig.define || {}), - ...injectDefineEnv('TSS_PUBLIC_BASE', publicBase), - ...injectDefineEnv('TSS_CLIENT_BASE', clientBase), - ...injectDefineEnv('TSS_API_BASE', apiBase), - ...injectDefineEnv('TSS_SERVER_FN_BASE', serverBase), - ...injectDefineEnv( - 'TSS_OUTPUT_PUBLIC_DIR', - nitroOutputPublicDir, - ), - }, - ssr: mergeSsrOptions([ - viteConfig.userConfig.ssr, - serverViteConfig.userConfig.ssr, - { - noExternal, - }, - ]), - optimizeDeps: { - entries: [], - ...(viteConfig.userConfig.optimizeDeps || {}), - ...(serverViteConfig.userConfig.optimizeDeps || {}), - }, - }), - TanStackRouterVite({ - ...tsrConfig, - enableRouteGeneration: false, - autoCodeSplitting: true, - __enableAPIRoutesGeneration: true, - experimental: { - ...tsrConfig.experimental, - }, - }), - TanStackStartPlugin.server, - TanStackServerFnsPlugin.server, - // TODO: RSCS - remove this - // resolve: { - // conditions: [], - // }, - // TODO: RSCs - add this - // serverComponents.serverActions({ - // resolve: { - // conditions: [ - // 'react-server', - // // 'node', - // 'import', - // process.env.NODE_ENV, - // ], - // }, - // runtime: '@vinxi/react-server-dom/runtime', - // transpileDeps: ['react', 'react-dom', '@vinxi/react-server-dom'], - // }), - ...(viteConfig.plugins || []), - ...(serverViteConfig.plugins || []), - ] - }, - }, - ], - }) - - const noExternal = [ - '@tanstack/start', - '@tanstack/react-start', - '@tanstack/react-start/server', - '@tanstack/react-start-client', - '@tanstack/react-start-server', - '@tanstack/start-server-functions-fetcher', - '@tanstack/start-server-functions-handler', - '@tanstack/start-server-functions-client', - '@tanstack/start-server-functions-ssr', - '@tanstack/start-server-functions-server', - '@tanstack/react-start-router-manifest', - '@tanstack/react-start-config', - '@tanstack/start-api-routes', - '@tanstack/server-functions-plugin', - 'tsr:routes-manifest', - 'tsr:server-fn-manifest', - ] - - // If API routes handler exists, add a router for it - if (apiEntryExists) { - vinxiApp = vinxiApp.addRouter({ - name: 'api', - type: 'http', - target: 'server', - base: apiBase, - handler: apiEntry, - middleware: apiMiddleware, - routes: tanstackStartVinxiFileRouter({ tsrConfig, apiBase }), - plugins: () => { - const viteConfig = getUserViteConfig(opts.vite) - const apiViteConfig = getUserViteConfig(opts.routers?.api?.vite) - - return [ - config('tsr-vite-config-api', { - ...viteConfig.userConfig, - ...apiViteConfig.userConfig, - ssr: mergeSsrOptions([ - viteConfig.userConfig.ssr, - apiViteConfig.userConfig.ssr, - { - noExternal, - }, - ]), - optimizeDeps: { - entries: [], - ...(viteConfig.userConfig.optimizeDeps || {}), - ...(apiViteConfig.userConfig.optimizeDeps || {}), - }, - define: { - ...(viteConfig.userConfig.define || {}), - ...(apiViteConfig.userConfig.define || {}), - ...injectDefineEnv('TSS_PUBLIC_BASE', publicBase), - ...injectDefineEnv('TSS_CLIENT_BASE', clientBase), - ...injectDefineEnv('TSS_API_BASE', apiBase), - ...injectDefineEnv('TSS_OUTPUT_PUBLIC_DIR', nitroOutputPublicDir), - }, - }), - TanStackRouterVite({ - ...tsrConfig, - enableRouteGeneration: false, - autoCodeSplitting: true, - __enableAPIRoutesGeneration: true, - experimental: { - ...tsrConfig.experimental, - }, - }), - ...(viteConfig.plugins || []), - ...(apiViteConfig.plugins || []), - ] - }, - }) - } - - // Because Vinxi doesn't use the normal nitro dev server, it doesn't - // supply $fetch during dev. We need to hook into the dev server creation, - // nab the proper utils from the custom nitro instance that is used - // during dev and supply the $fetch to app. - // Hopefully and likely, this will just get removed when we move to - // Nitro directly. - vinxiApp.hooks.hook('app:dev:nitro:config', (devServer) => { - vinxiApp.hooks.hook( - 'app:dev:server:created', - ({ devApp: { localFetch } }) => { - const $fetch = createFetch({ - fetch: localFetch, - defaults: { - baseURL: devServer.nitro.options.runtimeConfig.app.baseURL, - }, - }) - - // @ts-expect-error - globalThis.$fetch = $fetch - }, - ) - }) - - return vinxiApp -} - -function importToProjectRelative(p: string) { - const resolved = fileURLToPath(resolve(p, import.meta.url)) - - const relative = path.relative(process.cwd(), resolved) - - return relative -} - -function tsrRoutesManifest(opts: { - tsrConfig: z.infer - clientBase: string -}): vite.Plugin { - let config: vite.ResolvedConfig - - return { - name: 'tsr-routes-manifest', - configResolved(resolvedConfig) { - config = resolvedConfig - }, - resolveId(id) { - if (id === 'tsr:routes-manifest') { - return id - } - return - }, - async load(id) { - if (id === 'tsr:routes-manifest') { - // If we're in development, return a dummy manifest - - if (config.command === 'serve') { - return `export default () => ({ - routes: {} - })` - } - - const clientViteManifestPath = path.resolve( - config.build.outDir, - `../client/${opts.clientBase}/.vite/manifest.json`, - ) - - type ViteManifest = Record< - string, - { - file: string - isEntry: boolean - imports: Array - } - > - - let manifest: ViteManifest - try { - manifest = JSON.parse(await readFile(clientViteManifestPath, 'utf-8')) - } catch (err) { - console.error(err) - throw new Error( - `Could not find the production client vite manifest at '${clientViteManifestPath}'!`, - ) - } - - const routeTreePath = path.resolve(opts.tsrConfig.generatedRouteTree) - - let routeTreeContent: string - try { - routeTreeContent = readFileSync(routeTreePath, 'utf-8') - } catch (err) { - console.error(err) - throw new Error( - `Could not find the generated route tree at '${routeTreePath}'!`, - ) - } - - // Extract the routesManifest JSON from the route tree file. - // It's located between the /* ROUTE_MANIFEST_START and ROUTE_MANIFEST_END */ comment block. - - const routerManifest = JSON.parse( - routeTreeContent.match( - /\/\* ROUTE_MANIFEST_START([\s\S]*?)ROUTE_MANIFEST_END \*\//, - )?.[1] || '{ routes: {} }', - ) as Manifest - - const routes = routerManifest.routes - - let entryFile: - | { - file: string - imports: Array - } - | undefined - - const filesByRouteFilePath: ViteManifest = Object.fromEntries( - Object.entries(manifest).map(([k, v]) => { - if (v.isEntry) { - entryFile = v - } - - const rPath = k.split('?')[0] - - return [rPath, v] - }, {}), - ) - - // Add preloads to the routes from the vite manifest - Object.entries(routes).forEach(([k, v]) => { - const file = - filesByRouteFilePath[ - path.join(opts.tsrConfig.routesDirectory, v.filePath as string) - ] - - if (file) { - const preloads = file.imports.map((d) => - path.join(opts.clientBase, manifest[d]!.file), - ) - - preloads.unshift(path.join(opts.clientBase, file.file)) - - routes[k] = { - ...v, - preloads, - } - } - }) - - if (entryFile) { - routes.__root__!.preloads = [ - path.join(opts.clientBase, entryFile.file), - ...entryFile.imports.map((d) => - path.join(opts.clientBase, manifest[d]!.file), - ), - ] - } - - const recurseRoute = ( - route: { - preloads?: Array - children?: Array - }, - seenPreloads = {} as Record, - ) => { - route.preloads = route.preloads?.filter((preload) => { - if (seenPreloads[preload]) { - return false - } - seenPreloads[preload] = true - return true - }) - - if (route.children) { - route.children.forEach((child) => { - const childRoute = routes[child]! - recurseRoute(childRoute, { ...seenPreloads }) - }) - } - } - - // @ts-expect-error - recurseRoute(routes.__root__) - - const routesManifest = { - routes, - } - - if (process.env.TSR_VITE_DEBUG) { - console.info( - 'Routes Manifest: \n' + JSON.stringify(routesManifest, null, 2), - ) - } - - return `export default () => (${JSON.stringify(routesManifest)})` - } - return - }, - } -} - -function injectDefineEnv( - key: TKey, - value: TValue, -): { [P in `process.env.${TKey}` | `import.meta.env.${TKey}`]: TValue } { - return { - [`process.env.${key}`]: JSON.stringify(value), - [`import.meta.env.${key}`]: JSON.stringify(value), - } as { [P in `process.env.${TKey}` | `import.meta.env.${TKey}`]: TValue } -} diff --git a/packages/react-start-config/src/schema.ts b/packages/react-start-config/src/schema.ts deleted file mode 100644 index 4529483793..0000000000 --- a/packages/react-start-config/src/schema.ts +++ /dev/null @@ -1,198 +0,0 @@ -import { configSchema } from '@tanstack/router-generator' -import { z } from 'zod' -import type { PluginOption } from 'vite' -import type { AppOptions as VinxiAppOptions } from 'vinxi' -import type { NitroOptions } from 'nitropack' -import type { Options as ViteReactOptions } from '@vitejs/plugin-react' -import type { CustomizableConfig } from 'vinxi/dist/types/lib/vite-dev' - -type StartUserViteConfig = CustomizableConfig | (() => CustomizableConfig) - -export function getUserViteConfig(config?: StartUserViteConfig): { - plugins: Array | undefined - userConfig: CustomizableConfig -} { - const { plugins, ...userConfig } = - typeof config === 'function' ? config() : { ...config } - return { plugins, userConfig } -} - -/** - * Not all the deployment presets are fully functional or tested. - * @see https://github.com/TanStack/router/pull/2002 - */ -const vinxiDeploymentPresets = [ - 'alwaysdata', // untested - 'aws-amplify', // untested - 'aws-lambda', // untested - 'azure', // untested - 'azure-functions', // untested - 'base-worker', // untested - 'bun', // ✅ working - 'cleavr', // untested - 'cli', // untested - 'cloudflare', // untested - 'cloudflare-module', // untested - 'cloudflare-pages', // ✅ working - 'cloudflare-pages-static', // untested - 'deno', // untested - 'deno-deploy', // untested - 'deno-server', // untested - 'digital-ocean', // untested - 'edgio', // untested - 'firebase', // untested - 'flight-control', // untested - 'github-pages', // untested - 'heroku', // untested - 'iis', // untested - 'iis-handler', // untested - 'iis-node', // untested - 'koyeb', // untested - 'layer0', // untested - 'netlify', // ✅ working - 'netlify-builder', // untested - 'netlify-edge', // untested - 'netlify-static', // untested - 'nitro-dev', // untested - 'nitro-prerender', // untested - 'node', // partially working - 'node-cluster', // untested - 'node-server', // ✅ working - 'platform-sh', // untested - 'service-worker', // untested - 'static', // 🟧 partially working - 'stormkit', // untested - 'vercel', // ✅ working - 'vercel-edge', // untested - 'vercel-static', // untested - 'winterjs', // untested - 'zeabur', // untested - 'zeabur-static', // untested -] as const - -type DeploymentPreset = (typeof vinxiDeploymentPresets)[number] | (string & {}) - -const testedDeploymentPresets: Array = [ - 'bun', - 'netlify', - 'vercel', - 'cloudflare-pages', - 'node-server', -] - -export function checkDeploymentPresetInput( - preset?: string, -): DeploymentPreset | undefined { - if (preset) { - if (!vinxiDeploymentPresets.includes(preset as any)) { - console.warn( - `Invalid deployment preset "${preset}". Available presets are: ${vinxiDeploymentPresets - .map((p) => `"${p}"`) - .join(', ')}.`, - ) - } - - if (!testedDeploymentPresets.includes(preset as any)) { - console.warn( - `The deployment preset '${preset}' is not fully supported yet and may not work as expected.`, - ) - } - } - - return preset -} - -type HTTPSOptions = { - cert?: string - key?: string - pfx?: string - passphrase?: string - validityDays?: number - domains?: Array -} - -type ServerOptions_ = VinxiAppOptions['server'] & { - https?: boolean | HTTPSOptions -} - -type ServerOptions = { - [K in keyof ServerOptions_]: ServerOptions_[K] -} - -export const serverSchema = z - .object({ - routeRules: z.custom().optional(), - preset: z.custom().optional(), - static: z.boolean().optional(), - prerender: z - .object({ - routes: z.array(z.string()), - ignore: z - .array( - z.custom< - string | RegExp | ((path: string) => undefined | null | boolean) - >(), - ) - .optional(), - crawlLinks: z.boolean().optional(), - }) - .optional(), - }) - .and(z.custom()) - -const viteSchema = z.custom() - -const viteReactSchema = z.custom() - -const routersSchema = z.object({ - ssr: z - .object({ - entry: z.string().optional(), - middleware: z.string().optional(), - vite: viteSchema.optional(), - }) - .optional(), - client: z - .object({ - entry: z.string().optional(), - base: z.string().optional(), - vite: viteSchema.optional(), - }) - .optional(), - server: z - .object({ - base: z.string().optional(), - globalMiddlewareEntry: z.string().optional(), - middleware: z.string().optional(), - vite: viteSchema.optional(), - }) - .optional(), - api: z - .object({ - entry: z.string().optional(), - middleware: z.string().optional(), - vite: viteSchema.optional(), - }) - .optional(), - public: z - .object({ - dir: z.string().optional(), - base: z.string().optional(), - }) - .optional(), -}) - -const tsrConfig = configSchema.partial().extend({ - appDirectory: z.string().optional(), -}) - -export const inlineConfigSchema = z.object({ - react: viteReactSchema.optional(), - vite: viteSchema.optional(), - tsr: tsrConfig.optional(), - routers: routersSchema.optional(), - server: serverSchema.optional(), -}) - -export type TanStackStartInputConfig = z.input -export type TanStackStartOutputConfig = z.infer diff --git a/packages/react-start-config/src/vinxi-file-router.ts b/packages/react-start-config/src/vinxi-file-router.ts deleted file mode 100644 index 9e6d829d1b..0000000000 --- a/packages/react-start-config/src/vinxi-file-router.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { - BaseFileSystemRouter as VinxiBaseFileSystemRouter, - analyzeModule as vinxiFsRouterAnalyzeModule, - cleanPath as vinxiFsRouterCleanPath, -} from 'vinxi/fs-router' -import { - CONSTANTS as GENERATOR_CONSTANTS, - startAPIRouteSegmentsFromTSRFilePath, -} from '@tanstack/router-generator' -import type { configSchema } from '@tanstack/router-generator' -import type { - AppOptions as VinxiAppOptions, - RouterSchemaInput as VinxiRouterSchemaInput, -} from 'vinxi' -import type { z } from 'zod' - -export function tanstackStartVinxiFileRouter(opts: { - tsrConfig: z.infer - apiBase: string -}) { - const apiBaseSegment = opts.apiBase.split('/').filter(Boolean).join('/') - const isAPIPath = new RegExp(`/${apiBaseSegment}/`) - - return function (router: VinxiRouterSchemaInput, app: VinxiAppOptions) { - // Our own custom File Router that extends the VinxiBaseFileSystemRouter - // for splitting the API routes into its own "bundle" - // and adding the $APIRoute metadata to the route object - // This could be customized in future to support more complex splits - class TanStackStartFsRouter extends VinxiBaseFileSystemRouter { - toPath(src: string): string { - const inputPath = vinxiFsRouterCleanPath(src, this.config) - - const segments = startAPIRouteSegmentsFromTSRFilePath( - inputPath, - opts.tsrConfig, - ) - - const pathname = segments - .map((part) => { - if (part.type === 'splat') { - return `*splat` - } - - if (part.type === 'param') { - return `:${part.value}?` - } - - return part.value - }) - .join('/') - - return pathname.length > 0 ? `/${pathname}` : '/' - } - - toRoute(src: string) { - const webPath = this.toPath(src) - - const [_, exports] = vinxiFsRouterAnalyzeModule(src) - - const hasAPIRoute = exports.find( - (exp) => exp.n === GENERATOR_CONSTANTS.APIRouteExportVariable, - ) - - return { - path: webPath, - filePath: src, - $APIRoute: - isAPIPath.test(webPath) && hasAPIRoute - ? { - src, - pick: [GENERATOR_CONSTANTS.APIRouteExportVariable], - } - : undefined, - } - } - } - - return new TanStackStartFsRouter( - { - dir: opts.tsrConfig.routesDirectory, - extensions: ['js', 'jsx', 'ts', 'tsx'], - }, - router, - app, - ) - } -} diff --git a/packages/react-start-config/tsconfig.json b/packages/react-start-config/tsconfig.json deleted file mode 100644 index 940a9cce0a..0000000000 --- a/packages/react-start-config/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["src/index.ts"], - "compilerOptions": { - "rootDir": "src", - "outDir": "dist/esm", - "target": "esnext", - "noEmit": false - } -} diff --git a/packages/react-start-plugin/README.md b/packages/react-start-plugin/README.md index 90488bbcd8..45e57a4d5b 100644 --- a/packages/react-start-plugin/README.md +++ b/packages/react-start-plugin/README.md @@ -1,5 +1,9 @@ -# TanStack Start Vite Plugin +# TanStack React Start - Plugin -See https://tanstack.com/router/latest/docs/framework/react/routing/file-based-routing +This package is not meant to be used directly. It is a dependency of [`@tanstack/react-start`](https://www.npmjs.com/package/@tanstack/react-start). + +TanStack React Start is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router). + +Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started. diff --git a/packages/react-start-plugin/package.json b/packages/react-start-plugin/package.json index f13d4951cc..a7ae54fd97 100644 --- a/packages/react-start-plugin/package.json +++ b/packages/react-start-plugin/package.json @@ -27,7 +27,7 @@ "clean": "rimraf ./dist && rimraf ./coverage", "clean:snapshots": "rimraf **/*snapshot* --glob", "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit", - "test:unit": "vitest", + "test:unit": "exit 0; vitest", "test:eslint": "eslint ./src", "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"", "test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js", @@ -65,22 +65,12 @@ "node": ">=12" }, "dependencies": { - "@babel/code-frame": "7.26.2", - "@babel/core": "^7.26.8", - "@babel/plugin-syntax-jsx": "^7.25.9", - "@babel/plugin-syntax-typescript": "^7.25.9", - "@babel/template": "^7.26.8", - "@babel/traverse": "^7.26.8", - "@babel/types": "^7.26.8", + "@tanstack/router-plugin": "workspace:^", "@tanstack/router-utils": "workspace:^", - "babel-dead-code-elimination": "^1.0.10", - "tiny-invariant": "^1.3.3", - "vite": "6.1.4" - }, - "devDependencies": { - "@types/babel__code-frame": "^7.0.6", - "@types/babel__core": "^7.20.5", - "@types/babel__template": "^7.4.4", - "@types/babel__traverse": "^7.20.6" + "@tanstack/server-functions-plugin": "workspace:^", + "@tanstack/start-plugin-core": "workspace:^", + "@vitejs/plugin-react": "^4.3.4", + "vite": "6.1.4", + "zod": "^3.24.2" } } diff --git a/packages/react-start-plugin/src/compilers.ts b/packages/react-start-plugin/src/compilers.ts deleted file mode 100644 index ca806fc991..0000000000 --- a/packages/react-start-plugin/src/compilers.ts +++ /dev/null @@ -1,584 +0,0 @@ -import * as babel from '@babel/core' -import * as t from '@babel/types' -import { codeFrameColumns } from '@babel/code-frame' -import { - deadCodeElimination, - findReferencedIdentifiers, -} from 'babel-dead-code-elimination' -import { generateFromAst, parseAst } from '@tanstack/router-utils' -import type { GeneratorResult, ParseAstOptions } from '@tanstack/router-utils' - -// build these once and reuse them -const handleServerOnlyCallExpression = - buildEnvOnlyCallExpressionHandler('server') -const handleClientOnlyCallExpression = - buildEnvOnlyCallExpressionHandler('client') - -type CompileOptions = ParseAstOptions & { - env: 'server' | 'client' | 'ssr' - dce?: boolean -} - -type IdentifierConfig = { - name: string - type: 'ImportSpecifier' | 'ImportNamespaceSpecifier' - namespaceId: string - handleCallExpression: ( - path: babel.NodePath, - opts: CompileOptions, - ) => void - paths: Array -} - -export function compileStartOutput(opts: CompileOptions): GeneratorResult { - const ast = parseAst(opts) - - const doDce = opts.dce ?? true - // find referenced identifiers *before* we transform anything - const refIdents = doDce ? findReferencedIdentifiers(ast) : undefined - - babel.traverse(ast, { - Program: { - enter(programPath) { - const identifiers: { - createServerFn: IdentifierConfig - createMiddleware: IdentifierConfig - serverOnly: IdentifierConfig - clientOnly: IdentifierConfig - createIsomorphicFn: IdentifierConfig - } = { - createServerFn: { - name: 'createServerFn', - type: 'ImportSpecifier', - namespaceId: '', - handleCallExpression: handleCreateServerFnCallExpression, - paths: [], - }, - createMiddleware: { - name: 'createMiddleware', - type: 'ImportSpecifier', - namespaceId: '', - handleCallExpression: handleCreateMiddlewareCallExpression, - paths: [], - }, - serverOnly: { - name: 'serverOnly', - type: 'ImportSpecifier', - namespaceId: '', - handleCallExpression: handleServerOnlyCallExpression, - paths: [], - }, - clientOnly: { - name: 'clientOnly', - type: 'ImportSpecifier', - namespaceId: '', - handleCallExpression: handleClientOnlyCallExpression, - paths: [], - }, - createIsomorphicFn: { - name: 'createIsomorphicFn', - type: 'ImportSpecifier', - namespaceId: '', - handleCallExpression: handleCreateIsomorphicFnCallExpression, - paths: [], - }, - } - - const identifierKeys = Object.keys(identifiers) as Array< - keyof typeof identifiers - > - - programPath.traverse({ - ImportDeclaration: (path) => { - if (path.node.source.value !== '@tanstack/react-start') { - return - } - - // handle a destructured imports being renamed like "import { createServerFn as myCreateServerFn } from '@tanstack/react-start';" - path.node.specifiers.forEach((specifier) => { - identifierKeys.forEach((identifierKey) => { - const identifier = identifiers[identifierKey] - - if ( - specifier.type === 'ImportSpecifier' && - specifier.imported.type === 'Identifier' - ) { - if (specifier.imported.name === identifierKey) { - identifier.name = specifier.local.name - identifier.type = 'ImportSpecifier' - } - } - - // handle namespace imports like "import * as TanStackStart from '@tanstack/react-start';" - if (specifier.type === 'ImportNamespaceSpecifier') { - identifier.type = 'ImportNamespaceSpecifier' - identifier.namespaceId = specifier.local.name - identifier.name = `${identifier.namespaceId}.${identifierKey}` - } - }) - }) - }, - CallExpression: (path) => { - identifierKeys.forEach((identifierKey) => { - // Check to see if the call expression is a call to the - // identifiers[identifierKey].name - if ( - t.isIdentifier(path.node.callee) && - path.node.callee.name === identifiers[identifierKey].name - ) { - // The identifier could be a call to the original function - // in the source code. If this is case, we need to ignore it. - // Check the scope to see if the identifier is a function declaration. - // if it is, then we can ignore it. - - if ( - path.scope.getBinding(identifiers[identifierKey].name)?.path - .node.type === 'FunctionDeclaration' - ) { - return - } - - return identifiers[identifierKey].paths.push(path) - } - - if (t.isMemberExpression(path.node.callee)) { - if ( - t.isIdentifier(path.node.callee.object) && - t.isIdentifier(path.node.callee.property) - ) { - const callname = [ - path.node.callee.object.name, - path.node.callee.property.name, - ].join('.') - - if (callname === identifiers[identifierKey].name) { - identifiers[identifierKey].paths.push(path) - } - } - } - - return - }) - }, - }) - - identifierKeys.forEach((identifierKey) => { - identifiers[identifierKey].paths.forEach((path) => { - identifiers[identifierKey].handleCallExpression( - path as babel.NodePath, - opts, - ) - }) - }) - }, - }, - }) - - if (doDce) { - deadCodeElimination(ast, refIdents) - } - - return generateFromAst(ast, { - sourceMaps: true, - sourceFileName: opts.filename, - filename: opts.filename, - }) -} - -function handleCreateServerFnCallExpression( - path: babel.NodePath, - opts: ParseAstOptions, -) { - // The function is the 'fn' property of the object passed to createServerFn - - // const firstArg = path.node.arguments[0] - // if (t.isObjectExpression(firstArg)) { - // // Was called with some options - // } - - // Traverse the member expression and find the call expressions for - // the validator, handler, and middleware methods. Check to make sure they - // are children of the createServerFn call expression. - - const calledOptions = path.node.arguments[0] - ? (path.get('arguments.0') as babel.NodePath) - : null - - const shouldValidateClient = !!calledOptions?.node.properties.find((prop) => { - return ( - t.isObjectProperty(prop) && - t.isIdentifier(prop.key) && - prop.key.name === 'validateClient' && - t.isBooleanLiteral(prop.value) && - prop.value.value === true - ) - }) - - const callExpressionPaths = { - middleware: null as babel.NodePath | null, - validator: null as babel.NodePath | null, - handler: null as babel.NodePath | null, - } - - const validMethods = Object.keys(callExpressionPaths) - - const rootCallExpression = getRootCallExpression(path) - - // if (debug) - // console.info( - // 'Handling createServerFn call expression:', - // rootCallExpression.toString(), - // ) - - // Check if the call is assigned to a variable - if (!rootCallExpression.parentPath.isVariableDeclarator()) { - throw new Error('createServerFn must be assigned to a variable!') - } - - // Get the identifier name of the variable - const variableDeclarator = rootCallExpression.parentPath.node - const existingVariableName = (variableDeclarator.id as t.Identifier).name - - rootCallExpression.traverse({ - MemberExpression(memberExpressionPath) { - if (t.isIdentifier(memberExpressionPath.node.property)) { - const name = memberExpressionPath.node.property - .name as keyof typeof callExpressionPaths - - if ( - validMethods.includes(name) && - memberExpressionPath.parentPath.isCallExpression() - ) { - callExpressionPaths[name] = memberExpressionPath.parentPath - } - } - }, - }) - - if (callExpressionPaths.validator) { - const innerInputExpression = callExpressionPaths.validator.node.arguments[0] - - if (!innerInputExpression) { - throw new Error( - 'createServerFn().validator() must be called with a validator!', - ) - } - - // If we're on the client, and we're not validating the client, remove the validator call expression - if ( - opts.env === 'client' && - !shouldValidateClient && - t.isMemberExpression(callExpressionPaths.validator.node.callee) - ) { - callExpressionPaths.validator.replaceWith( - callExpressionPaths.validator.node.callee.object, - ) - } - } - - // First, we need to move the handler function to a nested function call - // that is applied to the arguments passed to the server function. - - const handlerFnPath = callExpressionPaths.handler?.get( - 'arguments.0', - ) as babel.NodePath - - if (!callExpressionPaths.handler || !handlerFnPath.node) { - throw codeFrameError( - opts.code, - path.node.callee.loc!, - `createServerFn must be called with a "handler" property!`, - ) - } - - const handlerFn = handlerFnPath.node - - // So, the way we do this is we give the handler function a way - // to access the serverFn ctx on the server via function scope. - // The 'use server' extracted function will be called with the - // payload from the client, then use the scoped serverFn ctx - // to execute the handler function. - // This way, we can do things like data and middleware validation - // in the __execute function without having to AST transform the - // handler function too much itself. - - // .handler((optsOut, ctx) => { - // return ((optsIn) => { - // 'use server' - // ctx.__execute(handlerFn, optsIn) - // })(optsOut) - // }) - - // If the handler function is an identifier and we're on the client, we need to - // remove the bound function from the file. - // If we're on the server, you can leave it, since it will get referenced - // as a second argument. - - if (t.isIdentifier(handlerFn)) { - if (opts.env === 'client' || opts.env === 'ssr') { - // Find the binding for the handler function - const binding = handlerFnPath.scope.getBinding(handlerFn.name) - // Remove it - if (binding) { - binding.path.remove() - } - } - // If the env is server, just leave it alone - } - - handlerFnPath.replaceWith( - t.arrowFunctionExpression( - [t.identifier('opts'), t.identifier('signal')], - t.blockStatement( - // Everything in here is server-only, since the client - // will strip out anything in the 'use server' directive. - [ - t.returnStatement( - t.callExpression( - t.identifier(`${existingVariableName}.__executeServer`), - [t.identifier('opts'), t.identifier('signal')], - ), - ), - ], - [t.directive(t.directiveLiteral('use server'))], - ), - ), - ) - - if (opts.env === 'server') { - callExpressionPaths.handler.node.arguments.push(handlerFn) - } -} - -function handleCreateMiddlewareCallExpression( - path: babel.NodePath, - opts: ParseAstOptions, -) { - const rootCallExpression = getRootCallExpression(path) - - // if (debug) - // console.info( - // 'Handling createMiddleware call expression:', - // rootCallExpression.toString(), - // ) - - const callExpressionPaths = { - middleware: null as babel.NodePath | null, - validator: null as babel.NodePath | null, - client: null as babel.NodePath | null, - server: null as babel.NodePath | null, - } - - const validMethods = Object.keys(callExpressionPaths) - - rootCallExpression.traverse({ - MemberExpression(memberExpressionPath) { - if (t.isIdentifier(memberExpressionPath.node.property)) { - const name = memberExpressionPath.node.property - .name as keyof typeof callExpressionPaths - - if ( - validMethods.includes(name) && - memberExpressionPath.parentPath.isCallExpression() - ) { - callExpressionPaths[name] = memberExpressionPath.parentPath - } - } - }, - }) - - if (callExpressionPaths.validator) { - const innerInputExpression = callExpressionPaths.validator.node.arguments[0] - - if (!innerInputExpression) { - throw new Error( - 'createMiddleware().validator() must be called with a validator!', - ) - } - - // If we're on the client or ssr, remove the validator call expression - if (opts.env === 'client' || opts.env === 'ssr') { - if (t.isMemberExpression(callExpressionPaths.validator.node.callee)) { - callExpressionPaths.validator.replaceWith( - callExpressionPaths.validator.node.callee.object, - ) - } - } - } - - const serverFnPath = callExpressionPaths.server?.get( - 'arguments.0', - ) as babel.NodePath - - if ( - callExpressionPaths.server && - serverFnPath.node && - (opts.env === 'client' || opts.env === 'ssr') - ) { - // If we're on the client, remove the server call expression - if (t.isMemberExpression(callExpressionPaths.server.node.callee)) { - callExpressionPaths.server.replaceWith( - callExpressionPaths.server.node.callee.object, - ) - } - } -} - -function buildEnvOnlyCallExpressionHandler(env: 'client' | 'server') { - return function envOnlyCallExpressionHandler( - path: babel.NodePath, - opts: ParseAstOptions, - ) { - // if (debug) - // console.info(`Handling ${env}Only call expression:`, path.toString()) - - const isEnvMatch = - env === 'client' - ? opts.env === 'client' - : opts.env === 'server' || opts.env === 'ssr' - - if (isEnvMatch) { - // extract the inner function from the call expression - const innerInputExpression = path.node.arguments[0] - - if (!t.isExpression(innerInputExpression)) { - throw new Error( - `${env}Only() functions must be called with a function!`, - ) - } - - path.replaceWith(innerInputExpression) - return - } - - // If we're on the wrong environment, replace the call expression - // with a function that always throws an error. - path.replaceWith( - t.arrowFunctionExpression( - [], - t.blockStatement([ - t.throwStatement( - t.newExpression(t.identifier('Error'), [ - t.stringLiteral( - `${env}Only() functions can only be called on the ${env}!`, - ), - ]), - ), - ]), - ), - ) - } -} - -function handleCreateIsomorphicFnCallExpression( - path: babel.NodePath, - opts: CompileOptions, -) { - const rootCallExpression = getRootCallExpression(path) - - // if (debug) - // console.info( - // 'Handling createIsomorphicFn call expression:', - // rootCallExpression.toString(), - // ) - - const callExpressionPaths = { - client: null as babel.NodePath | null, - server: null as babel.NodePath | null, - } - - const validMethods = Object.keys(callExpressionPaths) - - rootCallExpression.traverse({ - MemberExpression(memberExpressionPath) { - if (t.isIdentifier(memberExpressionPath.node.property)) { - const name = memberExpressionPath.node.property - .name as keyof typeof callExpressionPaths - - if ( - validMethods.includes(name) && - memberExpressionPath.parentPath.isCallExpression() - ) { - callExpressionPaths[name] = memberExpressionPath.parentPath - } - } - }, - }) - - if ( - validMethods.every( - (method) => - !callExpressionPaths[method as keyof typeof callExpressionPaths], - ) - ) { - const variableId = rootCallExpression.parentPath.isVariableDeclarator() - ? rootCallExpression.parentPath.node.id - : null - console.warn( - 'createIsomorphicFn called without a client or server implementation!', - 'This will result in a no-op function.', - 'Variable name:', - t.isIdentifier(variableId) ? variableId.name : 'unknown', - ) - } - - const resolvedEnv = opts.env === 'ssr' ? 'server' : opts.env - - const envCallExpression = callExpressionPaths[resolvedEnv] - - if (!envCallExpression) { - // if we don't have an implementation for this environment, default to a no-op - rootCallExpression.replaceWith( - t.arrowFunctionExpression([], t.blockStatement([])), - ) - return - } - - const innerInputExpression = envCallExpression.node.arguments[0] - - if (!t.isExpression(innerInputExpression)) { - throw new Error( - `createIsomorphicFn().${resolvedEnv}(func) must be called with a function!`, - ) - } - - rootCallExpression.replaceWith(innerInputExpression) -} - -function getRootCallExpression(path: babel.NodePath) { - // Find the highest callExpression parent - let rootCallExpression: babel.NodePath = path - - // Traverse up the chain of CallExpressions - while (rootCallExpression.parentPath.isMemberExpression()) { - const parent = rootCallExpression.parentPath - if (parent.parentPath.isCallExpression()) { - rootCallExpression = parent.parentPath - } - } - - return rootCallExpression -} - -function codeFrameError( - code: string, - loc: { - start: { line: number; column: number } - end: { line: number; column: number } - }, - message: string, -) { - const frame = codeFrameColumns( - code, - { - start: loc.start, - end: loc.end, - }, - { - highlightCode: true, - message, - }, - ) - - return new Error(frame) -} diff --git a/packages/react-start-plugin/src/index.ts b/packages/react-start-plugin/src/index.ts index 6ab529afca..018c5d59f9 100644 --- a/packages/react-start-plugin/src/index.ts +++ b/packages/react-start-plugin/src/index.ts @@ -1,143 +1,119 @@ -import { fileURLToPath, pathToFileURL } from 'node:url' import path from 'node:path' -import { existsSync } from 'node:fs' -import { logDiff } from '@tanstack/router-utils' -import { compileStartOutput } from './compilers' -import type { Plugin } from 'vite' +import { TanStackServerFnPluginEnv } from '@tanstack/server-functions-plugin' +import { TanStackRouterVite } from '@tanstack/router-plugin/vite' +import viteReact from '@vitejs/plugin-react' +import { + TanStackStartServerRoutesVite, + TanStackStartVitePluginCore, +} from '@tanstack/start-plugin-core' +import { getTanStackStartOptions } from './schema' +import type { TanStackStartInputConfig, WithReactPlugin } from './schema' +import type { PluginOption } from 'vite' -const debug = - process.env.TSR_VITE_DEBUG && - ['true', 'react-start-plugin'].includes(process.env.TSR_VITE_DEBUG) +export type { + TanStackStartInputConfig, + TanStackStartOutputConfig, + WithReactPlugin, +} from './schema' -export type TanStackStartViteOptions = { - globalMiddlewareEntry: string -} +export function TanStackStartVitePlugin( + opts?: TanStackStartInputConfig & WithReactPlugin, +): Array { + type OptionsWithReact = ReturnType & + WithReactPlugin + const options: OptionsWithReact = getTanStackStartOptions(opts) -const transformFuncs = [ - 'createServerFn', - 'createMiddleware', - 'serverOnly', - 'clientOnly', - 'createIsomorphicFn', -] -const tokenRegex = new RegExp(transformFuncs.join('|')) -// const eitherFuncRegex = new RegExp( -// `(function ${transformFuncs.join('|function ')})`, -// ) - -export function createTanStackStartPlugin(opts: TanStackStartViteOptions): { - client: Array - ssr: Array - server: Array -} { - const globalMiddlewarePlugin = (): Plugin => { - let entry: string | null = null - let resolvedGlobalMiddlewareEntry: string | null = null - let globalMiddlewareEntryExists = false - let ROOT: string = process.cwd() - return { - name: 'vite-plugin-tanstack-start-ensure-global-middleware', - enforce: 'pre', - configResolved: (config) => { - ROOT = config.root - entry = path.resolve(ROOT, (config as any).router.handler) - resolvedGlobalMiddlewareEntry = path.resolve( - ROOT, - opts.globalMiddlewareEntry, - ) - globalMiddlewareEntryExists = existsSync(resolvedGlobalMiddlewareEntry) - - if (!entry) { - throw new Error( - '@tanstack/react-start-plugin: No server entry found!', - ) + return [ + TanStackStartVitePluginCore('react', options), + { + name: 'tanstack-react-start:resolve-entries', + resolveId(id) { + if ( + [ + '/~start/server-entry', + '/~start/default-server-entry', + '/~start/default-client-entry', + ].includes(id) + ) { + return `${id}.tsx` } - }, - transform(code, id) { - if (entry && id.includes(entry)) { - if (globalMiddlewareEntryExists) { - return { - code: `${code}\n\nimport '${path.resolve(ROOT, opts.globalMiddlewareEntry)}'`, - map: null, - } - } + if (id === '/~start/server-entry.tsx') { + return id } + return null }, - } - } - - return { - client: [ - globalMiddlewarePlugin(), - TanStackStartServerFnsAndMiddleware({ ...opts, env: 'client' }), - ], - ssr: [ - globalMiddlewarePlugin(), - TanStackStartServerFnsAndMiddleware({ ...opts, env: 'ssr' }), - ], - server: [ - globalMiddlewarePlugin(), - TanStackStartServerFnsAndMiddleware({ ...opts, env: 'server' }), - ], - } -} - -export function TanStackStartServerFnsAndMiddleware(opts: { - env: 'server' | 'ssr' | 'client' -}): Plugin { - let ROOT: string = process.cwd() - - return { - name: 'vite-plugin-tanstack-start-create-server-fn', - enforce: 'pre', - configResolved: (config) => { - ROOT = config.root - }, - transform(code, id) { - const url = pathToFileURL(id) - url.searchParams.delete('v') - id = fileURLToPath(url).replace(/\\/g, '/') - - const includesToken = tokenRegex.test(code) - // const includesEitherFunc = eitherFuncRegex.test(code) - - if ( - !includesToken - // includesEitherFunc - // /node_modules/.test(id) - ) { - return null - } - - if (code.includes('@react-refresh')) { - throw new Error( - `We detected that the '@vitejs/plugin-react' was passed before '@tanstack/react-start-plugin'. Please make sure that '@tanstack/router-vite-plugin' is passed before '@vitejs/plugin-react' and try again: -e.g. - -plugins: [ - TanStackStartVite(), // Place this before viteReact() - viteReact(), -] -`, + load(id) { + const routerImportPath = JSON.stringify( + path.resolve(options.root, options.tsr.srcDirectory, 'router'), ) - } - if (debug) console.info(`${opts.env} Compiling Start: `, id) + if (id === '/~start/server-entry.tsx') { + return ` +import { toWebRequest, defineEventHandler, __setGlobalOrigin, __getAbsoluteUrl } from '@tanstack/react-start/server'; +import serverEntry from '${options.serverEntryPath}'; - const compiled = compileStartOutput({ - code, - root: ROOT, - filename: id, - env: opts.env, - }) +export default defineEventHandler(function(event) { + const request = toWebRequest(event); + __setGlobalOrigin(__getAbsoluteUrl(request)); + return serverEntry({ request }); +}) +` + } - if (debug) { - logDiff(code, compiled.code) - console.log('Output:\n', compiled.code + '\n\n') - } + if (id === '/~start/default-client-entry.tsx') { + return ` +import { hydrateRoot } from 'react-dom/client' +import { StartClient } from '@tanstack/react-start' +import { createRouter } from ${routerImportPath} - return compiled +const router = createRouter() + +hydrateRoot(document, ) +` + } + + if (id === '/~start/default-server-entry.tsx') { + return ` +import { createStartHandler, defaultStreamHandler } from '@tanstack/react-start/server' +import { createRouter } from ${routerImportPath} + +export default createStartHandler({ + createRouter, +})(defaultStreamHandler) +` + } + + return null + }, }, - } + TanStackServerFnPluginEnv({ + // This is the ID that will be available to look up and import + // our server function manifest and resolve its module + manifestVirtualImportId: 'tanstack:server-fn-manifest', + client: { + getRuntimeCode: () => + `import { createClientRpc } from '@tanstack/react-start/server-functions-client'`, + replacer: (d) => + `createClientRpc('${d.functionId}', '${options.serverFns.base}')`, + }, + server: { + getRuntimeCode: () => + `import { createServerRpc } from '@tanstack/react-start/server-functions-server'`, + replacer: (d) => + `createServerRpc('${d.functionId}', '${options.serverFns.base}', ${d.fn})`, + }, + }), + TanStackRouterVite({ + ...options.tsr, + target: 'react', + enableRouteGeneration: true, + autoCodeSplitting: true, + }), + TanStackStartServerRoutesVite({ + ...options.tsr, + target: 'react', + }), + viteReact(options.react), + ] } diff --git a/packages/react-start-plugin/src/schema.ts b/packages/react-start-plugin/src/schema.ts new file mode 100644 index 0000000000..4522cc801a --- /dev/null +++ b/packages/react-start-plugin/src/schema.ts @@ -0,0 +1,31 @@ +import { z } from 'zod' +import { + createTanStackConfig, + createTanStackStartOptionsSchema, +} from '@tanstack/start-plugin-core' +import type { Options as ViteReactOptions } from '@vitejs/plugin-react' + +export type WithReactPlugin = { + react?: ViteReactOptions +} + +const frameworkPlugin = { + react: z.custom().optional(), +} + +// eslint-disable-next-line unused-imports/no-unused-vars +const TanStackStartOptionsSchema = + createTanStackStartOptionsSchema(frameworkPlugin) + +const defaultConfig = createTanStackConfig(frameworkPlugin) + +export function getTanStackStartOptions(opts?: TanStackStartInputConfig) { + return defaultConfig.parse(opts) +} + +export type TanStackStartInputConfig = z.input< + typeof TanStackStartOptionsSchema +> +export type TanStackStartOutputConfig = ReturnType< + typeof getTanStackStartOptions +> diff --git a/packages/react-start-plugin/tsconfig.json b/packages/react-start-plugin/tsconfig.json index 37d21ef6ca..090ec3917d 100644 --- a/packages/react-start-plugin/tsconfig.json +++ b/packages/react-start-plugin/tsconfig.json @@ -3,6 +3,8 @@ "include": ["src", "vite.config.ts", "tests"], "exclude": ["tests/**/test-files/**", "tests/**/snapshots/**"], "compilerOptions": { - "jsx": "react-jsx" + "outDir": "dist/esm", + "target": "esnext", + "noEmit": true } } diff --git a/packages/react-start-plugin/vite.config.ts b/packages/react-start-plugin/vite.config.ts index 5389f0f739..2c711fd181 100644 --- a/packages/react-start-plugin/vite.config.ts +++ b/packages/react-start-plugin/vite.config.ts @@ -16,5 +16,6 @@ export default mergeConfig( tanstackViteConfig({ entry: './src/index.ts', srcDir: './src', + outDir: './dist', }), ) diff --git a/packages/react-start-router-manifest/README.md b/packages/react-start-router-manifest/README.md deleted file mode 100644 index bb009b0c87..0000000000 --- a/packages/react-start-router-manifest/README.md +++ /dev/null @@ -1,33 +0,0 @@ -> 🤫 we're cooking up something special! - - - -# TanStack Start - -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) - -🤖 Type-safe router w/ built-in caching & URL state management for React! - - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - - -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! diff --git a/packages/react-start-router-manifest/eslint.config.js b/packages/react-start-router-manifest/eslint.config.js deleted file mode 100644 index 931f0ec774..0000000000 --- a/packages/react-start-router-manifest/eslint.config.js +++ /dev/null @@ -1,31 +0,0 @@ -// @ts-check - -import pluginReact from '@eslint-react/eslint-plugin' -import pluginReactHooks from 'eslint-plugin-react-hooks' -import rootConfig from '../../eslint.config.js' - -export default [ - ...rootConfig, - { - ...pluginReact.configs.recommended, - files: ['**/*.{ts,tsx}'], - }, - { - plugins: { - 'react-hooks': pluginReactHooks, - }, - rules: { - '@eslint-react/no-unstable-context-value': 'off', - '@eslint-react/no-unstable-default-props': 'off', - '@eslint-react/dom/no-missing-button-type': 'off', - 'react-hooks/exhaustive-deps': 'error', - 'react-hooks/rules-of-hooks': 'error', - }, - }, - { - files: ['**/__tests__/**'], - rules: { - '@typescript-eslint/no-unnecessary-condition': 'off', - }, - }, -] diff --git a/packages/react-start-router-manifest/package.json b/packages/react-start-router-manifest/package.json deleted file mode 100644 index f367442a9c..0000000000 --- a/packages/react-start-router-manifest/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@tanstack/react-start-router-manifest", - "version": "1.120.3", - "description": "Modern and scalable routing for React applications", - "author": "Tanner Linsley", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/TanStack/router.git", - "directory": "packages/react-start-router-manifest" - }, - "homepage": "https://tanstack.com/start", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/tannerlinsley" - }, - "keywords": [ - "react", - "location", - "router", - "routing", - "async", - "async router", - "typescript" - ], - "scripts": { - "clean": "rimraf ./dist && rimraf ./coverage", - "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit", - "test:unit": "exit 0; vitest", - "test:eslint": "eslint ./src", - "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"", - "test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js", - "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js", - "test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js", - "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js", - "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js", - "test:types:ts58": "tsc", - "test:build": "publint --strict && attw --ignore-rules no-resolution --pack .", - "build": "tsc" - }, - "type": "module", - "types": "dist/esm/index.d.ts", - "exports": { - ".": { - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - } - }, - "./package.json": "./package.json" - }, - "sideEffects": false, - "files": [ - "dist", - "src" - ], - "engines": { - "node": ">=12" - }, - "dependencies": { - "@tanstack/router-core": "workspace:^", - "tiny-invariant": "^1.3.3", - "vinxi": "0.5.3" - }, - "devDependencies": { - "typescript": "^5.7.2" - } -} diff --git a/packages/react-start-router-manifest/src/index.ts b/packages/react-start-router-manifest/src/index.ts deleted file mode 100644 index 3f0a37f609..0000000000 --- a/packages/react-start-router-manifest/src/index.ts +++ /dev/null @@ -1,88 +0,0 @@ -// @ts-expect-error -import tsrGetManifest from 'tsr:routes-manifest' -import { getManifest } from 'vinxi/manifest' -import { default as invariant } from 'tiny-invariant' -import type { Manifest } from '@tanstack/router-core' - -function sanitizeBase(base: string) { - return base.replace(/^\/|\/$/g, '') -} - -/** - * @description Returns the full, unfiltered router manifest. This includes relationships - * between routes, assets, and preloads and is NOT what you want to serialize and - * send to the client. - */ -export function getFullRouterManifest() { - const routerManifest = tsrGetManifest() as Manifest - - const rootRoute = (routerManifest.routes.__root__ = - routerManifest.routes.__root__ || {}) - - rootRoute.assets = rootRoute.assets || [] - - let script = '' - // Always fake that HMR is ready - if (process.env.NODE_ENV === 'development') { - const CLIENT_BASE = sanitizeBase(process.env.TSS_CLIENT_BASE || '') - - if (!CLIENT_BASE) { - throw new Error( - 'tanstack/start-router-manifest: TSS_CLIENT_BASE must be defined in your environment for getFullRouterManifest()', - ) - } - script = `import RefreshRuntime from "/${CLIENT_BASE}/@react-refresh"; - RefreshRuntime.injectIntoGlobalHook(window) - window.$RefreshReg$ = () => {} - window.$RefreshSig$ = () => (type) => type - window.__vite_plugin_react_preamble_installed__ = true;` - } - - // Get the entry for the client from vinxi - const vinxiClientManifest = getManifest('client') - - const importPath = - vinxiClientManifest.inputs[vinxiClientManifest.handler]?.output.path - if (!importPath) { - invariant(importPath, 'Could not find client entry in vinxi manifest') - } - - rootRoute.assets.push({ - tag: 'script', - attrs: { - type: 'module', - suppressHydrationWarning: true, - async: true, - }, - children: `${script}import("${importPath}")`, - }) - - return routerManifest -} - -/** - * @description Returns the router manifest that should be sent to the client. - * This includes only the assets and preloads for the current route and any - * special assets that are needed for the client. It does not include relationships - * between routes or any other data that is not needed for the client. - */ -export function getRouterManifest() { - const routerManifest = getFullRouterManifest() - - // Strip out anything that isn't needed for the client - return { - ...routerManifest, - routes: Object.fromEntries( - Object.entries(routerManifest.routes).map(([k, v]: any) => { - const { preloads, assets } = v - return [ - k, - { - preloads, - assets, - }, - ] - }), - ), - } -} diff --git a/packages/react-start-router-manifest/tsconfig.json b/packages/react-start-router-manifest/tsconfig.json deleted file mode 100644 index 940a9cce0a..0000000000 --- a/packages/react-start-router-manifest/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["src/index.ts"], - "compilerOptions": { - "rootDir": "src", - "outDir": "dist/esm", - "target": "esnext", - "noEmit": false - } -} diff --git a/packages/react-start-router-manifest/vite.config.ts b/packages/react-start-router-manifest/vite.config.ts deleted file mode 100644 index d6472068fb..0000000000 --- a/packages/react-start-router-manifest/vite.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { defineConfig, mergeConfig } from 'vitest/config' -import { tanstackViteConfig } from '@tanstack/config/vite' -import packageJson from './package.json' -import type { ViteUserConfig } from 'vitest/config' - -const config = defineConfig({ - plugins: [] as ViteUserConfig['plugins'], - test: { - name: packageJson.name, - watch: false, - environment: 'jsdom', - }, -}) - -export default mergeConfig( - config, - tanstackViteConfig({ - entry: './src/index.ts', - srcDir: './src', - externalDeps: ['tsr:routes-manifest'], - }), -) diff --git a/packages/react-start-server/README.md b/packages/react-start-server/README.md index bb009b0c87..7be47d33fd 100644 --- a/packages/react-start-server/README.md +++ b/packages/react-start-server/README.md @@ -1,33 +1,9 @@ -> 🤫 we're cooking up something special! - -# TanStack Start +# TanStack React Start - Server -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) +This package is not meant to be used directly. It is a dependency of [`@tanstack/react-start`](https://www.npmjs.com/package/@tanstack/react-start). -🤖 Type-safe router w/ built-in caching & URL state management for React! +TanStack React Start is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router). - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - - -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! +Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started. diff --git a/packages/react-start-server/package.json b/packages/react-start-server/package.json index 9bbf439abe..0a04a3c2b4 100644 --- a/packages/react-start-server/package.json +++ b/packages/react-start-server/package.json @@ -68,6 +68,7 @@ "@tanstack/start-client-core": "workspace:^", "@tanstack/start-server-core": "workspace:^", "tiny-warning": "^1.0.3", + "tiny-invariant": "^1.3.3", "h3": "1.13.0", "isbot": "^5.1.22", "jsesc": "^3.1.0", diff --git a/packages/react-start-server/tsconfig.json b/packages/react-start-server/tsconfig.json index 134e51f065..b447592593 100644 --- a/packages/react-start-server/tsconfig.json +++ b/packages/react-start-server/tsconfig.json @@ -8,6 +8,6 @@ "src", "tests", "vite.config.ts", - "../start-client/src/tsrScript.ts" + "../start-server-core/src/server-functions-handler.ts" ] } diff --git a/packages/react-start-server/vite.config.ts b/packages/react-start-server/vite.config.ts index e05e5cc394..010f101521 100644 --- a/packages/react-start-server/vite.config.ts +++ b/packages/react-start-server/vite.config.ts @@ -19,5 +19,6 @@ export default mergeConfig( tanstackViteConfig({ srcDir: './src', entry: './src/index.tsx', + externalDeps: ['tanstack:server-fn-manifest', 'tanstack:start-manifest'], }), ) diff --git a/packages/react-start/README.md b/packages/react-start/README.md index bb009b0c87..a36c48bd14 100644 --- a/packages/react-start/README.md +++ b/packages/react-start/README.md @@ -1,33 +1,42 @@ -> 🤫 we're cooking up something special! - -# TanStack Start +# TanStack React Start -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) +![TanStack React Start Header](https://github.com/tanstack/router/raw/main/media/header.png) -🤖 Type-safe router w/ built-in caching & URL state management for React! +SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router) and Vite. Ready to deploy to your favorite hosting provider. #TanStack - + + - - - - - - semantic-release - + + + + + + + + + semantic-release + + Join the discussion on Github -Best of JS + + + Best of JS + + - + + - + + Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! +Visit [tanstack.com/start](https://tanstack.com/start) for docs, guides, API and more! diff --git a/packages/react-start/package.json b/packages/react-start/package.json index a08b503980..38d25f6401 100644 --- a/packages/react-start/package.json +++ b/packages/react-start/package.json @@ -62,34 +62,14 @@ "default": "./dist/cjs/server.cjs" } }, - "./config": { + "./plugin": { "import": { - "types": "./dist/esm/config.d.ts", - "default": "./dist/esm/config.js" + "types": "./dist/esm/plugin.d.ts", + "default": "./dist/esm/plugin.js" }, "require": { - "types": "./dist/cjs/config.d.cts", - "default": "./dist/cjs/config.cjs" - } - }, - "./api": { - "import": { - "types": "./dist/esm/api.d.ts", - "default": "./dist/esm/api.js" - }, - "require": { - "types": "./dist/cjs/api.d.cts", - "default": "./dist/cjs/api.cjs" - } - }, - "./router-manifest": { - "import": { - "types": "./dist/esm/router-manifest.d.ts", - "default": "./dist/esm/router-manifest.js" - }, - "require": { - "types": "./dist/cjs/router-manifest.d.cts", - "default": "./dist/cjs/router-manifest.cjs" + "types": "./dist/cjs/plugin.d.cts", + "default": "./dist/cjs/plugin.cjs" } }, "./server-functions-client": { @@ -112,26 +92,6 @@ "default": "./dist/cjs/server-functions-server.cjs" } }, - "./server-functions-handler": { - "import": { - "types": "./dist/esm/server-functions-handler.d.ts", - "default": "./dist/esm/server-functions-handler.js" - }, - "require": { - "types": "./dist/cjs/server-functions-handler.d.cts", - "default": "./dist/cjs/server-functions-handler.cjs" - } - }, - "./server-functions-ssr": { - "import": { - "types": "./dist/esm/server-functions-ssr.d.ts", - "default": "./dist/esm/server-functions-ssr.js" - }, - "require": { - "types": "./dist/cjs/server-functions-ssr.d.cts", - "default": "./dist/cjs/server-functions-ssr.cjs" - } - }, "./package.json": "./package.json" }, "sideEffects": false, @@ -145,13 +105,9 @@ "dependencies": { "@tanstack/react-start-client": "workspace:^", "@tanstack/react-start-server": "workspace:^", - "@tanstack/react-start-config": "workspace:^", - "@tanstack/react-start-router-manifest": "workspace:^", + "@tanstack/react-start-plugin": "workspace:^", "@tanstack/start-server-functions-client": "workspace:^", - "@tanstack/start-server-functions-server": "workspace:^", - "@tanstack/start-server-functions-handler": "workspace:^", - "@tanstack/start-server-functions-ssr": "workspace:^", - "@tanstack/start-api-routes": "workspace:^" + "@tanstack/start-server-functions-server": "workspace:^" }, "peerDependencies": { "react": ">=18.0.0 || >=19.0.0", diff --git a/packages/react-start/src/api.tsx b/packages/react-start/src/api.tsx deleted file mode 100644 index fff3bec5ea..0000000000 --- a/packages/react-start/src/api.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from '@tanstack/start-api-routes' diff --git a/packages/react-start/src/config.tsx b/packages/react-start/src/config.tsx deleted file mode 100644 index 57a7ae394d..0000000000 --- a/packages/react-start/src/config.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from '@tanstack/react-start-config' diff --git a/packages/react-start/src/plugin.ts b/packages/react-start/src/plugin.ts new file mode 100644 index 0000000000..d991c3b71c --- /dev/null +++ b/packages/react-start/src/plugin.ts @@ -0,0 +1 @@ +export * from '@tanstack/react-start-plugin' diff --git a/packages/react-start/src/router-manifest.tsx b/packages/react-start/src/router-manifest.tsx deleted file mode 100644 index ce430d7884..0000000000 --- a/packages/react-start/src/router-manifest.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from '@tanstack/react-start-router-manifest' diff --git a/packages/react-start/src/server-functions-handler.tsx b/packages/react-start/src/server-functions-handler.tsx deleted file mode 100644 index c3cc9770d2..0000000000 --- a/packages/react-start/src/server-functions-handler.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from '@tanstack/start-server-functions-handler' diff --git a/packages/react-start/src/server-functions-ssr.tsx b/packages/react-start/src/server-functions-ssr.tsx deleted file mode 100644 index 7359e26f45..0000000000 --- a/packages/react-start/src/server-functions-ssr.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from '@tanstack/start-server-functions-ssr' diff --git a/packages/react-start/vite.config.ts b/packages/react-start/vite.config.ts index 46bc2ea875..048299dbf8 100644 --- a/packages/react-start/vite.config.ts +++ b/packages/react-start/vite.config.ts @@ -17,22 +17,16 @@ export default mergeConfig( entry: [ './src/client.tsx', './src/server.tsx', - './src/config.tsx', - './src/router-manifest.tsx', + './src/plugin.ts', './src/server-functions-client.tsx', './src/server-functions-server.tsx', - './src/server-functions-ssr.tsx', - './src/api.tsx', ], externalDeps: [ '@tanstack/react-start-client', '@tanstack/react-start-server', - '@tanstack/react-start-config', - '@tanstack/react-start-router-manifest', + '@tanstack/react-start-plugin', '@tanstack/start-server-functions-client', '@tanstack/start-server-functions-server', - '@tanstack/start-server-functions-ssr', - '@tanstack/start-api-routes', ], }), ) diff --git a/packages/router-core/src/fileRoute.ts b/packages/router-core/src/fileRoute.ts index 8d2e5b33a5..7ae3be5455 100644 --- a/packages/router-core/src/fileRoute.ts +++ b/packages/router-core/src/fileRoute.ts @@ -2,6 +2,10 @@ import type { AnyContext, AnyPathParams, AnyRoute, + FileBaseRouteOptions, + ResolveParams, + Route, + RouteConstraints, UpdatableRouteOptions, } from './route' import type { AnyValidator } from './validators' @@ -28,6 +32,87 @@ export interface FileRoutesByPath { // } } +export interface FileRouteOptions< + TFilePath extends string, + TParentRoute extends AnyRoute, + TId extends RouteConstraints['TId'], + TPath extends RouteConstraints['TPath'], + TFullPath extends RouteConstraints['TFullPath'], + TSearchValidator = undefined, + TParams = ResolveParams, + TRouteContextFn = AnyContext, + TBeforeLoadFn = AnyContext, + TLoaderDeps extends Record = {}, + TLoaderFn = undefined, +> extends FileBaseRouteOptions< + TParentRoute, + TId, + TPath, + TSearchValidator, + TParams, + TLoaderDeps, + TLoaderFn, + AnyContext, + TRouteContextFn, + TBeforeLoadFn + >, + UpdatableRouteOptions< + TParentRoute, + TId, + TFullPath, + TParams, + TSearchValidator, + TLoaderFn, + TLoaderDeps, + AnyContext, + TRouteContextFn, + TBeforeLoadFn + > {} + +export type CreateFileRoute< + TFilePath extends string, + TParentRoute extends AnyRoute, + TId extends RouteConstraints['TId'], + TPath extends RouteConstraints['TPath'], + TFullPath extends RouteConstraints['TFullPath'], +> = < + TSearchValidator = undefined, + TParams = ResolveParams, + TRouteContextFn = AnyContext, + TBeforeLoadFn = AnyContext, + TLoaderDeps extends Record = {}, + TLoaderFn = undefined, +>( + options?: FileRouteOptions< + TFilePath, + TParentRoute, + TId, + TPath, + TFullPath, + TSearchValidator, + TParams, + TRouteContextFn, + TBeforeLoadFn, + TLoaderDeps, + TLoaderFn + >, +) => Route< + TParentRoute, + TPath, + TFullPath, + TFilePath, + TId, + TSearchValidator, + TParams, + AnyContext, + TRouteContextFn, + TBeforeLoadFn, + TLoaderDeps, + TLoaderFn, + unknown, + unknown +> + export type LazyRouteOptions = Pick< UpdatableRouteOptions< AnyRoute, diff --git a/packages/router-core/src/index.ts b/packages/router-core/src/index.ts index 4988400855..fa3991fc62 100644 --- a/packages/router-core/src/index.ts +++ b/packages/router-core/src/index.ts @@ -3,7 +3,6 @@ export type { DeferredPromiseState, DeferredPromise } from './defer' export { preloadWarning } from './link' export type { IsRequiredParams, - ParsePathParams, AddTrailingSlash, RemoveTrailingSlashes, AddLeadingSlash, @@ -60,6 +59,7 @@ export type { InferFileRouteTypes, FileRouteTypes, FileRoutesByPath, + CreateFileRoute, LazyRoute, LazyRouteOptions, } from './fileRoute' @@ -142,15 +142,11 @@ export type { ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, - ParseSplatParams, - SplatParams, ResolveParams, ParseParamsFn, StringifyParamsFn, ParamsOptions, UpdatableStaticRouteOption, - LooseReturnType, - LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveRouteContext, @@ -209,6 +205,8 @@ export { SearchParamError, PathParamError, getInitialRouterState, + processRouteTree, + getMatchedRoutes, } from './router' export type { ViewTransitionOptions, @@ -322,6 +320,8 @@ export type { MergeAll, ValidateJSON, StrictOrFrom, + LooseReturnType, + LooseAsyncReturnType, } from './utils' export type { @@ -370,7 +370,13 @@ export type { UseLoaderDataResult, ResolveUseLoaderData } from './useLoaderData' export type { Redirect, ResolvedRedirect, AnyRedirect } from './redirect' -export { redirect, isRedirect, isResolvedRedirect } from './redirect' +export { + redirect, + isRedirect, + isResolvedRedirect, + tsrRedirectHeaderKey, + parseRedirect, +} from './redirect' export type { NotFoundError } from './not-found' export { isNotFound, notFound } from './not-found' diff --git a/packages/router-core/src/link.ts b/packages/router-core/src/link.ts index 26d038e769..7fbfe6a2b5 100644 --- a/packages/router-core/src/link.ts +++ b/packages/router-core/src/link.ts @@ -30,18 +30,74 @@ import type { ParsedLocation } from './location' export type IsRequiredParams = Record extends TParams ? never : true -export type ParsePathParams = T & - `${string}$${string}` extends never - ? TAcc - : T extends `${string}$${infer TPossiblyParam}` - ? TPossiblyParam extends '' - ? TAcc - : TPossiblyParam & `${string}/${string}` extends never - ? TPossiblyParam | TAcc - : TPossiblyParam extends `${infer TParam}/${infer TRest}` - ? ParsePathParams - : never - : TAcc +export interface ParsePathParamsResult { + required: TRequired + optional: TOptional + rest: TRest +} + +export type AnyParsePathParamsResult = ParsePathParamsResult< + string, + string, + string +> + +export type ParsePathParamsBoundaryStart = + T extends `${infer TLeft}{-${infer TRight}` + ? ParsePathParamsResult< + ParsePathParams['required'], + | ParsePathParams['optional'] + | ParsePathParams['required'] + | ParsePathParams['optional'], + ParsePathParams['rest'] + > + : T extends `${infer TLeft}{${infer TRight}` + ? ParsePathParamsResult< + | ParsePathParams['required'] + | ParsePathParams['required'], + | ParsePathParams['optional'] + | ParsePathParams['optional'], + ParsePathParams['rest'] + > + : never + +export type ParsePathParamsSymbol = + T extends `${string}$${infer TRight}` + ? TRight extends `${infer TParam}/${infer TRest}` + ? TParam extends '' + ? ParsePathParamsResult< + ParsePathParams['required'], + '_splat' | ParsePathParams['optional'], + ParsePathParams['rest'] + > + : ParsePathParamsResult< + TParam | ParsePathParams['required'], + ParsePathParams['optional'], + ParsePathParams['rest'] + > + : TRight extends '' + ? ParsePathParamsResult + : ParsePathParamsResult + : never + +export type ParsePathParamsBoundaryEnd = + T extends `${infer TLeft}}${infer TRight}` + ? ParsePathParamsResult< + | ParsePathParams['required'] + | ParsePathParams['required'], + | ParsePathParams['optional'] + | ParsePathParams['optional'], + ParsePathParams['rest'] + > + : never + +export type ParsePathParams = T extends `${string}}${string}` + ? ParsePathParamsBoundaryEnd + : T extends `${string}{${string}` + ? ParsePathParamsBoundaryStart + : T extends `${string}$${string}` + ? ParsePathParamsSymbol + : never export type AddTrailingSlash = T extends `${string}/` ? T : `${T & string}/` @@ -591,6 +647,11 @@ export interface LinkOptionsProps { * @default false */ disabled?: boolean + /** + * When the preload strategy is set to `intent`, this controls the proximity of the link to the cursor before it is preloaded. + * If the user exits this proximity before this delay, the preload will be cancelled. + */ + preloadIntentProximity?: number } export type LinkOptions< diff --git a/packages/router-core/src/path.ts b/packages/router-core/src/path.ts index 4d002673cd..e1f6d737df 100644 --- a/packages/router-core/src/path.ts +++ b/packages/router-core/src/path.ts @@ -5,6 +5,9 @@ import type { AnyPathParams } from './route' export interface Segment { type: 'pathname' | 'param' | 'wildcard' value: string + // Add a new property to store the static segment if present + prefixSegment?: string + suffixSegment?: string } export function joinPaths(paths: Array) { @@ -137,10 +140,52 @@ export function resolvePath({ } } - const joined = joinPaths([basepath, ...baseSegments.map((d) => d.value)]) + const segmentValues = baseSegments.map((segment) => { + if (segment.type === 'param') { + const param = segment.value.substring(1) + if (segment.prefixSegment && segment.suffixSegment) { + return `${segment.prefixSegment}{$${param}}${segment.suffixSegment}` + } else if (segment.prefixSegment) { + return `${segment.prefixSegment}{$${param}}` + } else if (segment.suffixSegment) { + return `{$${param}}${segment.suffixSegment}` + } + } + if (segment.type === 'wildcard') { + if (segment.prefixSegment && segment.suffixSegment) { + return `${segment.prefixSegment}{$}${segment.suffixSegment}` + } else if (segment.prefixSegment) { + return `${segment.prefixSegment}{$}` + } else if (segment.suffixSegment) { + return `{$}${segment.suffixSegment}` + } + } + return segment.value + }) + const joined = joinPaths([basepath, ...segmentValues]) return cleanPath(joined) } +const PARAM_RE = /^\$.{1,}$/ // $paramName +const PARAM_W_CURLY_BRACES_RE = /^(.*?)\{(\$[a-zA-Z_$][a-zA-Z0-9_$]*)\}(.*)$/ // prefix{$paramName}suffix +const WILDCARD_RE = /^\$$/ // $ +const WILDCARD_W_CURLY_BRACES_RE = /^(.*?)\{\$\}(.*)$/ // prefix{$}suffix + +/** + * Required: `/foo/$bar` ✅ + * Prefix and Suffix: `/foo/prefix${bar}suffix` ✅ + * Wildcard: `/foo/$` ✅ + * Wildcard with Prefix and Suffix: `/foo/prefix{$}suffix` ✅ + * + * Future: + * Optional: `/foo/{-bar}` + * Optional named segment: `/foo/{bar}` + * Optional named segment with Prefix and Suffix: `/foo/prefix{-bar}suffix` + * Escape special characters: + * - `/foo/[$]` - Static route + * - `/foo/[$]{$foo} - Dynamic route with a static prefix of `$` + * - `/foo/{$foo}[$]` - Dynamic route with a static suffix of `$` + */ export function parsePathname(pathname?: string): Array { if (!pathname) { return [] @@ -167,20 +212,55 @@ export function parsePathname(pathname?: string): Array { segments.push( ...split.map((part): Segment => { - if (part === '$' || part === '*') { + // Check for wildcard with curly braces: prefix{$}suffix + const wildcardBracesMatch = part.match(WILDCARD_W_CURLY_BRACES_RE) + if (wildcardBracesMatch) { + const prefix = wildcardBracesMatch[1] + const suffix = wildcardBracesMatch[2] return { type: 'wildcard', - value: part, + value: '$', + prefixSegment: prefix || undefined, + suffixSegment: suffix || undefined, } } - if (part.charAt(0) === '$') { + // Check for the new parameter format: prefix{$paramName}suffix + const paramBracesMatch = part.match(PARAM_W_CURLY_BRACES_RE) + if (paramBracesMatch) { + const prefix = paramBracesMatch[1] + const paramName = paramBracesMatch[2] + const suffix = paramBracesMatch[3] return { type: 'param', - value: part, + value: '' + paramName, + prefixSegment: prefix || undefined, + suffixSegment: suffix || undefined, } } + // Check for bare parameter format: $paramName (without curly braces) + if (PARAM_RE.test(part)) { + const paramName = part.substring(1) + return { + type: 'param', + value: '$' + paramName, + prefixSegment: undefined, + suffixSegment: undefined, + } + } + + // Check for bare wildcard: $ (without curly braces) + if (WILDCARD_RE.test(part)) { + return { + type: 'wildcard', + value: '$', + prefixSegment: undefined, + suffixSegment: undefined, + } + } + + // Handle regular pathname segment return { type: 'pathname', value: part.includes('%25') @@ -248,9 +328,13 @@ export function interpolatePath({ interpolatedPathSegments.map((segment) => { if (segment.type === 'wildcard') { usedParams._splat = params._splat + const segmentPrefix = segment.prefixSegment || '' + const segmentSuffix = segment.suffixSegment || '' const value = encodeParam('_splat') - if (leaveWildcards) return `${segment.value}${value ?? ''}` - return value + if (leaveWildcards) { + return `${segmentPrefix}${segment.value}${value ?? ''}${segmentSuffix}` + } + return `${segmentPrefix}${value}${segmentSuffix}` } if (segment.type === 'param') { @@ -259,11 +343,14 @@ export function interpolatePath({ isMissingParams = true } usedParams[key] = params[key] + + const segmentPrefix = segment.prefixSegment || '' + const segmentSuffix = segment.suffixSegment || '' if (leaveParams) { const value = encodeParam(segment.value) - return `${segment.value}${value ?? ''}` + return `${segmentPrefix}${segment.value}${value ?? ''}${segmentSuffix}` } - return encodeParam(key) ?? 'undefined' + return `${segmentPrefix}${encodeParam(key) ?? 'undefined'}${segmentSuffix}` } return segment.value @@ -390,9 +477,57 @@ export function matchByPath( if (routeSegment) { if (routeSegment.type === 'wildcard') { - const _splat = decodeURI( - joinPaths(baseSegments.slice(i).map((d) => d.value)), - ) + // Capture all remaining segments for a wildcard + const remainingBaseSegments = baseSegments.slice(i) + + let _splat: string + + // If this is a wildcard with prefix/suffix, we need to handle the first segment specially + if (routeSegment.prefixSegment || routeSegment.suffixSegment) { + if (!baseSegment) return false + + const prefix = routeSegment.prefixSegment || '' + const suffix = routeSegment.suffixSegment || '' + + // Check if the base segment starts with prefix and ends with suffix + const baseValue = baseSegment.value + if ('prefixSegment' in routeSegment) { + if (!baseValue.startsWith(prefix)) { + return false + } + } + if ('suffixSegment' in routeSegment) { + if ( + !baseSegments[baseSegments.length - 1]?.value.endsWith(suffix) + ) { + return false + } + } + + let rejoinedSplat = decodeURI( + joinPaths(remainingBaseSegments.map((d) => d.value)), + ) + + // Remove the prefix and suffix from the rejoined splat + if (prefix && rejoinedSplat.startsWith(prefix)) { + rejoinedSplat = rejoinedSplat.slice(prefix.length) + } + + if (suffix && rejoinedSplat.endsWith(suffix)) { + rejoinedSplat = rejoinedSplat.slice( + 0, + rejoinedSplat.length - suffix.length, + ) + } + + _splat = rejoinedSplat + } else { + // If no prefix/suffix, just rejoin the remaining segments + _splat = decodeURI( + joinPaths(remainingBaseSegments.map((d) => d.value)), + ) + } + // TODO: Deprecate * params['*'] = _splat params['_splat'] = _splat @@ -426,11 +561,41 @@ export function matchByPath( if (baseSegment.value === '/') { return false } - if (baseSegment.value.charAt(0) !== '$') { - params[routeSegment.value.substring(1)] = decodeURIComponent( - baseSegment.value, - ) + + let _paramValue: string + + // If this param has prefix/suffix, we need to extract the actual parameter value + if (routeSegment.prefixSegment || routeSegment.suffixSegment) { + const prefix = routeSegment.prefixSegment || '' + const suffix = routeSegment.suffixSegment || '' + + // Check if the base segment starts with prefix and ends with suffix + const baseValue = baseSegment.value + if (prefix && !baseValue.startsWith(prefix)) { + return false + } + if (suffix && !baseValue.endsWith(suffix)) { + return false + } + + let paramValue = baseValue + if (prefix && paramValue.startsWith(prefix)) { + paramValue = paramValue.slice(prefix.length) + } + if (suffix && paramValue.endsWith(suffix)) { + paramValue = paramValue.slice( + 0, + paramValue.length - suffix.length, + ) + } + + _paramValue = decodeURIComponent(paramValue) + } else { + // If no prefix/suffix, just decode the base segment value + _paramValue = decodeURIComponent(baseSegment.value) } + + params[routeSegment.value.substring(1)] = _paramValue } } diff --git a/packages/router-core/src/redirect.ts b/packages/router-core/src/redirect.ts index 24de9024b2..84b82cc652 100644 --- a/packages/router-core/src/redirect.ts +++ b/packages/router-core/src/redirect.ts @@ -1,6 +1,7 @@ import type { NavigateOptions } from './link' import type { AnyRouter, RegisteredRouter } from './router' -import type { PickAsRequired } from './utils' + +export const tsrRedirectHeaderKey = 'X-Tanstack-Router-Redirect-Options' export type AnyRedirect = Redirect @@ -13,6 +14,17 @@ export type Redirect< TTo extends string | undefined = undefined, TMaskFrom extends string = TFrom, TMaskTo extends string = '.', +> = Response & { + options: NavigateOptions + redirectHandled?: boolean +} + +export type RedirectOptions< + TRouter extends AnyRouter = RegisteredRouter, + TFrom extends string = string, + TTo extends string | undefined = undefined, + TMaskFrom extends string = TFrom, + TMaskTo extends string = '.', > = { href?: string /** @@ -42,12 +54,7 @@ export type ResolvedRedirect< TTo extends string = '', TMaskFrom extends string = TFrom, TMaskTo extends string = '', -> = PickAsRequired< - Redirect, - 'code' | 'statusCode' | 'headers' -> & { - href: string -} +> = Redirect export function redirect< TRouter extends AnyRouter = RegisteredRouter, @@ -56,30 +63,38 @@ export function redirect< const TMaskFrom extends string = TFrom, const TMaskTo extends string = '', >( - opts: Redirect, + opts: RedirectOptions, ): Redirect { - ;(opts as any).isRedirect = true opts.statusCode = opts.statusCode || opts.code || 307 - opts.headers = opts.headers || {} - if (!opts.reloadDocument) { - opts.reloadDocument = false - try { - new URL(`${opts.href}`) - opts.reloadDocument = true - } catch {} - } + const headers = new Headers(opts.headers || {}) + + const response = new Response(null, { + status: opts.statusCode, + headers, + }) + + ;(response as Redirect).options = + opts if (opts.throw) { - throw opts + throw response } - return opts + return response as Redirect } export function isRedirect(obj: any): obj is AnyRedirect { - return !!obj?.isRedirect + return obj instanceof Response && !!(obj as any).options } -export function isResolvedRedirect(obj: any): obj is ResolvedRedirect { - return !!obj?.isRedirect && obj.href +export function isResolvedRedirect(obj: any): obj is AnyRedirect { + return isRedirect(obj) && !!obj.options.href +} + +export function parseRedirect(obj: any) { + if (typeof obj === 'object' && obj.isSerializedRedirect) { + return redirect(obj) + } + + return undefined } diff --git a/packages/router-core/src/route.ts b/packages/router-core/src/route.ts index 6344357790..d92fecc406 100644 --- a/packages/router-core/src/route.ts +++ b/packages/router-core/src/route.ts @@ -1,3 +1,4 @@ +import invariant from 'tiny-invariant' import { joinPaths, trimPathLeft } from './path' import { notFound } from './not-found' import { rootRouteId } from './root' @@ -20,6 +21,8 @@ import type { Constrain, Expand, IntersectAssign, + LooseAsyncReturnType, + LooseReturnType, NoInfer, } from './utils' import type { @@ -150,27 +153,17 @@ export type ResolveSearchSchema = ? ResolveSearchSchemaFn : ResolveSearchSchemaFn -export type ParseSplatParams = TPath & - `${string}$` extends never - ? TPath & `${string}$/${string}` extends never - ? never - : '_splat' - : '_splat' - -export interface SplatParams { - _splat?: string -} - -export type ResolveParams = - ParseSplatParams extends never - ? Record, string> - : Record, string> & SplatParams +export type ResolveParams = Record< + ParsePathParams['required'], + T +> & + Partial['optional'], T>> export type ParseParamsFn = ( - rawParams: ResolveParams, -) => TParams extends Record, any> + rawParams: Expand>, +) => TParams extends ResolveParams ? TParams - : Record, any> + : ResolveParams export type StringifyParamsFn = ( params: TParams, @@ -270,20 +263,6 @@ export type TrimPathRight = T extends '/' ? TrimPathRight : T -export type LooseReturnType = T extends ( - ...args: Array -) => infer TReturn - ? TReturn - : never - -export type LooseAsyncReturnType = T extends ( - ...args: Array -) => infer TReturn - ? TReturn extends Promise - ? TReturn - : TReturn - : never - export type ContextReturnType = unknown extends TContextFn ? TContextFn : LooseReturnType extends never @@ -1409,7 +1388,8 @@ export class BaseRoute< if (isRoot) { this._path = rootRouteId as TPath } else if (!this.parentRoute) { - throw new Error( + invariant( + false, `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`, ) } @@ -1449,6 +1429,16 @@ export class BaseRoute< this._ssr = options?.ssr ?? opts.defaultSsr ?? true } + clone = (other: typeof this) => { + this._path = other._path + this._id = other._id + this._fullPath = other._fullPath + this._to = other._to + this._ssr = other._ssr + this.options.getParentRoute = other.options.getParentRoute + this.children = other.children + } + addChildren: RouteAddChildrenFn< TParentRoute, TPath, diff --git a/packages/router-core/src/router.ts b/packages/router-core/src/router.ts index 3a510d6506..f1fa7de4d3 100644 --- a/packages/router-core/src/router.ts +++ b/packages/router-core/src/router.ts @@ -28,7 +28,7 @@ import { isNotFound } from './not-found' import { setupScrollRestoration } from './scroll-restoration' import { defaultParseSearch, defaultStringifySearch } from './searchParams' import { rootRouteId } from './root' -import { isRedirect, isResolvedRedirect } from './redirect' +import { isRedirect } from './redirect' import type { SearchParser, SearchSerializer } from './searchParams' import type { AnyRedirect, ResolvedRedirect } from './redirect' import type { @@ -165,6 +165,14 @@ export interface RouterOptions< * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-delay) */ defaultPreloadDelay?: number + /** + * The default `preloadIntentProximity` a route should use if no preloadIntentProximity is provided. + * + * @default 0 + * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadintentproximity-property) + * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-intent-proximity) + */ + defaultPreloadIntentProximity?: number /** * The default `pendingMs` a route should use if no pendingMs is provided. * @@ -407,7 +415,7 @@ export interface RouterState< location: ParsedLocation> resolvedLocation?: ParsedLocation> statusCode: number - redirect?: ResolvedRedirect + redirect?: AnyRedirect } export interface BuildNextOptions { @@ -593,8 +601,8 @@ export type ParseLocationFn = ( ) => ParsedLocation> export type GetMatchRoutesFn = ( - next: ParsedLocation, - dest?: BuildNextOptions, + pathname: string, + routePathname: string | undefined, ) => { matchedRoutes: Array routeParams: Record @@ -882,7 +890,6 @@ export class RouterCore< } if ( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition !this.history || (this.options.history && this.options.history !== this.history) ) { @@ -901,7 +908,6 @@ export class RouterCore< this.buildRouteTree() } - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!this.__store) { this.__store = new Store(getInitialRouterState(this.latestLocation), { onUpdate: () => { @@ -920,7 +926,6 @@ export class RouterCore< if ( typeof window !== 'undefined' && 'CSS' in window && - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition typeof window.CSS?.supports === 'function' ) { this.isViewTransitionTypesSupported = window.CSS.supports( @@ -934,124 +939,29 @@ export class RouterCore< } buildRouteTree = () => { - this.routesById = {} as RoutesById - this.routesByPath = {} as RoutesByPath + const { routesById, routesByPath, flatRoutes } = processRouteTree({ + routeTree: this.routeTree, + initRoute: (route, i) => { + route.init({ + originalIndex: i, + defaultSsr: this.options.defaultSsr, + }) + }, + }) + + this.routesById = routesById as RoutesById + this.routesByPath = routesByPath as RoutesByPath + this.flatRoutes = flatRoutes as Array const notFoundRoute = this.options.notFoundRoute + if (notFoundRoute) { notFoundRoute.init({ originalIndex: 99999999999, defaultSsr: this.options.defaultSsr, }) - ;(this.routesById as any)[notFoundRoute.id] = notFoundRoute + this.routesById[notFoundRoute.id] = notFoundRoute } - - const recurseRoutes = (childRoutes: Array) => { - childRoutes.forEach((childRoute, i) => { - childRoute.init({ - originalIndex: i, - defaultSsr: this.options.defaultSsr, - }) - - const existingRoute = (this.routesById as any)[childRoute.id] - - invariant( - !existingRoute, - `Duplicate routes found with id: ${String(childRoute.id)}`, - ) - ;(this.routesById as any)[childRoute.id] = childRoute - - if (!childRoute.isRoot && childRoute.path) { - const trimmedFullPath = trimPathRight(childRoute.fullPath) - if ( - !(this.routesByPath as any)[trimmedFullPath] || - childRoute.fullPath.endsWith('/') - ) { - ;(this.routesByPath as any)[trimmedFullPath] = childRoute - } - } - - const children = childRoute.children - - if (children?.length) { - recurseRoutes(children) - } - }) - } - - recurseRoutes([this.routeTree]) - - const scoredRoutes: Array<{ - child: AnyRoute - trimmed: string - parsed: ReturnType - index: number - scores: Array - }> = [] - - const routes: Array = Object.values(this.routesById) - - routes.forEach((d, i) => { - if (d.isRoot || !d.path) { - return - } - - const trimmed = trimPathLeft(d.fullPath) - const parsed = parsePathname(trimmed) - - while (parsed.length > 1 && parsed[0]?.value === '/') { - parsed.shift() - } - - const scores = parsed.map((segment) => { - if (segment.value === '/') { - return 0.75 - } - - if (segment.type === 'param') { - return 0.5 - } - - if (segment.type === 'wildcard') { - return 0.25 - } - - return 1 - }) - - scoredRoutes.push({ child: d, trimmed, parsed, index: i, scores }) - }) - - this.flatRoutes = scoredRoutes - .sort((a, b) => { - const minLength = Math.min(a.scores.length, b.scores.length) - - // Sort by min available score - for (let i = 0; i < minLength; i++) { - if (a.scores[i] !== b.scores[i]) { - return b.scores[i]! - a.scores[i]! - } - } - - // Sort by length of score - if (a.scores.length !== b.scores.length) { - return b.scores.length - a.scores.length - } - - // Sort by min available parsed value - for (let i = 0; i < minLength; i++) { - if (a.parsed[i]!.value !== b.parsed[i]!.value) { - return a.parsed[i]!.value > b.parsed[i]!.value ? 1 : -1 - } - } - - // Sort by original index - return a.index - b.index - }) - .map((d, i) => { - d.child.rank = i - return d.child - }) } subscribe: SubscribeFn = (eventType, fn) => { @@ -1165,8 +1075,8 @@ export class RouterCore< opts?: MatchRoutesOpts, ): Array { const { foundRoute, matchedRoutes, routeParams } = this.getMatchedRoutes( - next, - opts?.dest, + next.pathname, + opts?.dest?.to as string, ) let isGlobalNotFound = false @@ -1472,47 +1382,19 @@ export class RouterCore< return matches } - getMatchedRoutes: GetMatchRoutesFn = (next, dest) => { - let routeParams: Record = {} - const trimmedPath = trimPathRight(next.pathname) - const getMatchedParams = (route: AnyRoute) => { - const result = matchPathname(this.basepath, trimmedPath, { - to: route.fullPath, - caseSensitive: - route.options.caseSensitive ?? this.options.caseSensitive, - fuzzy: true, - }) - return result - } - - let foundRoute: AnyRoute | undefined = - dest?.to !== undefined ? this.routesByPath[dest.to!] : undefined - if (foundRoute) { - routeParams = getMatchedParams(foundRoute)! - } else { - foundRoute = this.flatRoutes.find((route) => { - const matchedParams = getMatchedParams(route) - - if (matchedParams) { - routeParams = matchedParams - return true - } - - return false - }) - } - - let routeCursor: AnyRoute = - foundRoute || (this.routesById as any)[rootRouteId] - - const matchedRoutes: Array = [routeCursor] - - while (routeCursor.parentRoute) { - routeCursor = routeCursor.parentRoute - matchedRoutes.unshift(routeCursor) - } - - return { matchedRoutes, routeParams, foundRoute } + getMatchedRoutes: GetMatchRoutesFn = ( + pathname: string, + routePathname: string | undefined, + ) => { + return getMatchedRoutes({ + pathname, + routePathname, + basepath: this.basepath, + caseSensitive: this.options.caseSensitive, + routesByPath: this.routesByPath, + routesById: this.routesById, + flatRoutes: this.flatRoutes, + }) } cancelMatch = (id: string) => { @@ -1812,11 +1694,17 @@ export class RouterCore< } } - const nextMatches = this.getMatchedRoutes(next, dest) + const nextMatches = this.getMatchedRoutes( + next.pathname, + dest.to as string, + ) const final = build(dest, nextMatches) if (maskedNext) { - const maskedMatches = this.getMatchedRoutes(maskedNext, maskedDest) + const maskedMatches = this.getMatchedRoutes( + maskedNext.pathname, + maskedDest?.to as string, + ) const maskedFinal = build(maskedDest, maskedMatches) final.maskedLocation = maskedFinal } @@ -1958,6 +1846,13 @@ export class RouterCore< } navigate: NavigateFn = ({ to, reloadDocument, href, ...rest }) => { + if (!reloadDocument && href) { + try { + new URL(`${href}`) + reloadDocument = true + } catch {} + } + if (reloadDocument) { if (!href) { const location = this.buildLocation({ to, ...rest } as any) @@ -1980,10 +1875,30 @@ export class RouterCore< latestLoadPromise: undefined | Promise - load: LoadFn = async (opts?: { sync?: boolean }): Promise => { + beforeLoad = () => { + // Cancel any pending matches + this.cancelMatches() this.latestLocation = this.parseLocation(this.latestLocation) - let redirect: ResolvedRedirect | undefined + // Match the routes + const pendingMatches = this.matchRoutes(this.latestLocation) + + // Ingest the new matches + this.__store.setState((s) => ({ + ...s, + status: 'pending', + isLoading: true, + location: this.latestLocation, + pendingMatches, + // If a cached moved to pendingMatches, remove it from cachedMatches + cachedMatches: s.cachedMatches.filter((d) => { + return !pendingMatches.find((e) => e.id === d.id) + }), + })) + } + + load: LoadFn = async (opts?: { sync?: boolean }): Promise => { + let redirect: AnyRedirect | undefined let notFound: NotFoundError | undefined let loadPromise: Promise @@ -1995,32 +1910,7 @@ export class RouterCore< const next = this.latestLocation const prevLocation = this.state.resolvedLocation - // Cancel any pending matches - this.cancelMatches() - - let pendingMatches!: Array - - batch(() => { - // this call breaks a route context of destination route after a redirect - // we should be fine not eagerly calling this since we call it later - // this.clearExpiredCache() - - // Match the routes - pendingMatches = this.matchRoutes(next) - - // Ingest the new matches - this.__store.setState((s) => ({ - ...s, - status: 'pending', - isLoading: true, - location: next, - pendingMatches, - // If a cached moved to pendingMatches, remove it from cachedMatches - cachedMatches: s.cachedMatches.filter((d) => { - return !pendingMatches.find((e) => e.id === d.id) - }), - })) - }) + this.beforeLoad() if (!this.state.redirect) { this.emit({ @@ -2042,7 +1932,7 @@ export class RouterCore< await this.loadMatches({ sync: opts?.sync, - matches: pendingMatches, + matches: this.state.pendingMatches as Array, location: next, // eslint-disable-next-line @typescript-eslint/require-await onReady: async () => { @@ -2103,11 +1993,11 @@ export class RouterCore< }, }) } catch (err) { - if (isResolvedRedirect(err)) { + if (isRedirect(err)) { redirect = err if (!this.isServer) { this.navigate({ - ...redirect, + ...redirect.options, replace: true, ignoreBlocker: true, }) @@ -2119,7 +2009,7 @@ export class RouterCore< this.__store.setState((s) => ({ ...s, statusCode: redirect - ? redirect.statusCode + ? redirect.status : notFound ? 404 : s.matches.some((d) => d.status === 'error') @@ -2275,13 +2165,15 @@ export class RouterCore< } const handleRedirectAndNotFound = (match: AnyRouteMatch, err: any) => { - if (isResolvedRedirect(err)) { - if (!err.reloadDocument) { - throw err - } - } - if (isRedirect(err) || isNotFound(err)) { + if (isRedirect(err)) { + if (err.redirectHandled) { + if (!err.options.reloadDocument) { + throw err + } + } + } + updateMatch(match.id, (prev) => ({ ...prev, status: isRedirect(err) @@ -2305,7 +2197,9 @@ export class RouterCore< if (isRedirect(err)) { rendered = true - err = this.resolveRedirect({ ...err, _fromLocation: location }) + err.options._fromLocation = location + err.redirectHandled = true + err = this.resolveRedirect(err) throw err } else if (isNotFound(err)) { this._handleNotFound(matches, err, { @@ -2742,8 +2636,8 @@ export class RouterCore< loaderPromise: undefined, })) } catch (err) { - if (isResolvedRedirect(err)) { - await this.navigate(err) + if (isRedirect(err)) { + await this.navigate(err.options) } } })() @@ -2828,11 +2722,10 @@ export class RouterCore< return this.load({ sync: opts?.sync }) } - resolveRedirect = (err: AnyRedirect): ResolvedRedirect => { - const redirect = err as ResolvedRedirect - - if (!redirect.href) { - redirect.href = this.buildLocation(redirect as any).href + resolveRedirect = (redirect: AnyRedirect): AnyRedirect => { + if (!redirect.options.href) { + redirect.options.href = this.buildLocation(redirect.options).href + redirect.headers.set('Location', redirect.options.href) } return redirect @@ -2967,7 +2860,7 @@ export class RouterCore< return matches } catch (err) { if (isRedirect(err)) { - if (err.reloadDocument) { + if (!err.options.reloadDocument) { return undefined } return await this.preloadRoute({ @@ -3205,3 +3098,224 @@ function routeNeedsPreload(route: AnyRoute) { } return false } + +interface RouteLike { + id: string + isRoot?: boolean + path?: string + fullPath: string + rank?: number + parentRoute?: RouteLike + children?: Array + options?: { + caseSensitive?: boolean + } +} + +export function processRouteTree({ + routeTree, + initRoute, +}: { + routeTree: TRouteLike + initRoute?: (route: TRouteLike, index: number) => void +}) { + const routesById = {} as Record + const routesByPath = {} as Record + + const recurseRoutes = (childRoutes: Array) => { + childRoutes.forEach((childRoute, i) => { + initRoute?.(childRoute, i) + + const existingRoute = routesById[childRoute.id] + + invariant( + !existingRoute, + `Duplicate routes found with id: ${String(childRoute.id)}`, + ) + + routesById[childRoute.id] = childRoute + + if (!childRoute.isRoot && childRoute.path) { + const trimmedFullPath = trimPathRight(childRoute.fullPath) + if ( + !routesByPath[trimmedFullPath] || + childRoute.fullPath.endsWith('/') + ) { + routesByPath[trimmedFullPath] = childRoute + } + } + + const children = childRoute.children as Array + + if (children?.length) { + recurseRoutes(children) + } + }) + } + + recurseRoutes([routeTree]) + + const scoredRoutes: Array<{ + child: TRouteLike + trimmed: string + parsed: ReturnType + index: number + scores: Array + }> = [] + + const routes: Array = Object.values(routesById) + + routes.forEach((d, i) => { + if (d.isRoot || !d.path) { + return + } + + const trimmed = trimPathLeft(d.fullPath) + const parsed = parsePathname(trimmed) + + // Removes the leading slash if it is not the only remaining segment + while (parsed.length > 1 && parsed[0]?.value === '/') { + parsed.shift() + } + + const scores = parsed.map((segment) => { + if (segment.value === '/') { + return 0.75 + } + + if ( + segment.type === 'param' && + segment.prefixSegment && + segment.suffixSegment + ) { + return 0.55 + } + + if (segment.type === 'param' && segment.prefixSegment) { + return 0.52 + } + + if (segment.type === 'param' && segment.suffixSegment) { + return 0.51 + } + + if (segment.type === 'param') { + return 0.5 + } + + if ( + segment.type === 'wildcard' && + segment.prefixSegment && + segment.suffixSegment + ) { + return 0.3 + } + + if (segment.type === 'wildcard' && segment.prefixSegment) { + return 0.27 + } + + if (segment.type === 'wildcard' && segment.suffixSegment) { + return 0.26 + } + + if (segment.type === 'wildcard') { + return 0.25 + } + + return 1 + }) + + scoredRoutes.push({ child: d, trimmed, parsed, index: i, scores }) + }) + + const flatRoutes = scoredRoutes + .sort((a, b) => { + const minLength = Math.min(a.scores.length, b.scores.length) + + // Sort by min available score + for (let i = 0; i < minLength; i++) { + if (a.scores[i] !== b.scores[i]) { + return b.scores[i]! - a.scores[i]! + } + } + + // Sort by length of score + if (a.scores.length !== b.scores.length) { + return b.scores.length - a.scores.length + } + + // Sort by min available parsed value + for (let i = 0; i < minLength; i++) { + if (a.parsed[i]!.value !== b.parsed[i]!.value) { + return a.parsed[i]!.value > b.parsed[i]!.value ? 1 : -1 + } + } + + // Sort by original index + return a.index - b.index + }) + .map((d, i) => { + d.child.rank = i + return d.child + }) + + return { routesById, routesByPath, flatRoutes } +} + +export function getMatchedRoutes({ + pathname, + routePathname, + basepath, + caseSensitive, + routesByPath, + routesById, + flatRoutes, +}: { + pathname: string + routePathname?: string + basepath: string + caseSensitive?: boolean + routesByPath: Record + routesById: Record + flatRoutes: Array +}) { + let routeParams: Record = {} + const trimmedPath = trimPathRight(pathname) + const getMatchedParams = (route: TRouteLike) => { + const result = matchPathname(basepath, trimmedPath, { + to: route.fullPath, + caseSensitive: route.options?.caseSensitive ?? caseSensitive, + fuzzy: true, + }) + return result + } + + let foundRoute: TRouteLike | undefined = + routePathname !== undefined ? routesByPath[routePathname] : undefined + if (foundRoute) { + routeParams = getMatchedParams(foundRoute)! + } else { + foundRoute = flatRoutes.find((route) => { + const matchedParams = getMatchedParams(route) + + if (matchedParams) { + routeParams = matchedParams + return true + } + + return false + }) + } + + let routeCursor: TRouteLike = foundRoute || routesById[rootRouteId]! + + const matchedRoutes: Array = [routeCursor] + + while (routeCursor.parentRoute) { + routeCursor = routeCursor.parentRoute as TRouteLike + matchedRoutes.unshift(routeCursor) + } + + return { matchedRoutes, routeParams, foundRoute } +} diff --git a/packages/router-core/src/typePrimitives.ts b/packages/router-core/src/typePrimitives.ts index f0c5d2ae9f..ebc80ed732 100644 --- a/packages/router-core/src/typePrimitives.ts +++ b/packages/router-core/src/typePrimitives.ts @@ -5,7 +5,7 @@ import type { SearchParamOptions, ToPathOption, } from './link' -import type { Redirect } from './redirect' +import type { RedirectOptions } from './redirect' import type { RouteIds } from './routeInfo' import type { AnyRouter, RegisteredRouter } from './router' import type { UseParamsResult } from './useParams' @@ -104,7 +104,7 @@ export type ValidateRedirectOptions< TDefaultFrom extends string = string, > = Constrain< TOptions, - Redirect< + RedirectOptions< TRouter, InferFrom, InferTo, diff --git a/packages/router-core/src/utils.ts b/packages/router-core/src/utils.ts index 1df674e8b9..2b522a284b 100644 --- a/packages/router-core/src/utils.ts +++ b/packages/router-core/src/utils.ts @@ -169,6 +169,20 @@ export type ValidateJSON = ((...args: Array) => any) extends T : 'Function is not serializable' : { [K in keyof T]: ValidateJSON } +export type LooseReturnType = T extends ( + ...args: Array +) => infer TReturn + ? TReturn + : never + +export type LooseAsyncReturnType = T extends ( + ...args: Array +) => infer TReturn + ? TReturn extends Promise + ? TReturn + : TReturn + : never + export function last(arr: Array) { return arr[arr.length - 1] } diff --git a/packages/router-core/tests/path.test.ts b/packages/router-core/tests/path.test.ts index 0b709d2453..8d9ff4ad7e 100644 --- a/packages/router-core/tests/path.test.ts +++ b/packages/router-core/tests/path.test.ts @@ -3,10 +3,13 @@ import { exactPathTest, interpolatePath, matchPathname, + parsePathname, removeBasepath, removeTrailingSlash, resolvePath, + trimPathLeft, } from '../src/path' +import type { Segment as PathSegment } from '../src/path' describe('removeBasepath', () => { it.each([ @@ -263,110 +266,261 @@ describe('resolvePath', () => { }) }) }) + + describe.each([{ base: '/' }, { base: '/nested' }])( + 'param routes w/ base=$base', + ({ base }) => { + describe('wildcard (prefix + suffix)', () => { + it.each([ + { name: 'regular top-level', to: '/$' }, + { name: 'regular nested', to: '/params/wildcard/$' }, + { name: 'with top-level prefix', to: '/prefix{$}' }, + { name: 'with nested prefix', to: '/params/wildcard/prefix{$}' }, + { name: 'with top-level suffix', to: '/{$}suffix' }, + { name: 'with nested suffix', to: '/params/wildcard/{$}suffix' }, + { + name: 'with top-level prefix + suffix', + to: '/prefix{$}suffix', + }, + { + name: 'with nested prefix + suffix', + to: '/params/wildcard/prefix{$}suffix', + }, + ])('$name', ({ to }) => { + const candidate = base + trimPathLeft(to) + expect( + resolvePath({ + basepath: '/', + base, + to: candidate, + trailingSlash: 'never', + caseSensitive: false, + }), + ).toEqual(candidate) + }) + }) + + describe('named (prefix + suffix)', () => { + it.each([ + { name: 'regular top-level', to: '/$foo' }, + { name: 'regular nested', to: '/params/named/$foo' }, + { name: 'with top-level prefix', to: '/prefix{$foo}' }, + { name: 'with nested prefix', to: '/params/named/prefix{$foo}' }, + { name: 'with top-level suffix', to: '/{$foo}suffix' }, + { name: 'with nested suffix', to: '/params/named/{$foo}suffix' }, + { + name: 'with top-level prefix + suffix', + to: '/prefix{$foo}suffix', + }, + { + name: 'with nested prefix + suffix', + to: '/params/named/prefix{$foo}suffix', + }, + ])('$name', ({ to }) => { + const candidate = base + trimPathLeft(to) + expect( + resolvePath({ + basepath: '/', + base, + to: candidate, + trailingSlash: 'never', + caseSensitive: false, + }), + ).toEqual(candidate) + }) + }) + }, + ) }) describe('interpolatePath', () => { - it.each([ - { - name: 'should interpolate the path', - path: '/users/$id', - params: { id: '123' }, - result: '/users/123', - }, - { - name: 'should interpolate the path with multiple params', - path: '/users/$id/$name', - params: { id: '123', name: 'tanner' }, - result: '/users/123/tanner', - }, - { - name: 'should interpolate the path with extra params', - path: '/users/$id', - params: { id: '123', name: 'tanner' }, - result: '/users/123', - }, - { - name: 'should interpolate the path with missing params', - path: '/users/$id/$name', - params: { id: '123' }, - result: '/users/123/undefined', - }, - { - name: 'should interpolate the path with missing params and extra params', - path: '/users/$id', - params: { name: 'john' }, - result: '/users/undefined', - }, - { - name: 'should interpolate the path with the param being a number', - path: '/users/$id', - params: { id: 123 }, - result: '/users/123', - }, - { - name: 'should interpolate the path with the param being a falsey number', - path: '/users/$id', - params: { id: 0 }, - result: '/users/0', - }, - { - name: 'should interpolate the path with URI component encoding', - path: '/users/$id', - params: { id: '?#@john+smith' }, - result: '/users/%3F%23%40john%2Bsmith', - }, - { - name: 'should interpolate the path without URI encoding characters in decodeCharMap', - path: '/users/$id', - params: { id: '?#@john+smith' }, - result: '/users/%3F%23@john+smith', - decodeCharMap: new Map( - ['@', '+'].map((char) => [encodeURIComponent(char), char]), - ), - }, - { - name: 'should interpolate the path with the splat param at the end', - path: '/users/$', - params: { _splat: '123' }, - result: '/users/123', - }, - { - name: 'should interpolate the path with a single named path param and the splat param at the end', - path: '/users/$username/$', - params: { username: 'seancassiere', _splat: '123' }, - result: '/users/seancassiere/123', - }, - { - name: 'should interpolate the path with 2 named path params with the splat param at the end', - path: '/users/$username/$id/$', - params: { username: 'seancassiere', id: '123', _splat: '456' }, - result: '/users/seancassiere/123/456', - }, - { - name: 'should interpolate the path with multiple named path params with the splat param at the end', - path: '/$username/settings/$repo/$id/$', - params: { - username: 'sean-cassiere', - repo: 'my-repo', - id: '123', - _splat: '456', + describe('regular usage', () => { + it.each([ + { + name: 'should interpolate the path', + path: '/users/$id', + params: { id: '123' }, + result: '/users/123', }, - result: '/sean-cassiere/settings/my-repo/123/456', - }, - { - name: 'should interpolate the path with the splat param containing slashes', - path: '/users/$', - params: { _splat: 'sean/cassiere' }, - result: '/users/sean/cassiere', - }, - ])('$name', ({ path, params, decodeCharMap, result }) => { - expect( - interpolatePath({ - path, - params, - decodeCharMap, - }).interpolatedPath, - ).toBe(result) + { + name: 'should interpolate the path with multiple params', + path: '/users/$id/$name', + params: { id: '123', name: 'tanner' }, + result: '/users/123/tanner', + }, + { + name: 'should interpolate the path with extra params', + path: '/users/$id', + params: { id: '123', name: 'tanner' }, + result: '/users/123', + }, + { + name: 'should interpolate the path with missing params', + path: '/users/$id/$name', + params: { id: '123' }, + result: '/users/123/undefined', + }, + { + name: 'should interpolate the path with missing params and extra params', + path: '/users/$id', + params: { name: 'john' }, + result: '/users/undefined', + }, + { + name: 'should interpolate the path with the param being a number', + path: '/users/$id', + params: { id: 123 }, + result: '/users/123', + }, + { + name: 'should interpolate the path with the param being a falsey number', + path: '/users/$id', + params: { id: 0 }, + result: '/users/0', + }, + { + name: 'should interpolate the path with URI component encoding', + path: '/users/$id', + params: { id: '?#@john+smith' }, + result: '/users/%3F%23%40john%2Bsmith', + }, + { + name: 'should interpolate the path without URI encoding characters in decodeCharMap', + path: '/users/$id', + params: { id: '?#@john+smith' }, + result: '/users/%3F%23@john+smith', + decodeCharMap: new Map( + ['@', '+'].map((char) => [encodeURIComponent(char), char]), + ), + }, + { + name: 'should interpolate the path with the splat param at the end', + path: '/users/$', + params: { _splat: '123' }, + result: '/users/123', + }, + { + name: 'should interpolate the path with a single named path param and the splat param at the end', + path: '/users/$username/$', + params: { username: 'seancassiere', _splat: '123' }, + result: '/users/seancassiere/123', + }, + { + name: 'should interpolate the path with 2 named path params with the splat param at the end', + path: '/users/$username/$id/$', + params: { username: 'seancassiere', id: '123', _splat: '456' }, + result: '/users/seancassiere/123/456', + }, + { + name: 'should interpolate the path with multiple named path params with the splat param at the end', + path: '/$username/settings/$repo/$id/$', + params: { + username: 'sean-cassiere', + repo: 'my-repo', + id: '123', + _splat: '456', + }, + result: '/sean-cassiere/settings/my-repo/123/456', + }, + { + name: 'should interpolate the path with the splat param containing slashes', + path: '/users/$', + params: { _splat: 'sean/cassiere' }, + result: '/users/sean/cassiere', + }, + ])('$name', ({ path, params, decodeCharMap, result }) => { + expect( + interpolatePath({ + path, + params, + decodeCharMap, + }).interpolatedPath, + ).toBe(result) + }) + }) + + describe('wildcard (prefix + suffix)', () => { + it.each([ + { + name: 'regular', + to: '/$', + params: { _splat: 'bar/foo/me' }, + result: '/bar/foo/me', + }, + { + name: 'regular curly braces', + to: '/{$}', + params: { _splat: 'bar/foo/me' }, + result: '/bar/foo/me', + }, + { + name: 'with prefix', + to: '/prefix{$}', + params: { _splat: 'bar' }, + result: '/prefixbar', + }, + { + name: 'with suffix', + to: '/{$}-suffix', + params: { _splat: 'bar' }, + result: '/bar-suffix', + }, + { + name: 'with prefix + suffix', + to: '/prefix{$}-suffix', + params: { _splat: 'bar' }, + result: '/prefixbar-suffix', + }, + ])('$name', ({ to, params, result }) => { + expect( + interpolatePath({ + path: to, + params, + }).interpolatedPath, + ).toBe(result) + }) + }) + + describe('named params (prefix + suffix', () => { + it.each([ + { + name: 'regular', + to: '/$foo', + params: { foo: 'bar' }, + result: '/bar', + }, + { + name: 'regular curly braces', + to: '/{$foo}', + params: { foo: 'bar' }, + result: '/bar', + }, + { + name: 'with prefix', + to: '/prefix{$bar}', + params: { bar: 'baz' }, + result: '/prefixbaz', + }, + { + name: 'with suffix', + to: '/{$foo}.suffix', + params: { foo: 'bar' }, + result: '/bar.suffix', + }, + { + name: 'with prefix and suffix', + to: '/prefix{$param}.suffix', + params: { param: 'foobar' }, + result: '/prefixfoobar.suffix', + }, + ])('$name', ({ to, params, result }) => { + expect( + interpolatePath({ + path: to, + params, + }).interpolatedPath, + ).toBe(result) + }) }) }) @@ -491,6 +645,140 @@ describe('matchPathname', () => { _splat: '456', }, }, + { + name: 'should match and return the splat params when multiple subsequent segments are present', + input: '/docs/tanner/sean/manuel', + matchingOptions: { + to: '/docs/$', + }, + expectedMatchedParams: { + '*': 'tanner/sean/manuel', + _splat: 'tanner/sean/manuel', + }, + }, + ])('$name', ({ input, matchingOptions, expectedMatchedParams }) => { + expect(matchPathname('/', input, matchingOptions)).toStrictEqual( + expectedMatchedParams, + ) + }) + }) + + describe('wildcard (prefix + suffix)', () => { + it.each([ + { + name: 'regular', + input: '/docs/foo/bar', + matchingOptions: { + to: '/docs/$', + }, + expectedMatchedParams: { + '*': 'foo/bar', + _splat: 'foo/bar', + }, + }, + { + name: 'regular curly braces', + input: '/docs/foo/bar', + matchingOptions: { + to: '/docs/{$}', + }, + expectedMatchedParams: { + '*': 'foo/bar', + _splat: 'foo/bar', + }, + }, + { + name: 'with prefix', + input: '/docs/prefixbar/baz', + matchingOptions: { + to: '/docs/prefix{$}', + }, + expectedMatchedParams: { + '*': 'bar/baz', + _splat: 'bar/baz', + }, + }, + { + name: 'with suffix', + input: '/docs/bar/baz.suffix', + matchingOptions: { + to: '/docs/{$}.suffix', + }, + expectedMatchedParams: { + '*': 'bar/baz', + _splat: 'bar/baz', + }, + }, + { + name: 'with prefix + suffix', + input: '/docs/prefixbar/baz-suffix', + matchingOptions: { + to: '/docs/prefix{$}-suffix', + }, + expectedMatchedParams: { + '*': 'bar/baz', + _splat: 'bar/baz', + }, + }, + ])('$name', ({ input, matchingOptions, expectedMatchedParams }) => { + expect(matchPathname('/', input, matchingOptions)).toStrictEqual( + expectedMatchedParams, + ) + }) + }) + + describe('named params (prefix + suffix)', () => { + it.each([ + { + name: 'regular', + input: '/docs/foo', + matchingOptions: { + to: '/docs/$bar', + }, + expectedMatchedParams: { + bar: 'foo', + }, + }, + { + name: 'regular curly braces', + input: '/docs/foo', + matchingOptions: { + to: '/docs/{$bar}', + }, + expectedMatchedParams: { + bar: 'foo', + }, + }, + { + name: 'with prefix', + input: '/docs/prefixfoo', + matchingOptions: { + to: '/docs/prefix{$bar}', + }, + expectedMatchedParams: { + bar: 'foo', + }, + }, + { + name: 'with suffix', + input: '/docs/foo.suffix', + matchingOptions: { + to: '/docs/{$bar}.suffix', + }, + expectedMatchedParams: { + bar: 'foo', + }, + }, + { + name: 'with prefix + suffix', + input: '/docs/prefixfoobar-suffix', + matchingOptions: { + to: '/docs/prefix{$param}-suffix', + }, + expectedMatchedParams: { + param: 'foobar', + }, + }, ])('$name', ({ input, matchingOptions, expectedMatchedParams }) => { expect(matchPathname('/', input, matchingOptions)).toStrictEqual( expectedMatchedParams, @@ -498,3 +786,301 @@ describe('matchPathname', () => { }) }) }) + +describe('parsePathname', () => { + type ParsePathnameTestScheme = Array<{ + name: string + to: string | undefined + expected: Array + }> + + describe('regular usage', () => { + it.each([ + { + name: 'should handle pathname being undefined', + to: undefined, + expected: [], + }, + { + name: 'should handle pathname being empty', + to: '', + expected: [], + }, + { + name: 'should handle pathname at root', + to: '/', + expected: [{ type: 'pathname', value: '/' }], + }, + { + name: 'should handle pathname with a single segment', + to: '/foo', + expected: [ + { type: 'pathname', value: '/' }, + { type: 'pathname', value: 'foo' }, + ], + }, + { + name: 'should handle pathname with multiple segments', + to: '/foo/bar/baz', + expected: [ + { type: 'pathname', value: '/' }, + { type: 'pathname', value: 'foo' }, + { type: 'pathname', value: 'bar' }, + { type: 'pathname', value: 'baz' }, + ], + }, + { + name: 'should handle pathname with a trailing slash', + to: '/foo/', + expected: [ + { type: 'pathname', value: '/' }, + { type: 'pathname', value: 'foo' }, + { type: 'pathname', value: '/' }, + ], + }, + { + name: 'should handle named params', + to: '/foo/$bar', + expected: [ + { type: 'pathname', value: '/' }, + { type: 'pathname', value: 'foo' }, + { type: 'param', value: '$bar' }, + ], + }, + { + name: 'should handle named params at the root', + to: '/$bar', + expected: [ + { type: 'pathname', value: '/' }, + { type: 'param', value: '$bar' }, + ], + }, + { + name: 'should handle named params followed by a segment', + to: '/foo/$bar/baz', + expected: [ + { type: 'pathname', value: '/' }, + { type: 'pathname', value: 'foo' }, + { type: 'param', value: '$bar' }, + { type: 'pathname', value: 'baz' }, + ], + }, + { + name: 'should handle multiple named params', + to: '/foo/$bar/$baz/qux/$quux', + expected: [ + { type: 'pathname', value: '/' }, + { type: 'pathname', value: 'foo' }, + { type: 'param', value: '$bar' }, + { type: 'param', value: '$baz' }, + { type: 'pathname', value: 'qux' }, + { type: 'param', value: '$quux' }, + ], + }, + { + name: 'should handle splat params', + to: '/foo/$', + expected: [ + { type: 'pathname', value: '/' }, + { type: 'pathname', value: 'foo' }, + { type: 'wildcard', value: '$' }, + ], + }, + { + name: 'should handle splat params at the root', + to: '/$', + expected: [ + { type: 'pathname', value: '/' }, + { type: 'wildcard', value: '$' }, + ], + }, + ] satisfies ParsePathnameTestScheme)('$name', ({ to, expected }) => { + const result = parsePathname(to) + expect(result).toEqual(expected) + }) + }) + + describe('wildcard (prefix + suffix)', () => { + it.each([ + { + name: 'regular', + to: '/$', + expected: [ + { type: 'pathname', value: '/' }, + { type: 'wildcard', value: '$' }, + ], + }, + { + name: 'regular curly braces', + to: '/{$}', + expected: [ + { type: 'pathname', value: '/' }, + { type: 'wildcard', value: '$' }, + ], + }, + { + name: 'with prefix (regular text)', + to: '/foo{$}', + expected: [ + { type: 'pathname', value: '/' }, + { + type: 'wildcard', + value: '$', + prefixSegment: 'foo', + }, + ], + }, + { + name: 'with prefix + followed by special character', + to: '/foo.{$}', + expected: [ + { type: 'pathname', value: '/' }, + { + type: 'wildcard', + value: '$', + prefixSegment: 'foo.', + }, + ], + }, + { + name: 'with suffix', + to: '/{$}-foo', + expected: [ + { type: 'pathname', value: '/' }, + { + type: 'wildcard', + value: '$', + suffixSegment: '-foo', + }, + ], + }, + { + name: 'with prefix + suffix', + to: '/foo{$}-bar', + expected: [ + { type: 'pathname', value: '/' }, + { + type: 'wildcard', + value: '$', + prefixSegment: 'foo', + suffixSegment: '-bar', + }, + ], + }, + { + name: 'with prefix + followed by special character and a segment', + to: '/foo.{$}/bar', + expected: [ + { type: 'pathname', value: '/' }, + { + type: 'wildcard', + value: '$', + prefixSegment: 'foo.', + }, + { type: 'pathname', value: 'bar' }, + ], + }, + ] satisfies ParsePathnameTestScheme)('$name', ({ to, expected }) => { + const result = parsePathname(to) + expect(result).toEqual(expected) + }) + }) + + describe('named params (prefix + suffix)', () => { + it.each([ + { + name: 'regular', + to: '/$bar', + expected: [ + { type: 'pathname', value: '/' }, + { type: 'param', value: '$bar' }, + ], + }, + { + name: 'regular curly braces', + to: '/{$bar}', + expected: [ + { type: 'pathname', value: '/' }, + { type: 'param', value: '$bar' }, + ], + }, + { + name: 'with prefix (regular text)', + to: '/foo{$bar}', + expected: [ + { type: 'pathname', value: '/' }, + { + type: 'param', + value: '$bar', + prefixSegment: 'foo', + }, + ], + }, + { + name: 'with prefix + followed by special character', + to: '/foo.{$bar}', + expected: [ + { type: 'pathname', value: '/' }, + { + type: 'param', + value: '$bar', + prefixSegment: 'foo.', + }, + ], + }, + { + name: 'with suffix', + to: '/{$bar}.foo', + expected: [ + { type: 'pathname', value: '/' }, + { + type: 'param', + value: '$bar', + suffixSegment: '.foo', + }, + ], + }, + { + name: 'with suffix + started by special character', + to: '/{$bar}.foo', + expected: [ + { type: 'pathname', value: '/' }, + { + type: 'param', + value: '$bar', + suffixSegment: '.foo', + }, + ], + }, + { + name: 'with suffix + started by special character and followed by segment', + to: '/{$bar}.foo/baz', + expected: [ + { type: 'pathname', value: '/' }, + { + type: 'param', + value: '$bar', + suffixSegment: '.foo', + }, + { type: 'pathname', value: 'baz' }, + ], + }, + { + name: 'with suffix + prefix', + to: '/foo{$bar}.baz', + expected: [ + { type: 'pathname', value: '/' }, + { + type: 'param', + value: '$bar', + prefixSegment: 'foo', + suffixSegment: '.baz', + }, + ], + }, + ] satisfies ParsePathnameTestScheme)('$name', ({ to, expected }) => { + const result = parsePathname(to) + expect(result).toEqual(expected) + }) + }) +}) diff --git a/packages/router-generator/src/config.ts b/packages/router-generator/src/config.ts index b76b1d5af3..1d48d89324 100644 --- a/packages/router-generator/src/config.ts +++ b/packages/router-generator/src/config.ts @@ -3,23 +3,16 @@ import { existsSync, readFileSync } from 'node:fs' import { z } from 'zod' import { virtualRootRouteSchema } from './filesystem/virtual/config' -export const configSchema = z.object({ +export const baseConfigSchema = z.object({ target: z.enum(['react', 'solid']).optional().default('react'), virtualRouteConfig: virtualRootRouteSchema.or(z.string()).optional(), routeFilePrefix: z.string().optional(), routeFileIgnorePrefix: z.string().optional().default('-'), routeFileIgnorePattern: z.string().optional(), routesDirectory: z.string().optional().default('./src/routes'), - generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'), quoteStyle: z.enum(['single', 'double']).optional().default('single'), semicolons: z.boolean().optional().default(false), - disableTypes: z.boolean().optional().default(false), - addExtensions: z.boolean().optional().default(false), disableLogging: z.boolean().optional().default(false), - disableManifestGeneration: z.boolean().optional().default(false), - enableRouteTreeFormatting: z.boolean().optional().default(true), - __enableAPIRoutesGeneration: z.boolean().optional(), // Internal flag to be turned on for TanStack Start - apiBase: z.string().optional().default('/api'), routeTreeFileHeader: z .array(z.string()) .optional() @@ -28,18 +21,27 @@ export const configSchema = z.object({ '// @ts-nocheck', '// noinspection JSUnusedGlobalSymbols', ]), - routeTreeFileFooter: z.array(z.string()).optional().default([]), - autoCodeSplitting: z.boolean().optional(), indexToken: z.string().optional().default('index'), routeToken: z.string().optional().default('route'), pathParamsAllowedCharacters: z .array(z.enum([';', ':', '@', '&', '=', '+', '$', ','])) .optional(), +}) + +export type BaseConfig = z.infer + +export const configSchema = baseConfigSchema.extend({ + generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'), + disableTypes: z.boolean().optional().default(false), + addExtensions: z.boolean().optional().default(false), + disableManifestGeneration: z.boolean().optional().default(false), + enableRouteTreeFormatting: z.boolean().optional().default(true), + routeTreeFileFooter: z.array(z.string()).optional().default([]), + autoCodeSplitting: z.boolean().optional(), customScaffolding: z .object({ routeTemplate: z.string().optional(), lazyRouteTemplate: z.string().optional(), - apiTemplate: z.string().optional(), }) .optional(), experimental: z diff --git a/packages/router-generator/src/filesystem/physical/getRouteNodes.ts b/packages/router-generator/src/filesystem/physical/getRouteNodes.ts index 0c0df6ea5d..f72da5fac2 100644 --- a/packages/router-generator/src/filesystem/physical/getRouteNodes.ts +++ b/packages/router-generator/src/filesystem/physical/getRouteNodes.ts @@ -4,8 +4,6 @@ import { determineInitialRoutePath, logging, removeExt, - removeLeadingSlash, - removeTrailingSlash, replaceBackslash, routePathToVariable, } from '../../utils' @@ -22,7 +20,16 @@ import type { Config } from '../../config' const disallowedRouteGroupConfiguration = /\(([^)]+)\).(ts|js|tsx|jsx)/ export async function getRouteNodes( - config: Config, + config: Pick< + Config, + | 'routesDirectory' + | 'routeFilePrefix' + | 'routeFileIgnorePrefix' + | 'routeFileIgnorePattern' + | 'disableLogging' + | 'routeToken' + | 'indexToken' + >, root: string, ): Promise { const { routeFilePrefix, routeFileIgnorePrefix, routeFileIgnorePattern } = @@ -196,7 +203,7 @@ export async function getRouteNodes( */ export function getRouteMeta( routePath: string, - config: Config, + config: Pick, ): { // `__root` is can be more easily determined by filtering down to routePath === /${rootPathId} // `pathless` is needs to determined after `lazy` has been cleaned up from the routePath @@ -215,15 +222,7 @@ export function getRouteMeta( } { let fsRouteType: FsRouteType = 'static' - if ( - removeLeadingSlash(routePath).startsWith( - `${removeTrailingSlash(removeLeadingSlash(config.apiBase))}/`, - ) && - config.__enableAPIRoutesGeneration - ) { - // api routes, i.e. `/api/foo.ts` - fsRouteType = 'api' - } else if (routePath.endsWith(`/${config.routeToken}`)) { + if (routePath.endsWith(`/${config.routeToken}`)) { // layout routes, i.e `/foo/route.tsx` or `/foo/_layout/route.tsx` fsRouteType = 'layout' } else if (routePath.endsWith('/lazy')) { @@ -257,7 +256,7 @@ export function getRouteMeta( function isValidPathlessLayoutRoute( normalizedRoutePath: string, routeType: FsRouteType, - config: Config, + config: Pick, ): boolean { if (routeType === 'lazy') { return false diff --git a/packages/router-generator/src/filesystem/virtual/getRouteNodes.ts b/packages/router-generator/src/filesystem/virtual/getRouteNodes.ts index b9fa25c41a..9cca5b59bd 100644 --- a/packages/router-generator/src/filesystem/virtual/getRouteNodes.ts +++ b/packages/router-generator/src/filesystem/virtual/getRouteNodes.ts @@ -37,7 +37,15 @@ function flattenTree(node: RouteNode): Array { } export async function getRouteNodes( - tsrConfig: Config, + tsrConfig: Pick< + Config, + | 'routesDirectory' + | 'virtualRouteConfig' + | 'routeFileIgnorePrefix' + | 'disableLogging' + | 'indexToken' + | 'routeToken' + >, root: string, ): Promise { const fullDir = resolve(tsrConfig.routesDirectory) @@ -90,7 +98,7 @@ export async function getRouteNodes( * */ async function getVirtualRouteConfigFromFileExport( - tsrConfig: Config, + tsrConfig: Pick, root: string, ): Promise { if ( @@ -115,7 +123,14 @@ async function getVirtualRouteConfigFromFileExport( } export async function getRouteNodesRecursive( - tsrConfig: Config, + tsrConfig: Pick< + Config, + | 'routesDirectory' + | 'routeFileIgnorePrefix' + | 'disableLogging' + | 'indexToken' + | 'routeToken' + >, root: string, fullDir: string, nodes?: Array, diff --git a/packages/router-generator/src/generator.ts b/packages/router-generator/src/generator.ts index b7c579daec..e14981735d 100644 --- a/packages/router-generator/src/generator.ts +++ b/packages/router-generator/src/generator.ts @@ -2,12 +2,10 @@ import path from 'node:path' import * as fs from 'node:fs' import * as fsp from 'node:fs/promises' import { - determineInitialRoutePath, format, logging, multiSortBy, removeExt, - removeTrailingSlash, removeUnderscores, replaceBackslash, resetRegex, @@ -18,18 +16,12 @@ import { import { getRouteNodes as physicalGetRouteNodes } from './filesystem/physical/getRouteNodes' import { getRouteNodes as virtualGetRouteNodes } from './filesystem/virtual/getRouteNodes' import { rootPathId } from './filesystem/physical/rootPathId' -import { - defaultAPIRouteTemplate, - fillTemplate, - getTargetTemplate, -} from './template' +import { fillTemplate, getTargetTemplate } from './template' import type { FsRouteType, GetRouteNodesResult, RouteNode } from './types' import type { Config } from './config' -export const CONSTANTS = { - // When changing this, you'll want to update the import in `start-api-routes/src/index.ts#defaultAPIFileRouteHandler` - APIRouteExportVariable: 'APIRoute', -} +// Maybe import this from `@tanstack/router-core` in the future??? +const rootRouteId = '__root__' let latestTask = 0 const routeGroupPatternRegex = /\(.+\)/g @@ -76,10 +68,6 @@ export async function generator(config: Config, root: string) { const TYPES_DISABLED = config.disableTypes - // Controls whether API Routes are generated for TanStack Start - const ENABLED_API_ROUTES_GENERATION = - config.__enableAPIRoutesGeneration ?? false - let getRouteNodesResult: GetRouteNodesResult if (config.virtualRouteConfig) { @@ -117,30 +105,6 @@ export async function generator(config: Config, root: string) { const routeTree: Array = [] const routePiecesByPath: Record = {} - // Filtered API Route nodes - const onlyAPIRouteNodes = preRouteNodes.filter((d) => { - if (!ENABLED_API_ROUTES_GENERATION) { - return false - } - - if (d._fsRouteType !== 'api') { - return false - } - - return true - }) - - // Filtered Generator Route nodes - const onlyGeneratorRouteNodes = preRouteNodes.filter((d) => { - if (ENABLED_API_ROUTES_GENERATION) { - if (d._fsRouteType === 'api') { - return false - } - } - - return true - }) - // Loop over the flat list of routeNodes and // build up a tree based on the routeNodes' routePath const routeNodes: Array = [] @@ -243,7 +207,7 @@ export async function generator(config: Config, root: string) { tLazyRouteTemplate.template(), { tsrImports: tLazyRouteTemplate.imports.tsrImports(), - tsrPath: escapedRoutePath, + tsrPath: escapedRoutePath.replaceAll(/\{(.+)\}/gm, '$1'), tsrExportStart: tLazyRouteTemplate.imports.tsrExportStart(escapedRoutePath), tsrExportEnd: tLazyRouteTemplate.imports.tsrExportEnd(), @@ -269,7 +233,7 @@ export async function generator(config: Config, root: string) { tRouteTemplate.template(), { tsrImports: tRouteTemplate.imports.tsrImports(), - tsrPath: escapedRoutePath, + tsrPath: escapedRoutePath.replaceAll(/\{(.+)\}/gm, '$1'), tsrExportStart: tRouteTemplate.imports.tsrExportStart(escapedRoutePath), tsrExportEnd: tRouteTemplate.imports.tsrExportEnd(), @@ -277,6 +241,15 @@ export async function generator(config: Config, root: string) { ) } } else { + // Check if the route file has a Route export + if ( + !routeCode + .split('\n') + .some((line) => line.trim().startsWith('export const Route')) + ) { + return + } + // Update the existing route file replaced = routeCode .replace( @@ -285,16 +258,56 @@ export async function generator(config: Config, root: string) { ) .replace( new RegExp( - `(import\\s*\\{.*)(create(Lazy)?FileRoute)(.*\\}\\s*from\\s*['"]@tanstack\\/${ROUTE_TEMPLATE.subPkg}['"])`, + `(import\\s*\\{)(.*)(create(Lazy)?FileRoute)(.*)(\\}\\s*from\\s*['"]@tanstack\\/${ROUTE_TEMPLATE.subPkg}['"])`, 'gs', ), - (_, p1, __, ___, p4) => - `${p1}${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}${p4}`, + (_, p1, p2, ___, ____, p5, p6) => { + const beforeCreateFileRoute = () => { + if (!p2) return '' + + let trimmed = p2.trim() + + if (trimmed.endsWith(',')) { + trimmed = trimmed.slice(0, -1) + } + + return trimmed + } + + const afterCreateFileRoute = () => { + if (!p5) return '' + + let trimmed = p5.trim() + + if (trimmed.startsWith(',')) { + trimmed = trimmed.slice(1) + } + + return trimmed + } + + const newImport = () => { + const before = beforeCreateFileRoute() + const after = afterCreateFileRoute() + + if (!before) return after + + if (!after) return before + + return `${before},${after}` + } + + const middle = newImport() + + if (middle === '') return '' + + return `${p1} ${newImport()} ${p6}` + }, ) .replace( /create(Lazy)?FileRoute(\(\s*['"])([^\s]*)(['"],?\s*\))/g, (_, __, p2, ___, p4) => - `${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}${p2}${escapedRoutePath}${p4}`, + `${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}`, ) } @@ -406,77 +419,22 @@ export async function generator(config: Config, root: string) { routeNodes.push(node) } - for (const node of onlyGeneratorRouteNodes) { + for (const node of preRouteNodes) { await handleNode(node) } + + // This is run against the `preRouteNodes` array since it + // has the flattened Route nodes and not the full tree + // Since TSR allows multiple way of defining a route, + // we need to ensure that a user hasn't defined the + // same route in multiple ways (i.e. `flat`, `nested`, `virtual`) checkRouteFullPathUniqueness( preRouteNodes.filter( - (d) => - d.children === undefined && - (['api', 'lazy'] satisfies Array).every( - (type) => type !== d._fsRouteType, - ), + (d) => d.children === undefined && 'lazy' !== d._fsRouteType, ), config, ) - const startAPIRouteNodes: Array = checkStartAPIRoutes( - onlyAPIRouteNodes, - config, - ) - - const handleAPINode = async (node: RouteNode) => { - const routeCode = fs.readFileSync(node.fullPath, 'utf-8') - - const escapedRoutePath = node.routePath?.replaceAll('$', '$$') ?? '' - - if (!routeCode) { - const replaced = await fillTemplate( - config, - config.customScaffolding?.apiTemplate ?? defaultAPIRouteTemplate, - { - tsrImports: - "import { createAPIFileRoute } from '@tanstack/react-start/api';", - tsrPath: escapedRoutePath, - tsrExportStart: `export const ${CONSTANTS.APIRouteExportVariable} = createAPIFileRoute('${escapedRoutePath}')(`, - tsrExportEnd: ');', - }, - ) - - await writeIfDifferent( - node.fullPath, - '', // Empty string because the file doesn't exist yet - replaced, - { - beforeWrite: () => { - logger.log(`🟡 Creating ${node.fullPath}`) - }, - }, - ) - } else { - await writeIfDifferent( - node.fullPath, - routeCode, - routeCode.replace( - /(createAPIFileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g, - (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`, - ), - { - beforeWrite: () => { - logger.log(`🟡 Updating ${node.fullPath}`) - }, - }, - ) - } - } - - // Handle the API routes for TanStack Start - if (ENABLED_API_ROUTES_GENERATION) { - for (const node of startAPIRouteNodes) { - await handleAPINode(node) - } - } - function buildRouteTreeConfig(nodes: Array, depth = 1): string { const children = nodes.map((node) => { if (node._fsRouteType === '__root') { @@ -555,6 +513,7 @@ export async function generator(config: Config, root: string) { ), ) } + const routeImports = [ ...config.routeTreeFileHeader, `// This file was automatically generated by TanStack Router. @@ -565,13 +524,18 @@ export async function generator(config: Config, root: string) { : '', '// Import Routes', [ + ...(TYPES_DISABLED + ? [] + : [ + `import type { FileRoutesByPath, CreateFileRoute } from '${ROUTE_TEMPLATE.fullPkg}'`, + ]), `import { Route as rootRoute } from './${getImportPath(rootRouteNode)}'`, ...sortedRouteNodes .filter((d) => !d.isVirtual) .map((node) => { return `import { Route as ${ node.variableName - }Import } from './${getImportPath(node)}'` + }RouteImport } from './${getImportPath(node)}'` }), ].join('\n'), virtualRouteNodes.length ? '// Create Virtual Routes' : '', @@ -579,7 +543,7 @@ export async function generator(config: Config, root: string) { .map((node) => { return `const ${ node.variableName - }Import = createFileRoute('${node.routePath}')()` + }RouteImport = createFileRoute('${node.routePath}')()` }) .join('\n'), '// Create/Update Routes', @@ -594,7 +558,8 @@ export async function generator(config: Config, root: string) { const lazyComponentNode = routePiecesByPath[node.routePath!]?.lazy return [ - `const ${node.variableName}Route = ${node.variableName}Import.update({ + [ + `const ${node.variableName}Route = ${node.variableName}RouteImport.update({ ${[ `id: '${node.path}'`, !node.isNonPath ? `path: '${node.cleanedPath}'` : undefined, @@ -603,19 +568,19 @@ export async function generator(config: Config, root: string) { .filter(Boolean) .join(',')} }${TYPES_DISABLED ? '' : 'as any'})`, - loaderNode - ? `.updateLoader({ loader: lazyFn(() => import('./${replaceBackslash( - removeExt( - path.relative( - path.dirname(config.generatedRouteTree), - path.resolve(config.routesDirectory, loaderNode.filePath), + loaderNode + ? `.updateLoader({ loader: lazyFn(() => import('./${replaceBackslash( + removeExt( + path.relative( + path.dirname(config.generatedRouteTree), + path.resolve(config.routesDirectory, loaderNode.filePath), + ), + config.addExtensions, ), - config.addExtensions, - ), - )}'), 'loader') })` - : '', - componentNode || errorComponentNode || pendingComponentNode - ? `.update({ + )}'), 'loader') })` + : '', + componentNode || errorComponentNode || pendingComponentNode + ? `.update({ ${( [ ['component', componentNode], @@ -639,22 +604,23 @@ export async function generator(config: Config, root: string) { }) .join('\n,')} })` - : '', - lazyComponentNode - ? `.lazy(() => import('./${replaceBackslash( - removeExt( - path.relative( - path.dirname(config.generatedRouteTree), - path.resolve( - config.routesDirectory, - lazyComponentNode.filePath, + : '', + lazyComponentNode + ? `.lazy(() => import('./${replaceBackslash( + removeExt( + path.relative( + path.dirname(config.generatedRouteTree), + path.resolve( + config.routesDirectory, + lazyComponentNode.filePath, + ), ), + config.addExtensions, ), - config.addExtensions, - ), - )}').then((d) => d.Route))` - : '', - ].join('') + )}').then((d) => d.Route))` + : '', + ].join(''), + ].join('\n\n') }) .join('\n\n'), ...(TYPES_DISABLED @@ -671,12 +637,12 @@ export async function generator(config: Config, root: string) { id: '${filePathId}' path: '${inferPath(routeNode)}' fullPath: '${inferFullPath(routeNode)}' - preLoaderRoute: typeof ${routeNode.variableName}Import + preLoaderRoute: typeof ${routeNode.variableName}RouteImport parentRoute: typeof ${ routeNode.isVirtualParentRequired ? `${routeNode.parent?.variableName}Route` : routeNode.parent?.variableName - ? `${routeNode.parent.variableName}Import` + ? `${routeNode.parent.variableName}RouteImport` : 'rootRoute' } }` @@ -685,6 +651,35 @@ export async function generator(config: Config, root: string) { } }`, ]), + ...(TYPES_DISABLED + ? [] + : [ + `// Add type-safety to the createFileRoute function across the route tree`, + routeNodes + .map((routeNode) => { + function getModuleDeclaration(routeNode?: RouteNode) { + if (!routeNode) { + return '' + } + return `declare module './${getImportPath(routeNode)}' { + const ${routeNode._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}: CreateFileRoute< + '${routeNode.routePath}', + FileRoutesByPath['${routeNode.routePath}']['parentRoute'], + FileRoutesByPath['${routeNode.routePath}']['id'], + FileRoutesByPath['${routeNode.routePath}']['path'], + FileRoutesByPath['${routeNode.routePath}']['fullPath'] + > + }` + } + return ( + getModuleDeclaration(routeNode) + + getModuleDeclaration( + routePiecesByPath[routeNode.routePath!]?.lazy, + ) + ) + }) + .join('\n'), + ]), '// Create and export the route tree', routeConfigChildrenText, ...(TYPES_DISABLED @@ -703,7 +698,7 @@ export async function generator(config: Config, root: string) { })} }`, `export interface FileRoutesById { - '__root__': typeof rootRoute, + '${rootRouteId}': typeof rootRoute, ${[...createRouteNodesById(routeNodes).entries()].map(([id, routeNode]) => { return `'${id}': typeof ${getResolvedRouteNodeVariableName(routeNode)}` })} @@ -713,7 +708,7 @@ export async function generator(config: Config, root: string) { fullPaths: ${routeNodes.length > 0 ? [...createRouteNodesByFullPath(routeNodes).keys()].map((fullPath) => `'${fullPath}'`).join('|') : 'never'} fileRoutesByTo: FileRoutesByTo to: ${routeNodes.length > 0 ? [...createRouteNodesByTo(routeNodes).keys()].map((to) => `'${to}'`).join('|') : 'never'} - id: ${[`'__root__'`, ...[...createRouteNodesById(routeNodes).keys()].map((id) => `'${id}'`)].join('|')} + id: ${[`'${rootRouteId}'`, ...[...createRouteNodesById(routeNodes).keys()].map((id) => `'${id}'`)].join('|')} fileRoutesById: FileRoutesById }`, `export interface RootRouteChildren { @@ -724,6 +719,18 @@ export async function generator(config: Config, root: string) { ${routeTree.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')} }`, `export const routeTree = rootRoute._addFileChildren(rootRouteChildren)${TYPES_DISABLED ? '' : '._addFileTypes()'}`, + !TYPES_DISABLED + ? `// @ts-ignore +import type * as ServerTypes from '${replaceBackslash( + path.relative( + path.dirname(config.generatedRouteTree), + path.resolve( + root, + '.tanstack-start/server-routes/routeTree.gen.ts', + ), + ), + )}'` + : '', ...config.routeTreeFileFooter, ] .filter(Boolean) @@ -731,7 +738,7 @@ export async function generator(config: Config, root: string) { const createRouteManifest = () => { const routesManifest = { - __root__: { + [rootRouteId]: { filePath: rootRouteNode.filePath, children: routeTree.map((d) => d.routePath), }, @@ -847,7 +854,7 @@ function determineNodePath(node: RouteNode) { * @example * removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth' */ -export function removeLastSegmentFromPath(routePath: string = '/'): string { +function removeLastSegmentFromPath(routePath: string = '/'): string { const segments = routePath.split('/') segments.pop() // Remove the last segment return segments.join('/') @@ -867,7 +874,7 @@ function removeLayoutSegments(routePath: string = '/'): string { return newSegments.join('/') } -export function hasParentRoute( +function hasParentRoute( routes: Array, node: RouteNode, routePathToCheck: string | undefined, @@ -902,9 +909,7 @@ export function hasParentRoute( /** * Gets the final variable name for a route */ -export const getResolvedRouteNodeVariableName = ( - routeNode: RouteNode, -): string => { +const getResolvedRouteNodeVariableName = (routeNode: RouteNode): string => { return routeNode.children?.length ? `${routeNode.variableName}RouteWithChildren` : `${routeNode.variableName}Route` @@ -913,7 +918,7 @@ export const getResolvedRouteNodeVariableName = ( /** * Creates a map from fullPath to routeNode */ -export const createRouteNodesByFullPath = ( +const createRouteNodesByFullPath = ( routeNodes: Array, ): Map => { return new Map( @@ -924,7 +929,7 @@ export const createRouteNodesByFullPath = ( /** * Create a map from 'to' to a routeNode */ -export const createRouteNodesByTo = ( +const createRouteNodesByTo = ( routeNodes: Array, ): Map => { return new Map( @@ -938,7 +943,7 @@ export const createRouteNodesByTo = ( /** * Create a map from 'id' to a routeNode */ -export const createRouteNodesById = ( +const createRouteNodesById = ( routeNodes: Array, ): Map => { return new Map( @@ -952,7 +957,7 @@ export const createRouteNodesById = ( /** * Infers the full path for use by TS */ -export const inferFullPath = (routeNode: RouteNode): string => { +const inferFullPath = (routeNode: RouteNode): string => { const fullPath = removeGroups( removeUnderscores(removeLayoutSegments(routeNode.routePath)) ?? '', ) @@ -963,7 +968,7 @@ export const inferFullPath = (routeNode: RouteNode): string => { /** * Infers the path for use by TS */ -export const inferPath = (routeNode: RouteNode): string => { +const inferPath = (routeNode: RouteNode): string => { return routeNode.cleanedPath === '/' ? routeNode.cleanedPath : (routeNode.cleanedPath?.replace(/\/$/, '') ?? '') @@ -972,7 +977,7 @@ export const inferPath = (routeNode: RouteNode): string => { /** * Infers to path */ -export const inferTo = (routeNode: RouteNode): string => { +const inferTo = (routeNode: RouteNode): string => { const fullPath = inferFullPath(routeNode) if (fullPath === '/') return fullPath @@ -983,7 +988,7 @@ export const inferTo = (routeNode: RouteNode): string => { /** * Dedupes branches and index routes */ -export const dedupeBranchesAndIndexRoutes = ( +const dedupeBranchesAndIndexRoutes = ( routes: Array, ): Array => { return routes.filter((route) => { @@ -1022,75 +1027,8 @@ function checkRouteFullPathUniqueness( const errorMessage = `Conflicting configuration paths were found for the following route${conflictingFiles.length > 1 ? 's' : ''}: ${conflictingFiles .map((p) => `"${p.inferredFullPath}"`) .join(', ')}. -Please ensure each route has a unique full path. +Please ensure each Route has a unique full path. Conflicting files: \n ${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join('\n ')}\n` throw new Error(errorMessage) } } - -function checkStartAPIRoutes(_routes: Array, config: Config) { - if (_routes.length === 0) { - return [] - } - - // Make sure these are valid URLs - // Route Groups and Layout Routes aren't being removed since - // you may want to have an API route that starts with an underscore - // or be wrapped in parentheses - const routes = _routes.map((d) => { - const routePath = removeTrailingSlash(d.routePath ?? '') - return { ...d, routePath } - }) - - const conflictingFiles = checkUnique(routes, 'routePath') - - if (conflictingFiles !== undefined) { - const errorMessage = `Conflicting configuration paths were found for the following API route${conflictingFiles.length > 1 ? 's' : ''}: ${conflictingFiles - .map((p) => `"${p}"`) - .join(', ')}. - Please ensure each API route has a unique route path. -Conflicting files: \n ${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join('\n ')}\n` - throw new Error(errorMessage) - } - - return routes -} - -export type StartAPIRoutePathSegment = { - value: string - type: 'path' | 'param' | 'splat' -} - -/** - * This function takes in a path in the format accepted by TanStack Router - * and returns an array of path segments that can be used to generate - * the pathname of the TanStack Start API route. - * - * @param src - * @returns - */ -export function startAPIRouteSegmentsFromTSRFilePath( - src: string, - config: Config, -): Array { - const routePath = determineInitialRoutePath(src) - - const parts = routePath - .replaceAll('.', '/') - .split('/') - .filter((p) => !!p && p !== config.indexToken) - const segments: Array = parts.map((part) => { - if (part.startsWith('$')) { - if (part === '$') { - return { value: part, type: 'splat' } - } - - part.replaceAll('$', '') - return { value: part, type: 'param' } - } - - return { value: part, type: 'path' } - }) - - return segments -} diff --git a/packages/router-generator/src/index.ts b/packages/router-generator/src/index.ts index 4f22337a3c..21e7ba58fb 100644 --- a/packages/router-generator/src/index.ts +++ b/packages/router-generator/src/index.ts @@ -1,9 +1,34 @@ -export { configSchema, getConfig, resolveConfigPath } from './config' -export type { Config } from './config' +export { + configSchema, + getConfig, + resolveConfigPath, + baseConfigSchema, +} from './config' +export type { Config, BaseConfig } from './config' + +export { generator } from './generator' export { - generator, - startAPIRouteSegmentsFromTSRFilePath, - CONSTANTS, -} from './generator' -export type { StartAPIRoutePathSegment } from './generator' + logging, + capitalize, + cleanPath, + trimPathLeft, + removeLeadingSlash, + removeTrailingSlash, + determineInitialRoutePath, + replaceBackslash, + routePathToVariable, + removeUnderscores, + resetRegex, + multiSortBy, + writeIfDifferent, + format, + removeExt, +} from './utils' + +export type { RouteNode, GetRouteNodesResult } from './types' + +export { getRouteNodes as physicalGetRouteNodes } from './filesystem/physical/getRouteNodes' +export { getRouteNodes as virtualGetRouteNodes } from './filesystem/virtual/getRouteNodes' + +export { rootPathId } from './filesystem/physical/rootPathId' diff --git a/packages/router-generator/src/template.ts b/packages/router-generator/src/template.ts index 5650844a04..1c8747a97a 100644 --- a/packages/router-generator/src/template.ts +++ b/packages/router-generator/src/template.ts @@ -77,10 +77,8 @@ export function getTargetTemplate(target: Config['target']): TargetTemplate { 'function RouteComponent() { return
Hello "%%tsrPath%%"!
};\n', ].join(''), imports: { - tsrImports: () => - "import { createFileRoute } from '@tanstack/react-router';", - tsrExportStart: (routePath) => - `export const Route = createFileRoute('${routePath}')(`, + tsrImports: () => '', + tsrExportStart: () => `export const Route = createFileRoute(`, tsrExportEnd: () => ');', }, }, @@ -130,10 +128,8 @@ export function getTargetTemplate(target: Config['target']): TargetTemplate { 'function RouteComponent() { return
Hello "%%tsrPath%%"!
};\n', ].join(''), imports: { - tsrImports: () => - "import { createFileRoute } from '@tanstack/solid-router';", - tsrExportStart: (routePath) => - `export const Route = createFileRoute('${routePath}')(`, + tsrImports: () => '', + tsrExportStart: () => `export const Route = createFileRoute(`, tsrExportEnd: () => ');', }, }, @@ -158,10 +154,3 @@ export function getTargetTemplate(target: Config['target']): TargetTemplate { throw new Error(`router-generator: Unknown target type: ${target}`) } } - -export const defaultAPIRouteTemplate = [ - 'import { json } from "@tanstack/react-start";\n', - '%%tsrImports%%', - '\n\n', - '%%tsrExportStart%%{ GET: ({ request, params }) => { return json({ message:\'Hello "%%tsrPath%%"!\' }) }}%%tsrExportEnd%%\n', -].join('') diff --git a/packages/router-generator/src/types.ts b/packages/router-generator/src/types.ts index a8ba30feee..954401bdfe 100644 --- a/packages/router-generator/src/types.ts +++ b/packages/router-generator/src/types.ts @@ -25,7 +25,6 @@ export type FsRouteType = | 'layout' | 'pathless_layout' | 'lazy' - | 'api' | 'loader' // @deprecated | 'component' // @deprecated | 'pendingComponent' // @deprecated diff --git a/packages/router-generator/src/utils.ts b/packages/router-generator/src/utils.ts index 5155bb43ef..0280e9186e 100644 --- a/packages/router-generator/src/utils.ts +++ b/packages/router-generator/src/utils.ts @@ -1,6 +1,5 @@ import * as fs from 'node:fs' import * as prettier from 'prettier' -import type { Config } from './config' export function multiSortBy( arr: Array, @@ -86,7 +85,55 @@ export function removeTrailingSlash(s: string) { } export function determineInitialRoutePath(routePath: string) { - return cleanPath(`/${routePath.split('.').join('/')}`) || '' + const DISALLOWED_ESCAPE_CHARS = new Set([ + '/', + '\\', + '?', + '#', + ':', + '*', + '<', + '>', + '|', + '!', + '$', + '%', + ]) + + const parts = routePath.split(/(? { + // Check if any disallowed characters are used in brackets + const BRACKET_CONTENT_RE = /\[(.*?)\]/g + + let match + while ((match = BRACKET_CONTENT_RE.exec(part)) !== null) { + const character = match[1] + if (character === undefined) continue + if (DISALLOWED_ESCAPE_CHARS.has(character)) { + console.error( + `Error: Disallowed character "${character}" found in square brackets in route path "${routePath}".\nYou cannot use any of the following characters in square brackets: ${Array.from( + DISALLOWED_ESCAPE_CHARS, + ).join(', ')}\nPlease remove and/or replace them.`, + ) + process.exit(1) + } + } + + // Since this split segment is safe at this point, we can + // remove the brackets and replace them with the content inside + return part.replace(/\[(.)\]/g, '$1') + }) + + // If the syntax for prefix/suffix is different, from the path + // matching internals of router-core, we'd perform those changes here + // on the `escapedParts` array before it is joined back together in + // `final` + + const final = cleanPath(`/${escapedParts.join('/')}`) || '' + + return final } export function replaceBackslash(s: string) { @@ -94,15 +141,43 @@ export function replaceBackslash(s: string) { } export function routePathToVariable(routePath: string): string { + const toVariableSafeChar = (char: string): string => { + if (/[a-zA-Z0-9_]/.test(char)) { + return char // Keep alphanumeric characters and underscores as is + } + + // Replace special characters with meaningful text equivalents + switch (char) { + case '.': + return 'Dot' + case '-': + return 'Dash' + case '@': + return 'At' + case '(': + return '' // Removed since route groups use parentheses + case ')': + return '' // Removed since route groups use parentheses + case ' ': + return '' // Remove spaces + default: + return `Char${char.charCodeAt(0)}` // For any other characters + } + } + return ( removeUnderscores(routePath) ?.replace(/\/\$\//g, '/splat/') .replace(/\$$/g, 'splat') + .replace(/\$\{\$\}/g, 'splat') .replace(/\$/g, '') .split(/[/-]/g) .map((d, i) => (i > 0 ? capitalize(d) : d)) .join('') - .replace(/([^a-zA-Z0-9]|[.])/gm, '') + .split('') + .map(toVariableSafeChar) + .join('') + // .replace(/([^a-zA-Z0-9]|[.])/gm, '') .replace(/^(\d)/g, 'R$1') ?? '' ) } @@ -151,7 +226,13 @@ export async function writeIfDifferent( * @param config The configuration object * @returns The formatted content */ -export async function format(source: string, config: Config): Promise { +export async function format( + source: string, + config: { + quoteStyle: 'single' | 'double' + semicolons: boolean + }, +): Promise { const prettierOptions: prettier.Config = { semi: config.semicolons, singleQuote: config.quoteStyle === 'single', diff --git a/packages/router-generator/tests/generator.test.ts b/packages/router-generator/tests/generator.test.ts index daf787b2ec..f457b98ca4 100644 --- a/packages/router-generator/tests/generator.test.ts +++ b/packages/router-generator/tests/generator.test.ts @@ -116,11 +116,6 @@ function rewriteConfigByFolderName(folderName: string, config: Config) { '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n', 'function RouteComponent() { return "Hello %%tsrPath%%!" };\n', ].join(''), - apiTemplate: [ - 'import { json } from "@tanstack/react-start";\n', - '%%tsrImports%%\n\n', - '%%tsrExportStart%%{ GET: ({ request, params }) => { return json({ message: "Hello /api/test" }) }}%%tsrExportEnd%%\n', - ].join(''), lazyRouteTemplate: [ 'import React, { useState } from "react";\n', '%%tsrImports%%\n\n', @@ -128,7 +123,6 @@ function rewriteConfigByFolderName(folderName: string, config: Config) { 'function RouteComponent() { return "Hello %%tsrPath%%!" };\n', ].join(''), } - config.__enableAPIRoutesGeneration = true break default: break diff --git a/packages/router-generator/tests/generator/append-and-prepend/routeTree.snapshot.ts b/packages/router-generator/tests/generator/append-and-prepend/routeTree.snapshot.ts index 7ee554ed03..b6b5b55e25 100644 --- a/packages/router-generator/tests/generator/append-and-prepend/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/append-and-prepend/routeTree.snapshot.ts @@ -8,12 +8,13 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -27,12 +28,24 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -69,6 +82,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + // append1 // append2 diff --git a/packages/router-generator/tests/generator/append-and-prepend/routes/index.tsx b/packages/router-generator/tests/generator/append-and-prepend/routes/index.tsx index a525ebff0c..13c752995e 100644 --- a/packages/router-generator/tests/generator/append-and-prepend/routes/index.tsx +++ b/packages/router-generator/tests/generator/append-and-prepend/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: Home, validateSearch: () => ({ indexSearch: 'indexSearch', diff --git a/packages/router-generator/tests/generator/custom-scaffolding/routeTree.snapshot.ts b/packages/router-generator/tests/generator/custom-scaffolding/routeTree.snapshot.ts index 8ba4c94c1b..55bbb074c6 100644 --- a/packages/router-generator/tests/generator/custom-scaffolding/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/custom-scaffolding/routeTree.snapshot.ts @@ -12,27 +12,35 @@ import { createFileRoute } from '@tanstack/react-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' +import { Route as IndexRouteImport } from './routes/index' +import { Route as ApiBarRouteImport } from './routes/api/bar' // Create Virtual Routes -const FooLazyImport = createFileRoute('/foo')() +const FooLazyRouteImport = createFileRoute('/foo')() // Create/Update Routes -const FooLazyRoute = FooLazyImport.update({ +const FooLazyRoute = FooLazyRouteImport.update({ id: '/foo', path: '/foo', getParentRoute: () => rootRoute, } as any).lazy(() => import('./routes/foo.lazy').then((d) => d.Route)) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) +const ApiBarRoute = ApiBarRouteImport.update({ + id: '/api/bar', + path: '/api/bar', + getParentRoute: () => rootRoute, +} as any) + // Populate the FileRoutesByPath interface declare module '@tanstack/react-router' { @@ -41,60 +49,114 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/foo': { id: '/foo' path: '/foo' fullPath: '/foo' - preLoaderRoute: typeof FooLazyImport + preLoaderRoute: typeof FooLazyRouteImport + parentRoute: typeof rootRoute + } + '/api/bar': { + id: '/api/bar' + path: '/api/bar' + fullPath: '/api/bar' + preLoaderRoute: typeof ApiBarRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/foo.lazy' { + const createFileRoute: CreateFileRoute< + '/foo', + FileRoutesByPath['/foo']['parentRoute'], + FileRoutesByPath['/foo']['id'], + FileRoutesByPath['/foo']['path'], + FileRoutesByPath['/foo']['fullPath'] + > +} +declare module './routes/foo.lazy' { + const createLazyFileRoute: CreateFileRoute< + '/foo', + FileRoutesByPath['/foo']['parentRoute'], + FileRoutesByPath['/foo']['id'], + FileRoutesByPath['/foo']['path'], + FileRoutesByPath['/foo']['fullPath'] + > +} +declare module './routes/api/bar' { + const createFileRoute: CreateFileRoute< + '/api/bar', + FileRoutesByPath['/api/bar']['parentRoute'], + FileRoutesByPath['/api/bar']['id'], + FileRoutesByPath['/api/bar']['path'], + FileRoutesByPath['/api/bar']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { '/': typeof IndexRoute '/foo': typeof FooLazyRoute + '/api/bar': typeof ApiBarRoute } export interface FileRoutesByTo { '/': typeof IndexRoute '/foo': typeof FooLazyRoute + '/api/bar': typeof ApiBarRoute } export interface FileRoutesById { __root__: typeof rootRoute '/': typeof IndexRoute '/foo': typeof FooLazyRoute + '/api/bar': typeof ApiBarRoute } export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/foo' + fullPaths: '/' | '/foo' | '/api/bar' fileRoutesByTo: FileRoutesByTo - to: '/' | '/foo' - id: '__root__' | '/' | '/foo' + to: '/' | '/foo' | '/api/bar' + id: '__root__' | '/' | '/foo' | '/api/bar' fileRoutesById: FileRoutesById } export interface RootRouteChildren { IndexRoute: typeof IndexRoute FooLazyRoute: typeof FooLazyRoute + ApiBarRoute: typeof ApiBarRoute } const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, FooLazyRoute: FooLazyRoute, + ApiBarRoute: ApiBarRoute, } export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { @@ -102,7 +164,8 @@ export const routeTree = rootRoute "filePath": "__root.tsx", "children": [ "/", - "/foo" + "/foo", + "/api/bar" ] }, "/": { @@ -110,6 +173,9 @@ export const routeTree = rootRoute }, "/foo": { "filePath": "foo.lazy.tsx" + }, + "/api/bar": { + "filePath": "api/bar.tsx" } } } diff --git a/packages/router-generator/tests/generator/custom-scaffolding/routes/api/bar.tsx b/packages/router-generator/tests/generator/custom-scaffolding/routes/api/bar.tsx index 090f4b945a..13867e7bd1 100644 --- a/packages/router-generator/tests/generator/custom-scaffolding/routes/api/bar.tsx +++ b/packages/router-generator/tests/generator/custom-scaffolding/routes/api/bar.tsx @@ -1,8 +1,9 @@ -import { json } from '@tanstack/react-start' -import { createAPIFileRoute } from '@tanstack/react-start/api' +import * as React from 'react' -export const APIRoute = createAPIFileRoute('/api/bar')({ - GET: ({ request, params }) => { - return json({ message: 'Hello /api/test' }) - }, +export const Route = createFileRoute({ + component: RouteComponent, }) + +function RouteComponent() { + return 'Hello /api/bar!' +} diff --git a/packages/router-generator/tests/generator/custom-scaffolding/routes/index.tsx b/packages/router-generator/tests/generator/custom-scaffolding/routes/index.tsx index 8b22ea6bb5..659c416bc4 100644 --- a/packages/router-generator/tests/generator/custom-scaffolding/routes/index.tsx +++ b/packages/router-generator/tests/generator/custom-scaffolding/routes/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/custom-scaffolding/snapshot/api/bar.tsx b/packages/router-generator/tests/generator/custom-scaffolding/snapshot/api/bar.tsx index 090f4b945a..13867e7bd1 100644 --- a/packages/router-generator/tests/generator/custom-scaffolding/snapshot/api/bar.tsx +++ b/packages/router-generator/tests/generator/custom-scaffolding/snapshot/api/bar.tsx @@ -1,8 +1,9 @@ -import { json } from '@tanstack/react-start' -import { createAPIFileRoute } from '@tanstack/react-start/api' +import * as React from 'react' -export const APIRoute = createAPIFileRoute('/api/bar')({ - GET: ({ request, params }) => { - return json({ message: 'Hello /api/test' }) - }, +export const Route = createFileRoute({ + component: RouteComponent, }) + +function RouteComponent() { + return 'Hello /api/bar!' +} diff --git a/packages/router-generator/tests/generator/custom-scaffolding/snapshot/index.tsx b/packages/router-generator/tests/generator/custom-scaffolding/snapshot/index.tsx index 8b22ea6bb5..659c416bc4 100644 --- a/packages/router-generator/tests/generator/custom-scaffolding/snapshot/index.tsx +++ b/packages/router-generator/tests/generator/custom-scaffolding/snapshot/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/custom-tokens/routeTree.snapshot.ts b/packages/router-generator/tests/generator/custom-tokens/routeTree.snapshot.ts index a9170a93ef..c4ee4471a9 100644 --- a/packages/router-generator/tests/generator/custom-tokens/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/custom-tokens/routeTree.snapshot.ts @@ -10,61 +10,62 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostsR0ut3Import } from './routes/posts/_r0ut3_' -import { Route as BlogR0ut3Import } from './routes/blog/_r0ut3_' -import { Route as R1nd3xImport } from './routes/_1nd3x' -import { Route as Posts1nd3xImport } from './routes/posts/_1nd3x' -import { Route as Blog1nd3xImport } from './routes/blog/_1nd3x' -import { Route as BlogSlugImport } from './routes/blog/$slug' -import { Route as PostsPostId1nd3xImport } from './routes/posts/$postId/_1nd3x' -import { Route as PostsPostIdDeepImport } from './routes/posts/$postId/deep' +import { Route as PostsR0ut3RouteImport } from './routes/posts/_r0ut3_' +import { Route as BlogR0ut3RouteImport } from './routes/blog/_r0ut3_' +import { Route as R1nd3xRouteImport } from './routes/_1nd3x' +import { Route as Posts1nd3xRouteImport } from './routes/posts/_1nd3x' +import { Route as Blog1nd3xRouteImport } from './routes/blog/_1nd3x' +import { Route as BlogSlugRouteImport } from './routes/blog/$slug' +import { Route as PostsPostId1nd3xRouteImport } from './routes/posts/$postId/_1nd3x' +import { Route as PostsPostIdDeepRouteImport } from './routes/posts/$postId/deep' // Create/Update Routes -const PostsR0ut3Route = PostsR0ut3Import.update({ +const PostsR0ut3Route = PostsR0ut3RouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const BlogR0ut3Route = BlogR0ut3Import.update({ +const BlogR0ut3Route = BlogR0ut3RouteImport.update({ id: '/blog', path: '/blog', getParentRoute: () => rootRoute, } as any) -const R1nd3xRoute = R1nd3xImport.update({ +const R1nd3xRoute = R1nd3xRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const Posts1nd3xRoute = Posts1nd3xImport.update({ +const Posts1nd3xRoute = Posts1nd3xRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsR0ut3Route, } as any) -const Blog1nd3xRoute = Blog1nd3xImport.update({ +const Blog1nd3xRoute = Blog1nd3xRouteImport.update({ id: '/', path: '/', getParentRoute: () => BlogR0ut3Route, } as any) -const BlogSlugRoute = BlogSlugImport.update({ +const BlogSlugRoute = BlogSlugRouteImport.update({ id: '/$slug', path: '/$slug', getParentRoute: () => BlogR0ut3Route, } as any) -const PostsPostId1nd3xRoute = PostsPostId1nd3xImport.update({ +const PostsPostId1nd3xRoute = PostsPostId1nd3xRouteImport.update({ id: '/$postId/', path: '/$postId/', getParentRoute: () => PostsR0ut3Route, } as any) -const PostsPostIdDeepRoute = PostsPostIdDeepImport.update({ +const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ id: '/$postId/deep', path: '/$postId/deep', getParentRoute: () => PostsR0ut3Route, @@ -78,61 +79,136 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof R1nd3xImport + preLoaderRoute: typeof R1nd3xRouteImport parentRoute: typeof rootRoute } '/blog': { id: '/blog' path: '/blog' fullPath: '/blog' - preLoaderRoute: typeof BlogR0ut3Import + preLoaderRoute: typeof BlogR0ut3RouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsR0ut3Import + preLoaderRoute: typeof PostsR0ut3RouteImport parentRoute: typeof rootRoute } '/blog/$slug': { id: '/blog/$slug' path: '/$slug' fullPath: '/blog/$slug' - preLoaderRoute: typeof BlogSlugImport - parentRoute: typeof BlogR0ut3Import + preLoaderRoute: typeof BlogSlugRouteImport + parentRoute: typeof BlogR0ut3RouteImport } '/blog/': { id: '/blog/' path: '/' fullPath: '/blog/' - preLoaderRoute: typeof Blog1nd3xImport - parentRoute: typeof BlogR0ut3Import + preLoaderRoute: typeof Blog1nd3xRouteImport + parentRoute: typeof BlogR0ut3RouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof Posts1nd3xImport - parentRoute: typeof PostsR0ut3Import + preLoaderRoute: typeof Posts1nd3xRouteImport + parentRoute: typeof PostsR0ut3RouteImport } '/posts/$postId/deep': { id: '/posts/$postId/deep' path: '/$postId/deep' fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepImport - parentRoute: typeof PostsR0ut3Import + preLoaderRoute: typeof PostsPostIdDeepRouteImport + parentRoute: typeof PostsR0ut3RouteImport } '/posts/$postId/': { id: '/posts/$postId/' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostId1nd3xImport - parentRoute: typeof PostsR0ut3Import + preLoaderRoute: typeof PostsPostId1nd3xRouteImport + parentRoute: typeof PostsR0ut3RouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/_1nd3x' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/blog/_r0ut3_' { + const createFileRoute: CreateFileRoute< + '/blog', + FileRoutesByPath['/blog']['parentRoute'], + FileRoutesByPath['/blog']['id'], + FileRoutesByPath['/blog']['path'], + FileRoutesByPath['/blog']['fullPath'] + > +} +declare module './routes/posts/_r0ut3_' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/blog/$slug' { + const createFileRoute: CreateFileRoute< + '/blog/$slug', + FileRoutesByPath['/blog/$slug']['parentRoute'], + FileRoutesByPath['/blog/$slug']['id'], + FileRoutesByPath['/blog/$slug']['path'], + FileRoutesByPath['/blog/$slug']['fullPath'] + > +} +declare module './routes/blog/_1nd3x' { + const createFileRoute: CreateFileRoute< + '/blog/', + FileRoutesByPath['/blog/']['parentRoute'], + FileRoutesByPath['/blog/']['id'], + FileRoutesByPath['/blog/']['path'], + FileRoutesByPath['/blog/']['fullPath'] + > +} +declare module './routes/posts/_1nd3x' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/posts/$postId/deep' { + const createFileRoute: CreateFileRoute< + '/posts/$postId/deep', + FileRoutesByPath['/posts/$postId/deep']['parentRoute'], + FileRoutesByPath['/posts/$postId/deep']['id'], + FileRoutesByPath['/posts/$postId/deep']['path'], + FileRoutesByPath['/posts/$postId/deep']['fullPath'] + > +} +declare module './routes/posts/$postId/_1nd3x' { + const createFileRoute: CreateFileRoute< + '/posts/$postId/', + FileRoutesByPath['/posts/$postId/']['parentRoute'], + FileRoutesByPath['/posts/$postId/']['id'], + FileRoutesByPath['/posts/$postId/']['path'], + FileRoutesByPath['/posts/$postId/']['fullPath'] + > +} + // Create and export the route tree interface BlogR0ut3RouteChildren { @@ -245,6 +321,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/custom-tokens/routes/_1nd3x.tsx b/packages/router-generator/tests/generator/custom-tokens/routes/_1nd3x.tsx index a680913ded..22cab82307 100644 --- a/packages/router-generator/tests/generator/custom-tokens/routes/_1nd3x.tsx +++ b/packages/router-generator/tests/generator/custom-tokens/routes/_1nd3x.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: () =>
Hello /!
, }) diff --git a/packages/router-generator/tests/generator/custom-tokens/routes/blog/$slug.tsx b/packages/router-generator/tests/generator/custom-tokens/routes/blog/$slug.tsx index 0389370c39..784c2b78ae 100644 --- a/packages/router-generator/tests/generator/custom-tokens/routes/blog/$slug.tsx +++ b/packages/router-generator/tests/generator/custom-tokens/routes/blog/$slug.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/blog/$slug')({ +export const Route = createFileRoute({ component: () =>
Hello /blog/$slug!
, }) diff --git a/packages/router-generator/tests/generator/custom-tokens/routes/blog/_1nd3x.tsx b/packages/router-generator/tests/generator/custom-tokens/routes/blog/_1nd3x.tsx index 6fab51efb1..0754024ed7 100644 --- a/packages/router-generator/tests/generator/custom-tokens/routes/blog/_1nd3x.tsx +++ b/packages/router-generator/tests/generator/custom-tokens/routes/blog/_1nd3x.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/blog/')({ +export const Route = createFileRoute({ component: () =>
Hello /blog/!
, }) diff --git a/packages/router-generator/tests/generator/custom-tokens/routes/blog/_r0ut3_.tsx b/packages/router-generator/tests/generator/custom-tokens/routes/blog/_r0ut3_.tsx index 2833fcc588..ea94edad49 100644 --- a/packages/router-generator/tests/generator/custom-tokens/routes/blog/_r0ut3_.tsx +++ b/packages/router-generator/tests/generator/custom-tokens/routes/blog/_r0ut3_.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/blog')({ +export const Route = createFileRoute({ component: () =>
Hello /blog!
, }) diff --git a/packages/router-generator/tests/generator/custom-tokens/routes/posts/$postId/_1nd3x.tsx b/packages/router-generator/tests/generator/custom-tokens/routes/posts/$postId/_1nd3x.tsx index 3b2884f8aa..79316e21bb 100644 --- a/packages/router-generator/tests/generator/custom-tokens/routes/posts/$postId/_1nd3x.tsx +++ b/packages/router-generator/tests/generator/custom-tokens/routes/posts/$postId/_1nd3x.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/$postId/')({ +export const Route = createFileRoute({ component: () =>
Hello /posts/$postId/!
, }) diff --git a/packages/router-generator/tests/generator/custom-tokens/routes/posts/$postId/deep.tsx b/packages/router-generator/tests/generator/custom-tokens/routes/posts/$postId/deep.tsx index 0e0463301d..68ba9095e1 100644 --- a/packages/router-generator/tests/generator/custom-tokens/routes/posts/$postId/deep.tsx +++ b/packages/router-generator/tests/generator/custom-tokens/routes/posts/$postId/deep.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/$postId/deep')({ +export const Route = createFileRoute({ component: () =>
Hello /posts/$postId/deep!
, }) diff --git a/packages/router-generator/tests/generator/custom-tokens/routes/posts/_1nd3x.tsx b/packages/router-generator/tests/generator/custom-tokens/routes/posts/_1nd3x.tsx index f3c995416c..2e16af1ca1 100644 --- a/packages/router-generator/tests/generator/custom-tokens/routes/posts/_1nd3x.tsx +++ b/packages/router-generator/tests/generator/custom-tokens/routes/posts/_1nd3x.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: () =>
Hello /posts/!
, }) diff --git a/packages/router-generator/tests/generator/custom-tokens/routes/posts/_r0ut3_.tsx b/packages/router-generator/tests/generator/custom-tokens/routes/posts/_r0ut3_.tsx index c298ab4675..3617558181 100644 --- a/packages/router-generator/tests/generator/custom-tokens/routes/posts/_r0ut3_.tsx +++ b/packages/router-generator/tests/generator/custom-tokens/routes/posts/_r0ut3_.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ component: () =>
Hello /posts!
, }) diff --git a/packages/router-generator/tests/generator/dot-escaped/routeTree.snapshot.ts b/packages/router-generator/tests/generator/dot-escaped/routeTree.snapshot.ts new file mode 100644 index 0000000000..e8ce84c29a --- /dev/null +++ b/packages/router-generator/tests/generator/dot-escaped/routeTree.snapshot.ts @@ -0,0 +1,228 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' +import { Route as rootRoute } from './routes/__root' +import { Route as ScriptDotjsRouteImport } from './routes/script[.]js' +import { Route as NestedDotjsRouteImport } from './routes/nested[.]js' +import { Route as NestedDotjsScriptDotjsRouteImport } from './routes/nested[.]js.script[.]js' +import { Route as NestedDotjsDoubleDotextDotjsRouteImport } from './routes/nested[.]js.double[.]ext[.]js' + +// Create/Update Routes + +const ScriptDotjsRoute = ScriptDotjsRouteImport.update({ + id: '/script.js', + path: '/script.js', + getParentRoute: () => rootRoute, +} as any) + +const NestedDotjsRoute = NestedDotjsRouteImport.update({ + id: '/nested.js', + path: '/nested.js', + getParentRoute: () => rootRoute, +} as any) + +const NestedDotjsScriptDotjsRoute = NestedDotjsScriptDotjsRouteImport.update({ + id: '/script.js', + path: '/script.js', + getParentRoute: () => NestedDotjsRoute, +} as any) + +const NestedDotjsDoubleDotextDotjsRoute = + NestedDotjsDoubleDotextDotjsRouteImport.update({ + id: '/double.ext.js', + path: '/double.ext.js', + getParentRoute: () => NestedDotjsRoute, + } as any) + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-router' { + interface FileRoutesByPath { + '/nested.js': { + id: '/nested.js' + path: '/nested.js' + fullPath: '/nested.js' + preLoaderRoute: typeof NestedDotjsRouteImport + parentRoute: typeof rootRoute + } + '/script.js': { + id: '/script.js' + path: '/script.js' + fullPath: '/script.js' + preLoaderRoute: typeof ScriptDotjsRouteImport + parentRoute: typeof rootRoute + } + '/nested.js/double.ext.js': { + id: '/nested.js/double.ext.js' + path: '/double.ext.js' + fullPath: '/nested.js/double.ext.js' + preLoaderRoute: typeof NestedDotjsDoubleDotextDotjsRouteImport + parentRoute: typeof NestedDotjsRouteImport + } + '/nested.js/script.js': { + id: '/nested.js/script.js' + path: '/script.js' + fullPath: '/nested.js/script.js' + preLoaderRoute: typeof NestedDotjsScriptDotjsRouteImport + parentRoute: typeof NestedDotjsRouteImport + } + } +} + +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/nested[.]js' { + const createFileRoute: CreateFileRoute< + '/nested.js', + FileRoutesByPath['/nested.js']['parentRoute'], + FileRoutesByPath['/nested.js']['id'], + FileRoutesByPath['/nested.js']['path'], + FileRoutesByPath['/nested.js']['fullPath'] + > +} +declare module './routes/script[.]js' { + const createFileRoute: CreateFileRoute< + '/script.js', + FileRoutesByPath['/script.js']['parentRoute'], + FileRoutesByPath['/script.js']['id'], + FileRoutesByPath['/script.js']['path'], + FileRoutesByPath['/script.js']['fullPath'] + > +} +declare module './routes/nested[.]js.double[.]ext[.]js' { + const createFileRoute: CreateFileRoute< + '/nested.js/double.ext.js', + FileRoutesByPath['/nested.js/double.ext.js']['parentRoute'], + FileRoutesByPath['/nested.js/double.ext.js']['id'], + FileRoutesByPath['/nested.js/double.ext.js']['path'], + FileRoutesByPath['/nested.js/double.ext.js']['fullPath'] + > +} +declare module './routes/nested[.]js.script[.]js' { + const createFileRoute: CreateFileRoute< + '/nested.js/script.js', + FileRoutesByPath['/nested.js/script.js']['parentRoute'], + FileRoutesByPath['/nested.js/script.js']['id'], + FileRoutesByPath['/nested.js/script.js']['path'], + FileRoutesByPath['/nested.js/script.js']['fullPath'] + > +} + +// Create and export the route tree + +interface NestedDotjsRouteChildren { + NestedDotjsDoubleDotextDotjsRoute: typeof NestedDotjsDoubleDotextDotjsRoute + NestedDotjsScriptDotjsRoute: typeof NestedDotjsScriptDotjsRoute +} + +const NestedDotjsRouteChildren: NestedDotjsRouteChildren = { + NestedDotjsDoubleDotextDotjsRoute: NestedDotjsDoubleDotextDotjsRoute, + NestedDotjsScriptDotjsRoute: NestedDotjsScriptDotjsRoute, +} + +const NestedDotjsRouteWithChildren = NestedDotjsRoute._addFileChildren( + NestedDotjsRouteChildren, +) + +export interface FileRoutesByFullPath { + '/nested.js': typeof NestedDotjsRouteWithChildren + '/script.js': typeof ScriptDotjsRoute + '/nested.js/double.ext.js': typeof NestedDotjsDoubleDotextDotjsRoute + '/nested.js/script.js': typeof NestedDotjsScriptDotjsRoute +} + +export interface FileRoutesByTo { + '/nested.js': typeof NestedDotjsRouteWithChildren + '/script.js': typeof ScriptDotjsRoute + '/nested.js/double.ext.js': typeof NestedDotjsDoubleDotextDotjsRoute + '/nested.js/script.js': typeof NestedDotjsScriptDotjsRoute +} + +export interface FileRoutesById { + __root__: typeof rootRoute + '/nested.js': typeof NestedDotjsRouteWithChildren + '/script.js': typeof ScriptDotjsRoute + '/nested.js/double.ext.js': typeof NestedDotjsDoubleDotextDotjsRoute + '/nested.js/script.js': typeof NestedDotjsScriptDotjsRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: + | '/nested.js' + | '/script.js' + | '/nested.js/double.ext.js' + | '/nested.js/script.js' + fileRoutesByTo: FileRoutesByTo + to: + | '/nested.js' + | '/script.js' + | '/nested.js/double.ext.js' + | '/nested.js/script.js' + id: + | '__root__' + | '/nested.js' + | '/script.js' + | '/nested.js/double.ext.js' + | '/nested.js/script.js' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren { + NestedDotjsRoute: typeof NestedDotjsRouteWithChildren + ScriptDotjsRoute: typeof ScriptDotjsRoute +} + +const rootRouteChildren: RootRouteChildren = { + NestedDotjsRoute: NestedDotjsRouteWithChildren, + ScriptDotjsRoute: ScriptDotjsRoute, +} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [ + "/nested.js", + "/script.js" + ] + }, + "/nested.js": { + "filePath": "nested[.]js.tsx", + "children": [ + "/nested.js/double.ext.js", + "/nested.js/script.js" + ] + }, + "/script.js": { + "filePath": "script[.]js.tsx" + }, + "/nested.js/double.ext.js": { + "filePath": "nested[.]js.double[.]ext[.]js.tsx", + "parent": "/nested.js" + }, + "/nested.js/script.js": { + "filePath": "nested[.]js.script[.]js.tsx", + "parent": "/nested.js" + } + } +} +ROUTE_MANIFEST_END */ diff --git a/packages/router-generator/tests/generator/dot-escaped/routes/__root.tsx b/packages/router-generator/tests/generator/dot-escaped/routes/__root.tsx new file mode 100644 index 0000000000..ab504e42e9 --- /dev/null +++ b/packages/router-generator/tests/generator/dot-escaped/routes/__root.tsx @@ -0,0 +1 @@ +/** */ diff --git a/packages/router-generator/tests/generator/dot-escaped/routes/nested[.]js.double[.]ext[.]js.tsx b/packages/router-generator/tests/generator/dot-escaped/routes/nested[.]js.double[.]ext[.]js.tsx new file mode 100644 index 0000000000..a8c4d4c893 --- /dev/null +++ b/packages/router-generator/tests/generator/dot-escaped/routes/nested[.]js.double[.]ext[.]js.tsx @@ -0,0 +1,2 @@ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/dot-escaped/routes/nested[.]js.script[.]js.tsx b/packages/router-generator/tests/generator/dot-escaped/routes/nested[.]js.script[.]js.tsx new file mode 100644 index 0000000000..a8c4d4c893 --- /dev/null +++ b/packages/router-generator/tests/generator/dot-escaped/routes/nested[.]js.script[.]js.tsx @@ -0,0 +1,2 @@ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/dot-escaped/routes/nested[.]js.tsx b/packages/router-generator/tests/generator/dot-escaped/routes/nested[.]js.tsx new file mode 100644 index 0000000000..a8c4d4c893 --- /dev/null +++ b/packages/router-generator/tests/generator/dot-escaped/routes/nested[.]js.tsx @@ -0,0 +1,2 @@ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/dot-escaped/routes/script[.]js.tsx b/packages/router-generator/tests/generator/dot-escaped/routes/script[.]js.tsx new file mode 100644 index 0000000000..a8c4d4c893 --- /dev/null +++ b/packages/router-generator/tests/generator/dot-escaped/routes/script[.]js.tsx @@ -0,0 +1,2 @@ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/duplicate-fullPath/routes/_auth/index.tsx b/packages/router-generator/tests/generator/duplicate-fullPath/routes/_auth/index.tsx index 56b2ebca76..47d07771d4 100644 --- a/packages/router-generator/tests/generator/duplicate-fullPath/routes/_auth/index.tsx +++ b/packages/router-generator/tests/generator/duplicate-fullPath/routes/_auth/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_auth/')({ +export const Route = createFileRoute({ component: () =>
Hello /_auth/!
, }) diff --git a/packages/router-generator/tests/generator/duplicate-fullPath/routes/index.tsx b/packages/router-generator/tests/generator/duplicate-fullPath/routes/index.tsx index a680913ded..22cab82307 100644 --- a/packages/router-generator/tests/generator/duplicate-fullPath/routes/index.tsx +++ b/packages/router-generator/tests/generator/duplicate-fullPath/routes/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: () =>
Hello /!
, }) diff --git a/packages/router-generator/tests/generator/file-modification/post.$postId.tsx b/packages/router-generator/tests/generator/file-modification/post.$postId.tsx index b51b2f5ad4..790146adf0 100644 --- a/packages/router-generator/tests/generator/file-modification/post.$postId.tsx +++ b/packages/router-generator/tests/generator/file-modification/post.$postId.tsx @@ -36,7 +36,7 @@ function PostComponent() { postId: post.id, }} activeProps={{ className: 'text-black font-bold' }} - className="block py-1 text-blue-800 hover:text-blue-600" + className="inline-block py-1 text-blue-800 hover:text-blue-600" > Deep View diff --git a/packages/router-generator/tests/generator/file-modification/routeTree.snapshot.ts b/packages/router-generator/tests/generator/file-modification/routeTree.snapshot.ts index f42e1f086f..5cb749a67b 100644 --- a/packages/router-generator/tests/generator/file-modification/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/file-modification/routeTree.snapshot.ts @@ -12,18 +12,19 @@ import { createFileRoute } from '@tanstack/react-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as testInitiallyLazyImport } from './routes/(test)/initiallyLazy' -import { Route as testInitiallyEmptyImport } from './routes/(test)/initiallyEmpty' -import { Route as testFooImport } from './routes/(test)/foo' +import { Route as testInitiallyLazyRouteImport } from './routes/(test)/initiallyLazy' +import { Route as testInitiallyEmptyRouteImport } from './routes/(test)/initiallyEmpty' +import { Route as testFooRouteImport } from './routes/(test)/foo' // Create Virtual Routes -const testBarLazyImport = createFileRoute('/(test)/bar')() +const testBarLazyRouteImport = createFileRoute('/(test)/bar')() // Create/Update Routes -const testBarLazyRoute = testBarLazyImport +const testBarLazyRoute = testBarLazyRouteImport .update({ id: '/(test)/bar', path: '/bar', @@ -31,13 +32,13 @@ const testBarLazyRoute = testBarLazyImport } as any) .lazy(() => import('./routes/(test)/bar.lazy').then((d) => d.Route)) -const testInitiallyLazyRoute = testInitiallyLazyImport.update({ +const testInitiallyLazyRoute = testInitiallyLazyRouteImport.update({ id: '/(test)/initiallyLazy', path: '/initiallyLazy', getParentRoute: () => rootRoute, } as any) -const testInitiallyEmptyRoute = testInitiallyEmptyImport +const testInitiallyEmptyRoute = testInitiallyEmptyRouteImport .update({ id: '/(test)/initiallyEmpty', path: '/initiallyEmpty', @@ -47,7 +48,7 @@ const testInitiallyEmptyRoute = testInitiallyEmptyImport import('./routes/(test)/initiallyEmpty.lazy').then((d) => d.Route), ) -const testFooRoute = testFooImport.update({ +const testFooRoute = testFooRouteImport.update({ id: '/(test)/foo', path: '/foo', getParentRoute: () => rootRoute, @@ -61,33 +62,90 @@ declare module '@tanstack/react-router' { id: '/(test)/foo' path: '/foo' fullPath: '/foo' - preLoaderRoute: typeof testFooImport + preLoaderRoute: typeof testFooRouteImport parentRoute: typeof rootRoute } '/(test)/initiallyEmpty': { id: '/(test)/initiallyEmpty' path: '/initiallyEmpty' fullPath: '/initiallyEmpty' - preLoaderRoute: typeof testInitiallyEmptyImport + preLoaderRoute: typeof testInitiallyEmptyRouteImport parentRoute: typeof rootRoute } '/(test)/initiallyLazy': { id: '/(test)/initiallyLazy' path: '/initiallyLazy' fullPath: '/initiallyLazy' - preLoaderRoute: typeof testInitiallyLazyImport + preLoaderRoute: typeof testInitiallyLazyRouteImport parentRoute: typeof rootRoute } '/(test)/bar': { id: '/(test)/bar' path: '/bar' fullPath: '/bar' - preLoaderRoute: typeof testBarLazyImport + preLoaderRoute: typeof testBarLazyRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/(test)/foo' { + const createFileRoute: CreateFileRoute< + '/(test)/foo', + FileRoutesByPath['/(test)/foo']['parentRoute'], + FileRoutesByPath['/(test)/foo']['id'], + FileRoutesByPath['/(test)/foo']['path'], + FileRoutesByPath['/(test)/foo']['fullPath'] + > +} +declare module './routes/(test)/initiallyEmpty' { + const createFileRoute: CreateFileRoute< + '/(test)/initiallyEmpty', + FileRoutesByPath['/(test)/initiallyEmpty']['parentRoute'], + FileRoutesByPath['/(test)/initiallyEmpty']['id'], + FileRoutesByPath['/(test)/initiallyEmpty']['path'], + FileRoutesByPath['/(test)/initiallyEmpty']['fullPath'] + > +} +declare module './routes/(test)/initiallyEmpty.lazy' { + const createLazyFileRoute: CreateFileRoute< + '/(test)/initiallyEmpty', + FileRoutesByPath['/(test)/initiallyEmpty']['parentRoute'], + FileRoutesByPath['/(test)/initiallyEmpty']['id'], + FileRoutesByPath['/(test)/initiallyEmpty']['path'], + FileRoutesByPath['/(test)/initiallyEmpty']['fullPath'] + > +} +declare module './routes/(test)/initiallyLazy' { + const createFileRoute: CreateFileRoute< + '/(test)/initiallyLazy', + FileRoutesByPath['/(test)/initiallyLazy']['parentRoute'], + FileRoutesByPath['/(test)/initiallyLazy']['id'], + FileRoutesByPath['/(test)/initiallyLazy']['path'], + FileRoutesByPath['/(test)/initiallyLazy']['fullPath'] + > +} +declare module './routes/(test)/bar.lazy' { + const createFileRoute: CreateFileRoute< + '/(test)/bar', + FileRoutesByPath['/(test)/bar']['parentRoute'], + FileRoutesByPath['/(test)/bar']['id'], + FileRoutesByPath['/(test)/bar']['path'], + FileRoutesByPath['/(test)/bar']['fullPath'] + > +} +declare module './routes/(test)/bar.lazy' { + const createLazyFileRoute: CreateFileRoute< + '/(test)/bar', + FileRoutesByPath['/(test)/bar']['parentRoute'], + FileRoutesByPath['/(test)/bar']['id'], + FileRoutesByPath['/(test)/bar']['path'], + FileRoutesByPath['/(test)/bar']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -144,6 +202,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/file-modification/snapshot/bar.lazy.tsx b/packages/router-generator/tests/generator/file-modification/snapshot/bar.lazy.tsx index d8a6feca9b..cf174606e1 100644 --- a/packages/router-generator/tests/generator/file-modification/snapshot/bar.lazy.tsx +++ b/packages/router-generator/tests/generator/file-modification/snapshot/bar.lazy.tsx @@ -5,10 +5,9 @@ import { ErrorComponent, ErrorComponentProps, Link, - createFileRoute, } from '@tanstack/react-router' -export const Route = createFileRoute('/(test)/foo')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => ({ postId, title: 'title', @@ -39,7 +38,7 @@ function PostComponent() { postId: post.id, }} activeProps={{ className: 'text-black font-bold' }} - className="block py-1 text-blue-800 hover:text-blue-600" + className="inline-block py-1 text-blue-800 hover:text-blue-600" > Deep View diff --git a/packages/router-generator/tests/generator/file-modification/snapshot/foo.tsx b/packages/router-generator/tests/generator/file-modification/snapshot/foo.tsx index d8a6feca9b..cf174606e1 100644 --- a/packages/router-generator/tests/generator/file-modification/snapshot/foo.tsx +++ b/packages/router-generator/tests/generator/file-modification/snapshot/foo.tsx @@ -5,10 +5,9 @@ import { ErrorComponent, ErrorComponentProps, Link, - createFileRoute, } from '@tanstack/react-router' -export const Route = createFileRoute('/(test)/foo')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => ({ postId, title: 'title', @@ -39,7 +38,7 @@ function PostComponent() { postId: post.id, }} activeProps={{ className: 'text-black font-bold' }} - className="block py-1 text-blue-800 hover:text-blue-600" + className="inline-block py-1 text-blue-800 hover:text-blue-600" > Deep View diff --git a/packages/router-generator/tests/generator/file-modification/snapshot/initiallyEmpty.lazy.tsx b/packages/router-generator/tests/generator/file-modification/snapshot/initiallyEmpty.lazy.tsx index d8a6feca9b..cf174606e1 100644 --- a/packages/router-generator/tests/generator/file-modification/snapshot/initiallyEmpty.lazy.tsx +++ b/packages/router-generator/tests/generator/file-modification/snapshot/initiallyEmpty.lazy.tsx @@ -5,10 +5,9 @@ import { ErrorComponent, ErrorComponentProps, Link, - createFileRoute, } from '@tanstack/react-router' -export const Route = createFileRoute('/(test)/foo')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => ({ postId, title: 'title', @@ -39,7 +38,7 @@ function PostComponent() { postId: post.id, }} activeProps={{ className: 'text-black font-bold' }} - className="block py-1 text-blue-800 hover:text-blue-600" + className="inline-block py-1 text-blue-800 hover:text-blue-600" > Deep View diff --git a/packages/router-generator/tests/generator/file-modification/snapshot/initiallyEmpty.tsx b/packages/router-generator/tests/generator/file-modification/snapshot/initiallyEmpty.tsx index d8a6feca9b..cf174606e1 100644 --- a/packages/router-generator/tests/generator/file-modification/snapshot/initiallyEmpty.tsx +++ b/packages/router-generator/tests/generator/file-modification/snapshot/initiallyEmpty.tsx @@ -5,10 +5,9 @@ import { ErrorComponent, ErrorComponentProps, Link, - createFileRoute, } from '@tanstack/react-router' -export const Route = createFileRoute('/(test)/foo')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => ({ postId, title: 'title', @@ -39,7 +38,7 @@ function PostComponent() { postId: post.id, }} activeProps={{ className: 'text-black font-bold' }} - className="block py-1 text-blue-800 hover:text-blue-600" + className="inline-block py-1 text-blue-800 hover:text-blue-600" > Deep View diff --git a/packages/router-generator/tests/generator/file-modification/snapshot/initiallyLazy.tsx b/packages/router-generator/tests/generator/file-modification/snapshot/initiallyLazy.tsx index d8a6feca9b..cf174606e1 100644 --- a/packages/router-generator/tests/generator/file-modification/snapshot/initiallyLazy.tsx +++ b/packages/router-generator/tests/generator/file-modification/snapshot/initiallyLazy.tsx @@ -5,10 +5,9 @@ import { ErrorComponent, ErrorComponentProps, Link, - createFileRoute, } from '@tanstack/react-router' -export const Route = createFileRoute('/(test)/foo')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => ({ postId, title: 'title', @@ -39,7 +38,7 @@ function PostComponent() { postId: post.id, }} activeProps={{ className: 'text-black font-bold' }} - className="block py-1 text-blue-800 hover:text-blue-600" + className="inline-block py-1 text-blue-800 hover:text-blue-600" > Deep View diff --git a/packages/router-generator/tests/generator/file-modification/template.lazy.tsx b/packages/router-generator/tests/generator/file-modification/template.lazy.tsx index 76dc2c74c3..45a3d5871f 100644 --- a/packages/router-generator/tests/generator/file-modification/template.lazy.tsx +++ b/packages/router-generator/tests/generator/file-modification/template.lazy.tsx @@ -2,7 +2,7 @@ import { createLazyFileRoute, Link } from '@tanstack/react-router' -export const Route = createLazyFileRoute('/(test)/lazy')({ +export const Route = createLazyFileRoute({ component: () => { const post = Route.useLoaderData() diff --git a/packages/router-generator/tests/generator/file-modification/template.tsx b/packages/router-generator/tests/generator/file-modification/template.tsx index 918119d3f0..cf174606e1 100644 --- a/packages/router-generator/tests/generator/file-modification/template.tsx +++ b/packages/router-generator/tests/generator/file-modification/template.tsx @@ -5,10 +5,9 @@ import { ErrorComponent, ErrorComponentProps, Link, - createFileRoute, } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ loader: async ({ params: { postId } }) => ({ postId, title: 'title', @@ -39,7 +38,7 @@ function PostComponent() { postId: post.id, }} activeProps={{ className: 'text-black font-bold' }} - className="block py-1 text-blue-800 hover:text-blue-600" + className="inline-block py-1 text-blue-800 hover:text-blue-600" > Deep View diff --git a/packages/router-generator/tests/generator/flat/routeTree.snapshot.ts b/packages/router-generator/tests/generator/flat/routeTree.snapshot.ts index 50840b912e..0dd23cd117 100644 --- a/packages/router-generator/tests/generator/flat/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/flat/routeTree.snapshot.ts @@ -10,68 +10,69 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostsRouteImport } from './routes/posts.route' -import { Route as BlogRouteImport } from './routes/blog.route' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts.index' -import { Route as BlogIndexImport } from './routes/blog.index' -import { Route as BlogStatsImport } from './routes/blog_.stats' -import { Route as PostsPostIdIndexImport } from './routes/posts.$postId.index' -import { Route as BlogSlugIndexImport } from './routes/blog.$slug.index' -import { Route as PostsPostIdDeepImport } from './routes/posts.$postId.deep' +import { Route as PostsRouteRouteImport } from './routes/posts.route' +import { Route as BlogRouteRouteImport } from './routes/blog.route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts.index' +import { Route as BlogIndexRouteImport } from './routes/blog.index' +import { Route as BlogStatsRouteImport } from './routes/blog_.stats' +import { Route as PostsPostIdIndexRouteImport } from './routes/posts.$postId.index' +import { Route as BlogSlugIndexRouteImport } from './routes/blog.$slug.index' +import { Route as PostsPostIdDeepRouteImport } from './routes/posts.$postId.deep' // Create/Update Routes -const PostsRouteRoute = PostsRouteImport.update({ +const PostsRouteRoute = PostsRouteRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const BlogRouteRoute = BlogRouteImport.update({ +const BlogRouteRoute = BlogRouteRouteImport.update({ id: '/blog', path: '/blog', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRouteRoute, } as any) -const BlogIndexRoute = BlogIndexImport.update({ +const BlogIndexRoute = BlogIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => BlogRouteRoute, } as any) -const BlogStatsRoute = BlogStatsImport.update({ +const BlogStatsRoute = BlogStatsRouteImport.update({ id: '/blog_/stats', path: '/blog/stats', getParentRoute: () => rootRoute, } as any) -const PostsPostIdIndexRoute = PostsPostIdIndexImport.update({ +const PostsPostIdIndexRoute = PostsPostIdIndexRouteImport.update({ id: '/$postId/', path: '/$postId/', getParentRoute: () => PostsRouteRoute, } as any) -const BlogSlugIndexRoute = BlogSlugIndexImport.update({ +const BlogSlugIndexRoute = BlogSlugIndexRouteImport.update({ id: '/$slug/', path: '/$slug/', getParentRoute: () => BlogRouteRoute, } as any) -const PostsPostIdDeepRoute = PostsPostIdDeepImport.update({ +const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ id: '/$postId/deep', path: '/$postId/deep', getParentRoute: () => PostsRouteRoute, @@ -85,68 +86,152 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/blog': { id: '/blog' path: '/blog' fullPath: '/blog' - preLoaderRoute: typeof BlogRouteImport + preLoaderRoute: typeof BlogRouteRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsRouteRouteImport parentRoute: typeof rootRoute } '/blog_/stats': { id: '/blog_/stats' path: '/blog/stats' fullPath: '/blog/stats' - preLoaderRoute: typeof BlogStatsImport + preLoaderRoute: typeof BlogStatsRouteImport parentRoute: typeof rootRoute } '/blog/': { id: '/blog/' path: '/' fullPath: '/blog/' - preLoaderRoute: typeof BlogIndexImport - parentRoute: typeof BlogRouteImport + preLoaderRoute: typeof BlogIndexRouteImport + parentRoute: typeof BlogRouteRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteRouteImport } '/posts/$postId/deep': { id: '/posts/$postId/deep' path: '/$postId/deep' fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsPostIdDeepRouteImport + parentRoute: typeof PostsRouteRouteImport } '/blog/$slug/': { id: '/blog/$slug/' path: '/$slug' fullPath: '/blog/$slug' - preLoaderRoute: typeof BlogSlugIndexImport - parentRoute: typeof BlogRouteImport + preLoaderRoute: typeof BlogSlugIndexRouteImport + parentRoute: typeof BlogRouteRouteImport } '/posts/$postId/': { id: '/posts/$postId/' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdIndexImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsPostIdIndexRouteImport + parentRoute: typeof PostsRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/blog.route' { + const createFileRoute: CreateFileRoute< + '/blog', + FileRoutesByPath['/blog']['parentRoute'], + FileRoutesByPath['/blog']['id'], + FileRoutesByPath['/blog']['path'], + FileRoutesByPath['/blog']['fullPath'] + > +} +declare module './routes/posts.route' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/blog_.stats' { + const createFileRoute: CreateFileRoute< + '/blog_/stats', + FileRoutesByPath['/blog_/stats']['parentRoute'], + FileRoutesByPath['/blog_/stats']['id'], + FileRoutesByPath['/blog_/stats']['path'], + FileRoutesByPath['/blog_/stats']['fullPath'] + > +} +declare module './routes/blog.index' { + const createFileRoute: CreateFileRoute< + '/blog/', + FileRoutesByPath['/blog/']['parentRoute'], + FileRoutesByPath['/blog/']['id'], + FileRoutesByPath['/blog/']['path'], + FileRoutesByPath['/blog/']['fullPath'] + > +} +declare module './routes/posts.index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/posts.$postId.deep' { + const createFileRoute: CreateFileRoute< + '/posts/$postId/deep', + FileRoutesByPath['/posts/$postId/deep']['parentRoute'], + FileRoutesByPath['/posts/$postId/deep']['id'], + FileRoutesByPath['/posts/$postId/deep']['path'], + FileRoutesByPath['/posts/$postId/deep']['fullPath'] + > +} +declare module './routes/blog.$slug.index' { + const createFileRoute: CreateFileRoute< + '/blog/$slug/', + FileRoutesByPath['/blog/$slug/']['parentRoute'], + FileRoutesByPath['/blog/$slug/']['id'], + FileRoutesByPath['/blog/$slug/']['path'], + FileRoutesByPath['/blog/$slug/']['fullPath'] + > +} +declare module './routes/posts.$postId.index' { + const createFileRoute: CreateFileRoute< + '/posts/$postId/', + FileRoutesByPath['/posts/$postId/']['parentRoute'], + FileRoutesByPath['/posts/$postId/']['id'], + FileRoutesByPath['/posts/$postId/']['path'], + FileRoutesByPath['/posts/$postId/']['fullPath'] + > +} + // Create and export the route tree interface BlogRouteRouteChildren { @@ -267,6 +352,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/flat/routes/__root.tsx b/packages/router-generator/tests/generator/flat/routes/__root.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/flat/routes/__root.tsx +++ b/packages/router-generator/tests/generator/flat/routes/__root.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/flat/routes/blog.$slug.index.tsx b/packages/router-generator/tests/generator/flat/routes/blog.$slug.index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/flat/routes/blog.$slug.index.tsx +++ b/packages/router-generator/tests/generator/flat/routes/blog.$slug.index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/flat/routes/blog.index.tsx b/packages/router-generator/tests/generator/flat/routes/blog.index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/flat/routes/blog.index.tsx +++ b/packages/router-generator/tests/generator/flat/routes/blog.index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/flat/routes/blog.route.tsx b/packages/router-generator/tests/generator/flat/routes/blog.route.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/flat/routes/blog.route.tsx +++ b/packages/router-generator/tests/generator/flat/routes/blog.route.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/flat/routes/blog_.stats.tsx b/packages/router-generator/tests/generator/flat/routes/blog_.stats.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/flat/routes/blog_.stats.tsx +++ b/packages/router-generator/tests/generator/flat/routes/blog_.stats.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/flat/routes/index.tsx b/packages/router-generator/tests/generator/flat/routes/index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/flat/routes/index.tsx +++ b/packages/router-generator/tests/generator/flat/routes/index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/flat/routes/posts.$postId.deep.tsx b/packages/router-generator/tests/generator/flat/routes/posts.$postId.deep.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/flat/routes/posts.$postId.deep.tsx +++ b/packages/router-generator/tests/generator/flat/routes/posts.$postId.deep.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/flat/routes/posts.$postId.index.tsx b/packages/router-generator/tests/generator/flat/routes/posts.$postId.index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/flat/routes/posts.$postId.index.tsx +++ b/packages/router-generator/tests/generator/flat/routes/posts.$postId.index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/flat/routes/posts.index.tsx b/packages/router-generator/tests/generator/flat/routes/posts.index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/flat/routes/posts.index.tsx +++ b/packages/router-generator/tests/generator/flat/routes/posts.index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/flat/routes/posts.route.tsx b/packages/router-generator/tests/generator/flat/routes/posts.route.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/flat/routes/posts.route.tsx +++ b/packages/router-generator/tests/generator/flat/routes/posts.route.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routeTree.snapshot.ts b/packages/router-generator/tests/generator/nested-layouts/routeTree.snapshot.ts index 51095a9fea..7029ab12c3 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/nested-layouts/routeTree.snapshot.ts @@ -12,178 +12,181 @@ import { createFileRoute } from '@tanstack/react-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as LayoutA2Import } from './routes/_layout-a2' -import { Route as LayoutA1Import } from './routes/_layout-a1' -import { Route as JestedRouteImport } from './routes/jested/route' -import { Route as IndexImport } from './routes/index' -import { Route as NestedLayoutB2Import } from './routes/nested/_layout-b2' -import { Route as NestedLayoutB1Import } from './routes/nested/_layout-b1' -import { Route as JestedLayoutB4Import } from './routes/jested/_layout-b4' -import { Route as JestedLayoutB3Import } from './routes/jested/_layout-b3' -import { Route as FooBarImport } from './routes/foo/bar' -import { Route as LayoutA2BarImport } from './routes/_layout-a2/bar' -import { Route as LayoutA1FooImport } from './routes/_layout-a1/foo' -import { Route as folderInFolderImport } from './routes/(folder)/in-folder' -import { Route as FooLayoutB5RouteImport } from './routes/foo/_layout-b5/route' -import { Route as NestedLayoutB1IndexImport } from './routes/nested/_layout-b1/index' -import { Route as JestedLayoutB3IndexImport } from './routes/jested/_layout-b3/index' -import { Route as FooLayoutB5IndexImport } from './routes/foo/_layout-b5/index' -import { Route as NestedLayoutB2FooImport } from './routes/nested/_layout-b2/foo' -import { Route as NestedLayoutB1LayoutC1Import } from './routes/nested/_layout-b1/_layout-c1' -import { Route as JestedLayoutB4FooImport } from './routes/jested/_layout-b4/foo' -import { Route as JestedLayoutB3LayoutC2Import } from './routes/jested/_layout-b3/_layout-c2' -import { Route as FooLayoutB5IdImport } from './routes/foo/_layout-b5/$id' -import { Route as NestedLayoutB1LayoutC1BarImport } from './routes/nested/_layout-b1/_layout-c1/bar' -import { Route as JestedLayoutB3LayoutC2BarImport } from './routes/jested/_layout-b3/_layout-c2/bar' +import { Route as LayoutA2RouteImport } from './routes/_layout-a2' +import { Route as LayoutA1RouteImport } from './routes/_layout-a1' +import { Route as JestedRouteRouteImport } from './routes/jested/route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as NestedLayoutB2RouteImport } from './routes/nested/_layout-b2' +import { Route as NestedLayoutB1RouteImport } from './routes/nested/_layout-b1' +import { Route as JestedLayoutB4RouteImport } from './routes/jested/_layout-b4' +import { Route as JestedLayoutB3RouteImport } from './routes/jested/_layout-b3' +import { Route as FooBarRouteImport } from './routes/foo/bar' +import { Route as LayoutA2BarRouteImport } from './routes/_layout-a2/bar' +import { Route as LayoutA1FooRouteImport } from './routes/_layout-a1/foo' +import { Route as folderInFolderRouteImport } from './routes/(folder)/in-folder' +import { Route as FooLayoutB5RouteRouteImport } from './routes/foo/_layout-b5/route' +import { Route as NestedLayoutB1IndexRouteImport } from './routes/nested/_layout-b1/index' +import { Route as JestedLayoutB3IndexRouteImport } from './routes/jested/_layout-b3/index' +import { Route as FooLayoutB5IndexRouteImport } from './routes/foo/_layout-b5/index' +import { Route as NestedLayoutB2FooRouteImport } from './routes/nested/_layout-b2/foo' +import { Route as NestedLayoutB1LayoutC1RouteImport } from './routes/nested/_layout-b1/_layout-c1' +import { Route as JestedLayoutB4FooRouteImport } from './routes/jested/_layout-b4/foo' +import { Route as JestedLayoutB3LayoutC2RouteImport } from './routes/jested/_layout-b3/_layout-c2' +import { Route as FooLayoutB5IdRouteImport } from './routes/foo/_layout-b5/$id' +import { Route as NestedLayoutB1LayoutC1BarRouteImport } from './routes/nested/_layout-b1/_layout-c1/bar' +import { Route as JestedLayoutB3LayoutC2BarRouteImport } from './routes/jested/_layout-b3/_layout-c2/bar' // Create Virtual Routes -const NestedImport = createFileRoute('/nested')() -const FooImport = createFileRoute('/foo')() +const NestedRouteImport = createFileRoute('/nested')() +const FooRouteImport = createFileRoute('/foo')() // Create/Update Routes -const NestedRoute = NestedImport.update({ +const NestedRoute = NestedRouteImport.update({ id: '/nested', path: '/nested', getParentRoute: () => rootRoute, } as any) -const FooRoute = FooImport.update({ +const FooRoute = FooRouteImport.update({ id: '/foo', path: '/foo', getParentRoute: () => rootRoute, } as any) -const LayoutA2Route = LayoutA2Import.update({ +const LayoutA2Route = LayoutA2RouteImport.update({ id: '/_layout-a2', getParentRoute: () => rootRoute, } as any) -const LayoutA1Route = LayoutA1Import.update({ +const LayoutA1Route = LayoutA1RouteImport.update({ id: '/_layout-a1', getParentRoute: () => rootRoute, } as any) -const JestedRouteRoute = JestedRouteImport.update({ +const JestedRouteRoute = JestedRouteRouteImport.update({ id: '/jested', path: '/jested', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const NestedLayoutB2Route = NestedLayoutB2Import.update({ +const NestedLayoutB2Route = NestedLayoutB2RouteImport.update({ id: '/_layout-b2', getParentRoute: () => NestedRoute, } as any) -const NestedLayoutB1Route = NestedLayoutB1Import.update({ +const NestedLayoutB1Route = NestedLayoutB1RouteImport.update({ id: '/_layout-b1', getParentRoute: () => NestedRoute, } as any) -const JestedLayoutB4Route = JestedLayoutB4Import.update({ +const JestedLayoutB4Route = JestedLayoutB4RouteImport.update({ id: '/_layout-b4', getParentRoute: () => JestedRouteRoute, } as any) -const JestedLayoutB3Route = JestedLayoutB3Import.update({ +const JestedLayoutB3Route = JestedLayoutB3RouteImport.update({ id: '/_layout-b3', getParentRoute: () => JestedRouteRoute, } as any) -const FooBarRoute = FooBarImport.update({ +const FooBarRoute = FooBarRouteImport.update({ id: '/bar', path: '/bar', getParentRoute: () => FooRoute, } as any) -const LayoutA2BarRoute = LayoutA2BarImport.update({ +const LayoutA2BarRoute = LayoutA2BarRouteImport.update({ id: '/bar', path: '/bar', getParentRoute: () => LayoutA2Route, } as any) -const LayoutA1FooRoute = LayoutA1FooImport.update({ +const LayoutA1FooRoute = LayoutA1FooRouteImport.update({ id: '/foo', path: '/foo', getParentRoute: () => LayoutA1Route, } as any) -const folderInFolderRoute = folderInFolderImport.update({ +const folderInFolderRoute = folderInFolderRouteImport.update({ id: '/(folder)/in-folder', path: '/in-folder', getParentRoute: () => rootRoute, } as any) -const FooLayoutB5RouteRoute = FooLayoutB5RouteImport.update({ +const FooLayoutB5RouteRoute = FooLayoutB5RouteRouteImport.update({ id: '/_layout-b5', getParentRoute: () => FooRoute, } as any) -const NestedLayoutB1IndexRoute = NestedLayoutB1IndexImport.update({ +const NestedLayoutB1IndexRoute = NestedLayoutB1IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => NestedLayoutB1Route, } as any) -const JestedLayoutB3IndexRoute = JestedLayoutB3IndexImport.update({ +const JestedLayoutB3IndexRoute = JestedLayoutB3IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => JestedLayoutB3Route, } as any) -const FooLayoutB5IndexRoute = FooLayoutB5IndexImport.update({ +const FooLayoutB5IndexRoute = FooLayoutB5IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => FooLayoutB5RouteRoute, } as any) -const NestedLayoutB2FooRoute = NestedLayoutB2FooImport.update({ +const NestedLayoutB2FooRoute = NestedLayoutB2FooRouteImport.update({ id: '/foo', path: '/foo', getParentRoute: () => NestedLayoutB2Route, } as any) -const NestedLayoutB1LayoutC1Route = NestedLayoutB1LayoutC1Import.update({ +const NestedLayoutB1LayoutC1Route = NestedLayoutB1LayoutC1RouteImport.update({ id: '/_layout-c1', getParentRoute: () => NestedLayoutB1Route, } as any) -const JestedLayoutB4FooRoute = JestedLayoutB4FooImport.update({ +const JestedLayoutB4FooRoute = JestedLayoutB4FooRouteImport.update({ id: '/foo', path: '/foo', getParentRoute: () => JestedLayoutB4Route, } as any) -const JestedLayoutB3LayoutC2Route = JestedLayoutB3LayoutC2Import.update({ +const JestedLayoutB3LayoutC2Route = JestedLayoutB3LayoutC2RouteImport.update({ id: '/_layout-c2', getParentRoute: () => JestedLayoutB3Route, } as any) -const FooLayoutB5IdRoute = FooLayoutB5IdImport.update({ +const FooLayoutB5IdRoute = FooLayoutB5IdRouteImport.update({ id: '/$id', path: '/$id', getParentRoute: () => FooLayoutB5RouteRoute, } as any) -const NestedLayoutB1LayoutC1BarRoute = NestedLayoutB1LayoutC1BarImport.update({ - id: '/bar', - path: '/bar', - getParentRoute: () => NestedLayoutB1LayoutC1Route, -} as any) +const NestedLayoutB1LayoutC1BarRoute = + NestedLayoutB1LayoutC1BarRouteImport.update({ + id: '/bar', + path: '/bar', + getParentRoute: () => NestedLayoutB1LayoutC1Route, + } as any) -const JestedLayoutB3LayoutC2BarRoute = JestedLayoutB3LayoutC2BarImport.update({ - id: '/bar', - path: '/bar', - getParentRoute: () => JestedLayoutB3LayoutC2Route, -} as any) +const JestedLayoutB3LayoutC2BarRoute = + JestedLayoutB3LayoutC2BarRouteImport.update({ + id: '/bar', + path: '/bar', + getParentRoute: () => JestedLayoutB3LayoutC2Route, + } as any) // Populate the FileRoutesByPath interface @@ -193,180 +196,408 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/jested': { id: '/jested' path: '/jested' fullPath: '/jested' - preLoaderRoute: typeof JestedRouteImport + preLoaderRoute: typeof JestedRouteRouteImport parentRoute: typeof rootRoute } '/_layout-a1': { id: '/_layout-a1' path: '' fullPath: '' - preLoaderRoute: typeof LayoutA1Import + preLoaderRoute: typeof LayoutA1RouteImport parentRoute: typeof rootRoute } '/_layout-a2': { id: '/_layout-a2' path: '' fullPath: '' - preLoaderRoute: typeof LayoutA2Import + preLoaderRoute: typeof LayoutA2RouteImport parentRoute: typeof rootRoute } '/foo': { id: '/foo' path: '/foo' fullPath: '/foo' - preLoaderRoute: typeof FooImport + preLoaderRoute: typeof FooRouteImport parentRoute: typeof rootRoute } '/foo/_layout-b5': { id: '/foo/_layout-b5' path: '/foo' fullPath: '/foo' - preLoaderRoute: typeof FooLayoutB5RouteImport + preLoaderRoute: typeof FooLayoutB5RouteRouteImport parentRoute: typeof FooRoute } '/(folder)/in-folder': { id: '/(folder)/in-folder' path: '/in-folder' fullPath: '/in-folder' - preLoaderRoute: typeof folderInFolderImport + preLoaderRoute: typeof folderInFolderRouteImport parentRoute: typeof rootRoute } '/_layout-a1/foo': { id: '/_layout-a1/foo' path: '/foo' fullPath: '/foo' - preLoaderRoute: typeof LayoutA1FooImport - parentRoute: typeof LayoutA1Import + preLoaderRoute: typeof LayoutA1FooRouteImport + parentRoute: typeof LayoutA1RouteImport } '/_layout-a2/bar': { id: '/_layout-a2/bar' path: '/bar' fullPath: '/bar' - preLoaderRoute: typeof LayoutA2BarImport - parentRoute: typeof LayoutA2Import + preLoaderRoute: typeof LayoutA2BarRouteImport + parentRoute: typeof LayoutA2RouteImport } '/foo/bar': { id: '/foo/bar' path: '/bar' fullPath: '/foo/bar' - preLoaderRoute: typeof FooBarImport - parentRoute: typeof FooImport + preLoaderRoute: typeof FooBarRouteImport + parentRoute: typeof FooRouteImport } '/jested/_layout-b3': { id: '/jested/_layout-b3' path: '' fullPath: '/jested' - preLoaderRoute: typeof JestedLayoutB3Import - parentRoute: typeof JestedRouteImport + preLoaderRoute: typeof JestedLayoutB3RouteImport + parentRoute: typeof JestedRouteRouteImport } '/jested/_layout-b4': { id: '/jested/_layout-b4' path: '' fullPath: '/jested' - preLoaderRoute: typeof JestedLayoutB4Import - parentRoute: typeof JestedRouteImport + preLoaderRoute: typeof JestedLayoutB4RouteImport + parentRoute: typeof JestedRouteRouteImport } '/nested': { id: '/nested' path: '/nested' fullPath: '/nested' - preLoaderRoute: typeof NestedImport + preLoaderRoute: typeof NestedRouteImport parentRoute: typeof rootRoute } '/nested/_layout-b1': { id: '/nested/_layout-b1' path: '/nested' fullPath: '/nested' - preLoaderRoute: typeof NestedLayoutB1Import + preLoaderRoute: typeof NestedLayoutB1RouteImport parentRoute: typeof NestedRoute } '/nested/_layout-b2': { id: '/nested/_layout-b2' path: '' fullPath: '/nested' - preLoaderRoute: typeof NestedLayoutB2Import - parentRoute: typeof NestedImport + preLoaderRoute: typeof NestedLayoutB2RouteImport + parentRoute: typeof NestedRouteImport } '/foo/_layout-b5/$id': { id: '/foo/_layout-b5/$id' path: '/$id' fullPath: '/foo/$id' - preLoaderRoute: typeof FooLayoutB5IdImport - parentRoute: typeof FooLayoutB5RouteImport + preLoaderRoute: typeof FooLayoutB5IdRouteImport + parentRoute: typeof FooLayoutB5RouteRouteImport } '/jested/_layout-b3/_layout-c2': { id: '/jested/_layout-b3/_layout-c2' path: '' fullPath: '/jested' - preLoaderRoute: typeof JestedLayoutB3LayoutC2Import - parentRoute: typeof JestedLayoutB3Import + preLoaderRoute: typeof JestedLayoutB3LayoutC2RouteImport + parentRoute: typeof JestedLayoutB3RouteImport } '/jested/_layout-b4/foo': { id: '/jested/_layout-b4/foo' path: '/foo' fullPath: '/jested/foo' - preLoaderRoute: typeof JestedLayoutB4FooImport - parentRoute: typeof JestedLayoutB4Import + preLoaderRoute: typeof JestedLayoutB4FooRouteImport + parentRoute: typeof JestedLayoutB4RouteImport } '/nested/_layout-b1/_layout-c1': { id: '/nested/_layout-b1/_layout-c1' path: '' fullPath: '/nested' - preLoaderRoute: typeof NestedLayoutB1LayoutC1Import - parentRoute: typeof NestedLayoutB1Import + preLoaderRoute: typeof NestedLayoutB1LayoutC1RouteImport + parentRoute: typeof NestedLayoutB1RouteImport } '/nested/_layout-b2/foo': { id: '/nested/_layout-b2/foo' path: '/foo' fullPath: '/nested/foo' - preLoaderRoute: typeof NestedLayoutB2FooImport - parentRoute: typeof NestedLayoutB2Import + preLoaderRoute: typeof NestedLayoutB2FooRouteImport + parentRoute: typeof NestedLayoutB2RouteImport } '/foo/_layout-b5/': { id: '/foo/_layout-b5/' path: '/' fullPath: '/foo/' - preLoaderRoute: typeof FooLayoutB5IndexImport - parentRoute: typeof FooLayoutB5RouteImport + preLoaderRoute: typeof FooLayoutB5IndexRouteImport + parentRoute: typeof FooLayoutB5RouteRouteImport } '/jested/_layout-b3/': { id: '/jested/_layout-b3/' path: '/' fullPath: '/jested/' - preLoaderRoute: typeof JestedLayoutB3IndexImport - parentRoute: typeof JestedLayoutB3Import + preLoaderRoute: typeof JestedLayoutB3IndexRouteImport + parentRoute: typeof JestedLayoutB3RouteImport } '/nested/_layout-b1/': { id: '/nested/_layout-b1/' path: '/' fullPath: '/nested/' - preLoaderRoute: typeof NestedLayoutB1IndexImport - parentRoute: typeof NestedLayoutB1Import + preLoaderRoute: typeof NestedLayoutB1IndexRouteImport + parentRoute: typeof NestedLayoutB1RouteImport } '/jested/_layout-b3/_layout-c2/bar': { id: '/jested/_layout-b3/_layout-c2/bar' path: '/bar' fullPath: '/jested/bar' - preLoaderRoute: typeof JestedLayoutB3LayoutC2BarImport - parentRoute: typeof JestedLayoutB3LayoutC2Import + preLoaderRoute: typeof JestedLayoutB3LayoutC2BarRouteImport + parentRoute: typeof JestedLayoutB3LayoutC2RouteImport } '/nested/_layout-b1/_layout-c1/bar': { id: '/nested/_layout-b1/_layout-c1/bar' path: '/bar' fullPath: '/nested/bar' - preLoaderRoute: typeof NestedLayoutB1LayoutC1BarImport - parentRoute: typeof NestedLayoutB1LayoutC1Import + preLoaderRoute: typeof NestedLayoutB1LayoutC1BarRouteImport + parentRoute: typeof NestedLayoutB1LayoutC1RouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/jested/route' { + const createFileRoute: CreateFileRoute< + '/jested', + FileRoutesByPath['/jested']['parentRoute'], + FileRoutesByPath['/jested']['id'], + FileRoutesByPath['/jested']['path'], + FileRoutesByPath['/jested']['fullPath'] + > +} +declare module './routes/_layout-a1' { + const createFileRoute: CreateFileRoute< + '/_layout-a1', + FileRoutesByPath['/_layout-a1']['parentRoute'], + FileRoutesByPath['/_layout-a1']['id'], + FileRoutesByPath['/_layout-a1']['path'], + FileRoutesByPath['/_layout-a1']['fullPath'] + > +} +declare module './routes/_layout-a2' { + const createFileRoute: CreateFileRoute< + '/_layout-a2', + FileRoutesByPath['/_layout-a2']['parentRoute'], + FileRoutesByPath['/_layout-a2']['id'], + FileRoutesByPath['/_layout-a2']['path'], + FileRoutesByPath['/_layout-a2']['fullPath'] + > +} +declare module './routes/foo/_layout-b5' { + const createFileRoute: CreateFileRoute< + '/foo', + FileRoutesByPath['/foo']['parentRoute'], + FileRoutesByPath['/foo']['id'], + FileRoutesByPath['/foo']['path'], + FileRoutesByPath['/foo']['fullPath'] + > +} +declare module './routes/foo/_layout-b5/route' { + const createFileRoute: CreateFileRoute< + '/foo/_layout-b5', + FileRoutesByPath['/foo/_layout-b5']['parentRoute'], + FileRoutesByPath['/foo/_layout-b5']['id'], + FileRoutesByPath['/foo/_layout-b5']['path'], + FileRoutesByPath['/foo/_layout-b5']['fullPath'] + > +} +declare module './routes/(folder)/in-folder' { + const createFileRoute: CreateFileRoute< + '/(folder)/in-folder', + FileRoutesByPath['/(folder)/in-folder']['parentRoute'], + FileRoutesByPath['/(folder)/in-folder']['id'], + FileRoutesByPath['/(folder)/in-folder']['path'], + FileRoutesByPath['/(folder)/in-folder']['fullPath'] + > +} +declare module './routes/_layout-a1/foo' { + const createFileRoute: CreateFileRoute< + '/_layout-a1/foo', + FileRoutesByPath['/_layout-a1/foo']['parentRoute'], + FileRoutesByPath['/_layout-a1/foo']['id'], + FileRoutesByPath['/_layout-a1/foo']['path'], + FileRoutesByPath['/_layout-a1/foo']['fullPath'] + > +} +declare module './routes/_layout-a2/bar' { + const createFileRoute: CreateFileRoute< + '/_layout-a2/bar', + FileRoutesByPath['/_layout-a2/bar']['parentRoute'], + FileRoutesByPath['/_layout-a2/bar']['id'], + FileRoutesByPath['/_layout-a2/bar']['path'], + FileRoutesByPath['/_layout-a2/bar']['fullPath'] + > +} +declare module './routes/foo/bar' { + const createFileRoute: CreateFileRoute< + '/foo/bar', + FileRoutesByPath['/foo/bar']['parentRoute'], + FileRoutesByPath['/foo/bar']['id'], + FileRoutesByPath['/foo/bar']['path'], + FileRoutesByPath['/foo/bar']['fullPath'] + > +} +declare module './routes/jested/_layout-b3' { + const createFileRoute: CreateFileRoute< + '/jested/_layout-b3', + FileRoutesByPath['/jested/_layout-b3']['parentRoute'], + FileRoutesByPath['/jested/_layout-b3']['id'], + FileRoutesByPath['/jested/_layout-b3']['path'], + FileRoutesByPath['/jested/_layout-b3']['fullPath'] + > +} +declare module './routes/jested/_layout-b4' { + const createFileRoute: CreateFileRoute< + '/jested/_layout-b4', + FileRoutesByPath['/jested/_layout-b4']['parentRoute'], + FileRoutesByPath['/jested/_layout-b4']['id'], + FileRoutesByPath['/jested/_layout-b4']['path'], + FileRoutesByPath['/jested/_layout-b4']['fullPath'] + > +} +declare module './routes/nested' { + const createFileRoute: CreateFileRoute< + '/nested', + FileRoutesByPath['/nested']['parentRoute'], + FileRoutesByPath['/nested']['id'], + FileRoutesByPath['/nested']['path'], + FileRoutesByPath['/nested']['fullPath'] + > +} +declare module './routes/nested/_layout-b1' { + const createFileRoute: CreateFileRoute< + '/nested/_layout-b1', + FileRoutesByPath['/nested/_layout-b1']['parentRoute'], + FileRoutesByPath['/nested/_layout-b1']['id'], + FileRoutesByPath['/nested/_layout-b1']['path'], + FileRoutesByPath['/nested/_layout-b1']['fullPath'] + > +} +declare module './routes/nested/_layout-b2' { + const createFileRoute: CreateFileRoute< + '/nested/_layout-b2', + FileRoutesByPath['/nested/_layout-b2']['parentRoute'], + FileRoutesByPath['/nested/_layout-b2']['id'], + FileRoutesByPath['/nested/_layout-b2']['path'], + FileRoutesByPath['/nested/_layout-b2']['fullPath'] + > +} +declare module './routes/foo/_layout-b5/$id' { + const createFileRoute: CreateFileRoute< + '/foo/_layout-b5/$id', + FileRoutesByPath['/foo/_layout-b5/$id']['parentRoute'], + FileRoutesByPath['/foo/_layout-b5/$id']['id'], + FileRoutesByPath['/foo/_layout-b5/$id']['path'], + FileRoutesByPath['/foo/_layout-b5/$id']['fullPath'] + > +} +declare module './routes/jested/_layout-b3/_layout-c2' { + const createFileRoute: CreateFileRoute< + '/jested/_layout-b3/_layout-c2', + FileRoutesByPath['/jested/_layout-b3/_layout-c2']['parentRoute'], + FileRoutesByPath['/jested/_layout-b3/_layout-c2']['id'], + FileRoutesByPath['/jested/_layout-b3/_layout-c2']['path'], + FileRoutesByPath['/jested/_layout-b3/_layout-c2']['fullPath'] + > +} +declare module './routes/jested/_layout-b4/foo' { + const createFileRoute: CreateFileRoute< + '/jested/_layout-b4/foo', + FileRoutesByPath['/jested/_layout-b4/foo']['parentRoute'], + FileRoutesByPath['/jested/_layout-b4/foo']['id'], + FileRoutesByPath['/jested/_layout-b4/foo']['path'], + FileRoutesByPath['/jested/_layout-b4/foo']['fullPath'] + > +} +declare module './routes/nested/_layout-b1/_layout-c1' { + const createFileRoute: CreateFileRoute< + '/nested/_layout-b1/_layout-c1', + FileRoutesByPath['/nested/_layout-b1/_layout-c1']['parentRoute'], + FileRoutesByPath['/nested/_layout-b1/_layout-c1']['id'], + FileRoutesByPath['/nested/_layout-b1/_layout-c1']['path'], + FileRoutesByPath['/nested/_layout-b1/_layout-c1']['fullPath'] + > +} +declare module './routes/nested/_layout-b2/foo' { + const createFileRoute: CreateFileRoute< + '/nested/_layout-b2/foo', + FileRoutesByPath['/nested/_layout-b2/foo']['parentRoute'], + FileRoutesByPath['/nested/_layout-b2/foo']['id'], + FileRoutesByPath['/nested/_layout-b2/foo']['path'], + FileRoutesByPath['/nested/_layout-b2/foo']['fullPath'] + > +} +declare module './routes/foo/_layout-b5/index' { + const createFileRoute: CreateFileRoute< + '/foo/_layout-b5/', + FileRoutesByPath['/foo/_layout-b5/']['parentRoute'], + FileRoutesByPath['/foo/_layout-b5/']['id'], + FileRoutesByPath['/foo/_layout-b5/']['path'], + FileRoutesByPath['/foo/_layout-b5/']['fullPath'] + > +} +declare module './routes/jested/_layout-b3/index' { + const createFileRoute: CreateFileRoute< + '/jested/_layout-b3/', + FileRoutesByPath['/jested/_layout-b3/']['parentRoute'], + FileRoutesByPath['/jested/_layout-b3/']['id'], + FileRoutesByPath['/jested/_layout-b3/']['path'], + FileRoutesByPath['/jested/_layout-b3/']['fullPath'] + > +} +declare module './routes/nested/_layout-b1/index' { + const createFileRoute: CreateFileRoute< + '/nested/_layout-b1/', + FileRoutesByPath['/nested/_layout-b1/']['parentRoute'], + FileRoutesByPath['/nested/_layout-b1/']['id'], + FileRoutesByPath['/nested/_layout-b1/']['path'], + FileRoutesByPath['/nested/_layout-b1/']['fullPath'] + > +} +declare module './routes/jested/_layout-b3/_layout-c2/bar' { + const createFileRoute: CreateFileRoute< + '/jested/_layout-b3/_layout-c2/bar', + FileRoutesByPath['/jested/_layout-b3/_layout-c2/bar']['parentRoute'], + FileRoutesByPath['/jested/_layout-b3/_layout-c2/bar']['id'], + FileRoutesByPath['/jested/_layout-b3/_layout-c2/bar']['path'], + FileRoutesByPath['/jested/_layout-b3/_layout-c2/bar']['fullPath'] + > +} +declare module './routes/nested/_layout-b1/_layout-c1/bar' { + const createFileRoute: CreateFileRoute< + '/nested/_layout-b1/_layout-c1/bar', + FileRoutesByPath['/nested/_layout-b1/_layout-c1/bar']['parentRoute'], + FileRoutesByPath['/nested/_layout-b1/_layout-c1/bar']['id'], + FileRoutesByPath['/nested/_layout-b1/_layout-c1/bar']['path'], + FileRoutesByPath['/nested/_layout-b1/_layout-c1/bar']['fullPath'] + > +} + // Create and export the route tree interface JestedLayoutB3LayoutC2RouteChildren { @@ -677,6 +908,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/(folder)/in-folder.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/(folder)/in-folder.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/(folder)/in-folder.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/(folder)/in-folder.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/__root.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/__root.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/__root.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/__root.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a1.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a1.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a1.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a1.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a1/foo.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a1/foo.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a1/foo.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a1/foo.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a2.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a2.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a2.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a2.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a2/bar.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a2/bar.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a2/bar.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/_layout-a2/bar.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/foo/_layout-b5/$id.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/foo/_layout-b5/$id.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/foo/_layout-b5/$id.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/foo/_layout-b5/$id.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/foo/_layout-b5/index.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/foo/_layout-b5/index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/foo/_layout-b5/index.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/foo/_layout-b5/index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/foo/_layout-b5/route.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/foo/_layout-b5/route.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/foo/_layout-b5/route.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/foo/_layout-b5/route.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/foo/bar.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/foo/bar.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/foo/bar.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/foo/bar.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/index.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/index.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3/_layout-c2.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3/_layout-c2.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3/_layout-c2.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3/_layout-c2.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3/_layout-c2/bar.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3/_layout-c2/bar.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3/_layout-c2/bar.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3/_layout-c2/bar.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3/index.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3/index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3/index.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b3/index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b4.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b4.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b4.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b4.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b4/foo.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b4/foo.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b4/foo.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/jested/_layout-b4/foo.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/jested/route.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/jested/route.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/jested/route.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/jested/route.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1/_layout-c1.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1/_layout-c1.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1/_layout-c1.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1/_layout-c1.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1/_layout-c1/bar.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1/_layout-c1/bar.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1/_layout-c1/bar.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1/_layout-c1/bar.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1/index.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1/index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1/index.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b1/index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b2.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b2.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b2.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b2.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b2/foo.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b2/foo.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b2/foo.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/nested/_layout-b2/foo.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routeTree.snapshot.ts b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routeTree.snapshot.ts index 9a8c43334d..eb36287611 100644 --- a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routeTree.snapshot.ts @@ -12,72 +12,73 @@ import { createFileRoute } from '@tanstack/react-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as groupCLayoutCImport } from './routes/(group-c)/_layout-c' -import { Route as groupBLayoutBImport } from './routes/(group-b)/_layout-b' -import { Route as groupALayoutAImport } from './routes/(group-a)/_layout-a' -import { Route as groupCLayoutCIndexImport } from './routes/(group-c)/_layout-c/index' -import { Route as groupBLayoutBDashboardImport } from './routes/(group-b)/_layout-b/dashboard' -import { Route as groupALayoutASignupImport } from './routes/(group-a)/_layout-a/signup' -import { Route as groupALayoutALoginImport } from './routes/(group-a)/_layout-a/login' +import { Route as groupCLayoutCRouteImport } from './routes/(group-c)/_layout-c' +import { Route as groupBLayoutBRouteImport } from './routes/(group-b)/_layout-b' +import { Route as groupALayoutARouteImport } from './routes/(group-a)/_layout-a' +import { Route as groupCLayoutCIndexRouteImport } from './routes/(group-c)/_layout-c/index' +import { Route as groupBLayoutBDashboardRouteImport } from './routes/(group-b)/_layout-b/dashboard' +import { Route as groupALayoutASignupRouteImport } from './routes/(group-a)/_layout-a/signup' +import { Route as groupALayoutALoginRouteImport } from './routes/(group-a)/_layout-a/login' // Create Virtual Routes -const groupCImport = createFileRoute('/(group-c)')() -const groupBImport = createFileRoute('/(group-b)')() -const groupAImport = createFileRoute('/(group-a)')() +const groupCRouteImport = createFileRoute('/(group-c)')() +const groupBRouteImport = createFileRoute('/(group-b)')() +const groupARouteImport = createFileRoute('/(group-a)')() // Create/Update Routes -const groupCRoute = groupCImport.update({ +const groupCRoute = groupCRouteImport.update({ id: '/(group-c)', getParentRoute: () => rootRoute, } as any) -const groupBRoute = groupBImport.update({ +const groupBRoute = groupBRouteImport.update({ id: '/(group-b)', getParentRoute: () => rootRoute, } as any) -const groupARoute = groupAImport.update({ +const groupARoute = groupARouteImport.update({ id: '/(group-a)', getParentRoute: () => rootRoute, } as any) -const groupCLayoutCRoute = groupCLayoutCImport.update({ +const groupCLayoutCRoute = groupCLayoutCRouteImport.update({ id: '/_layout-c', getParentRoute: () => groupCRoute, } as any) -const groupBLayoutBRoute = groupBLayoutBImport.update({ +const groupBLayoutBRoute = groupBLayoutBRouteImport.update({ id: '/_layout-b', getParentRoute: () => groupBRoute, } as any) -const groupALayoutARoute = groupALayoutAImport.update({ +const groupALayoutARoute = groupALayoutARouteImport.update({ id: '/_layout-a', getParentRoute: () => groupARoute, } as any) -const groupCLayoutCIndexRoute = groupCLayoutCIndexImport.update({ +const groupCLayoutCIndexRoute = groupCLayoutCIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => groupCLayoutCRoute, } as any) -const groupBLayoutBDashboardRoute = groupBLayoutBDashboardImport.update({ +const groupBLayoutBDashboardRoute = groupBLayoutBDashboardRouteImport.update({ id: '/dashboard', path: '/dashboard', getParentRoute: () => groupBLayoutBRoute, } as any) -const groupALayoutASignupRoute = groupALayoutASignupImport.update({ +const groupALayoutASignupRoute = groupALayoutASignupRouteImport.update({ id: '/signup', path: '/signup', getParentRoute: () => groupALayoutARoute, } as any) -const groupALayoutALoginRoute = groupALayoutALoginImport.update({ +const groupALayoutALoginRoute = groupALayoutALoginRouteImport.update({ id: '/login', path: '/login', getParentRoute: () => groupALayoutARoute, @@ -91,75 +92,168 @@ declare module '@tanstack/react-router' { id: '/(group-a)' path: '/' fullPath: '/' - preLoaderRoute: typeof groupAImport + preLoaderRoute: typeof groupARouteImport parentRoute: typeof rootRoute } '/(group-a)/_layout-a': { id: '/(group-a)/_layout-a' path: '/' fullPath: '/' - preLoaderRoute: typeof groupALayoutAImport + preLoaderRoute: typeof groupALayoutARouteImport parentRoute: typeof groupARoute } '/(group-b)': { id: '/(group-b)' path: '/' fullPath: '/' - preLoaderRoute: typeof groupBImport + preLoaderRoute: typeof groupBRouteImport parentRoute: typeof rootRoute } '/(group-b)/_layout-b': { id: '/(group-b)/_layout-b' path: '/' fullPath: '/' - preLoaderRoute: typeof groupBLayoutBImport + preLoaderRoute: typeof groupBLayoutBRouteImport parentRoute: typeof groupBRoute } '/(group-c)': { id: '/(group-c)' path: '/' fullPath: '/' - preLoaderRoute: typeof groupCImport + preLoaderRoute: typeof groupCRouteImport parentRoute: typeof rootRoute } '/(group-c)/_layout-c': { id: '/(group-c)/_layout-c' path: '/' fullPath: '/' - preLoaderRoute: typeof groupCLayoutCImport + preLoaderRoute: typeof groupCLayoutCRouteImport parentRoute: typeof groupCRoute } '/(group-a)/_layout-a/login': { id: '/(group-a)/_layout-a/login' path: '/login' fullPath: '/login' - preLoaderRoute: typeof groupALayoutALoginImport - parentRoute: typeof groupALayoutAImport + preLoaderRoute: typeof groupALayoutALoginRouteImport + parentRoute: typeof groupALayoutARouteImport } '/(group-a)/_layout-a/signup': { id: '/(group-a)/_layout-a/signup' path: '/signup' fullPath: '/signup' - preLoaderRoute: typeof groupALayoutASignupImport - parentRoute: typeof groupALayoutAImport + preLoaderRoute: typeof groupALayoutASignupRouteImport + parentRoute: typeof groupALayoutARouteImport } '/(group-b)/_layout-b/dashboard': { id: '/(group-b)/_layout-b/dashboard' path: '/dashboard' fullPath: '/dashboard' - preLoaderRoute: typeof groupBLayoutBDashboardImport - parentRoute: typeof groupBLayoutBImport + preLoaderRoute: typeof groupBLayoutBDashboardRouteImport + parentRoute: typeof groupBLayoutBRouteImport } '/(group-c)/_layout-c/': { id: '/(group-c)/_layout-c/' path: '/' fullPath: '/' - preLoaderRoute: typeof groupCLayoutCIndexImport - parentRoute: typeof groupCLayoutCImport + preLoaderRoute: typeof groupCLayoutCIndexRouteImport + parentRoute: typeof groupCLayoutCRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/(group-a)' { + const createFileRoute: CreateFileRoute< + '/(group-a)', + FileRoutesByPath['/(group-a)']['parentRoute'], + FileRoutesByPath['/(group-a)']['id'], + FileRoutesByPath['/(group-a)']['path'], + FileRoutesByPath['/(group-a)']['fullPath'] + > +} +declare module './routes/(group-a)/_layout-a' { + const createFileRoute: CreateFileRoute< + '/(group-a)/_layout-a', + FileRoutesByPath['/(group-a)/_layout-a']['parentRoute'], + FileRoutesByPath['/(group-a)/_layout-a']['id'], + FileRoutesByPath['/(group-a)/_layout-a']['path'], + FileRoutesByPath['/(group-a)/_layout-a']['fullPath'] + > +} +declare module './routes/(group-b)' { + const createFileRoute: CreateFileRoute< + '/(group-b)', + FileRoutesByPath['/(group-b)']['parentRoute'], + FileRoutesByPath['/(group-b)']['id'], + FileRoutesByPath['/(group-b)']['path'], + FileRoutesByPath['/(group-b)']['fullPath'] + > +} +declare module './routes/(group-b)/_layout-b' { + const createFileRoute: CreateFileRoute< + '/(group-b)/_layout-b', + FileRoutesByPath['/(group-b)/_layout-b']['parentRoute'], + FileRoutesByPath['/(group-b)/_layout-b']['id'], + FileRoutesByPath['/(group-b)/_layout-b']['path'], + FileRoutesByPath['/(group-b)/_layout-b']['fullPath'] + > +} +declare module './routes/(group-c)' { + const createFileRoute: CreateFileRoute< + '/(group-c)', + FileRoutesByPath['/(group-c)']['parentRoute'], + FileRoutesByPath['/(group-c)']['id'], + FileRoutesByPath['/(group-c)']['path'], + FileRoutesByPath['/(group-c)']['fullPath'] + > +} +declare module './routes/(group-c)/_layout-c' { + const createFileRoute: CreateFileRoute< + '/(group-c)/_layout-c', + FileRoutesByPath['/(group-c)/_layout-c']['parentRoute'], + FileRoutesByPath['/(group-c)/_layout-c']['id'], + FileRoutesByPath['/(group-c)/_layout-c']['path'], + FileRoutesByPath['/(group-c)/_layout-c']['fullPath'] + > +} +declare module './routes/(group-a)/_layout-a/login' { + const createFileRoute: CreateFileRoute< + '/(group-a)/_layout-a/login', + FileRoutesByPath['/(group-a)/_layout-a/login']['parentRoute'], + FileRoutesByPath['/(group-a)/_layout-a/login']['id'], + FileRoutesByPath['/(group-a)/_layout-a/login']['path'], + FileRoutesByPath['/(group-a)/_layout-a/login']['fullPath'] + > +} +declare module './routes/(group-a)/_layout-a/signup' { + const createFileRoute: CreateFileRoute< + '/(group-a)/_layout-a/signup', + FileRoutesByPath['/(group-a)/_layout-a/signup']['parentRoute'], + FileRoutesByPath['/(group-a)/_layout-a/signup']['id'], + FileRoutesByPath['/(group-a)/_layout-a/signup']['path'], + FileRoutesByPath['/(group-a)/_layout-a/signup']['fullPath'] + > +} +declare module './routes/(group-b)/_layout-b/dashboard' { + const createFileRoute: CreateFileRoute< + '/(group-b)/_layout-b/dashboard', + FileRoutesByPath['/(group-b)/_layout-b/dashboard']['parentRoute'], + FileRoutesByPath['/(group-b)/_layout-b/dashboard']['id'], + FileRoutesByPath['/(group-b)/_layout-b/dashboard']['path'], + FileRoutesByPath['/(group-b)/_layout-b/dashboard']['fullPath'] + > +} +declare module './routes/(group-c)/_layout-c/index' { + const createFileRoute: CreateFileRoute< + '/(group-c)/_layout-c/', + FileRoutesByPath['/(group-c)/_layout-c/']['parentRoute'], + FileRoutesByPath['/(group-c)/_layout-c/']['id'], + FileRoutesByPath['/(group-c)/_layout-c/']['path'], + FileRoutesByPath['/(group-c)/_layout-c/']['fullPath'] + > +} + // Create and export the route tree interface groupALayoutARouteChildren { @@ -297,6 +391,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-a)/_layout-a.tsx b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-a)/_layout-a.tsx index e41597bd14..7716800144 100644 --- a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-a)/_layout-a.tsx +++ b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-a)/_layout-a.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(group-a)/_layout-a')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-a)/_layout-a/login.tsx b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-a)/_layout-a/login.tsx index 100a98b815..81dfefe2c4 100644 --- a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-a)/_layout-a/login.tsx +++ b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-a)/_layout-a/login.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(group-a)/_layout-a/login')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-a)/_layout-a/signup.tsx b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-a)/_layout-a/signup.tsx index 2214d268e7..705cfd12d6 100644 --- a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-a)/_layout-a/signup.tsx +++ b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-a)/_layout-a/signup.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(group-a)/_layout-a/signup')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-b)/_layout-b.tsx b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-b)/_layout-b.tsx index 9dc9043617..66bad5884c 100644 --- a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-b)/_layout-b.tsx +++ b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-b)/_layout-b.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(group-b)/_layout-b')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-b)/_layout-b/dashboard.tsx b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-b)/_layout-b/dashboard.tsx index c265a00158..5e70c639ea 100644 --- a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-b)/_layout-b/dashboard.tsx +++ b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-b)/_layout-b/dashboard.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(group-b)/_layout-b/dashboard')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-c)/_layout-c.tsx b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-c)/_layout-c.tsx index 37483d2b5d..de71033181 100644 --- a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-c)/_layout-c.tsx +++ b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-c)/_layout-c.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(group-c)/_layout-c')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-c)/_layout-c/index.tsx b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-c)/_layout-c/index.tsx index 31a16f0515..cac65fa5c4 100644 --- a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-c)/_layout-c/index.tsx +++ b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routes/(group-c)/_layout-c/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(group-c)/_layout-c/')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/nested/routeTree.snapshot.ts b/packages/router-generator/tests/generator/nested/routeTree.snapshot.ts index 49498ae411..48e53175e4 100644 --- a/packages/router-generator/tests/generator/nested/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/nested/routeTree.snapshot.ts @@ -10,68 +10,69 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostsRouteImport } from './routes/posts/route' -import { Route as BlogRouteImport } from './routes/blog/route' -import { Route as IndexImport } from './routes/index' -import { Route as PostsIndexImport } from './routes/posts/index' -import { Route as BlogIndexImport } from './routes/blog/index' -import { Route as BlogStatsImport } from './routes/blog_/stats' -import { Route as BlogSlugImport } from './routes/blog/$slug' -import { Route as PostsPostIdIndexImport } from './routes/posts/$postId/index' -import { Route as PostsPostIdDeepImport } from './routes/posts/$postId/deep' +import { Route as PostsRouteRouteImport } from './routes/posts/route' +import { Route as BlogRouteRouteImport } from './routes/blog/route' +import { Route as IndexRouteImport } from './routes/index' +import { Route as PostsIndexRouteImport } from './routes/posts/index' +import { Route as BlogIndexRouteImport } from './routes/blog/index' +import { Route as BlogStatsRouteImport } from './routes/blog_/stats' +import { Route as BlogSlugRouteImport } from './routes/blog/$slug' +import { Route as PostsPostIdIndexRouteImport } from './routes/posts/$postId/index' +import { Route as PostsPostIdDeepRouteImport } from './routes/posts/$postId/deep' // Create/Update Routes -const PostsRouteRoute = PostsRouteImport.update({ +const PostsRouteRoute = PostsRouteRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const BlogRouteRoute = BlogRouteImport.update({ +const BlogRouteRoute = BlogRouteRouteImport.update({ id: '/blog', path: '/blog', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const PostsIndexRoute = PostsIndexImport.update({ +const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => PostsRouteRoute, } as any) -const BlogIndexRoute = BlogIndexImport.update({ +const BlogIndexRoute = BlogIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => BlogRouteRoute, } as any) -const BlogStatsRoute = BlogStatsImport.update({ +const BlogStatsRoute = BlogStatsRouteImport.update({ id: '/blog_/stats', path: '/blog/stats', getParentRoute: () => rootRoute, } as any) -const BlogSlugRoute = BlogSlugImport.update({ +const BlogSlugRoute = BlogSlugRouteImport.update({ id: '/$slug', path: '/$slug', getParentRoute: () => BlogRouteRoute, } as any) -const PostsPostIdIndexRoute = PostsPostIdIndexImport.update({ +const PostsPostIdIndexRoute = PostsPostIdIndexRouteImport.update({ id: '/$postId/', path: '/$postId/', getParentRoute: () => PostsRouteRoute, } as any) -const PostsPostIdDeepRoute = PostsPostIdDeepImport.update({ +const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ id: '/$postId/deep', path: '/$postId/deep', getParentRoute: () => PostsRouteRoute, @@ -85,68 +86,152 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/blog': { id: '/blog' path: '/blog' fullPath: '/blog' - preLoaderRoute: typeof BlogRouteImport + preLoaderRoute: typeof BlogRouteRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsRouteRouteImport parentRoute: typeof rootRoute } '/blog/$slug': { id: '/blog/$slug' path: '/$slug' fullPath: '/blog/$slug' - preLoaderRoute: typeof BlogSlugImport - parentRoute: typeof BlogRouteImport + preLoaderRoute: typeof BlogSlugRouteImport + parentRoute: typeof BlogRouteRouteImport } '/blog_/stats': { id: '/blog_/stats' path: '/blog/stats' fullPath: '/blog/stats' - preLoaderRoute: typeof BlogStatsImport + preLoaderRoute: typeof BlogStatsRouteImport parentRoute: typeof rootRoute } '/blog/': { id: '/blog/' path: '/' fullPath: '/blog/' - preLoaderRoute: typeof BlogIndexImport - parentRoute: typeof BlogRouteImport + preLoaderRoute: typeof BlogIndexRouteImport + parentRoute: typeof BlogRouteRouteImport } '/posts/': { id: '/posts/' path: '/' fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsIndexRouteImport + parentRoute: typeof PostsRouteRouteImport } '/posts/$postId/deep': { id: '/posts/$postId/deep' path: '/$postId/deep' fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsPostIdDeepRouteImport + parentRoute: typeof PostsRouteRouteImport } '/posts/$postId/': { id: '/posts/$postId/' path: '/$postId' fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdIndexImport - parentRoute: typeof PostsRouteImport + preLoaderRoute: typeof PostsPostIdIndexRouteImport + parentRoute: typeof PostsRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/blog/route' { + const createFileRoute: CreateFileRoute< + '/blog', + FileRoutesByPath['/blog']['parentRoute'], + FileRoutesByPath['/blog']['id'], + FileRoutesByPath['/blog']['path'], + FileRoutesByPath['/blog']['fullPath'] + > +} +declare module './routes/posts/route' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} +declare module './routes/blog/$slug' { + const createFileRoute: CreateFileRoute< + '/blog/$slug', + FileRoutesByPath['/blog/$slug']['parentRoute'], + FileRoutesByPath['/blog/$slug']['id'], + FileRoutesByPath['/blog/$slug']['path'], + FileRoutesByPath['/blog/$slug']['fullPath'] + > +} +declare module './routes/blog_/stats' { + const createFileRoute: CreateFileRoute< + '/blog_/stats', + FileRoutesByPath['/blog_/stats']['parentRoute'], + FileRoutesByPath['/blog_/stats']['id'], + FileRoutesByPath['/blog_/stats']['path'], + FileRoutesByPath['/blog_/stats']['fullPath'] + > +} +declare module './routes/blog/index' { + const createFileRoute: CreateFileRoute< + '/blog/', + FileRoutesByPath['/blog/']['parentRoute'], + FileRoutesByPath['/blog/']['id'], + FileRoutesByPath['/blog/']['path'], + FileRoutesByPath['/blog/']['fullPath'] + > +} +declare module './routes/posts/index' { + const createFileRoute: CreateFileRoute< + '/posts/', + FileRoutesByPath['/posts/']['parentRoute'], + FileRoutesByPath['/posts/']['id'], + FileRoutesByPath['/posts/']['path'], + FileRoutesByPath['/posts/']['fullPath'] + > +} +declare module './routes/posts/$postId/deep' { + const createFileRoute: CreateFileRoute< + '/posts/$postId/deep', + FileRoutesByPath['/posts/$postId/deep']['parentRoute'], + FileRoutesByPath['/posts/$postId/deep']['id'], + FileRoutesByPath['/posts/$postId/deep']['path'], + FileRoutesByPath['/posts/$postId/deep']['fullPath'] + > +} +declare module './routes/posts/$postId/index' { + const createFileRoute: CreateFileRoute< + '/posts/$postId/', + FileRoutesByPath['/posts/$postId/']['parentRoute'], + FileRoutesByPath['/posts/$postId/']['id'], + FileRoutesByPath['/posts/$postId/']['path'], + FileRoutesByPath['/posts/$postId/']['fullPath'] + > +} + // Create and export the route tree interface BlogRouteRouteChildren { @@ -267,6 +352,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/nested/routes/blog/$slug.tsx b/packages/router-generator/tests/generator/nested/routes/blog/$slug.tsx index 0389370c39..784c2b78ae 100644 --- a/packages/router-generator/tests/generator/nested/routes/blog/$slug.tsx +++ b/packages/router-generator/tests/generator/nested/routes/blog/$slug.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/blog/$slug')({ +export const Route = createFileRoute({ component: () =>
Hello /blog/$slug!
, }) diff --git a/packages/router-generator/tests/generator/nested/routes/blog/index.tsx b/packages/router-generator/tests/generator/nested/routes/blog/index.tsx index 6fab51efb1..0754024ed7 100644 --- a/packages/router-generator/tests/generator/nested/routes/blog/index.tsx +++ b/packages/router-generator/tests/generator/nested/routes/blog/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/blog/')({ +export const Route = createFileRoute({ component: () =>
Hello /blog/!
, }) diff --git a/packages/router-generator/tests/generator/nested/routes/blog/route.tsx b/packages/router-generator/tests/generator/nested/routes/blog/route.tsx index 2833fcc588..ea94edad49 100644 --- a/packages/router-generator/tests/generator/nested/routes/blog/route.tsx +++ b/packages/router-generator/tests/generator/nested/routes/blog/route.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/blog')({ +export const Route = createFileRoute({ component: () =>
Hello /blog!
, }) diff --git a/packages/router-generator/tests/generator/nested/routes/blog_/stats.tsx b/packages/router-generator/tests/generator/nested/routes/blog_/stats.tsx index 3c7f60dc99..16cc7268df 100644 --- a/packages/router-generator/tests/generator/nested/routes/blog_/stats.tsx +++ b/packages/router-generator/tests/generator/nested/routes/blog_/stats.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/blog_/stats')({ +export const Route = createFileRoute({ component: () =>
Hello /blog/stats!
, }) diff --git a/packages/router-generator/tests/generator/nested/routes/index.tsx b/packages/router-generator/tests/generator/nested/routes/index.tsx index a680913ded..22cab82307 100644 --- a/packages/router-generator/tests/generator/nested/routes/index.tsx +++ b/packages/router-generator/tests/generator/nested/routes/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: () =>
Hello /!
, }) diff --git a/packages/router-generator/tests/generator/nested/routes/posts/$postId/deep.tsx b/packages/router-generator/tests/generator/nested/routes/posts/$postId/deep.tsx index eec00feafc..6e634d9098 100644 --- a/packages/router-generator/tests/generator/nested/routes/posts/$postId/deep.tsx +++ b/packages/router-generator/tests/generator/nested/routes/posts/$postId/deep.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/$postId/deep')({ +export const Route = createFileRoute({ context: () => ({ someContext: 'context' }), loaderDeps: () => ({ dep: 1 }), loader: () => ({ data: 'data' }), diff --git a/packages/router-generator/tests/generator/nested/routes/posts/$postId/index.tsx b/packages/router-generator/tests/generator/nested/routes/posts/$postId/index.tsx index 1f0f31b0b2..6e8e65dae7 100644 --- a/packages/router-generator/tests/generator/nested/routes/posts/$postId/index.tsx +++ b/packages/router-generator/tests/generator/nested/routes/posts/$postId/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/$postId/')({ +export const Route = createFileRoute({ validateSearch: () => ({ indexSearch: 'search', }), diff --git a/packages/router-generator/tests/generator/nested/routes/posts/index.tsx b/packages/router-generator/tests/generator/nested/routes/posts/index.tsx index f3c995416c..2e16af1ca1 100644 --- a/packages/router-generator/tests/generator/nested/routes/posts/index.tsx +++ b/packages/router-generator/tests/generator/nested/routes/posts/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts/')({ +export const Route = createFileRoute({ component: () =>
Hello /posts/!
, }) diff --git a/packages/router-generator/tests/generator/nested/routes/posts/route.tsx b/packages/router-generator/tests/generator/nested/routes/posts/route.tsx index c298ab4675..3617558181 100644 --- a/packages/router-generator/tests/generator/nested/routes/posts/route.tsx +++ b/packages/router-generator/tests/generator/nested/routes/posts/route.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ component: () =>
Hello /posts!
, }) diff --git a/packages/router-generator/tests/generator/no-duplicate-route-segment/routeTree.snapshot.ts b/packages/router-generator/tests/generator/no-duplicate-route-segment/routeTree.snapshot.ts index ed2a802515..f0d807ebb5 100644 --- a/packages/router-generator/tests/generator/no-duplicate-route-segment/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/no-duplicate-route-segment/routeTree.snapshot.ts @@ -12,28 +12,29 @@ import { createFileRoute } from '@tanstack/react-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as FooLayoutRouteImport } from './routes/foo/_layout/route' -import { Route as FooLayoutIndexImport } from './routes/foo/_layout/index' +import { Route as FooLayoutRouteRouteImport } from './routes/foo/_layout/route' +import { Route as FooLayoutIndexRouteImport } from './routes/foo/_layout/index' // Create Virtual Routes -const FooImport = createFileRoute('/foo')() +const FooRouteImport = createFileRoute('/foo')() // Create/Update Routes -const FooRoute = FooImport.update({ +const FooRoute = FooRouteImport.update({ id: '/foo', path: '/foo', getParentRoute: () => rootRoute, } as any) -const FooLayoutRouteRoute = FooLayoutRouteImport.update({ +const FooLayoutRouteRoute = FooLayoutRouteRouteImport.update({ id: '/_layout', getParentRoute: () => FooRoute, } as any) -const FooLayoutIndexRoute = FooLayoutIndexImport.update({ +const FooLayoutIndexRoute = FooLayoutIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => FooLayoutRouteRoute, @@ -47,26 +48,56 @@ declare module '@tanstack/react-router' { id: '/foo' path: '/foo' fullPath: '/foo' - preLoaderRoute: typeof FooImport + preLoaderRoute: typeof FooRouteImport parentRoute: typeof rootRoute } '/foo/_layout': { id: '/foo/_layout' path: '/foo' fullPath: '/foo' - preLoaderRoute: typeof FooLayoutRouteImport + preLoaderRoute: typeof FooLayoutRouteRouteImport parentRoute: typeof FooRoute } '/foo/_layout/': { id: '/foo/_layout/' path: '/' fullPath: '/foo/' - preLoaderRoute: typeof FooLayoutIndexImport - parentRoute: typeof FooLayoutRouteImport + preLoaderRoute: typeof FooLayoutIndexRouteImport + parentRoute: typeof FooLayoutRouteRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/foo/_layout' { + const createFileRoute: CreateFileRoute< + '/foo', + FileRoutesByPath['/foo']['parentRoute'], + FileRoutesByPath['/foo']['id'], + FileRoutesByPath['/foo']['path'], + FileRoutesByPath['/foo']['fullPath'] + > +} +declare module './routes/foo/_layout/route' { + const createFileRoute: CreateFileRoute< + '/foo/_layout', + FileRoutesByPath['/foo/_layout']['parentRoute'], + FileRoutesByPath['/foo/_layout']['id'], + FileRoutesByPath['/foo/_layout']['path'], + FileRoutesByPath['/foo/_layout']['fullPath'] + > +} +declare module './routes/foo/_layout/index' { + const createFileRoute: CreateFileRoute< + '/foo/_layout/', + FileRoutesByPath['/foo/_layout/']['parentRoute'], + FileRoutesByPath['/foo/_layout/']['id'], + FileRoutesByPath['/foo/_layout/']['path'], + FileRoutesByPath['/foo/_layout/']['fullPath'] + > +} + // Create and export the route tree interface FooLayoutRouteRouteChildren { @@ -128,6 +159,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/__root.tsx b/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/__root.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/__root.tsx +++ b/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/__root.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/foo/_layout/index.tsx b/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/foo/_layout/index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/foo/_layout/index.tsx +++ b/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/foo/_layout/index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/foo/_layout/route.tsx b/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/foo/_layout/route.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/foo/_layout/route.tsx +++ b/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/foo/_layout/route.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.snapshot.ts b/packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.snapshot.ts index 3caaefda94..fc011042dc 100644 --- a/packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.snapshot.ts @@ -10,22 +10,23 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' -import { Route as NestedIndexImport } from './routes/nested/index' -import { Route as NestedChildImport } from './routes/nested/child' +import { Route as IndexRouteImport } from './routes/index' +import { Route as NestedIndexRouteImport } from './routes/nested/index' +import { Route as NestedChildRouteImport } from './routes/nested/child' // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/',path: '/',getParentRoute: () => rootRoute }as any) -const NestedIndexRoute = NestedIndexImport.update({ +const NestedIndexRoute = NestedIndexRouteImport.update({ id: '/nested/',path: '/nested/',getParentRoute: () => rootRoute }as any) -const NestedChildRoute = NestedChildImport.update({ +const NestedChildRoute = NestedChildRouteImport.update({ id: '/nested/child',path: '/nested/child',getParentRoute: () => rootRoute }as any) @@ -37,26 +38,56 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/nested/child': { id: '/nested/child' path: '/nested/child' fullPath: '/nested/child' - preLoaderRoute: typeof NestedChildImport + preLoaderRoute: typeof NestedChildRouteImport parentRoute: typeof rootRoute } '/nested/': { id: '/nested/' path: '/nested' fullPath: '/nested' - preLoaderRoute: typeof NestedIndexImport + preLoaderRoute: typeof NestedIndexRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > + } +declare module './routes/nested/child' { + const createFileRoute: CreateFileRoute< + '/nested/child', + FileRoutesByPath['/nested/child']['parentRoute'], + FileRoutesByPath['/nested/child']['id'], + FileRoutesByPath['/nested/child']['path'], + FileRoutesByPath['/nested/child']['fullPath'] + > + } +declare module './routes/nested/index' { + const createFileRoute: CreateFileRoute< + '/nested/', + FileRoutesByPath['/nested/']['parentRoute'], + FileRoutesByPath['/nested/']['id'], + FileRoutesByPath['/nested/']['path'], + FileRoutesByPath['/nested/']['fullPath'] + > + } + // Create and export the route tree export interface FileRoutesByFullPath { @@ -91,6 +122,9 @@ const rootRouteChildren: RootRouteChildren = { export const routeTree = rootRoute._addFileChildren(rootRouteChildren)._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { diff --git a/packages/router-generator/tests/generator/no-formatted-route-tree/routes/__root.tsx b/packages/router-generator/tests/generator/no-formatted-route-tree/routes/__root.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/no-formatted-route-tree/routes/__root.tsx +++ b/packages/router-generator/tests/generator/no-formatted-route-tree/routes/__root.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/no-formatted-route-tree/routes/index.tsx b/packages/router-generator/tests/generator/no-formatted-route-tree/routes/index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/no-formatted-route-tree/routes/index.tsx +++ b/packages/router-generator/tests/generator/no-formatted-route-tree/routes/index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/no-formatted-route-tree/routes/nested/child.tsx b/packages/router-generator/tests/generator/no-formatted-route-tree/routes/nested/child.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/no-formatted-route-tree/routes/nested/child.tsx +++ b/packages/router-generator/tests/generator/no-formatted-route-tree/routes/nested/child.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/no-formatted-route-tree/routes/nested/index.tsx b/packages/router-generator/tests/generator/no-formatted-route-tree/routes/nested/index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/no-formatted-route-tree/routes/nested/index.tsx +++ b/packages/router-generator/tests/generator/no-formatted-route-tree/routes/nested/index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/no-manifest/routeTree.snapshot.ts b/packages/router-generator/tests/generator/no-manifest/routeTree.snapshot.ts index 8f3a052d06..87dfc37b74 100644 --- a/packages/router-generator/tests/generator/no-manifest/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/no-manifest/routeTree.snapshot.ts @@ -10,12 +10,13 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -29,12 +30,24 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -70,3 +83,6 @@ const rootRouteChildren: RootRouteChildren = { export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() + +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' diff --git a/packages/router-generator/tests/generator/no-manifest/routes/__root.tsx b/packages/router-generator/tests/generator/no-manifest/routes/__root.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/no-manifest/routes/__root.tsx +++ b/packages/router-generator/tests/generator/no-manifest/routes/__root.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/no-manifest/routes/index.tsx b/packages/router-generator/tests/generator/no-manifest/routes/index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/no-manifest/routes/index.tsx +++ b/packages/router-generator/tests/generator/no-manifest/routes/index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/numbers-in-path/routeTree.snapshot.ts b/packages/router-generator/tests/generator/numbers-in-path/routeTree.snapshot.ts index b9fe213c44..8df4ee784c 100644 --- a/packages/router-generator/tests/generator/numbers-in-path/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/numbers-in-path/routeTree.snapshot.ts @@ -10,40 +10,41 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as AboutImport } from './routes/about' -import { Route as R03Import } from './routes/03' -import { Route as IndexImport } from './routes/index' -import { Route as R02IndexImport } from './routes/02.index' -import { Route as R01ExampleIndexImport } from './routes/01-example/index' +import { Route as AboutRouteImport } from './routes/about' +import { Route as R03RouteImport } from './routes/03' +import { Route as IndexRouteImport } from './routes/index' +import { Route as R02IndexRouteImport } from './routes/02.index' +import { Route as R01ExampleIndexRouteImport } from './routes/01-example/index' // Create/Update Routes -const AboutRoute = AboutImport.update({ +const AboutRoute = AboutRouteImport.update({ id: '/about', path: '/about', getParentRoute: () => rootRoute, } as any) -const R03Route = R03Import.update({ +const R03Route = R03RouteImport.update({ id: '/03', path: '/03', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const R02IndexRoute = R02IndexImport.update({ +const R02IndexRoute = R02IndexRouteImport.update({ id: '/02/', path: '/02/', getParentRoute: () => rootRoute, } as any) -const R01ExampleIndexRoute = R01ExampleIndexImport.update({ +const R01ExampleIndexRoute = R01ExampleIndexRouteImport.update({ id: '/01-example/', path: '/01-example/', getParentRoute: () => rootRoute, @@ -57,40 +58,88 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/03': { id: '/03' path: '/03' fullPath: '/03' - preLoaderRoute: typeof R03Import + preLoaderRoute: typeof R03RouteImport parentRoute: typeof rootRoute } '/about': { id: '/about' path: '/about' fullPath: '/about' - preLoaderRoute: typeof AboutImport + preLoaderRoute: typeof AboutRouteImport parentRoute: typeof rootRoute } '/01-example/': { id: '/01-example/' path: '/01-example' fullPath: '/01-example' - preLoaderRoute: typeof R01ExampleIndexImport + preLoaderRoute: typeof R01ExampleIndexRouteImport parentRoute: typeof rootRoute } '/02/': { id: '/02/' path: '/02' fullPath: '/02' - preLoaderRoute: typeof R02IndexImport + preLoaderRoute: typeof R02IndexRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/03' { + const createFileRoute: CreateFileRoute< + '/03', + FileRoutesByPath['/03']['parentRoute'], + FileRoutesByPath['/03']['id'], + FileRoutesByPath['/03']['path'], + FileRoutesByPath['/03']['fullPath'] + > +} +declare module './routes/about' { + const createFileRoute: CreateFileRoute< + '/about', + FileRoutesByPath['/about']['parentRoute'], + FileRoutesByPath['/about']['id'], + FileRoutesByPath['/about']['path'], + FileRoutesByPath['/about']['fullPath'] + > +} +declare module './routes/01-example/index' { + const createFileRoute: CreateFileRoute< + '/01-example/', + FileRoutesByPath['/01-example/']['parentRoute'], + FileRoutesByPath['/01-example/']['id'], + FileRoutesByPath['/01-example/']['path'], + FileRoutesByPath['/01-example/']['fullPath'] + > +} +declare module './routes/02.index' { + const createFileRoute: CreateFileRoute< + '/02/', + FileRoutesByPath['/02/']['parentRoute'], + FileRoutesByPath['/02/']['id'], + FileRoutesByPath['/02/']['path'], + FileRoutesByPath['/02/']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -147,6 +196,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/numbers-in-path/routes/01-example/index.tsx b/packages/router-generator/tests/generator/numbers-in-path/routes/01-example/index.tsx index a4d5356ffd..6943669d72 100644 --- a/packages/router-generator/tests/generator/numbers-in-path/routes/01-example/index.tsx +++ b/packages/router-generator/tests/generator/numbers-in-path/routes/01-example/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/01-example/')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/numbers-in-path/routes/02.index.tsx b/packages/router-generator/tests/generator/numbers-in-path/routes/02.index.tsx index 40ec0494ad..445eec92dc 100644 --- a/packages/router-generator/tests/generator/numbers-in-path/routes/02.index.tsx +++ b/packages/router-generator/tests/generator/numbers-in-path/routes/02.index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/02/')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/numbers-in-path/routes/03.tsx b/packages/router-generator/tests/generator/numbers-in-path/routes/03.tsx index 4b6349bf17..3164148a3a 100644 --- a/packages/router-generator/tests/generator/numbers-in-path/routes/03.tsx +++ b/packages/router-generator/tests/generator/numbers-in-path/routes/03.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/03')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/numbers-in-path/routes/about.tsx b/packages/router-generator/tests/generator/numbers-in-path/routes/about.tsx index 1e6c7068e0..32071e180d 100644 --- a/packages/router-generator/tests/generator/numbers-in-path/routes/about.tsx +++ b/packages/router-generator/tests/generator/numbers-in-path/routes/about.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/about')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/numbers-in-path/routes/index.tsx b/packages/router-generator/tests/generator/numbers-in-path/routes/index.tsx index d58928d9ed..7ba4d00719 100644 --- a/packages/router-generator/tests/generator/numbers-in-path/routes/index.tsx +++ b/packages/router-generator/tests/generator/numbers-in-path/routes/index.tsx @@ -1,6 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/only-root/routeTree.snapshot.ts b/packages/router-generator/tests/generator/only-root/routeTree.snapshot.ts index 78c694471a..14d342bdd7 100644 --- a/packages/router-generator/tests/generator/only-root/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/only-root/routeTree.snapshot.ts @@ -10,6 +10,7 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' // Create/Update Routes @@ -20,6 +21,8 @@ declare module '@tanstack/react-router' { interface FileRoutesByPath {} } +// Add type-safety to the createFileRoute function across the route tree + // Create and export the route tree export interface FileRoutesByFullPath {} @@ -47,6 +50,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/prefix-suffix/routeTree.snapshot.ts b/packages/router-generator/tests/generator/prefix-suffix/routeTree.snapshot.ts new file mode 100644 index 0000000000..d452219d80 --- /dev/null +++ b/packages/router-generator/tests/generator/prefix-suffix/routeTree.snapshot.ts @@ -0,0 +1,216 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +// Import Routes + +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' +import { Route as rootRoute } from './routes/__root' +import { Route as WildcardChar123Char125suffixRouteImport } from './routes/wildcard/{$}suffix' +import { Route as WildcardChar123Char125DotsuffixRouteImport } from './routes/wildcard/{$}[.]suffix' +import { Route as WildcardPrefixChar123Char125RouteImport } from './routes/wildcard/prefix{$}' +import { Route as WildcardSplatRouteImport } from './routes/wildcard/$' + +// Create/Update Routes + +const WildcardChar123Char125suffixRoute = + WildcardChar123Char125suffixRouteImport.update({ + id: '/wildcard/{$}suffix', + path: '/wildcard/{$}suffix', + getParentRoute: () => rootRoute, + } as any) + +const WildcardChar123Char125DotsuffixRoute = + WildcardChar123Char125DotsuffixRouteImport.update({ + id: '/wildcard/{$}.suffix', + path: '/wildcard/{$}.suffix', + getParentRoute: () => rootRoute, + } as any) + +const WildcardPrefixChar123Char125Route = + WildcardPrefixChar123Char125RouteImport.update({ + id: '/wildcard/prefix{$}', + path: '/wildcard/prefix{$}', + getParentRoute: () => rootRoute, + } as any) + +const WildcardSplatRoute = WildcardSplatRouteImport.update({ + id: '/wildcard/$', + path: '/wildcard/$', + getParentRoute: () => rootRoute, +} as any) + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-router' { + interface FileRoutesByPath { + '/wildcard/$': { + id: '/wildcard/$' + path: '/wildcard/$' + fullPath: '/wildcard/$' + preLoaderRoute: typeof WildcardSplatRouteImport + parentRoute: typeof rootRoute + } + '/wildcard/prefix{$}': { + id: '/wildcard/prefix{$}' + path: '/wildcard/prefix{$}' + fullPath: '/wildcard/prefix{$}' + preLoaderRoute: typeof WildcardPrefixChar123Char125RouteImport + parentRoute: typeof rootRoute + } + '/wildcard/{$}.suffix': { + id: '/wildcard/{$}.suffix' + path: '/wildcard/{$}.suffix' + fullPath: '/wildcard/{$}.suffix' + preLoaderRoute: typeof WildcardChar123Char125DotsuffixRouteImport + parentRoute: typeof rootRoute + } + '/wildcard/{$}suffix': { + id: '/wildcard/{$}suffix' + path: '/wildcard/{$}suffix' + fullPath: '/wildcard/{$}suffix' + preLoaderRoute: typeof WildcardChar123Char125suffixRouteImport + parentRoute: typeof rootRoute + } + } +} + +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/wildcard/$' { + const createFileRoute: CreateFileRoute< + '/wildcard/$', + FileRoutesByPath['/wildcard/$']['parentRoute'], + FileRoutesByPath['/wildcard/$']['id'], + FileRoutesByPath['/wildcard/$']['path'], + FileRoutesByPath['/wildcard/$']['fullPath'] + > +} +declare module './routes/wildcard/prefix{$}' { + const createFileRoute: CreateFileRoute< + '/wildcard/prefix{$}', + FileRoutesByPath['/wildcard/prefix{$}']['parentRoute'], + FileRoutesByPath['/wildcard/prefix{$}']['id'], + FileRoutesByPath['/wildcard/prefix{$}']['path'], + FileRoutesByPath['/wildcard/prefix{$}']['fullPath'] + > +} +declare module './routes/wildcard/{$}[.]suffix' { + const createFileRoute: CreateFileRoute< + '/wildcard/{$}.suffix', + FileRoutesByPath['/wildcard/{$}.suffix']['parentRoute'], + FileRoutesByPath['/wildcard/{$}.suffix']['id'], + FileRoutesByPath['/wildcard/{$}.suffix']['path'], + FileRoutesByPath['/wildcard/{$}.suffix']['fullPath'] + > +} +declare module './routes/wildcard/{$}suffix' { + const createFileRoute: CreateFileRoute< + '/wildcard/{$}suffix', + FileRoutesByPath['/wildcard/{$}suffix']['parentRoute'], + FileRoutesByPath['/wildcard/{$}suffix']['id'], + FileRoutesByPath['/wildcard/{$}suffix']['path'], + FileRoutesByPath['/wildcard/{$}suffix']['fullPath'] + > +} + +// Create and export the route tree + +export interface FileRoutesByFullPath { + '/wildcard/$': typeof WildcardSplatRoute + '/wildcard/prefix{$}': typeof WildcardPrefixChar123Char125Route + '/wildcard/{$}.suffix': typeof WildcardChar123Char125DotsuffixRoute + '/wildcard/{$}suffix': typeof WildcardChar123Char125suffixRoute +} + +export interface FileRoutesByTo { + '/wildcard/$': typeof WildcardSplatRoute + '/wildcard/prefix{$}': typeof WildcardPrefixChar123Char125Route + '/wildcard/{$}.suffix': typeof WildcardChar123Char125DotsuffixRoute + '/wildcard/{$}suffix': typeof WildcardChar123Char125suffixRoute +} + +export interface FileRoutesById { + __root__: typeof rootRoute + '/wildcard/$': typeof WildcardSplatRoute + '/wildcard/prefix{$}': typeof WildcardPrefixChar123Char125Route + '/wildcard/{$}.suffix': typeof WildcardChar123Char125DotsuffixRoute + '/wildcard/{$}suffix': typeof WildcardChar123Char125suffixRoute +} + +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: + | '/wildcard/$' + | '/wildcard/prefix{$}' + | '/wildcard/{$}.suffix' + | '/wildcard/{$}suffix' + fileRoutesByTo: FileRoutesByTo + to: + | '/wildcard/$' + | '/wildcard/prefix{$}' + | '/wildcard/{$}.suffix' + | '/wildcard/{$}suffix' + id: + | '__root__' + | '/wildcard/$' + | '/wildcard/prefix{$}' + | '/wildcard/{$}.suffix' + | '/wildcard/{$}suffix' + fileRoutesById: FileRoutesById +} + +export interface RootRouteChildren { + WildcardSplatRoute: typeof WildcardSplatRoute + WildcardPrefixChar123Char125Route: typeof WildcardPrefixChar123Char125Route + WildcardChar123Char125DotsuffixRoute: typeof WildcardChar123Char125DotsuffixRoute + WildcardChar123Char125suffixRoute: typeof WildcardChar123Char125suffixRoute +} + +const rootRouteChildren: RootRouteChildren = { + WildcardSplatRoute: WildcardSplatRoute, + WildcardPrefixChar123Char125Route: WildcardPrefixChar123Char125Route, + WildcardChar123Char125DotsuffixRoute: WildcardChar123Char125DotsuffixRoute, + WildcardChar123Char125suffixRoute: WildcardChar123Char125suffixRoute, +} + +export const routeTree = rootRoute + ._addFileChildren(rootRouteChildren) + ._addFileTypes() + +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + +/* ROUTE_MANIFEST_START +{ + "routes": { + "__root__": { + "filePath": "__root.tsx", + "children": [ + "/wildcard/$", + "/wildcard/prefix{$}", + "/wildcard/{$}.suffix", + "/wildcard/{$}suffix" + ] + }, + "/wildcard/$": { + "filePath": "wildcard/$.tsx" + }, + "/wildcard/prefix{$}": { + "filePath": "wildcard/prefix{$}.tsx" + }, + "/wildcard/{$}.suffix": { + "filePath": "wildcard/{$}[.]suffix.tsx" + }, + "/wildcard/{$}suffix": { + "filePath": "wildcard/{$}suffix.tsx" + } + } +} +ROUTE_MANIFEST_END */ diff --git a/packages/router-generator/tests/generator/prefix-suffix/routes/__root.tsx b/packages/router-generator/tests/generator/prefix-suffix/routes/__root.tsx new file mode 100644 index 0000000000..3797d7bf8c --- /dev/null +++ b/packages/router-generator/tests/generator/prefix-suffix/routes/__root.tsx @@ -0,0 +1,15 @@ +import * as React from 'react' +import { Outlet, createRootRoute } from '@tanstack/react-router' + +export const Route = createRootRoute({ + component: RootComponent, +}) + +function RootComponent() { + return ( + +
Hello "__root"!
+ +
+ ) +} diff --git a/packages/router-generator/tests/generator/prefix-suffix/routes/index.tsx b/packages/router-generator/tests/generator/prefix-suffix/routes/index.tsx new file mode 100644 index 0000000000..ab504e42e9 --- /dev/null +++ b/packages/router-generator/tests/generator/prefix-suffix/routes/index.tsx @@ -0,0 +1 @@ +/** */ diff --git a/packages/router-generator/tests/generator/prefix-suffix/routes/wildcard/$.tsx b/packages/router-generator/tests/generator/prefix-suffix/routes/wildcard/$.tsx new file mode 100644 index 0000000000..5d18ba46cb --- /dev/null +++ b/packages/router-generator/tests/generator/prefix-suffix/routes/wildcard/$.tsx @@ -0,0 +1,7 @@ +export const Route = createFileRoute({ + component: RouteComponent, +}) + +function RouteComponent() { + return
Hello "/wildcard/$"!
+} diff --git a/packages/router-generator/tests/generator/prefix-suffix/routes/wildcard/prefix{$}.tsx b/packages/router-generator/tests/generator/prefix-suffix/routes/wildcard/prefix{$}.tsx new file mode 100644 index 0000000000..4d70429bed --- /dev/null +++ b/packages/router-generator/tests/generator/prefix-suffix/routes/wildcard/prefix{$}.tsx @@ -0,0 +1,7 @@ +export const Route = createFileRoute({ + component: RouteComponent, +}) + +function RouteComponent() { + return
Hello "/wildcard/prefix"!
+} diff --git a/packages/router-generator/tests/generator/prefix-suffix/routes/wildcard/{$}[.]suffix.tsx b/packages/router-generator/tests/generator/prefix-suffix/routes/wildcard/{$}[.]suffix.tsx new file mode 100644 index 0000000000..6d1a03f2f9 --- /dev/null +++ b/packages/router-generator/tests/generator/prefix-suffix/routes/wildcard/{$}[.]suffix.tsx @@ -0,0 +1,7 @@ +export const Route = createFileRoute({ + component: RouteComponent, +}) + +function RouteComponent() { + return
Hello "/wildcard/.suffix"!
+} diff --git a/packages/router-generator/tests/generator/prefix-suffix/routes/wildcard/{$}suffix.tsx b/packages/router-generator/tests/generator/prefix-suffix/routes/wildcard/{$}suffix.tsx new file mode 100644 index 0000000000..02bc57ef6e --- /dev/null +++ b/packages/router-generator/tests/generator/prefix-suffix/routes/wildcard/{$}suffix.tsx @@ -0,0 +1,7 @@ +export const Route = createFileRoute({ + component: RouteComponent, +}) + +function RouteComponent() { + return
Hello "/wildcard/suffix"!
+} diff --git a/packages/router-generator/tests/generator/route-groups/routeTree.snapshot.ts b/packages/router-generator/tests/generator/route-groups/routeTree.snapshot.ts index 57a9e6aa8c..fa9151cf27 100644 --- a/packages/router-generator/tests/generator/route-groups/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/route-groups/routeTree.snapshot.ts @@ -12,60 +12,62 @@ import { createFileRoute } from '@tanstack/react-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as fooAsdfLayoutImport } from './routes/(foo)/asdf/_layout' -import { Route as fooAsdfLayoutFooImport } from './routes/(foo)/asdf/_layout.foo' -import { Route as fooAsdfbarIdImport } from './routes/(foo)/asdf/(bar)/$id' -import { Route as fooAsdfanotherGroupLayoutImport } from './routes/(foo)/asdf/(another-group)/_layout' -import { Route as fooAsdfbarLayoutAboutImport } from './routes/(foo)/asdf/(bar)/_layout.about' -import { Route as fooAsdfanotherGroupLayoutBazImport } from './routes/(foo)/asdf/(another-group)/_layout.baz' +import { Route as fooAsdfLayoutRouteImport } from './routes/(foo)/asdf/_layout' +import { Route as fooAsdfLayoutFooRouteImport } from './routes/(foo)/asdf/_layout.foo' +import { Route as fooAsdfbarIdRouteImport } from './routes/(foo)/asdf/(bar)/$id' +import { Route as fooAsdfanotherGroupLayoutRouteImport } from './routes/(foo)/asdf/(another-group)/_layout' +import { Route as fooAsdfbarLayoutAboutRouteImport } from './routes/(foo)/asdf/(bar)/_layout.about' +import { Route as fooAsdfanotherGroupLayoutBazRouteImport } from './routes/(foo)/asdf/(another-group)/_layout.baz' // Create Virtual Routes -const fooAsdfImport = createFileRoute('/(foo)/asdf')() -const fooAsdfanotherGroupImport = createFileRoute( +const fooAsdfRouteImport = createFileRoute('/(foo)/asdf')() +const fooAsdfanotherGroupRouteImport = createFileRoute( '/(foo)/asdf/(another-group)', )() -const fooAsdfbarLayoutXyzLazyImport = createFileRoute( +const fooAsdfbarLayoutXyzLazyRouteImport = createFileRoute( '/(foo)/asdf/(bar)/_layout/xyz', )() // Create/Update Routes -const fooAsdfRoute = fooAsdfImport.update({ +const fooAsdfRoute = fooAsdfRouteImport.update({ id: '/(foo)/asdf', path: '/asdf', getParentRoute: () => rootRoute, } as any) -const fooAsdfanotherGroupRoute = fooAsdfanotherGroupImport.update({ +const fooAsdfanotherGroupRoute = fooAsdfanotherGroupRouteImport.update({ id: '/(another-group)', getParentRoute: () => fooAsdfRoute, } as any) -const fooAsdfLayoutRoute = fooAsdfLayoutImport.update({ +const fooAsdfLayoutRoute = fooAsdfLayoutRouteImport.update({ id: '/_layout', getParentRoute: () => fooAsdfRoute, } as any) -const fooAsdfLayoutFooRoute = fooAsdfLayoutFooImport.update({ +const fooAsdfLayoutFooRoute = fooAsdfLayoutFooRouteImport.update({ id: '/foo', path: '/foo', getParentRoute: () => fooAsdfLayoutRoute, } as any) -const fooAsdfbarIdRoute = fooAsdfbarIdImport.update({ +const fooAsdfbarIdRoute = fooAsdfbarIdRouteImport.update({ id: '/(bar)/$id', path: '/$id', getParentRoute: () => fooAsdfRoute, } as any) -const fooAsdfanotherGroupLayoutRoute = fooAsdfanotherGroupLayoutImport.update({ - id: '/_layout', - getParentRoute: () => fooAsdfanotherGroupRoute, -} as any) +const fooAsdfanotherGroupLayoutRoute = + fooAsdfanotherGroupLayoutRouteImport.update({ + id: '/_layout', + getParentRoute: () => fooAsdfanotherGroupRoute, + } as any) -const fooAsdfbarLayoutXyzLazyRoute = fooAsdfbarLayoutXyzLazyImport +const fooAsdfbarLayoutXyzLazyRoute = fooAsdfbarLayoutXyzLazyRouteImport .update({ id: '/(bar)/_layout/xyz', path: '/xyz', @@ -75,14 +77,14 @@ const fooAsdfbarLayoutXyzLazyRoute = fooAsdfbarLayoutXyzLazyImport import('./routes/(foo)/asdf/(bar)/_layout.xyz.lazy').then((d) => d.Route), ) -const fooAsdfbarLayoutAboutRoute = fooAsdfbarLayoutAboutImport.update({ +const fooAsdfbarLayoutAboutRoute = fooAsdfbarLayoutAboutRouteImport.update({ id: '/(bar)/_layout/about', path: '/about', getParentRoute: () => fooAsdfRoute, } as any) const fooAsdfanotherGroupLayoutBazRoute = - fooAsdfanotherGroupLayoutBazImport.update({ + fooAsdfanotherGroupLayoutBazRouteImport.update({ id: '/baz', path: '/baz', getParentRoute: () => fooAsdfanotherGroupLayoutRoute, @@ -96,68 +98,161 @@ declare module '@tanstack/react-router' { id: '/(foo)/asdf' path: '/asdf' fullPath: '/asdf' - preLoaderRoute: typeof fooAsdfImport + preLoaderRoute: typeof fooAsdfRouteImport parentRoute: typeof rootRoute } '/(foo)/asdf/_layout': { id: '/(foo)/asdf/_layout' path: '/asdf' fullPath: '/asdf' - preLoaderRoute: typeof fooAsdfLayoutImport + preLoaderRoute: typeof fooAsdfLayoutRouteImport parentRoute: typeof fooAsdfRoute } '/(foo)/asdf/(another-group)': { id: '/(foo)/asdf/(another-group)' path: '/' fullPath: '/asdf/' - preLoaderRoute: typeof fooAsdfanotherGroupImport - parentRoute: typeof fooAsdfImport + preLoaderRoute: typeof fooAsdfanotherGroupRouteImport + parentRoute: typeof fooAsdfRouteImport } '/(foo)/asdf/(another-group)/_layout': { id: '/(foo)/asdf/(another-group)/_layout' path: '/' fullPath: '/asdf/' - preLoaderRoute: typeof fooAsdfanotherGroupLayoutImport + preLoaderRoute: typeof fooAsdfanotherGroupLayoutRouteImport parentRoute: typeof fooAsdfanotherGroupRoute } '/(foo)/asdf/(bar)/$id': { id: '/(foo)/asdf/(bar)/$id' path: '/$id' fullPath: '/asdf/$id' - preLoaderRoute: typeof fooAsdfbarIdImport - parentRoute: typeof fooAsdfImport + preLoaderRoute: typeof fooAsdfbarIdRouteImport + parentRoute: typeof fooAsdfRouteImport } '/(foo)/asdf/_layout/foo': { id: '/(foo)/asdf/_layout/foo' path: '/foo' fullPath: '/asdf/foo' - preLoaderRoute: typeof fooAsdfLayoutFooImport - parentRoute: typeof fooAsdfLayoutImport + preLoaderRoute: typeof fooAsdfLayoutFooRouteImport + parentRoute: typeof fooAsdfLayoutRouteImport } '/(foo)/asdf/(another-group)/_layout/baz': { id: '/(foo)/asdf/(another-group)/_layout/baz' path: '/baz' fullPath: '/asdf/baz' - preLoaderRoute: typeof fooAsdfanotherGroupLayoutBazImport - parentRoute: typeof fooAsdfanotherGroupLayoutImport + preLoaderRoute: typeof fooAsdfanotherGroupLayoutBazRouteImport + parentRoute: typeof fooAsdfanotherGroupLayoutRouteImport } '/(foo)/asdf/(bar)/_layout/about': { id: '/(foo)/asdf/(bar)/_layout/about' path: '/about' fullPath: '/asdf/about' - preLoaderRoute: typeof fooAsdfbarLayoutAboutImport - parentRoute: typeof fooAsdfImport + preLoaderRoute: typeof fooAsdfbarLayoutAboutRouteImport + parentRoute: typeof fooAsdfRouteImport } '/(foo)/asdf/(bar)/_layout/xyz': { id: '/(foo)/asdf/(bar)/_layout/xyz' path: '/xyz' fullPath: '/asdf/xyz' - preLoaderRoute: typeof fooAsdfbarLayoutXyzLazyImport - parentRoute: typeof fooAsdfImport + preLoaderRoute: typeof fooAsdfbarLayoutXyzLazyRouteImport + parentRoute: typeof fooAsdfRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/(foo)/asdf' { + const createFileRoute: CreateFileRoute< + '/(foo)/asdf', + FileRoutesByPath['/(foo)/asdf']['parentRoute'], + FileRoutesByPath['/(foo)/asdf']['id'], + FileRoutesByPath['/(foo)/asdf']['path'], + FileRoutesByPath['/(foo)/asdf']['fullPath'] + > +} +declare module './routes/(foo)/asdf/_layout' { + const createFileRoute: CreateFileRoute< + '/(foo)/asdf/_layout', + FileRoutesByPath['/(foo)/asdf/_layout']['parentRoute'], + FileRoutesByPath['/(foo)/asdf/_layout']['id'], + FileRoutesByPath['/(foo)/asdf/_layout']['path'], + FileRoutesByPath['/(foo)/asdf/_layout']['fullPath'] + > +} +declare module './routes/(foo)/asdf/(another-group)' { + const createFileRoute: CreateFileRoute< + '/(foo)/asdf/(another-group)', + FileRoutesByPath['/(foo)/asdf/(another-group)']['parentRoute'], + FileRoutesByPath['/(foo)/asdf/(another-group)']['id'], + FileRoutesByPath['/(foo)/asdf/(another-group)']['path'], + FileRoutesByPath['/(foo)/asdf/(another-group)']['fullPath'] + > +} +declare module './routes/(foo)/asdf/(another-group)/_layout' { + const createFileRoute: CreateFileRoute< + '/(foo)/asdf/(another-group)/_layout', + FileRoutesByPath['/(foo)/asdf/(another-group)/_layout']['parentRoute'], + FileRoutesByPath['/(foo)/asdf/(another-group)/_layout']['id'], + FileRoutesByPath['/(foo)/asdf/(another-group)/_layout']['path'], + FileRoutesByPath['/(foo)/asdf/(another-group)/_layout']['fullPath'] + > +} +declare module './routes/(foo)/asdf/(bar)/$id' { + const createFileRoute: CreateFileRoute< + '/(foo)/asdf/(bar)/$id', + FileRoutesByPath['/(foo)/asdf/(bar)/$id']['parentRoute'], + FileRoutesByPath['/(foo)/asdf/(bar)/$id']['id'], + FileRoutesByPath['/(foo)/asdf/(bar)/$id']['path'], + FileRoutesByPath['/(foo)/asdf/(bar)/$id']['fullPath'] + > +} +declare module './routes/(foo)/asdf/_layout.foo' { + const createFileRoute: CreateFileRoute< + '/(foo)/asdf/_layout/foo', + FileRoutesByPath['/(foo)/asdf/_layout/foo']['parentRoute'], + FileRoutesByPath['/(foo)/asdf/_layout/foo']['id'], + FileRoutesByPath['/(foo)/asdf/_layout/foo']['path'], + FileRoutesByPath['/(foo)/asdf/_layout/foo']['fullPath'] + > +} +declare module './routes/(foo)/asdf/(another-group)/_layout.baz' { + const createFileRoute: CreateFileRoute< + '/(foo)/asdf/(another-group)/_layout/baz', + FileRoutesByPath['/(foo)/asdf/(another-group)/_layout/baz']['parentRoute'], + FileRoutesByPath['/(foo)/asdf/(another-group)/_layout/baz']['id'], + FileRoutesByPath['/(foo)/asdf/(another-group)/_layout/baz']['path'], + FileRoutesByPath['/(foo)/asdf/(another-group)/_layout/baz']['fullPath'] + > +} +declare module './routes/(foo)/asdf/(bar)/_layout.about' { + const createFileRoute: CreateFileRoute< + '/(foo)/asdf/(bar)/_layout/about', + FileRoutesByPath['/(foo)/asdf/(bar)/_layout/about']['parentRoute'], + FileRoutesByPath['/(foo)/asdf/(bar)/_layout/about']['id'], + FileRoutesByPath['/(foo)/asdf/(bar)/_layout/about']['path'], + FileRoutesByPath['/(foo)/asdf/(bar)/_layout/about']['fullPath'] + > +} +declare module './routes/(foo)/asdf/(bar)/_layout.xyz.lazy' { + const createFileRoute: CreateFileRoute< + '/(foo)/asdf/(bar)/_layout/xyz', + FileRoutesByPath['/(foo)/asdf/(bar)/_layout/xyz']['parentRoute'], + FileRoutesByPath['/(foo)/asdf/(bar)/_layout/xyz']['id'], + FileRoutesByPath['/(foo)/asdf/(bar)/_layout/xyz']['path'], + FileRoutesByPath['/(foo)/asdf/(bar)/_layout/xyz']['fullPath'] + > +} +declare module './routes/(foo)/asdf/(bar)/_layout.xyz.lazy' { + const createLazyFileRoute: CreateFileRoute< + '/(foo)/asdf/(bar)/_layout/xyz', + FileRoutesByPath['/(foo)/asdf/(bar)/_layout/xyz']['parentRoute'], + FileRoutesByPath['/(foo)/asdf/(bar)/_layout/xyz']['id'], + FileRoutesByPath['/(foo)/asdf/(bar)/_layout/xyz']['path'], + FileRoutesByPath['/(foo)/asdf/(bar)/_layout/xyz']['fullPath'] + > +} + // Create and export the route tree interface fooAsdfLayoutRouteChildren { @@ -292,6 +387,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(another-group)/_layout.baz.tsx b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(another-group)/_layout.baz.tsx index ce8ed9a546..6db8036f00 100644 --- a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(another-group)/_layout.baz.tsx +++ b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(another-group)/_layout.baz.tsx @@ -1,7 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(foo)/asdf/(another-group)/_layout/baz')( - { - component: () =>
Hello /(foo)/asdf/(another-group)/_layout/baz!
, - }, -) +export const Route = createFileRoute({ + component: () =>
Hello /(foo)/asdf/(another-group)/_layout/baz!
, +}) diff --git a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(another-group)/_layout.tsx b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(another-group)/_layout.tsx index c2e5c502fa..f69715bf48 100644 --- a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(another-group)/_layout.tsx +++ b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(another-group)/_layout.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(foo)/asdf/(another-group)/_layout')({ +export const Route = createFileRoute({ component: () =>
Hello /(foo)/asdf/(another-group)/_layout!
, }) diff --git a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/$id.tsx b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/$id.tsx index 75cbf8c35e..c46abc16f0 100644 --- a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/$id.tsx +++ b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/$id.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(foo)/asdf/(bar)/$id')({ +export const Route = createFileRoute({ component: () =>
Hello /(foo)/asdf/(bar)/$id!
, }) diff --git a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/_layout.about.tsx b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/_layout.about.tsx index 06daaef4e5..8fcb6f5964 100644 --- a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/_layout.about.tsx +++ b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/_layout.about.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(foo)/asdf/(bar)/_layout/about')({ +export const Route = createFileRoute({ component: () =>
Hello /(foo)/asdf/(bar)/_layout/about!
, }) diff --git a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/_layout.xyz.lazy.tsx b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/_layout.xyz.lazy.tsx index 955cd7f9bd..6e5db319eb 100644 --- a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/_layout.xyz.lazy.tsx +++ b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/_layout.xyz.lazy.tsx @@ -1,5 +1,5 @@ -import { createLazyFileRoute } from '@tanstack/react-router' +// @ts-nocheck -export const Route = createLazyFileRoute('/(foo)/asdf/(bar)/_layout/xyz')({ +export const Route = createLazyFileRoute({ component: () =>
Hello /(foo)/asdf/(bar)/_layout/xyz!
, }) diff --git a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/_layout.foo.tsx b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/_layout.foo.tsx index a090505278..57551c0b2e 100644 --- a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/_layout.foo.tsx +++ b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/_layout.foo.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(foo)/asdf/_layout/foo')({ +export const Route = createFileRoute({ component: () =>
Hello /(foo)/asdf/_layout/foo!
, }) diff --git a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/_layout.tsx b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/_layout.tsx index 6817284676..a78ffddd1d 100644 --- a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/_layout.tsx +++ b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/_layout.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(foo)/asdf/_layout')({ +export const Route = createFileRoute({ component: () =>
Hello /(foo)/asdf/_layout!
, }) diff --git a/packages/router-generator/tests/generator/single-level/routeTree.snapshot.ts b/packages/router-generator/tests/generator/single-level/routeTree.snapshot.ts index 2f69793c10..e6b8e79d9b 100644 --- a/packages/router-generator/tests/generator/single-level/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/single-level/routeTree.snapshot.ts @@ -10,19 +10,20 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as PostsImport } from './routes/posts' -import { Route as IndexImport } from './routes/index' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as IndexRouteImport } from './routes/index' // Create/Update Routes -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, } as any) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, @@ -36,19 +37,40 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/posts': { id: '/posts' path: '/posts' fullPath: '/posts' - preLoaderRoute: typeof PostsImport + preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRoute } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/posts' { + const createFileRoute: CreateFileRoute< + '/posts', + FileRoutesByPath['/posts']['parentRoute'], + FileRoutesByPath['/posts']['id'], + FileRoutesByPath['/posts']['path'], + FileRoutesByPath['/posts']['fullPath'] + > +} + // Create and export the route tree export interface FileRoutesByFullPath { @@ -90,6 +112,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/single-level/routes/__root.tsx b/packages/router-generator/tests/generator/single-level/routes/__root.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/single-level/routes/__root.tsx +++ b/packages/router-generator/tests/generator/single-level/routes/__root.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/single-level/routes/index.tsx b/packages/router-generator/tests/generator/single-level/routes/index.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/single-level/routes/index.tsx +++ b/packages/router-generator/tests/generator/single-level/routes/index.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/single-level/routes/posts.tsx b/packages/router-generator/tests/generator/single-level/routes/posts.tsx index ab504e42e9..a8c4d4c893 100644 --- a/packages/router-generator/tests/generator/single-level/routes/posts.tsx +++ b/packages/router-generator/tests/generator/single-level/routes/posts.tsx @@ -1 +1,2 @@ -/** */ +// @ts-nocheck +export const Route = createFileRoute() diff --git a/packages/router-generator/tests/generator/types-disabled/routeTree.snapshot.js b/packages/router-generator/tests/generator/types-disabled/routeTree.snapshot.js index e7e66c3847..10aeffda8c 100644 --- a/packages/router-generator/tests/generator/types-disabled/routeTree.snapshot.js +++ b/packages/router-generator/tests/generator/types-disabled/routeTree.snapshot.js @@ -11,32 +11,32 @@ // Import Routes import { Route as rootRoute } from './routes/__root' -import { Route as PostsImport } from './routes/posts' -import { Route as IndexImport } from './routes/index' -import { Route as UsersUserIdImport } from './routes/users.$userId' -import { Route as PostsPostIdImport } from './routes/posts/$postId' +import { Route as PostsRouteImport } from './routes/posts' +import { Route as IndexRouteImport } from './routes/index' +import { Route as UsersUserIdRouteImport } from './routes/users.$userId' +import { Route as PostsPostIdRouteImport } from './routes/posts/$postId' // Create/Update Routes -const PostsRoute = PostsImport.update({ +const PostsRoute = PostsRouteImport.update({ id: '/posts', path: '/posts', getParentRoute: () => rootRoute, }) -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, }) -const UsersUserIdRoute = UsersUserIdImport.update({ +const UsersUserIdRoute = UsersUserIdRouteImport.update({ id: '/users/$userId', path: '/users/$userId', getParentRoute: () => rootRoute, }) -const PostsPostIdRoute = PostsPostIdImport.update({ +const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', getParentRoute: () => PostsRoute, diff --git a/packages/router-generator/tests/generator/types-disabled/routes/index.tsx b/packages/router-generator/tests/generator/types-disabled/routes/index.tsx index cebf9db135..0c6b517ac3 100644 --- a/packages/router-generator/tests/generator/types-disabled/routes/index.tsx +++ b/packages/router-generator/tests/generator/types-disabled/routes/index.tsx @@ -1,6 +1,5 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: () =>
Hello /!
, }) diff --git a/packages/router-generator/tests/generator/types-disabled/routes/posts.tsx b/packages/router-generator/tests/generator/types-disabled/routes/posts.tsx index ec0b3fcee7..bbd5c622a3 100644 --- a/packages/router-generator/tests/generator/types-disabled/routes/posts.tsx +++ b/packages/router-generator/tests/generator/types-disabled/routes/posts.tsx @@ -1,6 +1,5 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts')({ +export const Route = createFileRoute({ component: () =>
Hello /posts!
, }) diff --git a/packages/router-generator/tests/generator/types-disabled/routes/posts/$postId.tsx b/packages/router-generator/tests/generator/types-disabled/routes/posts/$postId.tsx index 4528667792..0571c41009 100644 --- a/packages/router-generator/tests/generator/types-disabled/routes/posts/$postId.tsx +++ b/packages/router-generator/tests/generator/types-disabled/routes/posts/$postId.tsx @@ -1,6 +1,5 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/posts/$postId')({ +export const Route = createFileRoute({ component: () =>
Hello /posts/$postId!
, }) diff --git a/packages/router-generator/tests/generator/types-disabled/routes/users.$userId.tsx b/packages/router-generator/tests/generator/types-disabled/routes/users.$userId.tsx index b6553fe98a..32e776ec82 100644 --- a/packages/router-generator/tests/generator/types-disabled/routes/users.$userId.tsx +++ b/packages/router-generator/tests/generator/types-disabled/routes/users.$userId.tsx @@ -1,6 +1,5 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/users/$userId')({ +export const Route = createFileRoute({ component: () =>
Hello /users/$userId!
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-config-file-default-export/routeTree.snapshot.ts index ef967d5c21..4d3eef17b6 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/virtual-config-file-default-export/routeTree.snapshot.ts @@ -12,91 +12,92 @@ import { createFileRoute } from '@tanstack/react-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/root' -import { Route as layoutImport } from './routes/layout' -import { Route as indexImport } from './routes/index' -import { Route as dbDashboardImport } from './routes/db/dashboard' -import { Route as pagesImport } from './routes/pages' -import { Route as HelloIndexImport } from './routes/subtree/index' -import { Route as dbDashboardInvoicesImport } from './routes/db/dashboard-invoices' -import { Route as dbDashboardIndexImport } from './routes/db/dashboard-index' -import { Route as HelloFooIndexImport } from './routes/subtree/foo/index' -import { Route as HelloFooIdImport } from './routes/subtree/foo/$id' -import { Route as dbInvoiceDetailImport } from './routes/db/invoice-detail' -import { Route as dbInvoicesIndexImport } from './routes/db/invoices-index' +import { Route as layoutRouteImport } from './routes/layout' +import { Route as indexRouteImport } from './routes/index' +import { Route as dbDashboardRouteImport } from './routes/db/dashboard' +import { Route as pagesRouteImport } from './routes/pages' +import { Route as HelloIndexRouteImport } from './routes/subtree/index' +import { Route as dbDashboardInvoicesRouteImport } from './routes/db/dashboard-invoices' +import { Route as dbDashboardIndexRouteImport } from './routes/db/dashboard-index' +import { Route as HelloFooIndexRouteImport } from './routes/subtree/foo/index' +import { Route as HelloFooIdRouteImport } from './routes/subtree/foo/$id' +import { Route as dbInvoiceDetailRouteImport } from './routes/db/invoice-detail' +import { Route as dbInvoicesIndexRouteImport } from './routes/db/invoices-index' // Create Virtual Routes -const LangImport = createFileRoute('/$lang')() +const LangRouteImport = createFileRoute('/$lang')() // Create/Update Routes -const layoutRoute = layoutImport.update({ +const layoutRoute = layoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const LangRoute = LangImport.update({ +const LangRoute = LangRouteImport.update({ id: '/$lang', path: '/$lang', getParentRoute: () => rootRoute, } as any) -const indexRoute = indexImport.update({ +const indexRoute = indexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const dbDashboardRoute = dbDashboardImport.update({ +const dbDashboardRoute = dbDashboardRouteImport.update({ id: '/dashboard', path: '/dashboard', getParentRoute: () => layoutRoute, } as any) -const pagesRoute = pagesImport.update({ +const pagesRoute = pagesRouteImport.update({ id: '/', path: '/', getParentRoute: () => LangRoute, } as any) -const HelloIndexRoute = HelloIndexImport.update({ +const HelloIndexRoute = HelloIndexRouteImport.update({ id: '/hello/', path: '/hello/', getParentRoute: () => layoutRoute, } as any) -const dbDashboardInvoicesRoute = dbDashboardInvoicesImport.update({ +const dbDashboardInvoicesRoute = dbDashboardInvoicesRouteImport.update({ id: '/invoices', path: '/invoices', getParentRoute: () => dbDashboardRoute, } as any) -const dbDashboardIndexRoute = dbDashboardIndexImport.update({ +const dbDashboardIndexRoute = dbDashboardIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => dbDashboardRoute, } as any) -const HelloFooIndexRoute = HelloFooIndexImport.update({ +const HelloFooIndexRoute = HelloFooIndexRouteImport.update({ id: '/hello/foo/', path: '/hello/foo/', getParentRoute: () => layoutRoute, } as any) -const HelloFooIdRoute = HelloFooIdImport.update({ +const HelloFooIdRoute = HelloFooIdRouteImport.update({ id: '/hello/foo/$id', path: '/hello/foo/$id', getParentRoute: () => layoutRoute, } as any) -const dbInvoiceDetailRoute = dbInvoiceDetailImport.update({ +const dbInvoiceDetailRoute = dbInvoiceDetailRouteImport.update({ id: '/$id', path: '/$id', getParentRoute: () => dbDashboardInvoicesRoute, } as any) -const dbInvoicesIndexRoute = dbInvoicesIndexImport.update({ +const dbInvoicesIndexRoute = dbInvoicesIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => dbDashboardInvoicesRoute, @@ -110,89 +111,200 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof indexImport + preLoaderRoute: typeof indexRouteImport parentRoute: typeof rootRoute } '/$lang': { id: '/$lang' path: '/$lang' fullPath: '/$lang' - preLoaderRoute: typeof LangImport + preLoaderRoute: typeof LangRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof layoutImport + preLoaderRoute: typeof layoutRouteImport parentRoute: typeof rootRoute } '/$lang/': { id: '/$lang/' path: '/' fullPath: '/$lang/' - preLoaderRoute: typeof pagesImport - parentRoute: typeof LangImport + preLoaderRoute: typeof pagesRouteImport + parentRoute: typeof LangRouteImport } '/_layout/dashboard': { id: '/_layout/dashboard' path: '/dashboard' fullPath: '/dashboard' - preLoaderRoute: typeof dbDashboardImport - parentRoute: typeof layoutImport + preLoaderRoute: typeof dbDashboardRouteImport + parentRoute: typeof layoutRouteImport } '/_layout/dashboard/': { id: '/_layout/dashboard/' path: '/' fullPath: '/dashboard/' - preLoaderRoute: typeof dbDashboardIndexImport - parentRoute: typeof dbDashboardImport + preLoaderRoute: typeof dbDashboardIndexRouteImport + parentRoute: typeof dbDashboardRouteImport } '/_layout/dashboard/invoices': { id: '/_layout/dashboard/invoices' path: '/invoices' fullPath: '/dashboard/invoices' - preLoaderRoute: typeof dbDashboardInvoicesImport - parentRoute: typeof dbDashboardImport + preLoaderRoute: typeof dbDashboardInvoicesRouteImport + parentRoute: typeof dbDashboardRouteImport } '/_layout/hello/': { id: '/_layout/hello/' path: '/hello' fullPath: '/hello' - preLoaderRoute: typeof HelloIndexImport - parentRoute: typeof layoutImport + preLoaderRoute: typeof HelloIndexRouteImport + parentRoute: typeof layoutRouteImport } '/_layout/dashboard/invoices/': { id: '/_layout/dashboard/invoices/' path: '/' fullPath: '/dashboard/invoices/' - preLoaderRoute: typeof dbInvoicesIndexImport - parentRoute: typeof dbDashboardInvoicesImport + preLoaderRoute: typeof dbInvoicesIndexRouteImport + parentRoute: typeof dbDashboardInvoicesRouteImport } '/_layout/dashboard/invoices/$id': { id: '/_layout/dashboard/invoices/$id' path: '/$id' fullPath: '/dashboard/invoices/$id' - preLoaderRoute: typeof dbInvoiceDetailImport - parentRoute: typeof dbDashboardInvoicesImport + preLoaderRoute: typeof dbInvoiceDetailRouteImport + parentRoute: typeof dbDashboardInvoicesRouteImport } '/_layout/hello/foo/$id': { id: '/_layout/hello/foo/$id' path: '/hello/foo/$id' fullPath: '/hello/foo/$id' - preLoaderRoute: typeof HelloFooIdImport - parentRoute: typeof layoutImport + preLoaderRoute: typeof HelloFooIdRouteImport + parentRoute: typeof layoutRouteImport } '/_layout/hello/foo/': { id: '/_layout/hello/foo/' path: '/hello/foo' fullPath: '/hello/foo' - preLoaderRoute: typeof HelloFooIndexImport - parentRoute: typeof layoutImport + preLoaderRoute: typeof HelloFooIndexRouteImport + parentRoute: typeof layoutRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes' { + const createFileRoute: CreateFileRoute< + '/$lang', + FileRoutesByPath['/$lang']['parentRoute'], + FileRoutesByPath['/$lang']['id'], + FileRoutesByPath['/$lang']['path'], + FileRoutesByPath['/$lang']['fullPath'] + > +} +declare module './routes/layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/pages' { + const createFileRoute: CreateFileRoute< + '/$lang/', + FileRoutesByPath['/$lang/']['parentRoute'], + FileRoutesByPath['/$lang/']['id'], + FileRoutesByPath['/$lang/']['path'], + FileRoutesByPath['/$lang/']['fullPath'] + > +} +declare module './routes/db/dashboard' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard', + FileRoutesByPath['/_layout/dashboard']['parentRoute'], + FileRoutesByPath['/_layout/dashboard']['id'], + FileRoutesByPath['/_layout/dashboard']['path'], + FileRoutesByPath['/_layout/dashboard']['fullPath'] + > +} +declare module './routes/db/dashboard-index' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard/', + FileRoutesByPath['/_layout/dashboard/']['parentRoute'], + FileRoutesByPath['/_layout/dashboard/']['id'], + FileRoutesByPath['/_layout/dashboard/']['path'], + FileRoutesByPath['/_layout/dashboard/']['fullPath'] + > +} +declare module './routes/db/dashboard-invoices' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard/invoices', + FileRoutesByPath['/_layout/dashboard/invoices']['parentRoute'], + FileRoutesByPath['/_layout/dashboard/invoices']['id'], + FileRoutesByPath['/_layout/dashboard/invoices']['path'], + FileRoutesByPath['/_layout/dashboard/invoices']['fullPath'] + > +} +declare module './routes/subtree/index' { + const createFileRoute: CreateFileRoute< + '/_layout/hello/', + FileRoutesByPath['/_layout/hello/']['parentRoute'], + FileRoutesByPath['/_layout/hello/']['id'], + FileRoutesByPath['/_layout/hello/']['path'], + FileRoutesByPath['/_layout/hello/']['fullPath'] + > +} +declare module './routes/db/invoices-index' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard/invoices/', + FileRoutesByPath['/_layout/dashboard/invoices/']['parentRoute'], + FileRoutesByPath['/_layout/dashboard/invoices/']['id'], + FileRoutesByPath['/_layout/dashboard/invoices/']['path'], + FileRoutesByPath['/_layout/dashboard/invoices/']['fullPath'] + > +} +declare module './routes/db/invoice-detail' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard/invoices/$id', + FileRoutesByPath['/_layout/dashboard/invoices/$id']['parentRoute'], + FileRoutesByPath['/_layout/dashboard/invoices/$id']['id'], + FileRoutesByPath['/_layout/dashboard/invoices/$id']['path'], + FileRoutesByPath['/_layout/dashboard/invoices/$id']['fullPath'] + > +} +declare module './routes/subtree/foo/$id' { + const createFileRoute: CreateFileRoute< + '/_layout/hello/foo/$id', + FileRoutesByPath['/_layout/hello/foo/$id']['parentRoute'], + FileRoutesByPath['/_layout/hello/foo/$id']['id'], + FileRoutesByPath['/_layout/hello/foo/$id']['path'], + FileRoutesByPath['/_layout/hello/foo/$id']['fullPath'] + > +} +declare module './routes/subtree/foo/index' { + const createFileRoute: CreateFileRoute< + '/_layout/hello/foo/', + FileRoutesByPath['/_layout/hello/foo/']['parentRoute'], + FileRoutesByPath['/_layout/hello/foo/']['id'], + FileRoutesByPath['/_layout/hello/foo/']['path'], + FileRoutesByPath['/_layout/hello/foo/']['fullPath'] + > +} + // Create and export the route tree interface LangRouteChildren { @@ -351,6 +463,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/dashboard-index.tsx b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/dashboard-index.tsx index a92fc772c3..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/dashboard-index.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/dashboard-index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard/')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/dashboard-invoices.tsx b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/dashboard-invoices.tsx index bf7e5a02b2..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/dashboard-invoices.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/dashboard-invoices.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard/invoices')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/dashboard.tsx b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/dashboard.tsx index d5b4f49706..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/dashboard.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/dashboard.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/invoice-detail.tsx b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/invoice-detail.tsx index e7be6c1910..a1ed3d4a28 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/invoice-detail.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/invoice-detail.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard/invoices/$id')({ +export const Route = createFileRoute({ component: () =>
Hello /_layout/dashboard/invoices/$id!
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/invoices-index.tsx b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/invoices-index.tsx index f2e56721b6..960e382af9 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/invoices-index.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/db/invoices-index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard/invoices/')({ +export const Route = createFileRoute({ component: () =>
Hello /_layout/dashboard/invoices/!
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/index.tsx b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/index.tsx index a294139860..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/index.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/layout.tsx b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/layout.tsx index 2e48e48410..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/layout.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/layout.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/pages.tsx b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/pages.tsx index a942c7ce75..488a59a55a 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/pages.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/pages.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/$lang/')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/subtree/foo/$id.tsx b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/subtree/foo/$id.tsx index d8cbd795a7..8418001767 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/subtree/foo/$id.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/subtree/foo/$id.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/hello/foo/$id')({ +export const Route = createFileRoute({ component: () =>
Hello /foo/$id!
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/subtree/foo/index.tsx b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/subtree/foo/index.tsx index 10233de496..84660c4d04 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/subtree/foo/index.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/subtree/foo/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/hello/foo/')({ +export const Route = createFileRoute({ component: () =>
Hello /foo/!
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/subtree/index.tsx b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/subtree/index.tsx index 3367799b96..22cab82307 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/subtree/index.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/subtree/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/hello/')({ +export const Route = createFileRoute({ component: () =>
Hello /!
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-config-file-named-export/routeTree.snapshot.ts index ef967d5c21..4d3eef17b6 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/virtual-config-file-named-export/routeTree.snapshot.ts @@ -12,91 +12,92 @@ import { createFileRoute } from '@tanstack/react-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/root' -import { Route as layoutImport } from './routes/layout' -import { Route as indexImport } from './routes/index' -import { Route as dbDashboardImport } from './routes/db/dashboard' -import { Route as pagesImport } from './routes/pages' -import { Route as HelloIndexImport } from './routes/subtree/index' -import { Route as dbDashboardInvoicesImport } from './routes/db/dashboard-invoices' -import { Route as dbDashboardIndexImport } from './routes/db/dashboard-index' -import { Route as HelloFooIndexImport } from './routes/subtree/foo/index' -import { Route as HelloFooIdImport } from './routes/subtree/foo/$id' -import { Route as dbInvoiceDetailImport } from './routes/db/invoice-detail' -import { Route as dbInvoicesIndexImport } from './routes/db/invoices-index' +import { Route as layoutRouteImport } from './routes/layout' +import { Route as indexRouteImport } from './routes/index' +import { Route as dbDashboardRouteImport } from './routes/db/dashboard' +import { Route as pagesRouteImport } from './routes/pages' +import { Route as HelloIndexRouteImport } from './routes/subtree/index' +import { Route as dbDashboardInvoicesRouteImport } from './routes/db/dashboard-invoices' +import { Route as dbDashboardIndexRouteImport } from './routes/db/dashboard-index' +import { Route as HelloFooIndexRouteImport } from './routes/subtree/foo/index' +import { Route as HelloFooIdRouteImport } from './routes/subtree/foo/$id' +import { Route as dbInvoiceDetailRouteImport } from './routes/db/invoice-detail' +import { Route as dbInvoicesIndexRouteImport } from './routes/db/invoices-index' // Create Virtual Routes -const LangImport = createFileRoute('/$lang')() +const LangRouteImport = createFileRoute('/$lang')() // Create/Update Routes -const layoutRoute = layoutImport.update({ +const layoutRoute = layoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const LangRoute = LangImport.update({ +const LangRoute = LangRouteImport.update({ id: '/$lang', path: '/$lang', getParentRoute: () => rootRoute, } as any) -const indexRoute = indexImport.update({ +const indexRoute = indexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const dbDashboardRoute = dbDashboardImport.update({ +const dbDashboardRoute = dbDashboardRouteImport.update({ id: '/dashboard', path: '/dashboard', getParentRoute: () => layoutRoute, } as any) -const pagesRoute = pagesImport.update({ +const pagesRoute = pagesRouteImport.update({ id: '/', path: '/', getParentRoute: () => LangRoute, } as any) -const HelloIndexRoute = HelloIndexImport.update({ +const HelloIndexRoute = HelloIndexRouteImport.update({ id: '/hello/', path: '/hello/', getParentRoute: () => layoutRoute, } as any) -const dbDashboardInvoicesRoute = dbDashboardInvoicesImport.update({ +const dbDashboardInvoicesRoute = dbDashboardInvoicesRouteImport.update({ id: '/invoices', path: '/invoices', getParentRoute: () => dbDashboardRoute, } as any) -const dbDashboardIndexRoute = dbDashboardIndexImport.update({ +const dbDashboardIndexRoute = dbDashboardIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => dbDashboardRoute, } as any) -const HelloFooIndexRoute = HelloFooIndexImport.update({ +const HelloFooIndexRoute = HelloFooIndexRouteImport.update({ id: '/hello/foo/', path: '/hello/foo/', getParentRoute: () => layoutRoute, } as any) -const HelloFooIdRoute = HelloFooIdImport.update({ +const HelloFooIdRoute = HelloFooIdRouteImport.update({ id: '/hello/foo/$id', path: '/hello/foo/$id', getParentRoute: () => layoutRoute, } as any) -const dbInvoiceDetailRoute = dbInvoiceDetailImport.update({ +const dbInvoiceDetailRoute = dbInvoiceDetailRouteImport.update({ id: '/$id', path: '/$id', getParentRoute: () => dbDashboardInvoicesRoute, } as any) -const dbInvoicesIndexRoute = dbInvoicesIndexImport.update({ +const dbInvoicesIndexRoute = dbInvoicesIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => dbDashboardInvoicesRoute, @@ -110,89 +111,200 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof indexImport + preLoaderRoute: typeof indexRouteImport parentRoute: typeof rootRoute } '/$lang': { id: '/$lang' path: '/$lang' fullPath: '/$lang' - preLoaderRoute: typeof LangImport + preLoaderRoute: typeof LangRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof layoutImport + preLoaderRoute: typeof layoutRouteImport parentRoute: typeof rootRoute } '/$lang/': { id: '/$lang/' path: '/' fullPath: '/$lang/' - preLoaderRoute: typeof pagesImport - parentRoute: typeof LangImport + preLoaderRoute: typeof pagesRouteImport + parentRoute: typeof LangRouteImport } '/_layout/dashboard': { id: '/_layout/dashboard' path: '/dashboard' fullPath: '/dashboard' - preLoaderRoute: typeof dbDashboardImport - parentRoute: typeof layoutImport + preLoaderRoute: typeof dbDashboardRouteImport + parentRoute: typeof layoutRouteImport } '/_layout/dashboard/': { id: '/_layout/dashboard/' path: '/' fullPath: '/dashboard/' - preLoaderRoute: typeof dbDashboardIndexImport - parentRoute: typeof dbDashboardImport + preLoaderRoute: typeof dbDashboardIndexRouteImport + parentRoute: typeof dbDashboardRouteImport } '/_layout/dashboard/invoices': { id: '/_layout/dashboard/invoices' path: '/invoices' fullPath: '/dashboard/invoices' - preLoaderRoute: typeof dbDashboardInvoicesImport - parentRoute: typeof dbDashboardImport + preLoaderRoute: typeof dbDashboardInvoicesRouteImport + parentRoute: typeof dbDashboardRouteImport } '/_layout/hello/': { id: '/_layout/hello/' path: '/hello' fullPath: '/hello' - preLoaderRoute: typeof HelloIndexImport - parentRoute: typeof layoutImport + preLoaderRoute: typeof HelloIndexRouteImport + parentRoute: typeof layoutRouteImport } '/_layout/dashboard/invoices/': { id: '/_layout/dashboard/invoices/' path: '/' fullPath: '/dashboard/invoices/' - preLoaderRoute: typeof dbInvoicesIndexImport - parentRoute: typeof dbDashboardInvoicesImport + preLoaderRoute: typeof dbInvoicesIndexRouteImport + parentRoute: typeof dbDashboardInvoicesRouteImport } '/_layout/dashboard/invoices/$id': { id: '/_layout/dashboard/invoices/$id' path: '/$id' fullPath: '/dashboard/invoices/$id' - preLoaderRoute: typeof dbInvoiceDetailImport - parentRoute: typeof dbDashboardInvoicesImport + preLoaderRoute: typeof dbInvoiceDetailRouteImport + parentRoute: typeof dbDashboardInvoicesRouteImport } '/_layout/hello/foo/$id': { id: '/_layout/hello/foo/$id' path: '/hello/foo/$id' fullPath: '/hello/foo/$id' - preLoaderRoute: typeof HelloFooIdImport - parentRoute: typeof layoutImport + preLoaderRoute: typeof HelloFooIdRouteImport + parentRoute: typeof layoutRouteImport } '/_layout/hello/foo/': { id: '/_layout/hello/foo/' path: '/hello/foo' fullPath: '/hello/foo' - preLoaderRoute: typeof HelloFooIndexImport - parentRoute: typeof layoutImport + preLoaderRoute: typeof HelloFooIndexRouteImport + parentRoute: typeof layoutRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes' { + const createFileRoute: CreateFileRoute< + '/$lang', + FileRoutesByPath['/$lang']['parentRoute'], + FileRoutesByPath['/$lang']['id'], + FileRoutesByPath['/$lang']['path'], + FileRoutesByPath['/$lang']['fullPath'] + > +} +declare module './routes/layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/pages' { + const createFileRoute: CreateFileRoute< + '/$lang/', + FileRoutesByPath['/$lang/']['parentRoute'], + FileRoutesByPath['/$lang/']['id'], + FileRoutesByPath['/$lang/']['path'], + FileRoutesByPath['/$lang/']['fullPath'] + > +} +declare module './routes/db/dashboard' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard', + FileRoutesByPath['/_layout/dashboard']['parentRoute'], + FileRoutesByPath['/_layout/dashboard']['id'], + FileRoutesByPath['/_layout/dashboard']['path'], + FileRoutesByPath['/_layout/dashboard']['fullPath'] + > +} +declare module './routes/db/dashboard-index' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard/', + FileRoutesByPath['/_layout/dashboard/']['parentRoute'], + FileRoutesByPath['/_layout/dashboard/']['id'], + FileRoutesByPath['/_layout/dashboard/']['path'], + FileRoutesByPath['/_layout/dashboard/']['fullPath'] + > +} +declare module './routes/db/dashboard-invoices' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard/invoices', + FileRoutesByPath['/_layout/dashboard/invoices']['parentRoute'], + FileRoutesByPath['/_layout/dashboard/invoices']['id'], + FileRoutesByPath['/_layout/dashboard/invoices']['path'], + FileRoutesByPath['/_layout/dashboard/invoices']['fullPath'] + > +} +declare module './routes/subtree/index' { + const createFileRoute: CreateFileRoute< + '/_layout/hello/', + FileRoutesByPath['/_layout/hello/']['parentRoute'], + FileRoutesByPath['/_layout/hello/']['id'], + FileRoutesByPath['/_layout/hello/']['path'], + FileRoutesByPath['/_layout/hello/']['fullPath'] + > +} +declare module './routes/db/invoices-index' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard/invoices/', + FileRoutesByPath['/_layout/dashboard/invoices/']['parentRoute'], + FileRoutesByPath['/_layout/dashboard/invoices/']['id'], + FileRoutesByPath['/_layout/dashboard/invoices/']['path'], + FileRoutesByPath['/_layout/dashboard/invoices/']['fullPath'] + > +} +declare module './routes/db/invoice-detail' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard/invoices/$id', + FileRoutesByPath['/_layout/dashboard/invoices/$id']['parentRoute'], + FileRoutesByPath['/_layout/dashboard/invoices/$id']['id'], + FileRoutesByPath['/_layout/dashboard/invoices/$id']['path'], + FileRoutesByPath['/_layout/dashboard/invoices/$id']['fullPath'] + > +} +declare module './routes/subtree/foo/$id' { + const createFileRoute: CreateFileRoute< + '/_layout/hello/foo/$id', + FileRoutesByPath['/_layout/hello/foo/$id']['parentRoute'], + FileRoutesByPath['/_layout/hello/foo/$id']['id'], + FileRoutesByPath['/_layout/hello/foo/$id']['path'], + FileRoutesByPath['/_layout/hello/foo/$id']['fullPath'] + > +} +declare module './routes/subtree/foo/index' { + const createFileRoute: CreateFileRoute< + '/_layout/hello/foo/', + FileRoutesByPath['/_layout/hello/foo/']['parentRoute'], + FileRoutesByPath['/_layout/hello/foo/']['id'], + FileRoutesByPath['/_layout/hello/foo/']['path'], + FileRoutesByPath['/_layout/hello/foo/']['fullPath'] + > +} + // Create and export the route tree interface LangRouteChildren { @@ -351,6 +463,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/dashboard-index.tsx b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/dashboard-index.tsx index a92fc772c3..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/dashboard-index.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/dashboard-index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard/')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/dashboard-invoices.tsx b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/dashboard-invoices.tsx index bf7e5a02b2..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/dashboard-invoices.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/dashboard-invoices.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard/invoices')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/dashboard.tsx b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/dashboard.tsx index d5b4f49706..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/dashboard.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/dashboard.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/invoice-detail.tsx b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/invoice-detail.tsx index e7be6c1910..a1ed3d4a28 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/invoice-detail.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/invoice-detail.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard/invoices/$id')({ +export const Route = createFileRoute({ component: () =>
Hello /_layout/dashboard/invoices/$id!
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/invoices-index.tsx b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/invoices-index.tsx index f2e56721b6..960e382af9 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/invoices-index.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/db/invoices-index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard/invoices/')({ +export const Route = createFileRoute({ component: () =>
Hello /_layout/dashboard/invoices/!
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/index.tsx b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/index.tsx index a294139860..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/index.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/layout.tsx b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/layout.tsx index 2e48e48410..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/layout.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/layout.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/pages.tsx b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/pages.tsx index a942c7ce75..488a59a55a 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/pages.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/pages.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/$lang/')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/subtree/foo/$id.tsx b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/subtree/foo/$id.tsx index d8cbd795a7..8418001767 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/subtree/foo/$id.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/subtree/foo/$id.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/hello/foo/$id')({ +export const Route = createFileRoute({ component: () =>
Hello /foo/$id!
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/subtree/foo/index.tsx b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/subtree/foo/index.tsx index 10233de496..84660c4d04 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/subtree/foo/index.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/subtree/foo/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/hello/foo/')({ +export const Route = createFileRoute({ component: () =>
Hello /foo/!
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/subtree/index.tsx b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/subtree/index.tsx index 3367799b96..22cab82307 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/subtree/index.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/subtree/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/hello/')({ +export const Route = createFileRoute({ component: () =>
Hello /!
, }) diff --git a/packages/router-generator/tests/generator/virtual-inside-nested/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-inside-nested/routeTree.snapshot.ts index ca38556b08..0dac495f08 100644 --- a/packages/router-generator/tests/generator/virtual-inside-nested/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/virtual-inside-nested/routeTree.snapshot.ts @@ -10,33 +10,34 @@ // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' -import { Route as FooBarImport } from './routes/foo/bar' -import { Route as fooBarDetailsImport } from './routes/foo/bar/details' -import { Route as fooBarHomeImport } from './routes/foo/bar/home' +import { Route as IndexRouteImport } from './routes/index' +import { Route as FooBarRouteImport } from './routes/foo/bar' +import { Route as fooBarDetailsRouteImport } from './routes/foo/bar/details' +import { Route as fooBarHomeRouteImport } from './routes/foo/bar/home' // Create/Update Routes -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const FooBarRoute = FooBarImport.update({ +const FooBarRoute = FooBarRouteImport.update({ id: '/foo/bar', path: '/foo/bar', getParentRoute: () => rootRoute, } as any) -const fooBarDetailsRoute = fooBarDetailsImport.update({ +const fooBarDetailsRoute = fooBarDetailsRouteImport.update({ id: '/$id', path: '/$id', getParentRoute: () => FooBarRoute, } as any) -const fooBarHomeRoute = fooBarHomeImport.update({ +const fooBarHomeRoute = fooBarHomeRouteImport.update({ id: '/', path: '/', getParentRoute: () => FooBarRoute, @@ -50,33 +51,72 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof IndexImport + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRoute } '/foo/bar': { id: '/foo/bar' path: '/foo/bar' fullPath: '/foo/bar' - preLoaderRoute: typeof FooBarImport + preLoaderRoute: typeof FooBarRouteImport parentRoute: typeof rootRoute } '/foo/bar/': { id: '/foo/bar/' path: '/' fullPath: '/foo/bar/' - preLoaderRoute: typeof fooBarHomeImport - parentRoute: typeof FooBarImport + preLoaderRoute: typeof fooBarHomeRouteImport + parentRoute: typeof FooBarRouteImport } '/foo/bar/$id': { id: '/foo/bar/$id' path: '/$id' fullPath: '/foo/bar/$id' - preLoaderRoute: typeof fooBarDetailsImport - parentRoute: typeof FooBarImport + preLoaderRoute: typeof fooBarDetailsRouteImport + parentRoute: typeof FooBarRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes/foo/bar' { + const createFileRoute: CreateFileRoute< + '/foo/bar', + FileRoutesByPath['/foo/bar']['parentRoute'], + FileRoutesByPath['/foo/bar']['id'], + FileRoutesByPath['/foo/bar']['path'], + FileRoutesByPath['/foo/bar']['fullPath'] + > +} +declare module './routes/foo/bar/home' { + const createFileRoute: CreateFileRoute< + '/foo/bar/', + FileRoutesByPath['/foo/bar/']['parentRoute'], + FileRoutesByPath['/foo/bar/']['id'], + FileRoutesByPath['/foo/bar/']['path'], + FileRoutesByPath['/foo/bar/']['fullPath'] + > +} +declare module './routes/foo/bar/details' { + const createFileRoute: CreateFileRoute< + '/foo/bar/$id', + FileRoutesByPath['/foo/bar/$id']['parentRoute'], + FileRoutesByPath['/foo/bar/$id']['id'], + FileRoutesByPath['/foo/bar/$id']['path'], + FileRoutesByPath['/foo/bar/$id']['fullPath'] + > +} + // Create and export the route tree interface FooBarRouteChildren { @@ -136,6 +176,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/virtual-inside-nested/routes/foo/bar.tsx b/packages/router-generator/tests/generator/virtual-inside-nested/routes/foo/bar.tsx index 6ef5a1ca27..dc891bb587 100644 --- a/packages/router-generator/tests/generator/virtual-inside-nested/routes/foo/bar.tsx +++ b/packages/router-generator/tests/generator/virtual-inside-nested/routes/foo/bar.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/foo/bar')({ +export const Route = createFileRoute({ component: () =>
Hello /foo/bar!
, }) diff --git a/packages/router-generator/tests/generator/virtual-inside-nested/routes/foo/bar/details.tsx b/packages/router-generator/tests/generator/virtual-inside-nested/routes/foo/bar/details.tsx index 59c29910fe..4b4c9d6de1 100644 --- a/packages/router-generator/tests/generator/virtual-inside-nested/routes/foo/bar/details.tsx +++ b/packages/router-generator/tests/generator/virtual-inside-nested/routes/foo/bar/details.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/foo/bar/$id')({ +export const Route = createFileRoute({ component: () =>
Hello /foo/bar/$id!
, }) diff --git a/packages/router-generator/tests/generator/virtual-inside-nested/routes/foo/bar/home.tsx b/packages/router-generator/tests/generator/virtual-inside-nested/routes/foo/bar/home.tsx index b7a0742abf..a2d2a7e838 100644 --- a/packages/router-generator/tests/generator/virtual-inside-nested/routes/foo/bar/home.tsx +++ b/packages/router-generator/tests/generator/virtual-inside-nested/routes/foo/bar/home.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/foo/bar/')({ +export const Route = createFileRoute({ component: () =>
Hello /foo/bar/!
, }) diff --git a/packages/router-generator/tests/generator/virtual-inside-nested/routes/index.tsx b/packages/router-generator/tests/generator/virtual-inside-nested/routes/index.tsx index a680913ded..22cab82307 100644 --- a/packages/router-generator/tests/generator/virtual-inside-nested/routes/index.tsx +++ b/packages/router-generator/tests/generator/virtual-inside-nested/routes/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: () =>
Hello /!
, }) diff --git a/packages/router-generator/tests/generator/virtual/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual/routeTree.snapshot.ts index ef967d5c21..4d3eef17b6 100644 --- a/packages/router-generator/tests/generator/virtual/routeTree.snapshot.ts +++ b/packages/router-generator/tests/generator/virtual/routeTree.snapshot.ts @@ -12,91 +12,92 @@ import { createFileRoute } from '@tanstack/react-router' // Import Routes +import type { FileRoutesByPath, CreateFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/root' -import { Route as layoutImport } from './routes/layout' -import { Route as indexImport } from './routes/index' -import { Route as dbDashboardImport } from './routes/db/dashboard' -import { Route as pagesImport } from './routes/pages' -import { Route as HelloIndexImport } from './routes/subtree/index' -import { Route as dbDashboardInvoicesImport } from './routes/db/dashboard-invoices' -import { Route as dbDashboardIndexImport } from './routes/db/dashboard-index' -import { Route as HelloFooIndexImport } from './routes/subtree/foo/index' -import { Route as HelloFooIdImport } from './routes/subtree/foo/$id' -import { Route as dbInvoiceDetailImport } from './routes/db/invoice-detail' -import { Route as dbInvoicesIndexImport } from './routes/db/invoices-index' +import { Route as layoutRouteImport } from './routes/layout' +import { Route as indexRouteImport } from './routes/index' +import { Route as dbDashboardRouteImport } from './routes/db/dashboard' +import { Route as pagesRouteImport } from './routes/pages' +import { Route as HelloIndexRouteImport } from './routes/subtree/index' +import { Route as dbDashboardInvoicesRouteImport } from './routes/db/dashboard-invoices' +import { Route as dbDashboardIndexRouteImport } from './routes/db/dashboard-index' +import { Route as HelloFooIndexRouteImport } from './routes/subtree/foo/index' +import { Route as HelloFooIdRouteImport } from './routes/subtree/foo/$id' +import { Route as dbInvoiceDetailRouteImport } from './routes/db/invoice-detail' +import { Route as dbInvoicesIndexRouteImport } from './routes/db/invoices-index' // Create Virtual Routes -const LangImport = createFileRoute('/$lang')() +const LangRouteImport = createFileRoute('/$lang')() // Create/Update Routes -const layoutRoute = layoutImport.update({ +const layoutRoute = layoutRouteImport.update({ id: '/_layout', getParentRoute: () => rootRoute, } as any) -const LangRoute = LangImport.update({ +const LangRoute = LangRouteImport.update({ id: '/$lang', path: '/$lang', getParentRoute: () => rootRoute, } as any) -const indexRoute = indexImport.update({ +const indexRoute = indexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRoute, } as any) -const dbDashboardRoute = dbDashboardImport.update({ +const dbDashboardRoute = dbDashboardRouteImport.update({ id: '/dashboard', path: '/dashboard', getParentRoute: () => layoutRoute, } as any) -const pagesRoute = pagesImport.update({ +const pagesRoute = pagesRouteImport.update({ id: '/', path: '/', getParentRoute: () => LangRoute, } as any) -const HelloIndexRoute = HelloIndexImport.update({ +const HelloIndexRoute = HelloIndexRouteImport.update({ id: '/hello/', path: '/hello/', getParentRoute: () => layoutRoute, } as any) -const dbDashboardInvoicesRoute = dbDashboardInvoicesImport.update({ +const dbDashboardInvoicesRoute = dbDashboardInvoicesRouteImport.update({ id: '/invoices', path: '/invoices', getParentRoute: () => dbDashboardRoute, } as any) -const dbDashboardIndexRoute = dbDashboardIndexImport.update({ +const dbDashboardIndexRoute = dbDashboardIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => dbDashboardRoute, } as any) -const HelloFooIndexRoute = HelloFooIndexImport.update({ +const HelloFooIndexRoute = HelloFooIndexRouteImport.update({ id: '/hello/foo/', path: '/hello/foo/', getParentRoute: () => layoutRoute, } as any) -const HelloFooIdRoute = HelloFooIdImport.update({ +const HelloFooIdRoute = HelloFooIdRouteImport.update({ id: '/hello/foo/$id', path: '/hello/foo/$id', getParentRoute: () => layoutRoute, } as any) -const dbInvoiceDetailRoute = dbInvoiceDetailImport.update({ +const dbInvoiceDetailRoute = dbInvoiceDetailRouteImport.update({ id: '/$id', path: '/$id', getParentRoute: () => dbDashboardInvoicesRoute, } as any) -const dbInvoicesIndexRoute = dbInvoicesIndexImport.update({ +const dbInvoicesIndexRoute = dbInvoicesIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => dbDashboardInvoicesRoute, @@ -110,89 +111,200 @@ declare module '@tanstack/react-router' { id: '/' path: '/' fullPath: '/' - preLoaderRoute: typeof indexImport + preLoaderRoute: typeof indexRouteImport parentRoute: typeof rootRoute } '/$lang': { id: '/$lang' path: '/$lang' fullPath: '/$lang' - preLoaderRoute: typeof LangImport + preLoaderRoute: typeof LangRouteImport parentRoute: typeof rootRoute } '/_layout': { id: '/_layout' path: '' fullPath: '' - preLoaderRoute: typeof layoutImport + preLoaderRoute: typeof layoutRouteImport parentRoute: typeof rootRoute } '/$lang/': { id: '/$lang/' path: '/' fullPath: '/$lang/' - preLoaderRoute: typeof pagesImport - parentRoute: typeof LangImport + preLoaderRoute: typeof pagesRouteImport + parentRoute: typeof LangRouteImport } '/_layout/dashboard': { id: '/_layout/dashboard' path: '/dashboard' fullPath: '/dashboard' - preLoaderRoute: typeof dbDashboardImport - parentRoute: typeof layoutImport + preLoaderRoute: typeof dbDashboardRouteImport + parentRoute: typeof layoutRouteImport } '/_layout/dashboard/': { id: '/_layout/dashboard/' path: '/' fullPath: '/dashboard/' - preLoaderRoute: typeof dbDashboardIndexImport - parentRoute: typeof dbDashboardImport + preLoaderRoute: typeof dbDashboardIndexRouteImport + parentRoute: typeof dbDashboardRouteImport } '/_layout/dashboard/invoices': { id: '/_layout/dashboard/invoices' path: '/invoices' fullPath: '/dashboard/invoices' - preLoaderRoute: typeof dbDashboardInvoicesImport - parentRoute: typeof dbDashboardImport + preLoaderRoute: typeof dbDashboardInvoicesRouteImport + parentRoute: typeof dbDashboardRouteImport } '/_layout/hello/': { id: '/_layout/hello/' path: '/hello' fullPath: '/hello' - preLoaderRoute: typeof HelloIndexImport - parentRoute: typeof layoutImport + preLoaderRoute: typeof HelloIndexRouteImport + parentRoute: typeof layoutRouteImport } '/_layout/dashboard/invoices/': { id: '/_layout/dashboard/invoices/' path: '/' fullPath: '/dashboard/invoices/' - preLoaderRoute: typeof dbInvoicesIndexImport - parentRoute: typeof dbDashboardInvoicesImport + preLoaderRoute: typeof dbInvoicesIndexRouteImport + parentRoute: typeof dbDashboardInvoicesRouteImport } '/_layout/dashboard/invoices/$id': { id: '/_layout/dashboard/invoices/$id' path: '/$id' fullPath: '/dashboard/invoices/$id' - preLoaderRoute: typeof dbInvoiceDetailImport - parentRoute: typeof dbDashboardInvoicesImport + preLoaderRoute: typeof dbInvoiceDetailRouteImport + parentRoute: typeof dbDashboardInvoicesRouteImport } '/_layout/hello/foo/$id': { id: '/_layout/hello/foo/$id' path: '/hello/foo/$id' fullPath: '/hello/foo/$id' - preLoaderRoute: typeof HelloFooIdImport - parentRoute: typeof layoutImport + preLoaderRoute: typeof HelloFooIdRouteImport + parentRoute: typeof layoutRouteImport } '/_layout/hello/foo/': { id: '/_layout/hello/foo/' path: '/hello/foo' fullPath: '/hello/foo' - preLoaderRoute: typeof HelloFooIndexImport - parentRoute: typeof layoutImport + preLoaderRoute: typeof HelloFooIndexRouteImport + parentRoute: typeof layoutRouteImport } } } +// Add type-safety to the createFileRoute function across the route tree + +declare module './routes/index' { + const createFileRoute: CreateFileRoute< + '/', + FileRoutesByPath['/']['parentRoute'], + FileRoutesByPath['/']['id'], + FileRoutesByPath['/']['path'], + FileRoutesByPath['/']['fullPath'] + > +} +declare module './routes' { + const createFileRoute: CreateFileRoute< + '/$lang', + FileRoutesByPath['/$lang']['parentRoute'], + FileRoutesByPath['/$lang']['id'], + FileRoutesByPath['/$lang']['path'], + FileRoutesByPath['/$lang']['fullPath'] + > +} +declare module './routes/layout' { + const createFileRoute: CreateFileRoute< + '/_layout', + FileRoutesByPath['/_layout']['parentRoute'], + FileRoutesByPath['/_layout']['id'], + FileRoutesByPath['/_layout']['path'], + FileRoutesByPath['/_layout']['fullPath'] + > +} +declare module './routes/pages' { + const createFileRoute: CreateFileRoute< + '/$lang/', + FileRoutesByPath['/$lang/']['parentRoute'], + FileRoutesByPath['/$lang/']['id'], + FileRoutesByPath['/$lang/']['path'], + FileRoutesByPath['/$lang/']['fullPath'] + > +} +declare module './routes/db/dashboard' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard', + FileRoutesByPath['/_layout/dashboard']['parentRoute'], + FileRoutesByPath['/_layout/dashboard']['id'], + FileRoutesByPath['/_layout/dashboard']['path'], + FileRoutesByPath['/_layout/dashboard']['fullPath'] + > +} +declare module './routes/db/dashboard-index' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard/', + FileRoutesByPath['/_layout/dashboard/']['parentRoute'], + FileRoutesByPath['/_layout/dashboard/']['id'], + FileRoutesByPath['/_layout/dashboard/']['path'], + FileRoutesByPath['/_layout/dashboard/']['fullPath'] + > +} +declare module './routes/db/dashboard-invoices' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard/invoices', + FileRoutesByPath['/_layout/dashboard/invoices']['parentRoute'], + FileRoutesByPath['/_layout/dashboard/invoices']['id'], + FileRoutesByPath['/_layout/dashboard/invoices']['path'], + FileRoutesByPath['/_layout/dashboard/invoices']['fullPath'] + > +} +declare module './routes/subtree/index' { + const createFileRoute: CreateFileRoute< + '/_layout/hello/', + FileRoutesByPath['/_layout/hello/']['parentRoute'], + FileRoutesByPath['/_layout/hello/']['id'], + FileRoutesByPath['/_layout/hello/']['path'], + FileRoutesByPath['/_layout/hello/']['fullPath'] + > +} +declare module './routes/db/invoices-index' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard/invoices/', + FileRoutesByPath['/_layout/dashboard/invoices/']['parentRoute'], + FileRoutesByPath['/_layout/dashboard/invoices/']['id'], + FileRoutesByPath['/_layout/dashboard/invoices/']['path'], + FileRoutesByPath['/_layout/dashboard/invoices/']['fullPath'] + > +} +declare module './routes/db/invoice-detail' { + const createFileRoute: CreateFileRoute< + '/_layout/dashboard/invoices/$id', + FileRoutesByPath['/_layout/dashboard/invoices/$id']['parentRoute'], + FileRoutesByPath['/_layout/dashboard/invoices/$id']['id'], + FileRoutesByPath['/_layout/dashboard/invoices/$id']['path'], + FileRoutesByPath['/_layout/dashboard/invoices/$id']['fullPath'] + > +} +declare module './routes/subtree/foo/$id' { + const createFileRoute: CreateFileRoute< + '/_layout/hello/foo/$id', + FileRoutesByPath['/_layout/hello/foo/$id']['parentRoute'], + FileRoutesByPath['/_layout/hello/foo/$id']['id'], + FileRoutesByPath['/_layout/hello/foo/$id']['path'], + FileRoutesByPath['/_layout/hello/foo/$id']['fullPath'] + > +} +declare module './routes/subtree/foo/index' { + const createFileRoute: CreateFileRoute< + '/_layout/hello/foo/', + FileRoutesByPath['/_layout/hello/foo/']['parentRoute'], + FileRoutesByPath['/_layout/hello/foo/']['id'], + FileRoutesByPath['/_layout/hello/foo/']['path'], + FileRoutesByPath['/_layout/hello/foo/']['fullPath'] + > +} + // Create and export the route tree interface LangRouteChildren { @@ -351,6 +463,9 @@ export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) ._addFileTypes() +// @ts-ignore +import type * as ServerTypes from '.tanstack-start/server-routes/routeTree.gen.ts' + /* ROUTE_MANIFEST_START { "routes": { diff --git a/packages/router-generator/tests/generator/virtual/routes/db/dashboard-index.tsx b/packages/router-generator/tests/generator/virtual/routes/db/dashboard-index.tsx index a92fc772c3..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual/routes/db/dashboard-index.tsx +++ b/packages/router-generator/tests/generator/virtual/routes/db/dashboard-index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard/')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual/routes/db/dashboard-invoices.tsx b/packages/router-generator/tests/generator/virtual/routes/db/dashboard-invoices.tsx index bf7e5a02b2..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual/routes/db/dashboard-invoices.tsx +++ b/packages/router-generator/tests/generator/virtual/routes/db/dashboard-invoices.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard/invoices')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual/routes/db/dashboard.tsx b/packages/router-generator/tests/generator/virtual/routes/db/dashboard.tsx index d5b4f49706..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual/routes/db/dashboard.tsx +++ b/packages/router-generator/tests/generator/virtual/routes/db/dashboard.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual/routes/db/invoice-detail.tsx b/packages/router-generator/tests/generator/virtual/routes/db/invoice-detail.tsx index e7be6c1910..a1ed3d4a28 100644 --- a/packages/router-generator/tests/generator/virtual/routes/db/invoice-detail.tsx +++ b/packages/router-generator/tests/generator/virtual/routes/db/invoice-detail.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard/invoices/$id')({ +export const Route = createFileRoute({ component: () =>
Hello /_layout/dashboard/invoices/$id!
, }) diff --git a/packages/router-generator/tests/generator/virtual/routes/db/invoices-index.tsx b/packages/router-generator/tests/generator/virtual/routes/db/invoices-index.tsx index f2e56721b6..960e382af9 100644 --- a/packages/router-generator/tests/generator/virtual/routes/db/invoices-index.tsx +++ b/packages/router-generator/tests/generator/virtual/routes/db/invoices-index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/dashboard/invoices/')({ +export const Route = createFileRoute({ component: () =>
Hello /_layout/dashboard/invoices/!
, }) diff --git a/packages/router-generator/tests/generator/virtual/routes/index.tsx b/packages/router-generator/tests/generator/virtual/routes/index.tsx index a294139860..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual/routes/index.tsx +++ b/packages/router-generator/tests/generator/virtual/routes/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual/routes/layout.tsx b/packages/router-generator/tests/generator/virtual/routes/layout.tsx index 2e48e48410..67e477a70a 100644 --- a/packages/router-generator/tests/generator/virtual/routes/layout.tsx +++ b/packages/router-generator/tests/generator/virtual/routes/layout.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout')({ +export const Route = createFileRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual/routes/pages.tsx b/packages/router-generator/tests/generator/virtual/routes/pages.tsx index a942c7ce75..488a59a55a 100644 --- a/packages/router-generator/tests/generator/virtual/routes/pages.tsx +++ b/packages/router-generator/tests/generator/virtual/routes/pages.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/$lang/')({ +export const Route = createFileRoute({ component: RouteComponent, }) diff --git a/packages/router-generator/tests/generator/virtual/routes/subtree/foo/$id.tsx b/packages/router-generator/tests/generator/virtual/routes/subtree/foo/$id.tsx index d8cbd795a7..8418001767 100644 --- a/packages/router-generator/tests/generator/virtual/routes/subtree/foo/$id.tsx +++ b/packages/router-generator/tests/generator/virtual/routes/subtree/foo/$id.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/hello/foo/$id')({ +export const Route = createFileRoute({ component: () =>
Hello /foo/$id!
, }) diff --git a/packages/router-generator/tests/generator/virtual/routes/subtree/foo/index.tsx b/packages/router-generator/tests/generator/virtual/routes/subtree/foo/index.tsx index 10233de496..84660c4d04 100644 --- a/packages/router-generator/tests/generator/virtual/routes/subtree/foo/index.tsx +++ b/packages/router-generator/tests/generator/virtual/routes/subtree/foo/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/hello/foo/')({ +export const Route = createFileRoute({ component: () =>
Hello /foo/!
, }) diff --git a/packages/router-generator/tests/generator/virtual/routes/subtree/index.tsx b/packages/router-generator/tests/generator/virtual/routes/subtree/index.tsx index 3367799b96..22cab82307 100644 --- a/packages/router-generator/tests/generator/virtual/routes/subtree/index.tsx +++ b/packages/router-generator/tests/generator/virtual/routes/subtree/index.tsx @@ -1,5 +1,3 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/_layout/hello/')({ +export const Route = createFileRoute({ component: () =>
Hello /!
, }) diff --git a/packages/router-plugin/src/core/code-splitter/compilers.ts b/packages/router-plugin/src/core/code-splitter/compilers.ts index 91ca8ccf79..7b4aeb7f38 100644 --- a/packages/router-plugin/src/core/code-splitter/compilers.ts +++ b/packages/router-plugin/src/core/code-splitter/compilers.ts @@ -7,6 +7,7 @@ import { } from 'babel-dead-code-elimination' import { generateFromAst, parseAst } from '@tanstack/router-utils' import { tsrSplit } from '../constants' +import { routeHmrStatement } from '../route-hmr-statement' import { createIdentifier } from './path-ids' import { getFrameworkOptions } from './framework-options' import type { GeneratorResult, ParseAstOptions } from '@tanstack/router-utils' @@ -117,6 +118,8 @@ export function compileCodeSplitReferenceRoute( runtimeEnv: 'dev' | 'prod' codeSplitGroupings: CodeSplitGroupings targetFramework: Config['target'] + filename: string + id: string }, ): GeneratorResult { const ast = parseAst(opts) @@ -166,18 +169,13 @@ export function compileCodeSplitReferenceRoute( return } - if (t.isCallExpression(path.parentPath.node)) { - const options = resolveIdentifier( - path, - path.parentPath.node.arguments[0], - ) - + function babelHandleReference(routeOptions: t.Node | undefined) { const hasImportedOrDefinedIdentifier = (name: string) => { return programPath.scope.hasBinding(name) } - if (t.isObjectExpression(options)) { - options.properties.forEach((prop) => { + if (t.isObjectExpression(routeOptions)) { + routeOptions.properties.forEach((prop) => { if (t.isObjectProperty(prop)) { if (t.isIdentifier(prop.key)) { // If the user has not specified a split grouping for this key @@ -288,18 +286,9 @@ export function compileCodeSplitReferenceRoute( )() } - // If the TSRDummyComponent is not defined, define it - if ( - opts.runtimeEnv !== 'prod' && // only in development - !hasImportedOrDefinedIdentifier( - frameworkOptions.idents.dummyHMRComponent, - ) - ) { - programPath.pushContainer('body', [ - template.statement( - frameworkOptions.dummyHMRComponent, - )(), - ]) + // add HMR handling + if (opts.runtimeEnv !== 'prod') { + programPath.pushContainer('body', routeHmrStatement) } } @@ -369,6 +358,27 @@ export function compileCodeSplitReferenceRoute( }) } } + + if (t.isCallExpression(path.parentPath.node)) { + // createFileRoute('/')({ ... }) + const options = resolveIdentifier( + path, + path.parentPath.node.arguments[0], + ) + + babelHandleReference(options) + } else if (t.isVariableDeclarator(path.parentPath.node)) { + // createFileRoute({ ... }) + const caller = resolveIdentifier( + path, + path.parentPath.node.init, + ) + + if (t.isCallExpression(caller)) { + const options = resolveIdentifier(path, caller.arguments[0]) + babelHandleReference(options) + } + } }, }, state, @@ -406,6 +416,7 @@ export function compileCodeSplitReferenceRoute( export function compileCodeSplitVirtualRoute( opts: ParseAstOptions & { splitTargets: Array + filename: string }, ): GeneratorResult { const ast = parseAst(opts) @@ -448,12 +459,7 @@ export function compileCodeSplitVirtualRoute( return } - if (t.isCallExpression(path.parentPath.node)) { - const options = resolveIdentifier( - path, - path.parentPath.node.arguments[0], - ) - + function babelHandleVirtual(options: t.Node | undefined) { if (t.isObjectExpression(options)) { options.properties.forEach((prop) => { if (t.isObjectProperty(prop)) { @@ -497,6 +503,27 @@ export function compileCodeSplitVirtualRoute( options.properties = [] } } + + if (t.isCallExpression(path.parentPath.node)) { + // createFileRoute('/')({ ... }) + const options = resolveIdentifier( + path, + path.parentPath.node.arguments[0], + ) + + babelHandleVirtual(options) + } else if (t.isVariableDeclarator(path.parentPath.node)) { + // createFileRoute({ ... }) + const caller = resolveIdentifier( + path, + path.parentPath.node.init, + ) + + if (t.isCallExpression(caller)) { + const options = resolveIdentifier(path, caller.arguments[0]) + babelHandleVirtual(options) + } + } }, }, state, @@ -841,7 +868,7 @@ function getImportSpecifierAndPathFromLocalName( } // Reusable function to get literal value or resolve variable to literal -function resolveIdentifier(path: any, node: any) { +function resolveIdentifier(path: any, node: any): t.Node | undefined { if (t.isIdentifier(node)) { const binding = path.scope.getBinding(node.name) if ( diff --git a/packages/router-plugin/src/core/code-splitter/framework-options.ts b/packages/router-plugin/src/core/code-splitter/framework-options.ts index 909f7607d6..860178b1f1 100644 --- a/packages/router-plugin/src/core/code-splitter/framework-options.ts +++ b/packages/router-plugin/src/core/code-splitter/framework-options.ts @@ -4,9 +4,7 @@ type FrameworkOptions = { createFileRoute: string lazyFn: string lazyRouteComponent: string - dummyHMRComponent: string } - dummyHMRComponent: string } export function getFrameworkOptions(framework: string): FrameworkOptions { @@ -20,9 +18,7 @@ export function getFrameworkOptions(framework: string): FrameworkOptions { createFileRoute: 'createFileRoute', lazyFn: 'lazyFn', lazyRouteComponent: 'lazyRouteComponent', - dummyHMRComponent: 'TSRDummyComponent', }, - dummyHMRComponent: `export function TSRDummyComponent() { return null }`, } break case 'solid': @@ -32,9 +28,7 @@ export function getFrameworkOptions(framework: string): FrameworkOptions { createFileRoute: 'createFileRoute', lazyFn: 'lazyFn', lazyRouteComponent: 'lazyRouteComponent', - dummyHMRComponent: 'TSRDummyComponent', }, - dummyHMRComponent: `export function TSRDummyComponent() { return null }`, } break default: diff --git a/packages/router-plugin/src/core/route-hmr-statement.ts b/packages/router-plugin/src/core/route-hmr-statement.ts new file mode 100644 index 0000000000..73e66cf4cb --- /dev/null +++ b/packages/router-plugin/src/core/route-hmr-statement.ts @@ -0,0 +1,13 @@ +import * as template from '@babel/template' + +export const routeHmrStatement = template.statement( + ` +if (import.meta.hot) { + import.meta.hot.accept((newModule) => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route) + } + }) +} +`, +)() diff --git a/packages/router-plugin/src/core/router-code-splitter-plugin.ts b/packages/router-plugin/src/core/router-code-splitter-plugin.ts index 7c1ecc17a8..0c54f367e9 100644 --- a/packages/router-plugin/src/core/router-code-splitter-plugin.ts +++ b/packages/router-plugin/src/core/router-code-splitter-plugin.ts @@ -3,7 +3,6 @@ * https://github.com/TanStack/router/pull/3355 */ -import { isAbsolute, join, normalize } from 'node:path' import { fileURLToPath, pathToFileURL } from 'node:url' import { logDiff } from '@tanstack/router-utils' import { getConfig, splitGroupingsSchema } from './config' @@ -18,6 +17,7 @@ import { tsrSplit, } from './constants' import { decodeIdentifier } from './code-splitter/path-ids' +import { debug, fileIsInRoutesDirectory } from './utils' import type { CodeSplitGroupings, SplitRouteIdentNodes } from './constants' import type { Config } from './config' @@ -27,27 +27,10 @@ import type { TransformResult as UnpluginTransformResult, } from 'unplugin' -const debug = - process.env.TSR_VITE_DEBUG && - ['true', 'router-plugin'].includes(process.env.TSR_VITE_DEBUG) - function capitalizeFirst(str: string): string { return str.charAt(0).toUpperCase() + str.slice(1) } -function fileIsInRoutesDirectory( - filePath: string, - routesDirectory: string, -): boolean { - const routesDirectoryPath = isAbsolute(routesDirectory) - ? routesDirectory - : join(process.cwd(), routesDirectory) - - const path = normalize(filePath) - - return path.startsWith(routesDirectoryPath) -} - type BannedBeforeExternalPlugin = { identifier: string pkg: string @@ -104,8 +87,6 @@ export const unpluginRouterCodeSplitterFactory: UnpluginFactory< const fromCode = detectCodeSplitGroupingsFromRoute({ code, - root: ROOT, - filename: id, }) if (fromCode.groupings) { @@ -139,11 +120,11 @@ export const unpluginRouterCodeSplitterFactory: UnpluginFactory< const compiledReferenceRoute = compileCodeSplitReferenceRoute({ code, - root: ROOT, - filename: id, runtimeEnv: isProduction ? 'prod' : 'dev', codeSplitGroupings: splitGroupings, targetFramework: userConfig.target, + filename: id, + id, }) if (debug) { @@ -178,7 +159,6 @@ export const unpluginRouterCodeSplitterFactory: UnpluginFactory< const result = compileCodeSplitVirtualRoute({ code, - root: ROOT, filename: id, splitTargets: grouping, }) diff --git a/packages/router-plugin/src/core/router-composed-plugin.ts b/packages/router-plugin/src/core/router-composed-plugin.ts index a8256f8b4b..fe384be10f 100644 --- a/packages/router-plugin/src/core/router-composed-plugin.ts +++ b/packages/router-plugin/src/core/router-composed-plugin.ts @@ -1,22 +1,30 @@ import { unpluginRouterGeneratorFactory } from './router-generator-plugin' import { unpluginRouterCodeSplitterFactory } from './router-code-splitter-plugin' - +import { unpluginRouterHmrFactory } from './router-hmr-plugin' import type { Config } from './config' import type { UnpluginFactory } from 'unplugin' export const unpluginRouterComposedFactory: UnpluginFactory< Partial | undefined > = (options = {}, meta) => { - const routerGenerator = unpluginRouterGeneratorFactory(options, meta) + const getPlugin = (pluginFactory: UnpluginFactory>) => { + const plugin = pluginFactory(options, meta) + if (!Array.isArray(plugin)) { + return [plugin] + } + return plugin + } - const routerGeneratorOptions = Array.isArray(routerGenerator) - ? routerGenerator - : [routerGenerator] + const routerGenerator = getPlugin(unpluginRouterGeneratorFactory) + const routerCodeSplitter = getPlugin(unpluginRouterCodeSplitterFactory) - const routerCodeSplitter = unpluginRouterCodeSplitterFactory(options, meta) - const routerCodeSplitterOptions = Array.isArray(routerCodeSplitter) - ? routerCodeSplitter - : [routerCodeSplitter] + const result = [...routerGenerator, ...routerCodeSplitter] - return [...routerGeneratorOptions, ...routerCodeSplitterOptions] + const isProduction = process.env.NODE_ENV === 'production' + + if (!isProduction && !options.autoCodeSplitting) { + const routerHmr = getPlugin(unpluginRouterHmrFactory) + result.push(...routerHmr) + } + return result } diff --git a/packages/router-plugin/src/core/router-generator-plugin.ts b/packages/router-plugin/src/core/router-generator-plugin.ts index f4cec60235..39829d60a7 100644 --- a/packages/router-plugin/src/core/router-generator-plugin.ts +++ b/packages/router-plugin/src/core/router-generator-plugin.ts @@ -82,12 +82,23 @@ export const unpluginRouterGeneratorFactory: UnpluginFactory< }) }, vite: { - async configResolved(config) { + configResolved(config) { ROOT = config.root userConfig = getConfig(options, ROOT) + // if (config.command === 'serve') { + // await run(generate) + // } + }, + async buildStart() { + if (this.environment.name === 'server') { + // When building in environment mode, we only need to generate routes + // for the client environment + return + } await run(generate) }, + sharedDuringBuild: true, }, rspack(compiler) { userConfig = getConfig(options, ROOT) diff --git a/packages/router-plugin/src/core/router-hmr-plugin.ts b/packages/router-plugin/src/core/router-hmr-plugin.ts new file mode 100644 index 0000000000..406666421d --- /dev/null +++ b/packages/router-plugin/src/core/router-hmr-plugin.ts @@ -0,0 +1,67 @@ +import { generateFromAst, logDiff, parseAst } from '@tanstack/router-utils' +import { getConfig } from './config' +import { routeHmrStatement } from './route-hmr-statement' +import { debug, fileIsInRoutesDirectory } from './utils' +import type { Config } from './config' +import type { UnpluginFactory } from 'unplugin' + +/** + * This plugin adds HMR support for file routes. + * It is only added to the composed plugin in dev when autoCodeSplitting is disabled, since the code splitting plugin + * handles HMR for code-split routes itself. + */ +export const unpluginRouterHmrFactory: UnpluginFactory< + Partial | undefined +> = (options = {}) => { + let ROOT: string = process.cwd() + let userConfig = options as Config + + return { + name: 'router-hmr-plugin', + enforce: 'pre', + + transform(code, id) { + if (!code.includes('export const Route = createFileRoute(')) { + return null + } + + if (debug) console.info('Adding HMR handling to route ', id) + + const ast = parseAst({ code }) + ast.program.body.push(routeHmrStatement) + const result = generateFromAst(ast, { + sourceMaps: true, + filename: id, + sourceFileName: id, + }) + if (debug) { + logDiff(code, result.code) + console.log('Output:\n', result.code + '\n\n') + } + return result + }, + + transformInclude(id) { + return fileIsInRoutesDirectory(id, userConfig.routesDirectory) + }, + + vite: { + configResolved(config) { + ROOT = config.root + config.mode + + userConfig = getConfig(options, ROOT) + }, + }, + + rspack() { + ROOT = process.cwd() + userConfig = getConfig(options, ROOT) + }, + + webpack() { + ROOT = process.cwd() + userConfig = getConfig(options, ROOT) + }, + } +} diff --git a/packages/router-plugin/src/core/utils.ts b/packages/router-plugin/src/core/utils.ts new file mode 100644 index 0000000000..d866a2241f --- /dev/null +++ b/packages/router-plugin/src/core/utils.ts @@ -0,0 +1,18 @@ +import { isAbsolute, join, normalize } from 'node:path' + +export const debug = + process.env.TSR_VITE_DEBUG && + ['true', 'router-plugin'].includes(process.env.TSR_VITE_DEBUG) + +export function fileIsInRoutesDirectory( + filePath: string, + routesDirectory: string, +): boolean { + const routesDirectoryPath = isAbsolute(routesDirectory) + ? routesDirectory + : join(process.cwd(), routesDirectory) + + const path = normalize(filePath) + + return path.startsWith(routesDirectoryPath) +} diff --git a/packages/router-plugin/tests/code-splitter.test.ts b/packages/router-plugin/tests/code-splitter.test.ts index ec1bbec5e9..c4fa076cec 100644 --- a/packages/router-plugin/tests/code-splitter.test.ts +++ b/packages/router-plugin/tests/code-splitter.test.ts @@ -67,8 +67,8 @@ describe('code-splitter works', () => { const compileResult = compileCodeSplitReferenceRoute({ code, - root: dirs.files, filename, + id: filename, runtimeEnv: NODE_ENV === 'production' ? 'prod' : 'dev', codeSplitGroupings: grouping, targetFramework: framework, @@ -91,7 +91,6 @@ describe('code-splitter works', () => { const splitResult = compileCodeSplitVirtualRoute({ code, - root: dirs.files, filename: `${filename}?${ident}`, splitTargets: targets, }) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/arrow-function.tsx index 0e48584a4a..d13fdc0a9a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/arrow-function.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/posts')({ loader: fetchPosts, component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/chinese.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/chinese.tsx index dffbd70c4d..abe95e1645 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/chinese.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/chinese.tsx @@ -8,6 +8,10 @@ export const Route = createFileRoute('/')({ interface DemoProps { title: string; } -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/conditional-properties.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/conditional-properties.tsx index 26de4ca825..45da5048e8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/conditional-properties.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/conditional-properties.tsx @@ -8,6 +8,10 @@ export const Route = createFileRoute('/posts')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: isEnabled ? TrueImport.loader : falseLoader }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/destructured-react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/destructured-react-memo-imported-component.tsx index 0fbc312626..7b57f3ebd9 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/destructured-react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/destructured-react-memo-imported-component.tsx @@ -6,6 +6,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: importedLoader }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/export-default-component-and-normal-notFound.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/export-default-component-and-normal-notFound.tsx index 0c88bfe0ad..a0ab6c5ab1 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/export-default-component-and-normal-notFound.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/export-default-component-and-normal-notFound.tsx @@ -12,6 +12,10 @@ export default function Home() {

{one}

; } -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/function-declaration.tsx index c395bc44ee..ae10058a91 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/function-declaration.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/function-declaration.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/posts')({ loader: fetchPosts, component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/importAttribute.tsx index 8a221122d7..1207dee6d6 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/importAttribute.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/importAttribute.tsx @@ -4,6 +4,10 @@ import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-default-component-destructured-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-default-component-destructured-loader.tsx index e23a496a74..f33aef1023 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-default-component-destructured-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-default-component-destructured-loader.tsx @@ -6,6 +6,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: importedLoader }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-default-component.tsx index 968e6633d4..19b8875997 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-default-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-default-component.tsx @@ -4,6 +4,10 @@ import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-errorComponent.tsx index 0701029aa3..21a9069938 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-errorComponent.tsx @@ -6,6 +6,17 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); +} +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-notFoundComponent.tsx index 63787a44d6..9f608978f5 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-notFoundComponent.tsx @@ -6,6 +6,17 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); +} +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-pendingComponent.tsx index 13cfc22f7b..763d8ff26c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported-pendingComponent.tsx @@ -6,6 +6,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), pendingComponent: importedPendingComponent }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported.tsx index c4a5d9dbc4..7baa2e3057 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/imported.tsx @@ -6,6 +6,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: importedLoader }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/inline.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/inline.tsx index 931f6bce74..c19e2898d5 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/inline.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/inline.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/')({ }); Route.addChildren([]); export const test = 'test'; -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/random-number.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/random-number.tsx index b229826efb..8b00e0aa9c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/random-number.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/random-number.tsx @@ -30,6 +30,10 @@ export const Route = createFileRoute('/')({ }, component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/react-memo-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/react-memo-component.tsx index dc266fa611..c5f946a469 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/react-memo-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/react-memo-component.tsx @@ -6,6 +6,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: importedLoader }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/react-memo-imported-component.tsx index b1df7f4cf9..49922c6c9d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/react-memo-imported-component.tsx @@ -6,6 +6,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: importedLoader }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/retain-exports-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/retain-exports-loader.tsx index 2d40731c37..047970676d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/retain-exports-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/retain-exports-loader.tsx @@ -14,6 +14,10 @@ export const Route = createFileRoute('/_layout')({ export const SIDEBAR_WIDTH = '150px'; export const SIDEBAR_MINI_WIDTH = '80px'; const ASIDE_WIDTH = '250px'; -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/useStateDestructure.tsx index 6cfb35e525..103067c81a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/useStateDestructure.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/development/useStateDestructure.tsx @@ -116,9 +116,9 @@ export default function VersionIndex() {

Full-document SSR, Streaming, Server Functions, bundling and more, - powered by TanStack Router, Vinxi,{' '} - Nitro and Vite. Ready to deploy to - your favorite hosting provider. + powered by TanStack Router, Nitro{' '} + and Vite. Ready to deploy to your favorite hosting + provider.

diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/production/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/production/useStateDestructure.tsx index 6cfb35e525..103067c81a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/production/useStateDestructure.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/production/useStateDestructure.tsx @@ -116,9 +116,9 @@ export default function VersionIndex() {

Full-document SSR, Streaming, Server Functions, bundling and more, - powered by TanStack Router, Vinxi,{' '} - Nitro and Vite. Ready to deploy to - your favorite hosting provider. + powered by TanStack Router, Nitro{' '} + and Vite. Ready to deploy to your favorite hosting + provider.

diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/arrow-function.tsx index 7104674b73..99fdcb621a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/arrow-function.tsx @@ -8,6 +8,10 @@ export const Route = createFileRoute('/posts')({ loader: lazyFn($$splitLoaderImporter, 'loader'), component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/chinese.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/chinese.tsx index 3efbe3595d..5dc9c6c39c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/chinese.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/chinese.tsx @@ -8,6 +8,10 @@ export const Route = createFileRoute('/')({ interface DemoProps { title: string; } -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/conditional-properties.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/conditional-properties.tsx index a126bb6807..e59fb6b170 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/conditional-properties.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/conditional-properties.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/posts')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: lazyFn($$splitLoaderImporter, 'loader') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/destructured-react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/destructured-react-memo-imported-component.tsx index 65f2bfb918..1a97263515 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/destructured-react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/destructured-react-memo-imported-component.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: lazyFn($$splitLoaderImporter, 'loader') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/export-default-component-and-normal-notFound.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/export-default-component-and-normal-notFound.tsx index 762ac36b1d..fc60c1de1c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/export-default-component-and-normal-notFound.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/export-default-component-and-normal-notFound.tsx @@ -12,6 +12,10 @@ export default function Home() {

{one}

; } -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/function-declaration.tsx index d6e6fa8152..0c2b2f0f7f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/function-declaration.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/function-declaration.tsx @@ -8,6 +8,10 @@ export const Route = createFileRoute('/posts')({ loader: lazyFn($$splitLoaderImporter, 'loader'), component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/importAttribute.tsx index b89aede427..c189737cc9 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/importAttribute.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/importAttribute.tsx @@ -4,6 +4,10 @@ import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-default-component-destructured-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-default-component-destructured-loader.tsx index 9169f0b966..1519ca0183 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-default-component-destructured-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-default-component-destructured-loader.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: lazyFn($$splitLoaderImporter, 'loader') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-default-component.tsx index 9b38429966..27aa2140f6 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-default-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-default-component.tsx @@ -4,6 +4,10 @@ import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-errorComponent.tsx index 108ad65fde..7111e86e76 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-errorComponent.tsx @@ -6,6 +6,17 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); +} +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-notFoundComponent.tsx index 4df3a0edc2..5622edf3e8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-notFoundComponent.tsx @@ -6,6 +6,17 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); +} +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-pendingComponent.tsx index 8a12860d09..b01e0aec42 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported-pendingComponent.tsx @@ -6,6 +6,17 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), pendingComponent: lazyRouteComponent($$splitPendingComponentImporter, 'pendingComponent') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); +} +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported.tsx index b8c6e8c0ff..f2947f2004 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/imported.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: lazyFn($$splitLoaderImporter, 'loader') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/inline.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/inline.tsx index a179d36c0b..12626addb0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/inline.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/inline.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/')({ }); Route.addChildren([]); export const test = 'test'; -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/random-number.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/random-number.tsx index 92f502edde..bb9a25ce5b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/random-number.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/random-number.tsx @@ -26,6 +26,10 @@ export const Route = createFileRoute('/')({ loader: lazyFn($$splitLoaderImporter, 'loader'), component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/react-memo-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/react-memo-component.tsx index bf8ae8af25..f99d37f872 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/react-memo-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/react-memo-component.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: lazyFn($$splitLoaderImporter, 'loader') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/react-memo-imported-component.tsx index 5987f84c0a..6f5453d797 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/react-memo-imported-component.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: lazyFn($$splitLoaderImporter, 'loader') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/retain-exports-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/retain-exports-loader.tsx index c8da9752f0..9f37f2c2ba 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/retain-exports-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/retain-exports-loader.tsx @@ -14,6 +14,10 @@ export const Route = createFileRoute('/_layout')({ export const SIDEBAR_WIDTH = '150px'; export const SIDEBAR_MINI_WIDTH = '80px'; const ASIDE_WIDTH = '250px'; -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/useStateDestructure.tsx index 6cfb35e525..103067c81a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/useStateDestructure.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/development/useStateDestructure.tsx @@ -116,9 +116,9 @@ export default function VersionIndex() {

Full-document SSR, Streaming, Server Functions, bundling and more, - powered by TanStack Router, Vinxi,{' '} - Nitro and Vite. Ready to deploy to - your favorite hosting provider. + powered by TanStack Router, Nitro{' '} + and Vite. Ready to deploy to your favorite hosting + provider.

diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/production/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/production/useStateDestructure.tsx index 6cfb35e525..103067c81a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/production/useStateDestructure.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/production/useStateDestructure.tsx @@ -116,9 +116,9 @@ export default function VersionIndex() {

Full-document SSR, Streaming, Server Functions, bundling and more, - powered by TanStack Router, Vinxi,{' '} - Nitro and Vite. Ready to deploy to - your favorite hosting provider. + powered by TanStack Router, Nitro{' '} + and Vite. Ready to deploy to your favorite hosting + provider.

diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/arrow-function.tsx index 25bae96925..26e6cb91cf 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/arrow-function.tsx @@ -8,6 +8,10 @@ export const Route = createFileRoute('/posts')({ loader: lazyFn($$splitLoaderImporter, 'loader'), component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/chinese.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/chinese.tsx index 9abb4a9d61..c26129ff26 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/chinese.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/chinese.tsx @@ -8,6 +8,10 @@ export const Route = createFileRoute('/')({ interface DemoProps { title: string; } -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/conditional-properties.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/conditional-properties.tsx index 279773de15..6f59f24540 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/conditional-properties.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/conditional-properties.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/posts')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: lazyFn($$splitLoaderImporter, 'loader') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/destructured-react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/destructured-react-memo-imported-component.tsx index 0fe0b8418d..b0e77520d1 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/destructured-react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/destructured-react-memo-imported-component.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: lazyFn($$splitLoaderImporter, 'loader') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/export-default-component-and-normal-notFound.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/export-default-component-and-normal-notFound.tsx index 77e009583c..027607711c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/export-default-component-and-normal-notFound.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/export-default-component-and-normal-notFound.tsx @@ -12,6 +12,10 @@ export default function Home() {

{one}

; } -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/function-declaration.tsx index 01360ef869..41dd964317 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/function-declaration.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/function-declaration.tsx @@ -8,6 +8,10 @@ export const Route = createFileRoute('/posts')({ loader: lazyFn($$splitLoaderImporter, 'loader'), component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/importAttribute.tsx index d8355986bf..a79f652e83 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/importAttribute.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/importAttribute.tsx @@ -4,6 +4,10 @@ import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-default-component-destructured-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-default-component-destructured-loader.tsx index 4e0beddab5..abfa009cb3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-default-component-destructured-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-default-component-destructured-loader.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: lazyFn($$splitLoaderImporter, 'loader') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-default-component.tsx index b749bed2ea..d7af841661 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-default-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-default-component.tsx @@ -4,6 +4,10 @@ import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-errorComponent.tsx index 26951c2d0a..3fd46aa9ae 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-errorComponent.tsx @@ -6,6 +6,17 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); +} +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-notFoundComponent.tsx index 54565ca6f1..9bfc309859 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-notFoundComponent.tsx @@ -6,6 +6,17 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); +} +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-pendingComponent.tsx index 02997dc053..de977998cf 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported-pendingComponent.tsx @@ -6,6 +6,17 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), pendingComponent: lazyRouteComponent($$splitPendingComponentImporter, 'pendingComponent') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); +} +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported.tsx index c397f9dccc..a6c20d87ad 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/imported.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: lazyFn($$splitLoaderImporter, 'loader') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/inline.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/inline.tsx index ff044594ad..b452135b17 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/inline.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/inline.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/')({ }); Route.addChildren([]); export const test = 'test'; -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/random-number.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/random-number.tsx index 05f26ecf0d..769c2b9f63 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/random-number.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/random-number.tsx @@ -26,6 +26,10 @@ export const Route = createFileRoute('/')({ loader: lazyFn($$splitLoaderImporter, 'loader'), component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/react-memo-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/react-memo-component.tsx index 66da0c232a..37d9d53304 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/react-memo-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/react-memo-component.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: lazyFn($$splitLoaderImporter, 'loader') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/react-memo-imported-component.tsx index 8db833f30c..a5c16d16d3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/react-memo-imported-component.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), loader: lazyFn($$splitLoaderImporter, 'loader') }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/retain-exports-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/retain-exports-loader.tsx index eb4fd485bb..fec84f0be8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/retain-exports-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/retain-exports-loader.tsx @@ -14,6 +14,10 @@ export const Route = createFileRoute('/_layout')({ export const SIDEBAR_WIDTH = '150px'; export const SIDEBAR_MINI_WIDTH = '80px'; const ASIDE_WIDTH = '250px'; -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/useStateDestructure.tsx index 6cfb35e525..103067c81a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/useStateDestructure.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/development/useStateDestructure.tsx @@ -116,9 +116,9 @@ export default function VersionIndex() {

Full-document SSR, Streaming, Server Functions, bundling and more, - powered by TanStack Router, Vinxi,{' '} - Nitro and Vite. Ready to deploy to - your favorite hosting provider. + powered by TanStack Router, Nitro{' '} + and Vite. Ready to deploy to your favorite hosting + provider.

diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/production/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/production/useStateDestructure.tsx index 6cfb35e525..103067c81a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/production/useStateDestructure.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/production/useStateDestructure.tsx @@ -116,9 +116,9 @@ export default function VersionIndex() {

Full-document SSR, Streaming, Server Functions, bundling and more, - powered by TanStack Router, Vinxi,{' '} - Nitro and Vite. Ready to deploy to - your favorite hosting provider. + powered by TanStack Router, Nitro{' '} + and Vite. Ready to deploy to your favorite hosting + provider.

diff --git a/packages/router-plugin/tests/code-splitter/snapshots/solid/1-default/development/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/solid/1-default/development/arrow-function.tsx index f62b65b5eb..e2375ceb8b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/solid/1-default/development/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/solid/1-default/development/arrow-function.tsx @@ -6,6 +6,10 @@ export const Route = createFileRoute('/posts')({ loader: fetchPosts, component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/development/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/development/arrow-function.tsx index 5f36162818..b0356f3d87 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/development/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/development/arrow-function.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/posts')({ loader: lazyFn($$splitLoaderImporter, 'loader'), component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/solid/3-all-combined-errorComponent-separate/development/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/solid/3-all-combined-errorComponent-separate/development/arrow-function.tsx index 56e28dce37..8efe2d0465 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/solid/3-all-combined-errorComponent-separate/development/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/solid/3-all-combined-errorComponent-separate/development/arrow-function.tsx @@ -7,6 +7,10 @@ export const Route = createFileRoute('/posts')({ loader: lazyFn($$splitLoaderImporter, 'loader'), component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) }); -export function TSRDummyComponent() { - return null; +if (import.meta.hot) { + import.meta.hot.accept(newModule => { + if (newModule.Route && typeof newModule.Route.clone === 'function') { + newModule.Route.clone(Route); + } + }); } \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/test-files/react/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/test-files/react/useStateDestructure.tsx index 6a1a086eaf..8f79e69bf0 100644 --- a/packages/router-plugin/tests/code-splitter/test-files/react/useStateDestructure.tsx +++ b/packages/router-plugin/tests/code-splitter/test-files/react/useStateDestructure.tsx @@ -159,9 +159,9 @@ export default function VersionIndex() { lg:text-xl lg:max-w-[600px]" > Full-document SSR, Streaming, Server Functions, bundling and more, - powered by TanStack Router, Vinxi,{' '} - Nitro and Vite. Ready to deploy to - your favorite hosting provider. + powered by TanStack Router, Nitro{' '} + and Vite. Ready to deploy to your favorite hosting + provider.

diff --git a/packages/router-plugin/tests/detect-route-codesplit-groupings.test.ts b/packages/router-plugin/tests/detect-route-codesplit-groupings.test.ts index 49b6b40c0a..899ace556b 100644 --- a/packages/router-plugin/tests/detect-route-codesplit-groupings.test.ts +++ b/packages/router-plugin/tests/detect-route-codesplit-groupings.test.ts @@ -76,8 +76,7 @@ describe('detectCodeSplitGroupingsFromRoute - success', () => { ({ code, expectedGrouping, expectedRouteId }) => { const result = detectCodeSplitGroupingsFromRoute({ code: code, - filename: 'test.ts', - root: '/src', + sourceFilename: 'test.ts', }) expect(result.groupings).toEqual(expectedGrouping) @@ -121,8 +120,7 @@ describe('detectCodeSplitGroupingsFromRoute - fail', () => { expect(() => detectCodeSplitGroupingsFromRoute({ code: code, - filename: 'test.ts', - root: '/src', + sourceFilename: 'test.ts', }), ).toThrowError() }) diff --git a/packages/router-utils/src/ast.ts b/packages/router-utils/src/ast.ts index fbf6d970d5..586f1efb90 100644 --- a/packages/router-utils/src/ast.ts +++ b/packages/router-utils/src/ast.ts @@ -1,27 +1,21 @@ import { parse } from '@babel/parser' import _generate from '@babel/generator' import type { GeneratorOptions, GeneratorResult } from '@babel/generator' -import type { ParseResult } from '@babel/parser' +import type { ParseResult, ParserOptions } from '@babel/parser' import type * as _babel_types from '@babel/types' -export type ParseAstOptions = { +export type ParseAstOptions = ParserOptions & { code: string - filename: string - root: string - env?: 'server' | 'client' | 'ssr' } -export function parseAst( - opts: ParseAstOptions, -): ParseResult<_babel_types.File> { - return parse(opts.code, { +export function parseAst({ + code, + ...opts +}: ParseAstOptions): ParseResult<_babel_types.File> { + return parse(code, { plugins: ['jsx', 'typescript'], sourceType: 'module', - ...{ - root: opts.root, - filename: opts.filename, - env: opts.env, - }, + ...opts, }) } diff --git a/packages/server-functions-plugin/README.md b/packages/server-functions-plugin/README.md index 9eda7c0fc3..7f4b22702f 100644 --- a/packages/server-functions-plugin/README.md +++ b/packages/server-functions-plugin/README.md @@ -10,7 +10,7 @@ Create a new instance of the plugin with the following options: const TanStackServerFnsPlugin = createTanStackServerFnPlugin({ // This is the ID that will be available to look up and import // our server function manifest and resolve its module - manifestVirtualImportId: 'tsr:server-fn-manifest', + manifestVirtualImportId: 'tanstack:server-fn-manifest', client: { getRuntimeCode: () => `import { createClientRpc } from '@tanstack/react-start/client-runtime'`, @@ -71,7 +71,7 @@ function createClientRpc(functionId: string) { In your server handler, you can import the manifest and use it to look up and dynamically import the server function you want to call. ```ts -import serverFnManifest from 'tsr:server-fn-manifest' +import serverFnManifest from 'tanstack:server-fn-manifest' export const handler = async (req: Request) => { const functionId = req.url.split('/').pop() diff --git a/packages/server-functions-plugin/src/index.ts b/packages/server-functions-plugin/src/index.ts index dfa8993b45..cf55102643 100644 --- a/packages/server-functions-plugin/src/index.ts +++ b/packages/server-functions-plugin/src/index.ts @@ -1,6 +1,9 @@ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs' import path from 'node:path' -import { TanStackDirectiveFunctionsPlugin } from '@tanstack/directive-functions-plugin' +import { + TanStackDirectiveFunctionsPlugin, + TanStackDirectiveFunctionsPluginEnv, +} from '@tanstack/directive-functions-plugin' import type { Plugin } from 'vite' import type { DirectiveFn, @@ -25,6 +28,9 @@ export type ServerFnPluginOpts = { server: ServerFnPluginEnvOpts } +const manifestFilename = + '.tanstack-start/build/server/server-functions-manifest.json' + export type ServerFnPluginEnvOpts = { getRuntimeCode: () => string replacer: ReplacerFn @@ -36,8 +42,6 @@ export function createTanStackServerFnPlugin(opts: ServerFnPluginOpts): { server: Array } { const ROOT = process.cwd() - const manifestFilename = - 'node_modules/.tanstack-start/server-functions-manifest.json' globalThis.TSR_directiveFnsById = {} @@ -79,7 +83,6 @@ export function createTanStackServerFnPlugin(opts: ServerFnPluginOpts): { getRuntimeCode: opts.client.getRuntimeCode, replacer: opts.client.replacer, onDirectiveFnsById, - // devSplitImporter: `(globalThis.app.getRouter('server').internals.devServer.ssrLoadModule)`, }), { // Now that we have the directiveFnsById, we need to create a new @@ -93,7 +96,9 @@ export function createTanStackServerFnPlugin(opts: ServerFnPluginOpts): { // build. // Ensure the manifest directory exists - mkdirSync(path.dirname(manifestFilename), { recursive: true }) + mkdirSync(path.join(ROOT, path.dirname(manifestFilename)), { + recursive: true, + }) // Write the manifest to disk writeFileSync( @@ -124,7 +129,6 @@ export function createTanStackServerFnPlugin(opts: ServerFnPluginOpts): { getRuntimeCode: opts.ssr.getRuntimeCode, replacer: opts.ssr.replacer, onDirectiveFnsById, - // devSplitImporter: `(globalThis.app.getRouter('server').internals.devServer.ssrLoadModule)`, }), ], server: [ @@ -185,3 +189,167 @@ export function createTanStackServerFnPlugin(opts: ServerFnPluginOpts): { ], } } + +export function TanStackServerFnPluginEnv(opts: { + manifestVirtualImportId: string + client: { + envName?: string + getRuntimeCode: () => string + replacer: ReplacerFn + } + server: { + envName?: string + getRuntimeCode: () => string + replacer: ReplacerFn + } +}): Array { + opts = { + ...opts, + client: { + ...opts.client, + envName: opts.client.envName || 'client', + }, + server: { + ...opts.server, + envName: opts.server.envName || 'server', + }, + } + + const root = process.cwd() + + globalThis.TSR_directiveFnsById = {} + + const onDirectiveFnsById = (d: Record) => { + // When directives are compiled, save them to our global variable + // This variable will be used both during development to incrementally + // look up server functions and during build/production to produce a + // static manifest that can be read by the server build + Object.assign( + globalThis.TSR_directiveFnsById, + Object.fromEntries( + Object.entries(d).map(([id, fn]) => [ + id, + { + ...fn, + // This importer is required for the development server to + // work. It's also required in production, but cannot be serialized + // into the manifest because it's a dynamic import. Instead, as you'll + // see below, we augment the manifest output with a code-generated importer + // that looks exactly like this. + importer: () => import(fn.extractedFilename), + }, + ]), + ), + ) + } + + const directive = 'use server' + const directiveLabel = 'Server Function' + + return [ + // client: [ + // The client plugin is used to compile the client directives + // and save them so we can create a manifest + TanStackDirectiveFunctionsPluginEnv({ + directive, + directiveLabel, + onDirectiveFnsById, + environments: { + client: { + envLabel: 'Client', + getRuntimeCode: opts.client.getRuntimeCode, + replacer: opts.client.replacer, + }, + server: { + envLabel: 'Server', + getRuntimeCode: opts.server.getRuntimeCode, + replacer: opts.server.replacer, + }, + }, + }), + { + // Now that we have the directiveFnsById, we need to create a new + // virtual module that can be used to import that manifest + name: 'tanstack-start-server-fn-vite-plugin-build-client', + applyToEnvironment(environment) { + return environment.name === opts.client.envName + }, + buildEnd() { + // In production, we create a manifest so we can + // access it later in the server build, which likely does not run in the + // same vite build environment. This is essentially a + // serialized state transfer from the client build to the server + // build. + + // Ensure the manifest directory exists + mkdirSync(path.join(root, path.dirname(manifestFilename)), { + recursive: true, + }) + + // Write the manifest to disk + writeFileSync( + path.join(root, manifestFilename), + JSON.stringify( + Object.fromEntries( + Object.entries(globalThis.TSR_directiveFnsById).map( + ([id, fn]) => [ + id, + { + functionName: fn.functionName, + extractedFilename: fn.extractedFilename, + }, + ], + ), + ), + ), + ) + }, + }, + { + // On the server, we need to be able to read the server-function manifest from the client build. + // This is likely used in the handler for server functions, so we can find the server function + // by its ID, import it, and call it. We can't do this in memory here because the builds happen in isolation, + // so the manifest is like a serialized state from the client build to the server build + name: 'tanstack-start-server-fn-vite-plugin-manifest-server', + enforce: 'pre', + // applyToEnvironment(environment) { + // return environment.name === opts.server.envName + // }, + resolveId: (id) => (id === opts.manifestVirtualImportId ? id : null), + load(id) { + if (id !== opts.manifestVirtualImportId) return null + + // In development, we **can** use the in-memory manifest, and we should + // since it will be incrementally updated as we use the app and dynamic + // imports are triggered. + if (process.env.NODE_ENV === 'development') { + return `export default globalThis.TSR_directiveFnsById` + } + + // In production, we need to read the manifest from the client build. + // The manifest at that point should contain the full set of server functions + // that were found in the client build. + const manifest = JSON.parse( + readFileSync(path.join(root, manifestFilename), 'utf-8'), + ) + + // The manifest has a lot of information, but for now we only need to + // provide the function ID for lookup and the importer for loading + // This should keep the manifest small for now. + const manifestWithImports = ` + export default {${Object.entries(manifest) + .map( + ([id, fn]: any) => + `'${id}': { + functionName: '${fn.functionName}', + importer: () => import(${JSON.stringify(fn.extractedFilename)}) + }`, + ) + .join(',')}}` + + return manifestWithImports + }, + }, + // ], + ] +} diff --git a/packages/solid-router/src/HeadContent.tsx b/packages/solid-router/src/HeadContent.tsx index 512903273a..8caac5bf9f 100644 --- a/packages/solid-router/src/HeadContent.tsx +++ b/packages/solid-router/src/HeadContent.tsx @@ -59,8 +59,8 @@ export const useTags = () => { }) const links = useRouterState({ - select: (state) => - state.matches + select: (state) => { + const constructed = state.matches .map((match) => match.links!) .filter(Boolean) .flat(1) @@ -69,7 +69,27 @@ export const useTags = () => { attrs: { ...link, }, - })) as Array, + })) satisfies Array + + const manifest = router.ssr?.manifest + + // These are the assets extracted from the ViteManifest + // using the `startManifestPlugin` + const assets = state.matches + .map((match) => manifest?.routes[match.routeId]?.assets ?? []) + .filter(Boolean) + .flat(1) + .filter((asset) => asset.tag === 'link') + .map( + (asset) => + ({ + tag: 'link', + attrs: asset.attrs, + }) satisfies RouterManagedTag, + ) + + return [...constructed, ...assets] + }, }) const preloadMeta = useRouterState({ diff --git a/packages/solid-router/src/fileRoute.ts b/packages/solid-router/src/fileRoute.ts index b20789e938..3c28ccdf5c 100644 --- a/packages/solid-router/src/fileRoute.ts +++ b/packages/solid-router/src/fileRoute.ts @@ -41,8 +41,13 @@ export function createFileRoute< TFullPath extends RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'], >( - path: TFilePath, + path?: TFilePath, ): FileRoute['createRoute'] { + if (typeof path === 'object') { + return new FileRoute(path, { + silent: true, + }).createRoute(path) as any + } return new FileRoute(path, { silent: true, }).createRoute @@ -63,7 +68,7 @@ export class FileRoute< silent?: boolean constructor( - public path: TFilePath, + public path?: TFilePath, _opts?: { silent: boolean }, ) { this.silent = _opts?.silent diff --git a/packages/solid-router/src/index.tsx b/packages/solid-router/src/index.tsx index fc7c0bfd29..dbdee5c7be 100644 --- a/packages/solid-router/src/index.tsx +++ b/packages/solid-router/src/index.tsx @@ -207,6 +207,7 @@ export type { InjectedHtmlEntry, RouterErrorSerializer, SerializerExtensions, + CreateFileRoute, } from '@tanstack/router-core' export { diff --git a/packages/solid-router/src/router.ts b/packages/solid-router/src/router.ts index c2bbf24e7a..598e5d9470 100644 --- a/packages/solid-router/src/router.ts +++ b/packages/solid-router/src/router.ts @@ -1,4 +1,5 @@ import { RouterCore } from '@tanstack/router-core' +import { createFileRoute } from './fileRoute' import type { RouterHistory } from '@tanstack/history' import type { AnyRoute, @@ -101,3 +102,9 @@ export class Router< super(options) } } + +if (typeof globalThis !== 'undefined') { + ;(globalThis as any).createFileRoute = createFileRoute +} else if (typeof window !== 'undefined') { + ;(window as any).createFileRoute = createFileRoute +} diff --git a/packages/solid-router/src/useBlocker.tsx b/packages/solid-router/src/useBlocker.tsx index 5568c120f2..a769899600 100644 --- a/packages/solid-router/src/useBlocker.tsx +++ b/packages/solid-router/src/useBlocker.tsx @@ -180,7 +180,10 @@ export function useBlocker( location: HistoryLocation, ): AnyShouldBlockFnLocation { const parsedLocation = router.parseLocation(undefined, location) - const matchedRoutes = router.getMatchedRoutes(parsedLocation) + const matchedRoutes = router.getMatchedRoutes( + parsedLocation.pathname, + undefined, + ) if (matchedRoutes.foundRoute === undefined) { throw new Error(`No route found for location ${location.href}`) } diff --git a/packages/solid-router/vite.config.ts b/packages/solid-router/vite.config.ts index 3a3a4f2edf..197466bb5a 100644 --- a/packages/solid-router/vite.config.ts +++ b/packages/solid-router/vite.config.ts @@ -21,5 +21,14 @@ export default mergeConfig( tanstackViteConfig({ entry: './src/index.tsx', srcDir: './src', + beforeWriteDeclarationFile: (filePath, content) => { + if (filePath.includes('index.d.ts')) { + return content.replace( + `createFileRouteImpl as createFileRoute`, + `createFileRouteGlobal as createFileRoute`, + ) + } + return content + }, }), ) diff --git a/packages/solid-start-client/README.md b/packages/solid-start-client/README.md index fd6e98ac6d..273667a4af 100644 --- a/packages/solid-start-client/README.md +++ b/packages/solid-start-client/README.md @@ -1,33 +1,9 @@ -> 🤫 we're cooking up something special! - -# TanStack Start +# TanStack Solid Start - Client -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) +This package is not meant to be used directly. It is a dependency of [`@tanstack/solid-start`](https://www.npmjs.com/package/@tanstack/solid-start). -🤖 Type-safe router w/ built-in caching & URL state management for React! +TanStack Solid Start is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router). - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - - -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! +Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started. diff --git a/packages/solid-start-client/package.json b/packages/solid-start-client/package.json index 63e7524577..6fdd87d524 100644 --- a/packages/solid-start-client/package.json +++ b/packages/solid-start-client/package.json @@ -69,8 +69,7 @@ "cookie-es": "^1.2.2", "jsesc": "^3.1.0", "tiny-invariant": "^1.3.3", - "tiny-warning": "^1.0.3", - "vinxi": "^0.5.3" + "tiny-warning": "^1.0.3" }, "devDependencies": { "@solidjs/testing-library": "^0.8.10", diff --git a/packages/solid-start-client/src/index.tsx b/packages/solid-start-client/src/index.tsx index 6b9c30ee8f..3aebc26282 100644 --- a/packages/solid-start-client/src/index.tsx +++ b/packages/solid-start-client/src/index.tsx @@ -1,6 +1,15 @@ -/// -export { mergeHeaders } from '@tanstack/start-client-core' -export { startSerializer } from '@tanstack/start-client-core' +export { + mergeHeaders, + startSerializer, + createIsomorphicFn, + createServerFn, + createMiddleware, + registerGlobalMiddleware, + globalMiddleware, + serverOnly, + clientOnly, + json, +} from '@tanstack/start-client-core' export { type DehydratedRouter, type ClientExtractedBaseEntry, @@ -10,16 +19,10 @@ export { type ClientExtractedPromise, type ClientExtractedStream, type ResolvePromiseState, -} from '@tanstack/start-client-core' -export { - createIsomorphicFn, type IsomorphicFn, type ServerOnlyFn, type ClientOnlyFn, type IsomorphicFnBase, -} from '@tanstack/start-client-core' -export { createServerFn } from '@tanstack/start-client-core' -export { type ServerFn as FetchFn, type ServerFnCtx as FetchFnCtx, type CompiledFetcherFnOptions, @@ -31,43 +34,33 @@ export { type ServerFn, type ServerFnCtx, type ServerFnResponseType, -} from '@tanstack/start-client-core' -export { type JsonResponse } from '@tanstack/start-client-core' -export { - createMiddleware, + type JsonResponse, type IntersectAllValidatorInputs, type IntersectAllValidatorOutputs, - type MiddlewareServerFn, - type AnyMiddleware, - type MiddlewareOptions, - type MiddlewareWithTypes, - type MiddlewareValidator, - type MiddlewareServer, - type MiddlewareAfterClient, - type MiddlewareAfterMiddleware, - type MiddlewareAfterServer, - type Middleware, - type MiddlewareClientFnOptions, - type MiddlewareClientFnResult, - type MiddlewareClientNextFn, - type ClientResultWithContext, + type FunctionMiddlewareServerFn, + type AnyFunctionMiddleware, + type FunctionMiddlewareOptions, + type FunctionMiddlewareWithTypes, + type FunctionMiddlewareValidator, + type FunctionMiddlewareServer, + type FunctionMiddlewareAfterClient, + type FunctionMiddlewareAfterServer, + type FunctionMiddleware, + type FunctionMiddlewareClientFnOptions, + type FunctionMiddlewareClientFnResult, + type FunctionMiddlewareClientNextFn, + type FunctionClientResultWithContext, type AssignAllClientContextBeforeNext, type AssignAllMiddleware, type AssignAllServerContext, - type MiddlewareAfterValidator, - type MiddlewareClientFn, - type MiddlewareServerFnResult, - type MiddlewareClient, - type MiddlewareServerFnOptions, - type MiddlewareServerNextFn, - type ServerResultWithContext, + type FunctionMiddlewareAfterValidator, + type FunctionMiddlewareClientFn, + type FunctionMiddlewareServerFnResult, + type FunctionMiddlewareClient, + type FunctionMiddlewareServerFnOptions, + type FunctionMiddlewareServerNextFn, + type FunctionServerResultWithContext, } from '@tanstack/start-client-core' -export { - registerGlobalMiddleware, - globalMiddleware, -} from '@tanstack/start-client-core' -export { serverOnly, clientOnly } from '@tanstack/start-client-core' -export { json } from '@tanstack/start-client-core' export { Meta } from './Meta' export { Scripts } from './Scripts' export { StartClient } from './StartClient' diff --git a/packages/solid-start-client/src/routesManifest.ts b/packages/solid-start-client/src/routesManifest.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/solid-start-client/src/useServerFn.ts b/packages/solid-start-client/src/useServerFn.ts index c798c871c9..c10e73021a 100644 --- a/packages/solid-start-client/src/useServerFn.ts +++ b/packages/solid-start-client/src/useServerFn.ts @@ -17,12 +17,8 @@ export function useServerFn) => Promise>( return res } catch (err) { if (isRedirect(err)) { - const resolvedRedirect = router.resolveRedirect({ - ...err, - _fromLocation: router.state.location, - }) - - return router.navigate(resolvedRedirect) + err.options._fromLocation = router.state.location + return router.navigate(router.resolveRedirect(err).options) } throw err diff --git a/packages/solid-start-config/README.md b/packages/solid-start-config/README.md deleted file mode 100644 index bb009b0c87..0000000000 --- a/packages/solid-start-config/README.md +++ /dev/null @@ -1,33 +0,0 @@ -> 🤫 we're cooking up something special! - - - -# TanStack Start - -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) - -🤖 Type-safe router w/ built-in caching & URL state management for React! - - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - - -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! diff --git a/packages/solid-start-config/eslint.config.js b/packages/solid-start-config/eslint.config.js deleted file mode 100644 index 931f0ec774..0000000000 --- a/packages/solid-start-config/eslint.config.js +++ /dev/null @@ -1,31 +0,0 @@ -// @ts-check - -import pluginReact from '@eslint-react/eslint-plugin' -import pluginReactHooks from 'eslint-plugin-react-hooks' -import rootConfig from '../../eslint.config.js' - -export default [ - ...rootConfig, - { - ...pluginReact.configs.recommended, - files: ['**/*.{ts,tsx}'], - }, - { - plugins: { - 'react-hooks': pluginReactHooks, - }, - rules: { - '@eslint-react/no-unstable-context-value': 'off', - '@eslint-react/no-unstable-default-props': 'off', - '@eslint-react/dom/no-missing-button-type': 'off', - 'react-hooks/exhaustive-deps': 'error', - 'react-hooks/rules-of-hooks': 'error', - }, - }, - { - files: ['**/__tests__/**'], - rules: { - '@typescript-eslint/no-unnecessary-condition': 'off', - }, - }, -] diff --git a/packages/solid-start-config/package.json b/packages/solid-start-config/package.json deleted file mode 100644 index 0e730177d0..0000000000 --- a/packages/solid-start-config/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@tanstack/solid-start-config", - "version": "1.120.3", - "description": "Modern and scalable routing for Solid applications", - "author": "Tanner Linsley", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/TanStack/router.git", - "directory": "packages/start" - }, - "homepage": "https://tanstack.com/start", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/tannerlinsley" - }, - "keywords": [ - "solid", - "location", - "router", - "routing", - "async", - "async router", - "typescript" - ], - "scripts": { - "clean": "rimraf ./dist && rimraf ./coverage", - "build": "tsc", - "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit", - "test:unit": "exit 0;vitest", - "test:eslint": "eslint ./src", - "test:types": "exit 0; vitest" - }, - "type": "module", - "types": "dist/esm/index.d.ts", - "exports": { - ".": { - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - } - }, - "./package.json": "./package.json" - }, - "sideEffects": false, - "files": [ - "dist", - "src" - ], - "engines": { - "node": ">=12" - }, - "dependencies": { - "@tanstack/router-core": "workspace:^", - "@tanstack/router-generator": "workspace:^", - "@tanstack/router-plugin": "workspace:^", - "@tanstack/server-functions-plugin": "workspace:^", - "@tanstack/solid-start-plugin": "workspace:^", - "@tanstack/start-server-functions-handler": "workspace:^", - "vite-plugin-solid": "^2.11.2", - "import-meta-resolve": "^4.1.0", - "nitropack": "^2.10.4", - "ofetch": "^1.4.1", - "vite": "^6.1.0", - "vinxi": "0.5.3", - "zod": "^3.24.2" - }, - "peerDependencies": { - "solid-js": ">=1.0.0", - "vite": "^6.0.0" - } -} diff --git a/packages/solid-start-config/src/index.ts b/packages/solid-start-config/src/index.ts deleted file mode 100644 index 3a5c597f0d..0000000000 --- a/packages/solid-start-config/src/index.ts +++ /dev/null @@ -1,670 +0,0 @@ -import path from 'node:path' -import { existsSync, readFileSync } from 'node:fs' -import { readFile } from 'node:fs/promises' -import { fileURLToPath } from 'node:url' -import viteSolid from 'vite-plugin-solid' -import { resolve } from 'import-meta-resolve' -import { TanStackRouterVite } from '@tanstack/router-plugin/vite' -import { getConfig } from '@tanstack/router-generator' -import { createApp } from 'vinxi' -import { config } from 'vinxi/plugins/config' -// // @ts-expect-error -// import { serverComponents } from '@vinxi/server-components/plugin' -import { createTanStackServerFnPlugin } from '@tanstack/server-functions-plugin' -import { createTanStackStartPlugin } from '@tanstack/solid-start-plugin' -import { createFetch } from 'ofetch' -import { createNitro } from 'nitropack' -import { tanstackStartVinxiFileRouter } from './vinxi-file-router.js' -import { - checkDeploymentPresetInput, - getUserViteConfig, - inlineConfigSchema, - serverSchema, -} from './schema.js' -import type { configSchema } from '@tanstack/router-generator' -import type { z } from 'zod' -import type { - TanStackStartInputConfig, - TanStackStartOutputConfig, -} from './schema.js' -import type { App as VinxiApp } from 'vinxi' -import type { Manifest } from '@tanstack/router-core' -import type * as vite from 'vite' - -export type { - TanStackStartInputConfig, - TanStackStartOutputConfig, -} from './schema.js' - -function setTsrDefaults(config: TanStackStartOutputConfig['tsr']) { - // Normally these are `./src/___`, but we're using `./app/___` for Start stuff - const appDirectory = config?.appDirectory ?? './app' - return { - ...config, - appDirectory: config?.appDirectory ?? appDirectory, - routesDirectory: - config?.routesDirectory ?? path.join(appDirectory, 'routes'), - generatedRouteTree: - config?.generatedRouteTree ?? path.join(appDirectory, 'routeTree.gen.ts'), - } -} - -function mergeSsrOptions(options: Array) { - let ssrOptions: vite.SSROptions = {} - let noExternal: vite.SSROptions['noExternal'] = [] - for (const option of options) { - if (!option) { - continue - } - - if (option.noExternal) { - if (option.noExternal === true) { - noExternal = true - } else if (noExternal !== true) { - if (Array.isArray(option.noExternal)) { - noExternal.push(...option.noExternal) - } else { - noExternal.push(option.noExternal) - } - } - } - - ssrOptions = { - ...ssrOptions, - ...option, - noExternal, - } - } - - return ssrOptions -} - -export async function defineConfig( - inlineConfig: TanStackStartInputConfig = {}, -): Promise { - const opts = inlineConfigSchema.parse(inlineConfig) - - const { preset: configDeploymentPreset, ...serverOptions } = - serverSchema.parse(opts.server || {}) - - const deploymentPreset = checkDeploymentPresetInput(configDeploymentPreset) - const tsr = setTsrDefaults(opts.tsr) - const tsrConfig = getConfig(tsr) - - const appDirectory = tsr.appDirectory - const publicDir = opts.routers?.public?.dir || './public' - - const publicBase = opts.routers?.public?.base || '/' - const clientBase = opts.routers?.client?.base || '/_build' - const apiBase = opts.tsr?.apiBase || '/api' - const serverBase = opts.routers?.server?.base || '/_server' - - const apiMiddleware = opts.routers?.api?.middleware || undefined - const serverMiddleware = opts.routers?.server?.middleware || undefined - const ssrMiddleware = opts.routers?.ssr?.middleware || undefined - - const clientEntry = - opts.routers?.client?.entry || path.join(appDirectory, 'client.tsx') - const ssrEntry = - opts.routers?.ssr?.entry || path.join(appDirectory, 'ssr.tsx') - const apiEntry = opts.routers?.api?.entry || path.join(appDirectory, 'api.ts') - - const globalMiddlewareEntry = - opts.routers?.server?.globalMiddlewareEntry || - path.join(appDirectory, 'global-middleware.ts') - - const apiEntryExists = existsSync(apiEntry) - - const viteConfig = getUserViteConfig(opts.vite) - - const TanStackServerFnsPlugin = createTanStackServerFnPlugin({ - // This is the ID that will be available to look up and import - // our server function manifest and resolve its module - manifestVirtualImportId: 'tsr:server-fn-manifest', - client: { - getRuntimeCode: () => - `import { createClientRpc } from '@tanstack/solid-start/server-functions-client'`, - replacer: (opts) => - `createClientRpc('${opts.functionId}', '${serverBase}')`, - }, - ssr: { - getRuntimeCode: () => - `import { createSsrRpc } from '@tanstack/solid-start/server-functions-ssr'`, - replacer: (opts) => `createSsrRpc('${opts.functionId}', '${serverBase}')`, - }, - server: { - getRuntimeCode: () => - `import { createServerRpc } from '@tanstack/solid-start/server-functions-server'`, - replacer: (opts) => - `createServerRpc('${opts.functionId}', '${serverBase}', ${opts.fn})`, - }, - }) - - const TanStackStartPlugin = createTanStackStartPlugin({ - globalMiddlewareEntry, - }) - - // Create a dummy nitro app to get the resolved public output path - const dummyNitroApp = await createNitro({ - preset: deploymentPreset, - compatibilityDate: '2024-12-01', - }) - - const nitroOutputPublicDir = dummyNitroApp.options.output.publicDir - await dummyNitroApp.close() - - let vinxiApp = createApp({ - server: { - ...serverOptions, - preset: deploymentPreset, - experimental: { - ...serverOptions.experimental, - asyncContext: true, - }, - }, - routers: [ - { - name: 'public', - type: 'static', - dir: publicDir, - base: publicBase, - }, - { - name: 'client', - type: 'client', - target: 'browser', - handler: clientEntry, - base: clientBase, - // @ts-expect-error - build: { - sourcemap: true, - }, - plugins: () => { - const routerType = 'client' - const clientViteConfig = getUserViteConfig( - opts.routers?.[routerType]?.vite, - ) - - return [ - config('tss-vite-config-client', { - ...viteConfig.userConfig, - ...clientViteConfig.userConfig, - define: { - ...(viteConfig.userConfig.define || {}), - ...(clientViteConfig.userConfig.define || {}), - ...injectDefineEnv('TSS_PUBLIC_BASE', publicBase), - ...injectDefineEnv('TSS_CLIENT_BASE', clientBase), - ...injectDefineEnv('TSS_API_BASE', apiBase), - ...injectDefineEnv( - 'TSS_OUTPUT_PUBLIC_DIR', - nitroOutputPublicDir, - ), - }, - ssr: mergeSsrOptions([ - viteConfig.userConfig.ssr, - clientViteConfig.userConfig.ssr, - { - noExternal, - }, - ]), - optimizeDeps: { - entries: [], - ...(viteConfig.userConfig.optimizeDeps || {}), - ...(clientViteConfig.userConfig.optimizeDeps || {}), - }, - }), - TanStackRouterVite({ - ...tsrConfig, - target: 'solid', - enableRouteGeneration: true, - autoCodeSplitting: true, - __enableAPIRoutesGeneration: true, - experimental: { - ...tsrConfig.experimental, - }, - }), - TanStackStartPlugin.client, - TanStackServerFnsPlugin.client, - ...(viteConfig.plugins || []), - ...(clientViteConfig.plugins || []), - viteSolid({ ...opts.solid, ssr: true }), - // TODO: RSCS - enable this - // serverComponents.client(), - ] - }, - }, - { - name: 'ssr', - type: 'http', - target: 'server', - handler: ssrEntry, - middleware: ssrMiddleware, - // @ts-expect-error - link: { - client: 'client', - }, - plugins: () => { - const routerType = 'ssr' - const ssrViteConfig = getUserViteConfig( - opts.routers?.[routerType]?.vite, - ) - - return [ - config('tss-vite-config-ssr', { - ...viteConfig.userConfig, - ...ssrViteConfig.userConfig, - define: { - ...(viteConfig.userConfig.define || {}), - ...(ssrViteConfig.userConfig.define || {}), - ...injectDefineEnv('TSS_PUBLIC_BASE', publicBase), - ...injectDefineEnv('TSS_CLIENT_BASE', clientBase), - ...injectDefineEnv('TSS_API_BASE', apiBase), - ...injectDefineEnv( - 'TSS_OUTPUT_PUBLIC_DIR', - nitroOutputPublicDir, - ), - }, - ssr: mergeSsrOptions([ - viteConfig.userConfig.ssr, - ssrViteConfig.userConfig.ssr, - { - noExternal, - external: ['@vinxi/react-server-dom/client'], - }, - ]), - optimizeDeps: { - entries: [], - ...(viteConfig.userConfig.optimizeDeps || {}), - ...(ssrViteConfig.userConfig.optimizeDeps || {}), - }, - }), - TanStackRouterVite({ - ...tsrConfig, - target: 'solid', - enableRouteGeneration: false, - autoCodeSplitting: true, - __enableAPIRoutesGeneration: true, - experimental: { - ...tsrConfig.experimental, - }, - }), - TanStackStartPlugin.ssr, - TanStackServerFnsPlugin.ssr, - tsrRoutesManifest({ - tsrConfig, - clientBase, - }), - ...(getUserViteConfig(opts.vite).plugins || []), - ...(getUserViteConfig(opts.routers?.ssr?.vite).plugins || []), - viteSolid({ ...opts.solid, ssr: true }), - ] - }, - }, - { - name: 'server', - type: 'http', - target: 'server', - base: serverBase, - middleware: serverMiddleware, - // TODO: RSCS - enable this - // worker: true, - handler: importToProjectRelative( - '@tanstack/start-server-functions-handler', - ), - plugins: () => { - const routerType = 'server' - const serverViteConfig = getUserViteConfig( - opts.routers?.[routerType]?.vite, - ) - - return [ - config('tss-vite-config-server', { - ...viteConfig.userConfig, - ...serverViteConfig.userConfig, - define: { - ...(viteConfig.userConfig.define || {}), - ...(serverViteConfig.userConfig.define || {}), - ...injectDefineEnv('TSS_PUBLIC_BASE', publicBase), - ...injectDefineEnv('TSS_CLIENT_BASE', clientBase), - ...injectDefineEnv('TSS_API_BASE', apiBase), - ...injectDefineEnv('TSS_SERVER_FN_BASE', serverBase), - ...injectDefineEnv( - 'TSS_OUTPUT_PUBLIC_DIR', - nitroOutputPublicDir, - ), - }, - ssr: mergeSsrOptions([ - viteConfig.userConfig.ssr, - serverViteConfig.userConfig.ssr, - { - noExternal, - }, - ]), - optimizeDeps: { - entries: [], - ...(viteConfig.userConfig.optimizeDeps || {}), - ...(serverViteConfig.userConfig.optimizeDeps || {}), - }, - }), - TanStackRouterVite({ - ...tsrConfig, - target: 'solid', - enableRouteGeneration: false, - autoCodeSplitting: true, - __enableAPIRoutesGeneration: true, - experimental: { - ...tsrConfig.experimental, - }, - }), - TanStackStartPlugin.server, - TanStackServerFnsPlugin.server, - // TODO: RSCS - remove this - // resolve: { - // conditions: [], - // }, - // TODO: RSCs - add this - // serverComponents.serverActions({ - // resolve: { - // conditions: [ - // 'react-server', - // // 'node', - // 'import', - // process.env.NODE_ENV, - // ], - // }, - // runtime: '@vinxi/react-server-dom/runtime', - // transpileDeps: ['react', 'react-dom', '@vinxi/react-server-dom'], - // }), - ...(viteConfig.plugins || []), - ...(serverViteConfig.plugins || []), - viteSolid({ ...opts.solid, ssr: true }), - ] - }, - }, - ], - }) - - const noExternal = [ - '@tanstack/solid-start', - '@tanstack/solid-start/server', - '@tanstack/solid-start-client', - '@tanstack/solid-start-server', - '@tanstack/start-server-functions-fetcher', - '@tanstack/start-server-functions-handler', - '@tanstack/start-server-functions-client', - '@tanstack/start-server-functions-ssr', - '@tanstack/start-server-functions-server', - '@tanstack/solid-start-router-manifest', - '@tanstack/solid-start-config', - '@tanstack/start-api-routes', - '@tanstack/server-functions-plugin', - 'tsr:routes-manifest', - 'tsr:server-fn-manifest', - ] - - // If API routes handler exists, add a router for it - if (apiEntryExists) { - vinxiApp = vinxiApp.addRouter({ - name: 'api', - type: 'http', - target: 'server', - base: apiBase, - handler: apiEntry, - middleware: apiMiddleware, - routes: tanstackStartVinxiFileRouter({ tsrConfig, apiBase }), - plugins: () => { - const viteConfig = getUserViteConfig(opts.vite) - const apiViteConfig = getUserViteConfig(opts.routers?.api?.vite) - - return [ - config('tsr-vite-config-api', { - ...viteConfig.userConfig, - ...apiViteConfig.userConfig, - ssr: mergeSsrOptions([ - viteConfig.userConfig.ssr, - apiViteConfig.userConfig.ssr, - { - noExternal, - }, - ]), - optimizeDeps: { - entries: [], - ...(viteConfig.userConfig.optimizeDeps || {}), - ...(apiViteConfig.userConfig.optimizeDeps || {}), - }, - define: { - ...(viteConfig.userConfig.define || {}), - ...(apiViteConfig.userConfig.define || {}), - ...injectDefineEnv('TSS_PUBLIC_BASE', publicBase), - ...injectDefineEnv('TSS_CLIENT_BASE', clientBase), - ...injectDefineEnv('TSS_API_BASE', apiBase), - ...injectDefineEnv('TSS_OUTPUT_PUBLIC_DIR', nitroOutputPublicDir), - }, - }), - TanStackRouterVite({ - ...tsrConfig, - target: 'solid', - enableRouteGeneration: false, - autoCodeSplitting: true, - __enableAPIRoutesGeneration: true, - experimental: { - ...tsrConfig.experimental, - }, - }), - ...(viteConfig.plugins || []), - ...(apiViteConfig.plugins || []), - viteSolid({ ...opts.solid, ssr: true }), - ] - }, - }) - } - - // Because Vinxi doesn't use the normal nitro dev server, it doesn't - // supply $fetch during dev. We need to hook into the dev server creation, - // nab the proper utils from the custom nitro instance that is used - // during dev and supply the $fetch to app. - // Hopefully and likely, this will just get removed when we move to - // Nitro directly. - vinxiApp.hooks.hook('app:dev:nitro:config', (devServer) => { - vinxiApp.hooks.hook( - 'app:dev:server:created', - ({ devApp: { localFetch } }) => { - const $fetch = createFetch({ - fetch: localFetch, - defaults: { - baseURL: devServer.nitro.options.runtimeConfig.app.baseURL, - }, - }) - - // @ts-expect-error - globalThis.$fetch = $fetch - }, - ) - }) - - return vinxiApp -} - -function importToProjectRelative(p: string) { - const resolved = fileURLToPath(resolve(p, import.meta.url)) - - const relative = path.relative(process.cwd(), resolved) - - return relative -} - -function tsrRoutesManifest(opts: { - tsrConfig: z.infer - clientBase: string -}): vite.Plugin { - let config: vite.ResolvedConfig - - return { - name: 'tsr-routes-manifest', - configResolved(resolvedConfig) { - config = resolvedConfig - }, - resolveId(id) { - if (id === 'tsr:routes-manifest') { - return id - } - return - }, - async load(id) { - if (id === 'tsr:routes-manifest') { - // If we're in development, return a dummy manifest - - if (config.command === 'serve') { - return `export default () => ({ - routes: {} - })` - } - - const clientViteManifestPath = path.resolve( - config.build.outDir, - `../client/${opts.clientBase}/.vite/manifest.json`, - ) - - type ViteManifest = Record< - string, - { - file: string - isEntry: boolean - imports: Array - } - > - - let manifest: ViteManifest - try { - manifest = JSON.parse(await readFile(clientViteManifestPath, 'utf-8')) - } catch (err) { - console.error(err) - throw new Error( - `Could not find the production client vite manifest at '${clientViteManifestPath}'!`, - ) - } - - const routeTreePath = path.resolve(opts.tsrConfig.generatedRouteTree) - - let routeTreeContent: string - try { - routeTreeContent = readFileSync(routeTreePath, 'utf-8') - } catch (err) { - console.error(err) - throw new Error( - `Could not find the generated route tree at '${routeTreePath}'!`, - ) - } - - // Extract the routesManifest JSON from the route tree file. - // It's located between the /* ROUTE_MANIFEST_START and ROUTE_MANIFEST_END */ comment block. - - const routerManifest = JSON.parse( - routeTreeContent.match( - /\/\* ROUTE_MANIFEST_START([\s\S]*?)ROUTE_MANIFEST_END \*\//, - )?.[1] || '{ routes: {} }', - ) as Manifest - - const routes = routerManifest.routes - - let entryFile: - | { - file: string - imports: Array - } - | undefined - - const filesByRouteFilePath: ViteManifest = Object.fromEntries( - Object.entries(manifest).map(([k, v]) => { - if (v.isEntry) { - entryFile = v - } - - const rPath = k.split('?')[0] - - return [rPath, v] - }, {}), - ) - - // Add preloads to the routes from the vite manifest - Object.entries(routes).forEach(([k, v]) => { - const file = - filesByRouteFilePath[ - path.join(opts.tsrConfig.routesDirectory, v.filePath as string) - ] - - if (file) { - const preloads = file.imports.map((d) => - path.join(opts.clientBase, manifest[d]!.file), - ) - - preloads.unshift(path.join(opts.clientBase, file.file)) - - routes[k] = { - ...v, - preloads, - } - } - }) - - if (entryFile) { - routes.__root__!.preloads = [ - path.join(opts.clientBase, entryFile.file), - ...entryFile.imports.map((d) => - path.join(opts.clientBase, manifest[d]!.file), - ), - ] - } - - const recurseRoute = ( - route: { - preloads?: Array - children?: Array - }, - seenPreloads = {} as Record, - ) => { - route.preloads = route.preloads?.filter((preload) => { - if (seenPreloads[preload]) { - return false - } - seenPreloads[preload] = true - return true - }) - - if (route.children) { - route.children.forEach((child) => { - const childRoute = routes[child]! - recurseRoute(childRoute, { ...seenPreloads }) - }) - } - } - - // @ts-expect-error - recurseRoute(routes.__root__) - - const routesManifest = { - routes, - } - - if (process.env.TSR_VITE_DEBUG) { - console.info( - 'Routes Manifest: \n' + JSON.stringify(routesManifest, null, 2), - ) - } - - return `export default () => (${JSON.stringify(routesManifest)})` - } - return - }, - } -} - -function injectDefineEnv( - key: TKey, - value: TValue, -): { [P in `process.env.${TKey}` | `import.meta.env.${TKey}`]: TValue } { - return { - [`process.env.${key}`]: JSON.stringify(value), - [`import.meta.env.${key}`]: JSON.stringify(value), - } as { [P in `process.env.${TKey}` | `import.meta.env.${TKey}`]: TValue } -} diff --git a/packages/solid-start-config/src/schema.ts b/packages/solid-start-config/src/schema.ts deleted file mode 100644 index 9c8a6dc810..0000000000 --- a/packages/solid-start-config/src/schema.ts +++ /dev/null @@ -1,198 +0,0 @@ -import { configSchema } from '@tanstack/router-generator' -import { z } from 'zod' -import type { PluginOption } from 'vite' -import type { AppOptions as VinxiAppOptions } from 'vinxi' -import type { NitroOptions } from 'nitropack' -import type { Options as ViteSolidOptions } from 'vite-plugin-solid' -import type { CustomizableConfig } from 'vinxi/dist/types/lib/vite-dev' - -type StartUserViteConfig = CustomizableConfig | (() => CustomizableConfig) - -export function getUserViteConfig(config?: StartUserViteConfig): { - plugins: Array | undefined - userConfig: CustomizableConfig -} { - const { plugins, ...userConfig } = - typeof config === 'function' ? config() : { ...config } - return { plugins, userConfig } -} - -/** - * Not all the deployment presets are fully functional or tested. - * @see https://github.com/TanStack/router/pull/2002 - */ -const vinxiDeploymentPresets = [ - 'alwaysdata', // untested - 'aws-amplify', // untested - 'aws-lambda', // untested - 'azure', // untested - 'azure-functions', // untested - 'base-worker', // untested - 'bun', // ✅ working - 'cleavr', // untested - 'cli', // untested - 'cloudflare', // untested - 'cloudflare-module', // untested - 'cloudflare-pages', // ✅ working - 'cloudflare-pages-static', // untested - 'deno', // untested - 'deno-deploy', // untested - 'deno-server', // untested - 'digital-ocean', // untested - 'edgio', // untested - 'firebase', // untested - 'flight-control', // untested - 'github-pages', // untested - 'heroku', // untested - 'iis', // untested - 'iis-handler', // untested - 'iis-node', // untested - 'koyeb', // untested - 'layer0', // untested - 'netlify', // ✅ working - 'netlify-builder', // untested - 'netlify-edge', // untested - 'netlify-static', // untested - 'nitro-dev', // untested - 'nitro-prerender', // untested - 'node', // partially working - 'node-cluster', // untested - 'node-server', // ✅ working - 'platform-sh', // untested - 'service-worker', // untested - 'static', // 🟧 partially working - 'stormkit', // untested - 'vercel', // ✅ working - 'vercel-edge', // untested - 'vercel-static', // untested - 'winterjs', // untested - 'zeabur', // untested - 'zeabur-static', // untested -] as const - -type DeploymentPreset = (typeof vinxiDeploymentPresets)[number] | (string & {}) - -const testedDeploymentPresets: Array = [ - 'bun', - 'netlify', - 'vercel', - 'cloudflare-pages', - 'node-server', -] - -export function checkDeploymentPresetInput( - preset?: string, -): DeploymentPreset | undefined { - if (preset) { - if (!vinxiDeploymentPresets.includes(preset as any)) { - console.warn( - `Invalid deployment preset "${preset}". Available presets are: ${vinxiDeploymentPresets - .map((p) => `"${p}"`) - .join(', ')}.`, - ) - } - - if (!testedDeploymentPresets.includes(preset as any)) { - console.warn( - `The deployment preset '${preset}' is not fully supported yet and may not work as expected.`, - ) - } - } - - return preset -} - -type HTTPSOptions = { - cert?: string - key?: string - pfx?: string - passphrase?: string - validityDays?: number - domains?: Array -} - -type ServerOptions_ = VinxiAppOptions['server'] & { - https?: boolean | HTTPSOptions -} - -type ServerOptions = { - [K in keyof ServerOptions_]: ServerOptions_[K] -} - -export const serverSchema = z - .object({ - routeRules: z.custom().optional(), - preset: z.custom().optional(), - static: z.boolean().optional(), - prerender: z - .object({ - routes: z.array(z.string()), - ignore: z - .array( - z.custom< - string | RegExp | ((path: string) => undefined | null | boolean) - >(), - ) - .optional(), - crawlLinks: z.boolean().optional(), - }) - .optional(), - }) - .and(z.custom()) - -const viteSchema = z.custom() - -const viteSolidSchema = z.custom() - -const routersSchema = z.object({ - ssr: z - .object({ - entry: z.string().optional(), - middleware: z.string().optional(), - vite: viteSchema.optional(), - }) - .optional(), - client: z - .object({ - entry: z.string().optional(), - base: z.string().optional(), - vite: viteSchema.optional(), - }) - .optional(), - server: z - .object({ - base: z.string().optional(), - globalMiddlewareEntry: z.string().optional(), - middleware: z.string().optional(), - vite: viteSchema.optional(), - }) - .optional(), - api: z - .object({ - entry: z.string().optional(), - middleware: z.string().optional(), - vite: viteSchema.optional(), - }) - .optional(), - public: z - .object({ - dir: z.string().optional(), - base: z.string().optional(), - }) - .optional(), -}) - -const tsrConfig = configSchema.partial().extend({ - appDirectory: z.string().optional(), -}) - -export const inlineConfigSchema = z.object({ - solid: viteSolidSchema.optional(), - vite: viteSchema.optional(), - tsr: tsrConfig.optional(), - routers: routersSchema.optional(), - server: serverSchema.optional(), -}) - -export type TanStackStartInputConfig = z.input -export type TanStackStartOutputConfig = z.infer diff --git a/packages/solid-start-config/src/vinxi-file-router.ts b/packages/solid-start-config/src/vinxi-file-router.ts deleted file mode 100644 index 9e6d829d1b..0000000000 --- a/packages/solid-start-config/src/vinxi-file-router.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { - BaseFileSystemRouter as VinxiBaseFileSystemRouter, - analyzeModule as vinxiFsRouterAnalyzeModule, - cleanPath as vinxiFsRouterCleanPath, -} from 'vinxi/fs-router' -import { - CONSTANTS as GENERATOR_CONSTANTS, - startAPIRouteSegmentsFromTSRFilePath, -} from '@tanstack/router-generator' -import type { configSchema } from '@tanstack/router-generator' -import type { - AppOptions as VinxiAppOptions, - RouterSchemaInput as VinxiRouterSchemaInput, -} from 'vinxi' -import type { z } from 'zod' - -export function tanstackStartVinxiFileRouter(opts: { - tsrConfig: z.infer - apiBase: string -}) { - const apiBaseSegment = opts.apiBase.split('/').filter(Boolean).join('/') - const isAPIPath = new RegExp(`/${apiBaseSegment}/`) - - return function (router: VinxiRouterSchemaInput, app: VinxiAppOptions) { - // Our own custom File Router that extends the VinxiBaseFileSystemRouter - // for splitting the API routes into its own "bundle" - // and adding the $APIRoute metadata to the route object - // This could be customized in future to support more complex splits - class TanStackStartFsRouter extends VinxiBaseFileSystemRouter { - toPath(src: string): string { - const inputPath = vinxiFsRouterCleanPath(src, this.config) - - const segments = startAPIRouteSegmentsFromTSRFilePath( - inputPath, - opts.tsrConfig, - ) - - const pathname = segments - .map((part) => { - if (part.type === 'splat') { - return `*splat` - } - - if (part.type === 'param') { - return `:${part.value}?` - } - - return part.value - }) - .join('/') - - return pathname.length > 0 ? `/${pathname}` : '/' - } - - toRoute(src: string) { - const webPath = this.toPath(src) - - const [_, exports] = vinxiFsRouterAnalyzeModule(src) - - const hasAPIRoute = exports.find( - (exp) => exp.n === GENERATOR_CONSTANTS.APIRouteExportVariable, - ) - - return { - path: webPath, - filePath: src, - $APIRoute: - isAPIPath.test(webPath) && hasAPIRoute - ? { - src, - pick: [GENERATOR_CONSTANTS.APIRouteExportVariable], - } - : undefined, - } - } - } - - return new TanStackStartFsRouter( - { - dir: opts.tsrConfig.routesDirectory, - extensions: ['js', 'jsx', 'ts', 'tsx'], - }, - router, - app, - ) - } -} diff --git a/packages/solid-start-config/tsconfig.json b/packages/solid-start-config/tsconfig.json deleted file mode 100644 index 940a9cce0a..0000000000 --- a/packages/solid-start-config/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["src/index.ts"], - "compilerOptions": { - "rootDir": "src", - "outDir": "dist/esm", - "target": "esnext", - "noEmit": false - } -} diff --git a/packages/solid-start-plugin/README.md b/packages/solid-start-plugin/README.md index 798fa094a3..f1f10693be 100644 --- a/packages/solid-start-plugin/README.md +++ b/packages/solid-start-plugin/README.md @@ -1,5 +1,9 @@ -# TanStack Start Vite Plugin +# TanStack Solid Start - Plugin -See https://tanstack.com/router/latest/docs/framework/react/guide/file-based-routing +This package is not meant to be used directly. It is a dependency of [`@tanstack/solid-start`](https://www.npmjs.com/package/@tanstack/solid-start). + +TanStack Solid Start is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router). + +Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started. diff --git a/packages/solid-start-plugin/package.json b/packages/solid-start-plugin/package.json index 1fb0325218..b8f98a114b 100644 --- a/packages/solid-start-plugin/package.json +++ b/packages/solid-start-plugin/package.json @@ -27,7 +27,7 @@ "clean": "rimraf ./dist && rimraf ./coverage", "clean:snapshots": "rimraf **/*snapshot* --glob", "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit", - "test:unit": "vitest", + "test:unit": "exit 0; vitest", "test:eslint": "eslint ./src", "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"", "test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js", @@ -65,22 +65,12 @@ "node": ">=12" }, "dependencies": { - "@babel/code-frame": "7.26.2", - "@babel/core": "^7.26.8", - "@babel/plugin-syntax-jsx": "^7.25.9", - "@babel/plugin-syntax-typescript": "^7.25.9", - "@babel/template": "^7.26.8", - "@babel/traverse": "^7.26.8", - "@babel/types": "^7.26.8", + "@tanstack/router-plugin": "workspace:^", "@tanstack/router-utils": "workspace:^", - "babel-dead-code-elimination": "^1.0.9", - "tiny-invariant": "^1.3.3", - "vite": "6.1.4" - }, - "devDependencies": { - "@types/babel__code-frame": "^7.0.6", - "@types/babel__core": "^7.20.5", - "@types/babel__template": "^7.4.4", - "@types/babel__traverse": "^7.20.6" + "@tanstack/server-functions-plugin": "workspace:^", + "@tanstack/start-plugin-core": "workspace:^", + "vite": "6.1.4", + "vite-plugin-solid": "^2.11.6", + "zod": "^3.24.2" } } diff --git a/packages/solid-start-plugin/src/compilers.ts b/packages/solid-start-plugin/src/compilers.ts deleted file mode 100644 index 0fd65af65c..0000000000 --- a/packages/solid-start-plugin/src/compilers.ts +++ /dev/null @@ -1,584 +0,0 @@ -import * as babel from '@babel/core' -import * as t from '@babel/types' -import { codeFrameColumns } from '@babel/code-frame' -import { - deadCodeElimination, - findReferencedIdentifiers, -} from 'babel-dead-code-elimination' -import { generateFromAst, parseAst } from '@tanstack/router-utils' -import type { GeneratorResult, ParseAstOptions } from '@tanstack/router-utils' - -// build these once and reuse them -const handleServerOnlyCallExpression = - buildEnvOnlyCallExpressionHandler('server') -const handleClientOnlyCallExpression = - buildEnvOnlyCallExpressionHandler('client') - -type CompileOptions = ParseAstOptions & { - env: 'server' | 'client' | 'ssr' - dce?: boolean -} - -type IdentifierConfig = { - name: string - type: 'ImportSpecifier' | 'ImportNamespaceSpecifier' - namespaceId: string - handleCallExpression: ( - path: babel.NodePath, - opts: CompileOptions, - ) => void - paths: Array -} - -export function compileStartOutput(opts: CompileOptions): GeneratorResult { - const ast = parseAst(opts) - - const doDce = opts.dce ?? true - // find referenced identifiers *before* we transform anything - const refIdents = doDce ? findReferencedIdentifiers(ast) : undefined - - babel.traverse(ast, { - Program: { - enter(programPath) { - const identifiers: { - createServerFn: IdentifierConfig - createMiddleware: IdentifierConfig - serverOnly: IdentifierConfig - clientOnly: IdentifierConfig - createIsomorphicFn: IdentifierConfig - } = { - createServerFn: { - name: 'createServerFn', - type: 'ImportSpecifier', - namespaceId: '', - handleCallExpression: handleCreateServerFnCallExpression, - paths: [], - }, - createMiddleware: { - name: 'createMiddleware', - type: 'ImportSpecifier', - namespaceId: '', - handleCallExpression: handleCreateMiddlewareCallExpression, - paths: [], - }, - serverOnly: { - name: 'serverOnly', - type: 'ImportSpecifier', - namespaceId: '', - handleCallExpression: handleServerOnlyCallExpression, - paths: [], - }, - clientOnly: { - name: 'clientOnly', - type: 'ImportSpecifier', - namespaceId: '', - handleCallExpression: handleClientOnlyCallExpression, - paths: [], - }, - createIsomorphicFn: { - name: 'createIsomorphicFn', - type: 'ImportSpecifier', - namespaceId: '', - handleCallExpression: handleCreateIsomorphicFnCallExpression, - paths: [], - }, - } - - const identifierKeys = Object.keys(identifiers) as Array< - keyof typeof identifiers - > - - programPath.traverse({ - ImportDeclaration: (path) => { - if (path.node.source.value !== '@tanstack/solid-start') { - return - } - - // handle a destructured imports being renamed like "import { createServerFn as myCreateServerFn } from '@tanstack/solid-start';" - path.node.specifiers.forEach((specifier) => { - identifierKeys.forEach((identifierKey) => { - const identifier = identifiers[identifierKey] - - if ( - specifier.type === 'ImportSpecifier' && - specifier.imported.type === 'Identifier' - ) { - if (specifier.imported.name === identifierKey) { - identifier.name = specifier.local.name - identifier.type = 'ImportSpecifier' - } - } - - // handle namespace imports like "import * as TanStackStart from '@tanstack/solid-start';" - if (specifier.type === 'ImportNamespaceSpecifier') { - identifier.type = 'ImportNamespaceSpecifier' - identifier.namespaceId = specifier.local.name - identifier.name = `${identifier.namespaceId}.${identifierKey}` - } - }) - }) - }, - CallExpression: (path) => { - identifierKeys.forEach((identifierKey) => { - // Check to see if the call expression is a call to the - // identifiers[identifierKey].name - if ( - t.isIdentifier(path.node.callee) && - path.node.callee.name === identifiers[identifierKey].name - ) { - // The identifier could be a call to the original function - // in the source code. If this is case, we need to ignore it. - // Check the scope to see if the identifier is a function declaration. - // if it is, then we can ignore it. - - if ( - path.scope.getBinding(identifiers[identifierKey].name)?.path - .node.type === 'FunctionDeclaration' - ) { - return - } - - return identifiers[identifierKey].paths.push(path) - } - - if (t.isMemberExpression(path.node.callee)) { - if ( - t.isIdentifier(path.node.callee.object) && - t.isIdentifier(path.node.callee.property) - ) { - const callname = [ - path.node.callee.object.name, - path.node.callee.property.name, - ].join('.') - - if (callname === identifiers[identifierKey].name) { - identifiers[identifierKey].paths.push(path) - } - } - } - - return - }) - }, - }) - - identifierKeys.forEach((identifierKey) => { - identifiers[identifierKey].paths.forEach((path) => { - identifiers[identifierKey].handleCallExpression( - path as babel.NodePath, - opts, - ) - }) - }) - }, - }, - }) - - if (doDce) { - deadCodeElimination(ast, refIdents) - } - - return generateFromAst(ast, { - sourceMaps: true, - sourceFileName: opts.filename, - filename: opts.filename, - }) -} - -function handleCreateServerFnCallExpression( - path: babel.NodePath, - opts: ParseAstOptions, -) { - // The function is the 'fn' property of the object passed to createServerFn - - // const firstArg = path.node.arguments[0] - // if (t.isObjectExpression(firstArg)) { - // // Was called with some options - // } - - // Traverse the member expression and find the call expressions for - // the validator, handler, and middleware methods. Check to make sure they - // are children of the createServerFn call expression. - - const calledOptions = path.node.arguments[0] - ? (path.get('arguments.0') as babel.NodePath) - : null - - const shouldValidateClient = !!calledOptions?.node.properties.find((prop) => { - return ( - t.isObjectProperty(prop) && - t.isIdentifier(prop.key) && - prop.key.name === 'validateClient' && - t.isBooleanLiteral(prop.value) && - prop.value.value === true - ) - }) - - const callExpressionPaths = { - middleware: null as babel.NodePath | null, - validator: null as babel.NodePath | null, - handler: null as babel.NodePath | null, - } - - const validMethods = Object.keys(callExpressionPaths) - - const rootCallExpression = getRootCallExpression(path) - - // if (debug) - // console.info( - // 'Handling createServerFn call expression:', - // rootCallExpression.toString(), - // ) - - // Check if the call is assigned to a variable - if (!rootCallExpression.parentPath.isVariableDeclarator()) { - throw new Error('createServerFn must be assigned to a variable!') - } - - // Get the identifier name of the variable - const variableDeclarator = rootCallExpression.parentPath.node - const existingVariableName = (variableDeclarator.id as t.Identifier).name - - rootCallExpression.traverse({ - MemberExpression(memberExpressionPath) { - if (t.isIdentifier(memberExpressionPath.node.property)) { - const name = memberExpressionPath.node.property - .name as keyof typeof callExpressionPaths - - if ( - validMethods.includes(name) && - memberExpressionPath.parentPath.isCallExpression() - ) { - callExpressionPaths[name] = memberExpressionPath.parentPath - } - } - }, - }) - - if (callExpressionPaths.validator) { - const innerInputExpression = callExpressionPaths.validator.node.arguments[0] - - if (!innerInputExpression) { - throw new Error( - 'createServerFn().validator() must be called with a validator!', - ) - } - - // If we're on the client, and we're not validating the client, remove the validator call expression - if ( - opts.env === 'client' && - !shouldValidateClient && - t.isMemberExpression(callExpressionPaths.validator.node.callee) - ) { - callExpressionPaths.validator.replaceWith( - callExpressionPaths.validator.node.callee.object, - ) - } - } - - // First, we need to move the handler function to a nested function call - // that is applied to the arguments passed to the server function. - - const handlerFnPath = callExpressionPaths.handler?.get( - 'arguments.0', - ) as babel.NodePath - - if (!callExpressionPaths.handler || !handlerFnPath.node) { - throw codeFrameError( - opts.code, - path.node.callee.loc!, - `createServerFn must be called with a "handler" property!`, - ) - } - - const handlerFn = handlerFnPath.node - - // So, the way we do this is we give the handler function a way - // to access the serverFn ctx on the server via function scope. - // The 'use server' extracted function will be called with the - // payload from the client, then use the scoped serverFn ctx - // to execute the handler function. - // This way, we can do things like data and middleware validation - // in the __execute function without having to AST transform the - // handler function too much itself. - - // .handler((optsOut, ctx) => { - // return ((optsIn) => { - // 'use server' - // ctx.__execute(handlerFn, optsIn) - // })(optsOut) - // }) - - // If the handler function is an identifier and we're on the client, we need to - // remove the bound function from the file. - // If we're on the server, you can leave it, since it will get referenced - // as a second argument. - - if (t.isIdentifier(handlerFn)) { - if (opts.env === 'client' || opts.env === 'ssr') { - // Find the binding for the handler function - const binding = handlerFnPath.scope.getBinding(handlerFn.name) - // Remove it - if (binding) { - binding.path.remove() - } - } - // If the env is server, just leave it alone - } - - handlerFnPath.replaceWith( - t.arrowFunctionExpression( - [t.identifier('opts'), t.identifier('signal')], - t.blockStatement( - // Everything in here is server-only, since the client - // will strip out anything in the 'use server' directive. - [ - t.returnStatement( - t.callExpression( - t.identifier(`${existingVariableName}.__executeServer`), - [t.identifier('opts'), t.identifier('signal')], - ), - ), - ], - [t.directive(t.directiveLiteral('use server'))], - ), - ), - ) - - if (opts.env === 'server') { - callExpressionPaths.handler.node.arguments.push(handlerFn) - } -} - -function handleCreateMiddlewareCallExpression( - path: babel.NodePath, - opts: ParseAstOptions, -) { - const rootCallExpression = getRootCallExpression(path) - - // if (debug) - // console.info( - // 'Handling createMiddleware call expression:', - // rootCallExpression.toString(), - // ) - - const callExpressionPaths = { - middleware: null as babel.NodePath | null, - validator: null as babel.NodePath | null, - client: null as babel.NodePath | null, - server: null as babel.NodePath | null, - } - - const validMethods = Object.keys(callExpressionPaths) - - rootCallExpression.traverse({ - MemberExpression(memberExpressionPath) { - if (t.isIdentifier(memberExpressionPath.node.property)) { - const name = memberExpressionPath.node.property - .name as keyof typeof callExpressionPaths - - if ( - validMethods.includes(name) && - memberExpressionPath.parentPath.isCallExpression() - ) { - callExpressionPaths[name] = memberExpressionPath.parentPath - } - } - }, - }) - - if (callExpressionPaths.validator) { - const innerInputExpression = callExpressionPaths.validator.node.arguments[0] - - if (!innerInputExpression) { - throw new Error( - 'createMiddleware().validator() must be called with a validator!', - ) - } - - // If we're on the client or ssr, remove the validator call expression - if (opts.env === 'client' || opts.env === 'ssr') { - if (t.isMemberExpression(callExpressionPaths.validator.node.callee)) { - callExpressionPaths.validator.replaceWith( - callExpressionPaths.validator.node.callee.object, - ) - } - } - } - - const serverFnPath = callExpressionPaths.server?.get( - 'arguments.0', - ) as babel.NodePath - - if ( - callExpressionPaths.server && - serverFnPath.node && - (opts.env === 'client' || opts.env === 'ssr') - ) { - // If we're on the client, remove the server call expression - if (t.isMemberExpression(callExpressionPaths.server.node.callee)) { - callExpressionPaths.server.replaceWith( - callExpressionPaths.server.node.callee.object, - ) - } - } -} - -function buildEnvOnlyCallExpressionHandler(env: 'client' | 'server') { - return function envOnlyCallExpressionHandler( - path: babel.NodePath, - opts: ParseAstOptions, - ) { - // if (debug) - // console.info(`Handling ${env}Only call expression:`, path.toString()) - - const isEnvMatch = - env === 'client' - ? opts.env === 'client' - : opts.env === 'server' || opts.env === 'ssr' - - if (isEnvMatch) { - // extract the inner function from the call expression - const innerInputExpression = path.node.arguments[0] - - if (!t.isExpression(innerInputExpression)) { - throw new Error( - `${env}Only() functions must be called with a function!`, - ) - } - - path.replaceWith(innerInputExpression) - return - } - - // If we're on the wrong environment, replace the call expression - // with a function that always throws an error. - path.replaceWith( - t.arrowFunctionExpression( - [], - t.blockStatement([ - t.throwStatement( - t.newExpression(t.identifier('Error'), [ - t.stringLiteral( - `${env}Only() functions can only be called on the ${env}!`, - ), - ]), - ), - ]), - ), - ) - } -} - -function handleCreateIsomorphicFnCallExpression( - path: babel.NodePath, - opts: CompileOptions, -) { - const rootCallExpression = getRootCallExpression(path) - - // if (debug) - // console.info( - // 'Handling createIsomorphicFn call expression:', - // rootCallExpression.toString(), - // ) - - const callExpressionPaths = { - client: null as babel.NodePath | null, - server: null as babel.NodePath | null, - } - - const validMethods = Object.keys(callExpressionPaths) - - rootCallExpression.traverse({ - MemberExpression(memberExpressionPath) { - if (t.isIdentifier(memberExpressionPath.node.property)) { - const name = memberExpressionPath.node.property - .name as keyof typeof callExpressionPaths - - if ( - validMethods.includes(name) && - memberExpressionPath.parentPath.isCallExpression() - ) { - callExpressionPaths[name] = memberExpressionPath.parentPath - } - } - }, - }) - - if ( - validMethods.every( - (method) => - !callExpressionPaths[method as keyof typeof callExpressionPaths], - ) - ) { - const variableId = rootCallExpression.parentPath.isVariableDeclarator() - ? rootCallExpression.parentPath.node.id - : null - console.warn( - 'createIsomorphicFn called without a client or server implementation!', - 'This will result in a no-op function.', - 'Variable name:', - t.isIdentifier(variableId) ? variableId.name : 'unknown', - ) - } - - const resolvedEnv = opts.env === 'ssr' ? 'server' : opts.env - - const envCallExpression = callExpressionPaths[resolvedEnv] - - if (!envCallExpression) { - // if we don't have an implementation for this environment, default to a no-op - rootCallExpression.replaceWith( - t.arrowFunctionExpression([], t.blockStatement([])), - ) - return - } - - const innerInputExpression = envCallExpression.node.arguments[0] - - if (!t.isExpression(innerInputExpression)) { - throw new Error( - `createIsomorphicFn().${resolvedEnv}(func) must be called with a function!`, - ) - } - - rootCallExpression.replaceWith(innerInputExpression) -} - -function getRootCallExpression(path: babel.NodePath) { - // Find the highest callExpression parent - let rootCallExpression: babel.NodePath = path - - // Traverse up the chain of CallExpressions - while (rootCallExpression.parentPath.isMemberExpression()) { - const parent = rootCallExpression.parentPath - if (parent.parentPath.isCallExpression()) { - rootCallExpression = parent.parentPath - } - } - - return rootCallExpression -} - -function codeFrameError( - code: string, - loc: { - start: { line: number; column: number } - end: { line: number; column: number } - }, - message: string, -) { - const frame = codeFrameColumns( - code, - { - start: loc.start, - end: loc.end, - }, - { - highlightCode: true, - message, - }, - ) - - return new Error(frame) -} diff --git a/packages/solid-start-plugin/src/index.ts b/packages/solid-start-plugin/src/index.ts index f24f09d18a..9871d38ee7 100644 --- a/packages/solid-start-plugin/src/index.ts +++ b/packages/solid-start-plugin/src/index.ts @@ -1,130 +1,116 @@ -import { fileURLToPath, pathToFileURL } from 'node:url' import path from 'node:path' -import { existsSync } from 'node:fs' -import { logDiff } from '@tanstack/router-utils' -import { compileStartOutput } from './compilers' -import type { Plugin } from 'vite' +import { TanStackServerFnPluginEnv } from '@tanstack/server-functions-plugin' +import { TanStackRouterVite } from '@tanstack/router-plugin/vite' +import viteSolid from 'vite-plugin-solid' +import { + TanStackStartServerRoutesVite, + TanStackStartVitePluginCore, +} from '@tanstack/start-plugin-core' +import { getTanStackStartOptions } from './schema' +import type { PluginOption } from 'vite' +import type { TanStackStartInputConfig, WithSolidPlugin } from './schema' -const debug = - process.env.TSR_VITE_DEBUG && - ['true', 'solid-start-plugin'].includes(process.env.TSR_VITE_DEBUG) +export type { + TanStackStartInputConfig, + TanStackStartOutputConfig, + WithSolidPlugin, +} from './schema' -export type TanStackStartViteOptions = { - globalMiddlewareEntry: string -} +export function TanStackStartVitePlugin( + opts?: TanStackStartInputConfig & WithSolidPlugin, +): Array { + type OptionsWithSolid = ReturnType & + WithSolidPlugin + const options: OptionsWithSolid = getTanStackStartOptions(opts) -const transformFuncs = [ - 'createServerFn', - 'createMiddleware', - 'serverOnly', - 'clientOnly', - 'createIsomorphicFn', -] -const tokenRegex = new RegExp(transformFuncs.join('|')) -// const eitherFuncRegex = new RegExp( -// `(function ${transformFuncs.join('|function ')})`, -// ) - -export function createTanStackStartPlugin(opts: TanStackStartViteOptions): { - client: Array - ssr: Array - server: Array -} { - const globalMiddlewarePlugin = (): Plugin => { - let entry: string | null = null - let resolvedGlobalMiddlewareEntry: string | null = null - let globalMiddlewareEntryExists = false - let ROOT: string = process.cwd() - return { - name: 'vite-plugin-tanstack-start-ensure-global-middleware', - enforce: 'pre', - configResolved: (config) => { - ROOT = config.root - entry = path.resolve(ROOT, (config as any).router.handler) - resolvedGlobalMiddlewareEntry = path.resolve( - ROOT, - opts.globalMiddlewareEntry, - ) - globalMiddlewareEntryExists = existsSync(resolvedGlobalMiddlewareEntry) - - if (!entry) { - throw new Error( - '@tanstack/solid-start-plugin: No server entry found!', - ) + return [ + TanStackStartVitePluginCore('solid', options), + { + name: 'tanstack-solid-start:resolve-entries', + resolveId(id) { + if ( + [ + '/~start/server-entry', + '/~start/default-server-entry', + '/~start/default-client-entry', + ].includes(id) + ) { + return `${id}.tsx` } - }, - transform(code, id) { - if (entry && id.includes(entry)) { - if (globalMiddlewareEntryExists) { - return { - code: `${code}\n\nimport '${path.resolve(ROOT, opts.globalMiddlewareEntry)}'`, - map: null, - } - } - } - return code - }, - } - } - return { - client: [ - globalMiddlewarePlugin(), - TanStackStartServerFnsAndMiddleware({ ...opts, env: 'client' }), - ], - ssr: [ - globalMiddlewarePlugin(), - TanStackStartServerFnsAndMiddleware({ ...opts, env: 'ssr' }), - ], - server: [ - globalMiddlewarePlugin(), - TanStackStartServerFnsAndMiddleware({ ...opts, env: 'server' }), - ], - } -} - -export function TanStackStartServerFnsAndMiddleware(opts: { - env: 'server' | 'ssr' | 'client' -}): Plugin { - let ROOT: string = process.cwd() - - return { - name: 'vite-plugin-tanstack-start-create-server-fn', - enforce: 'pre', - configResolved: (config) => { - ROOT = config.root - }, - transform(code, id) { - const url = pathToFileURL(id) - url.searchParams.delete('v') - id = fileURLToPath(url).replace(/\\/g, '/') - - const includesToken = tokenRegex.test(code) - // const includesEitherFunc = eitherFuncRegex.test(code) - - if ( - !includesToken - // includesEitherFunc - // /node_modules/.test(id) - ) { return null - } + }, + load(id) { + const routerImportPath = JSON.stringify( + path.resolve(options.root, options.tsr.srcDirectory, 'router'), + ) - if (debug) console.info(`${opts.env} Compiling Start: `, id) + if (id === '/~start/server-entry.tsx') { + return ` +import { toWebRequest, defineEventHandler, __setGlobalOrigin, __getAbsoluteUrl } from '@tanstack/solid-start/server'; +import serverEntry from '${options.serverEntryPath}'; - const compiled = compileStartOutput({ - code, - root: ROOT, - filename: id, - env: opts.env, - }) +export default defineEventHandler(function(event) { + const request = toWebRequest(event); + __setGlobalOrigin(__getAbsoluteUrl(request)); + return serverEntry({ request }); +}) +` + } - if (debug) { - logDiff(code, compiled.code) - console.log('Output:\n', compiled.code + '\n\n') - } + if (id === '/~start/default-client-entry.tsx') { + return ` +import { hydrate } from 'solid-js/web' +import { StartClient } from '@tanstack/solid-start' +import { createRouter } from ${routerImportPath} - return compiled +const router = createRouter() + +hydrate(() => , document.body) +` + } + + if (id === '/~start/default-server-entry.tsx') { + return ` +import { createStartHandler, defaultStreamHandler } from '@tanstack/solid-start/server' +import { createRouter } from ${routerImportPath} + +export default createStartHandler({ + createRouter, +})(defaultStreamHandler) +` + } + + return null + }, }, - } + TanStackServerFnPluginEnv({ + // This is the ID that will be available to look up and import + // our server function manifest and resolve its module + manifestVirtualImportId: 'tanstack:server-fn-manifest', + client: { + getRuntimeCode: () => + `import { createClientRpc } from '@tanstack/solid-start/server-functions-client'`, + replacer: (d) => + `createClientRpc('${d.functionId}', '${options.serverFns.base}')`, + }, + server: { + getRuntimeCode: () => + `import { createServerRpc } from '@tanstack/solid-start/server-functions-server'`, + replacer: (d) => + `createServerRpc('${d.functionId}', '${options.serverFns.base}', ${d.fn})`, + }, + }), + TanStackRouterVite({ + ...options.tsr, + target: 'solid', + enableRouteGeneration: true, + autoCodeSplitting: true, + }), + TanStackStartServerRoutesVite({ + ...options.tsr, + target: 'solid', + }), + viteSolid({ ...options.solid, ssr: true }), + ] } diff --git a/packages/solid-start-plugin/src/schema.ts b/packages/solid-start-plugin/src/schema.ts new file mode 100644 index 0000000000..c9d836957c --- /dev/null +++ b/packages/solid-start-plugin/src/schema.ts @@ -0,0 +1,31 @@ +import { z } from 'zod' +import { + createTanStackConfig, + createTanStackStartOptionsSchema, +} from '@tanstack/start-plugin-core' +import type { Options as ViteSolidOptions } from 'vite-plugin-solid' + +export type WithSolidPlugin = { + solid?: ViteSolidOptions +} + +const frameworkPlugin = { + solid: z.custom().optional(), +} + +// eslint-disable-next-line unused-imports/no-unused-vars +const TanStackStartOptionsSchema = + createTanStackStartOptionsSchema(frameworkPlugin) + +const defaultConfig = createTanStackConfig(frameworkPlugin) + +export function getTanStackStartOptions(opts?: TanStackStartInputConfig) { + return defaultConfig.parse(opts) +} + +export type TanStackStartInputConfig = z.input< + typeof TanStackStartOptionsSchema +> +export type TanStackStartOutputConfig = ReturnType< + typeof getTanStackStartOptions +> diff --git a/packages/solid-start-plugin/tests/createIsomorphicFn/createIsomorphicFn.test.ts b/packages/solid-start-plugin/tests/createIsomorphicFn/createIsomorphicFn.test.ts deleted file mode 100644 index 9d1e78228e..0000000000 --- a/packages/solid-start-plugin/tests/createIsomorphicFn/createIsomorphicFn.test.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { readFile, readdir } from 'node:fs/promises' -import path from 'node:path' -import { afterAll, describe, expect, test, vi } from 'vitest' - -import { compileStartOutput } from '../../src/compilers' - -async function getFilenames() { - return await readdir(path.resolve(import.meta.dirname, './test-files')) -} - -describe('createIsomorphicFn compiles correctly', async () => { - const noImplWarning = - 'createIsomorphicFn called without a client or server implementation!' - - const originalConsoleWarn = console.warn - const consoleSpy = vi.spyOn(console, 'warn').mockImplementation((...args) => { - // we want to avoid sending this warning to the console, we know about it - if (args[0] === noImplWarning) { - return - } - originalConsoleWarn(...args) - }) - - afterAll(() => { - consoleSpy.mockRestore() - }) - - const filenames = await getFilenames() - - describe.each(filenames)('should handle "%s"', async (filename) => { - const file = await readFile( - path.resolve(import.meta.dirname, `./test-files/${filename}`), - ) - const code = file.toString() - - test.each(['client', 'server'] as const)( - `should compile for ${filename} %s`, - async (env) => { - const compiledResult = compileStartOutput({ - env, - code, - root: './test-files', - filename, - dce: false, - }) - - await expect(compiledResult.code).toMatchFileSnapshot( - `./snapshots/${env}/${filename}`, - ) - }, - ) - }) - test('should error if implementation not provided', () => { - expect(() => { - compileStartOutput({ - env: 'client', - code: ` - import { createIsomorphicFn } from '@tanstack/solid-start' - const clientOnly = createIsomorphicFn().client()`, - root: './test-files', - filename: 'no-fn.ts', - dce: false, - }) - }).toThrowError() - expect(() => { - compileStartOutput({ - env: 'server', - code: ` - import { createIsomorphicFn } from '@tanstack/solid-start' - const serverOnly = createIsomorphicFn().server()`, - root: './test-files', - filename: 'no-fn.ts', - dce: false, - }) - }).toThrowError() - }) - test('should warn to console if no implementations provided', () => { - compileStartOutput({ - env: 'client', - code: ` - import { createIsomorphicFn } from '@tanstack/solid-start' - const noImpl = createIsomorphicFn()`, - root: './test-files', - filename: 'no-fn.ts', - dce: false, - }) - expect(consoleSpy).toHaveBeenCalledWith( - noImplWarning, - 'This will result in a no-op function.', - 'Variable name:', - 'noImpl', - ) - }) -}) diff --git a/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx b/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx deleted file mode 100644 index 269cab1607..0000000000 --- a/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { createIsomorphicFn } from '@tanstack/solid-start'; -const noImpl = () => {}; -const serverOnlyFn = () => {}; -const clientOnlyFn = () => 'client'; -const serverThenClientFn = () => 'client'; -const clientThenServerFn = () => 'client'; -function abstractedServerFn() { - return 'server'; -} -const serverOnlyFnAbstracted = () => {}; -function abstractedClientFn() { - return 'client'; -} -const clientOnlyFnAbstracted = abstractedClientFn; -const serverThenClientFnAbstracted = abstractedClientFn; -const clientThenServerFnAbstracted = abstractedClientFn; \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx b/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx deleted file mode 100644 index 3c5c041e90..0000000000 --- a/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { createIsomorphicFn as isomorphicFn } from '@tanstack/solid-start'; -const noImpl = () => {}; -const serverOnlyFn = () => {}; -const clientOnlyFn = () => 'client'; -const serverThenClientFn = () => 'client'; -const clientThenServerFn = () => 'client'; -function abstractedServerFn() { - return 'server'; -} -const serverOnlyFnAbstracted = () => {}; -function abstractedClientFn() { - return 'client'; -} -const clientOnlyFnAbstracted = abstractedClientFn; -const serverThenClientFnAbstracted = abstractedClientFn; -const clientThenServerFnAbstracted = abstractedClientFn; \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx b/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx deleted file mode 100644 index 5b90ddeaf1..0000000000 --- a/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import * as TanStackStart from '@tanstack/solid-start'; -const noImpl = () => {}; -const serverOnlyFn = () => {}; -const clientOnlyFn = () => 'client'; -const serverThenClientFn = () => 'client'; -const clientThenServerFn = () => 'client'; -function abstractedServerFn() { - return 'server'; -} -const serverOnlyFnAbstracted = () => {}; -function abstractedClientFn() { - return 'client'; -} -const clientOnlyFnAbstracted = abstractedClientFn; -const serverThenClientFnAbstracted = abstractedClientFn; -const clientThenServerFnAbstracted = abstractedClientFn; \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx b/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx deleted file mode 100644 index 126e2404c5..0000000000 --- a/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { createIsomorphicFn } from '@tanstack/solid-start'; -const noImpl = () => {}; -const serverOnlyFn = () => 'server'; -const clientOnlyFn = () => {}; -const serverThenClientFn = () => 'server'; -const clientThenServerFn = () => 'server'; -function abstractedServerFn() { - return 'server'; -} -const serverOnlyFnAbstracted = abstractedServerFn; -function abstractedClientFn() { - return 'client'; -} -const clientOnlyFnAbstracted = () => {}; -const serverThenClientFnAbstracted = abstractedServerFn; -const clientThenServerFnAbstracted = abstractedServerFn; \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx b/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx deleted file mode 100644 index 442156f4e3..0000000000 --- a/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { createIsomorphicFn as isomorphicFn } from '@tanstack/solid-start'; -const noImpl = () => {}; -const serverOnlyFn = () => 'server'; -const clientOnlyFn = () => {}; -const serverThenClientFn = () => 'server'; -const clientThenServerFn = () => 'server'; -function abstractedServerFn() { - return 'server'; -} -const serverOnlyFnAbstracted = abstractedServerFn; -function abstractedClientFn() { - return 'client'; -} -const clientOnlyFnAbstracted = () => {}; -const serverThenClientFnAbstracted = abstractedServerFn; -const clientThenServerFnAbstracted = abstractedServerFn; \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx b/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx deleted file mode 100644 index 318745b993..0000000000 --- a/packages/solid-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import * as TanStackStart from '@tanstack/solid-start'; -const noImpl = () => {}; -const serverOnlyFn = () => 'server'; -const clientOnlyFn = () => {}; -const serverThenClientFn = () => 'server'; -const clientThenServerFn = () => 'server'; -function abstractedServerFn() { - return 'server'; -} -const serverOnlyFnAbstracted = abstractedServerFn; -function abstractedClientFn() { - return 'client'; -} -const clientOnlyFnAbstracted = () => {}; -const serverThenClientFnAbstracted = abstractedServerFn; -const clientThenServerFnAbstracted = abstractedServerFn; \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructured.tsx b/packages/solid-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructured.tsx deleted file mode 100644 index 51263bea85..0000000000 --- a/packages/solid-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructured.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { createIsomorphicFn } from '@tanstack/solid-start' - -const noImpl = createIsomorphicFn() - -const serverOnlyFn = createIsomorphicFn().server(() => 'server') - -const clientOnlyFn = createIsomorphicFn().client(() => 'client') - -const serverThenClientFn = createIsomorphicFn() - .server(() => 'server') - .client(() => 'client') - -const clientThenServerFn = createIsomorphicFn() - .client(() => 'client') - .server(() => 'server') - -function abstractedServerFn() { - return 'server' -} - -const serverOnlyFnAbstracted = createIsomorphicFn().server(abstractedServerFn) - -function abstractedClientFn() { - return 'client' -} - -const clientOnlyFnAbstracted = createIsomorphicFn().client(abstractedClientFn) - -const serverThenClientFnAbstracted = createIsomorphicFn() - .server(abstractedServerFn) - .client(abstractedClientFn) - -const clientThenServerFnAbstracted = createIsomorphicFn() - .client(abstractedClientFn) - .server(abstractedServerFn) diff --git a/packages/solid-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructuredRename.tsx b/packages/solid-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructuredRename.tsx deleted file mode 100644 index 6606a86c50..0000000000 --- a/packages/solid-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructuredRename.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { createIsomorphicFn as isomorphicFn } from '@tanstack/solid-start' - -const noImpl = isomorphicFn() - -const serverOnlyFn = isomorphicFn().server(() => 'server') - -const clientOnlyFn = isomorphicFn().client(() => 'client') - -const serverThenClientFn = isomorphicFn() - .server(() => 'server') - .client(() => 'client') - -const clientThenServerFn = isomorphicFn() - .client(() => 'client') - .server(() => 'server') - -function abstractedServerFn() { - return 'server' -} - -const serverOnlyFnAbstracted = isomorphicFn().server(abstractedServerFn) - -function abstractedClientFn() { - return 'client' -} - -const clientOnlyFnAbstracted = isomorphicFn().client(abstractedClientFn) - -const serverThenClientFnAbstracted = isomorphicFn() - .server(abstractedServerFn) - .client(abstractedClientFn) - -const clientThenServerFnAbstracted = isomorphicFn() - .client(abstractedClientFn) - .server(abstractedServerFn) diff --git a/packages/solid-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnStarImport.tsx b/packages/solid-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnStarImport.tsx deleted file mode 100644 index 9ca4b15b94..0000000000 --- a/packages/solid-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnStarImport.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import * as TanStackStart from '@tanstack/solid-start' - -const noImpl = TanStackStart.createIsomorphicFn() - -const serverOnlyFn = TanStackStart.createIsomorphicFn().server(() => 'server') - -const clientOnlyFn = TanStackStart.createIsomorphicFn().client(() => 'client') - -const serverThenClientFn = TanStackStart.createIsomorphicFn() - .server(() => 'server') - .client(() => 'client') - -const clientThenServerFn = TanStackStart.createIsomorphicFn() - .client(() => 'client') - .server(() => 'server') - -function abstractedServerFn() { - return 'server' -} - -const serverOnlyFnAbstracted = - TanStackStart.createIsomorphicFn().server(abstractedServerFn) - -function abstractedClientFn() { - return 'client' -} - -const clientOnlyFnAbstracted = - TanStackStart.createIsomorphicFn().client(abstractedClientFn) - -const serverThenClientFnAbstracted = TanStackStart.createIsomorphicFn() - .server(abstractedServerFn) - .client(abstractedClientFn) - -const clientThenServerFnAbstracted = TanStackStart.createIsomorphicFn() - .client(abstractedClientFn) - .server(abstractedServerFn) diff --git a/packages/solid-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx b/packages/solid-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx deleted file mode 100644 index ac0d1d2a9a..0000000000 --- a/packages/solid-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { createMiddleware } from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = createMiddleware({ - id: 'test' -}); -export const withoutUseServer = createMiddleware({ - id: 'test' -}); -export const withVariable = createMiddleware({ - id: 'test' -}); -async function abstractedFunction() { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -} -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { - return async (input: unknown) => { - return fn(schema.parse(input)); - }; -} -export const withZodValidator = createMiddleware({ - id: 'test' -}); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx b/packages/solid-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx deleted file mode 100644 index 3e917e901f..0000000000 --- a/packages/solid-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { createMiddleware as middlewareFn } from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = middlewareFn({ - id: 'test' -}); -export const withoutUseServer = middlewareFn({ - id: 'test' -}); -export const withVariable = middlewareFn({ - id: 'test' -}); -async function abstractedFunction() { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -} -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { - return async (input: unknown) => { - return fn(schema.parse(input)); - }; -} -export const withZodValidator = middlewareFn({ - id: 'test' -}); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx b/packages/solid-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx deleted file mode 100644 index 00d22094e8..0000000000 --- a/packages/solid-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import * as TanStackStart from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = TanStackStart.createMiddleware({ - id: 'test' -}); -export const withoutUseServer = TanStackStart.createMiddleware({ - id: 'test' -}); -export const withVariable = TanStackStart.createMiddleware({ - id: 'test' -}); -async function abstractedFunction() { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -} -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { - return async (input: unknown) => { - return fn(schema.parse(input)); - }; -} -export const withZodValidator = TanStackStart.createMiddleware({ - id: 'test' -}); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx b/packages/solid-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx deleted file mode 100644 index 40a49dca05..0000000000 --- a/packages/solid-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { createMiddleware } from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = createMiddleware({ - id: 'test' -}); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareDestructured.tsx b/packages/solid-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareDestructured.tsx deleted file mode 100644 index dda24f7c4e..0000000000 --- a/packages/solid-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareDestructured.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { createMiddleware } from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = createMiddleware({ - id: 'test' -}).server(async function () { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -export const withoutUseServer = createMiddleware({ - id: 'test' -}).server(async () => { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -export const withVariable = createMiddleware({ - id: 'test' -}).server(abstractedFunction); -async function abstractedFunction() { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -} -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { - return async (input: unknown) => { - return fn(schema.parse(input)); - }; -} -export const withZodValidator = createMiddleware({ - id: 'test' -}).server(zodValidator(z.number(), input => { - return { - 'you gave': input - }; -})); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareDestructuredRename.tsx b/packages/solid-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareDestructuredRename.tsx deleted file mode 100644 index 7fcc6b7b5a..0000000000 --- a/packages/solid-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareDestructuredRename.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { createMiddleware as middlewareFn } from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = middlewareFn({ - id: 'test' -}).server(async function () { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -export const withoutUseServer = middlewareFn({ - id: 'test' -}).server(async () => { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -export const withVariable = middlewareFn({ - id: 'test' -}).server(abstractedFunction); -async function abstractedFunction() { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -} -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { - return async (input: unknown) => { - return fn(schema.parse(input)); - }; -} -export const withZodValidator = middlewareFn({ - id: 'test' -}).server(zodValidator(z.number(), input => { - return { - 'you gave': input - }; -})); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareStarImport.tsx b/packages/solid-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareStarImport.tsx deleted file mode 100644 index 92047bfa0a..0000000000 --- a/packages/solid-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareStarImport.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import * as TanStackStart from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = TanStackStart.createMiddleware({ - id: 'test' -}).server(async function () { - 'use server'; - - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -export const withoutUseServer = TanStackStart.createMiddleware({ - id: 'test' -}).server(async () => { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -export const withVariable = TanStackStart.createMiddleware({ - id: 'test' -}).server(abstractedFunction); -async function abstractedFunction() { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -} -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { - return async (input: unknown) => { - return fn(schema.parse(input)); - }; -} -export const withZodValidator = TanStackStart.createMiddleware({ - id: 'test' -}).server(zodValidator(z.number(), input => { - return { - 'you gave': input - }; -})); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareValidator.tsx b/packages/solid-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareValidator.tsx deleted file mode 100644 index eb3d933b77..0000000000 --- a/packages/solid-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareValidator.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { createMiddleware } from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = createMiddleware({ - id: 'test' -}).validator(z.number()).server(({ - input -}) => input + 1); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createMiddleware/test-files/createMiddlewareDestructured.tsx b/packages/solid-start-plugin/tests/createMiddleware/test-files/createMiddlewareDestructured.tsx deleted file mode 100644 index 595099cdbe..0000000000 --- a/packages/solid-start-plugin/tests/createMiddleware/test-files/createMiddlewareDestructured.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { createMiddleware } from '@tanstack/solid-start' -import { z } from 'zod' - -export const withUseServer = createMiddleware({ - id: 'test', -}).server(async function () { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withoutUseServer = createMiddleware({ - id: 'test', -}).server(async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withVariable = createMiddleware({ - id: 'test', -}).server(abstractedFunction) - -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} - -function zodValidator( - schema: TSchema, - fn: (input: z.output) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} - -export const withZodValidator = createMiddleware({ - id: 'test', -}).server( - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) diff --git a/packages/solid-start-plugin/tests/createMiddleware/test-files/createMiddlewareDestructuredRename.tsx b/packages/solid-start-plugin/tests/createMiddleware/test-files/createMiddlewareDestructuredRename.tsx deleted file mode 100644 index 700da4fe63..0000000000 --- a/packages/solid-start-plugin/tests/createMiddleware/test-files/createMiddlewareDestructuredRename.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { createMiddleware as middlewareFn } from '@tanstack/solid-start' -import { z } from 'zod' - -export const withUseServer = middlewareFn({ - id: 'test', -}).server(async function () { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withoutUseServer = middlewareFn({ - id: 'test', -}).server(async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withVariable = middlewareFn({ - id: 'test', -}).server(abstractedFunction) - -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} - -function zodValidator( - schema: TSchema, - fn: (input: z.output) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} - -export const withZodValidator = middlewareFn({ - id: 'test', -}).server( - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) diff --git a/packages/solid-start-plugin/tests/createMiddleware/test-files/createMiddlewareStarImport.tsx b/packages/solid-start-plugin/tests/createMiddleware/test-files/createMiddlewareStarImport.tsx deleted file mode 100644 index 315d29e1c7..0000000000 --- a/packages/solid-start-plugin/tests/createMiddleware/test-files/createMiddlewareStarImport.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import * as TanStackStart from '@tanstack/solid-start' -import { z } from 'zod' - -export const withUseServer = TanStackStart.createMiddleware({ - id: 'test', -}).server(async function () { - 'use server' - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withoutUseServer = TanStackStart.createMiddleware({ - id: 'test', -}).server(async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withVariable = TanStackStart.createMiddleware({ - id: 'test', -}).server(abstractedFunction) - -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} - -function zodValidator( - schema: TSchema, - fn: (input: z.output) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} - -export const withZodValidator = TanStackStart.createMiddleware({ - id: 'test', -}).server( - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) diff --git a/packages/solid-start-plugin/tests/createMiddleware/test-files/createMiddlewareValidator.tsx b/packages/solid-start-plugin/tests/createMiddleware/test-files/createMiddlewareValidator.tsx deleted file mode 100644 index 62ea02b36a..0000000000 --- a/packages/solid-start-plugin/tests/createMiddleware/test-files/createMiddlewareValidator.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { createMiddleware } from '@tanstack/solid-start' -import { z } from 'zod' - -export const withUseServer = createMiddleware({ - id: 'test', -}) - .validator(z.number()) - .server(({ input }) => input + 1) diff --git a/packages/solid-start-plugin/tests/createServerFn/createServerFn.test.ts b/packages/solid-start-plugin/tests/createServerFn/createServerFn.test.ts deleted file mode 100644 index 8d30fee5ad..0000000000 --- a/packages/solid-start-plugin/tests/createServerFn/createServerFn.test.ts +++ /dev/null @@ -1,176 +0,0 @@ -import { readFile, readdir } from 'node:fs/promises' -import path from 'node:path' -import { describe, expect, test } from 'vitest' - -import { compileStartOutput } from '../../src/compilers' - -async function getFilenames() { - return await readdir(path.resolve(import.meta.dirname, './test-files')) -} - -describe('createServerFn compiles correctly', async () => { - const filenames = await getFilenames() - - describe.each(filenames)('should handle "%s"', async (filename) => { - const file = await readFile( - path.resolve(import.meta.dirname, `./test-files/${filename}`), - ) - const code = file.toString() - - test.each(['client', 'server'] as const)( - `should compile for ${filename} %s`, - async (env) => { - const compiledResult = compileStartOutput({ - env, - code, - root: './test-files', - filename, - dce: false, - }) - - await expect(compiledResult.code).toMatchFileSnapshot( - `./snapshots/${env}/${filename}`, - ) - }, - ) - }) - - test('should error if created without a handler', () => { - expect(() => { - compileStartOutput({ - env: 'client', - code: ` - import { createServerFn } from '@tanstack/solid-start' - createServerFn()`, - root: './test-files', - filename: 'no-fn.ts', - dce: false, - }) - }).toThrowError() - }) - - test('should be assigned to a variable', () => { - expect(() => { - compileStartOutput({ - env: 'client', - code: ` - import { createServerFn } from '@tanstack/solid-start' - createServerFn().handler(async () => {})`, - root: './test-files', - filename: 'no-fn.ts', - dce: false, - }) - }).toThrowError() - }) - - test('should work with identifiers of functions', () => { - const code = ` - import { createServerFn } from '@tanstack/solid-start' - const myFunc = () => { - return 'hello from the server' - } - const myServerFn = createServerFn().handler(myFunc)` - - const compiledResultClient = compileStartOutput({ - root: '/test', - filename: 'test.ts', - code, - env: 'client', - dce: false, - }) - - const compiledResultServer = compileStartOutput({ - root: '/test', - filename: 'test.ts', - code, - env: 'server', - dce: false, - }) - - expect(compiledResultClient.code).toMatchInlineSnapshot(` - "import { createServerFn } from '@tanstack/solid-start'; - const myServerFn = createServerFn().handler((opts, signal) => { - "use server"; - - return myServerFn.__executeServer(opts, signal); - });" - `) - - expect(compiledResultServer.code).toMatchInlineSnapshot(` - "import { createServerFn } from '@tanstack/solid-start'; - const myFunc = () => { - return 'hello from the server'; - }; - const myServerFn = createServerFn().handler((opts, signal) => { - "use server"; - - return myServerFn.__executeServer(opts, signal); - }, myFunc);" - `) - }) - - test('should use dce by default', () => { - const code = ` - import { createServerFn } from '@tanstack/solid-start' - const exportedVar = 'exported' - export const exportedFn = createServerFn().handler(async () => { - return exportedVar - }) - const nonExportedVar = 'non-exported' - const nonExportedFn = createServerFn().handler(async () => { - return nonExportedVar - })` - - // Client - const compiledResult = compileStartOutput({ - root: '/test', - filename: 'test.ts', - code, - env: 'client', - dce: true, - }) - - expect(compiledResult.code).toMatchInlineSnapshot(` - "import { createServerFn } from '@tanstack/solid-start'; - export const exportedFn = createServerFn().handler((opts, signal) => { - "use server"; - - return exportedFn.__executeServer(opts, signal); - }); - const nonExportedFn = createServerFn().handler((opts, signal) => { - "use server"; - - return nonExportedFn.__executeServer(opts, signal); - });" - `) - - // Server - const compiledResultServer = compileStartOutput({ - root: '/test', - filename: 'test.ts', - code, - env: 'server', - dce: true, - }) - - expect(compiledResultServer.code).toMatchInlineSnapshot(` - "import { createServerFn } from '@tanstack/solid-start'; - const exportedVar = 'exported'; - export const exportedFn = createServerFn().handler((opts, signal) => { - "use server"; - - return exportedFn.__executeServer(opts, signal); - }, async () => { - return exportedVar; - }); - const nonExportedVar = 'non-exported'; - const nonExportedFn = createServerFn().handler((opts, signal) => { - "use server"; - - return nonExportedFn.__executeServer(opts, signal); - }, async () => { - return nonExportedVar; - });" - `) - }) -}) diff --git a/packages/solid-start-plugin/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx b/packages/solid-start-plugin/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx deleted file mode 100644 index d8105165f0..0000000000 --- a/packages/solid-start-plugin/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { createServerFn } from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withUseServer.__executeServer(opts, signal); -}); -export const withArrowFunction = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withArrowFunction.__executeServer(opts, signal); -}); -export const withArrowFunctionAndFunction = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withArrowFunctionAndFunction.__executeServer(opts, signal); -}); -export const withoutUseServer = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withoutUseServer.__executeServer(opts, signal); -}); -export const withVariable = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withVariable.__executeServer(opts, signal); -}); -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { - return async (input: unknown) => { - return fn(schema.parse(input)); - }; -} -export const withZodValidator = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withZodValidator.__executeServer(opts, signal); -}); -export const withValidatorFn = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withValidatorFn.__executeServer(opts, signal); -}); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx b/packages/solid-start-plugin/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx deleted file mode 100644 index e7d1010563..0000000000 --- a/packages/solid-start-plugin/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { createServerFn as serverFn } from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = serverFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withUseServer.__executeServer(opts, signal); -}); -export const withoutUseServer = serverFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withoutUseServer.__executeServer(opts, signal); -}); -export const withVariable = serverFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withVariable.__executeServer(opts, signal); -}); -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { - return async (input: unknown) => { - return fn(schema.parse(input)); - }; -} -export const withZodValidator = serverFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withZodValidator.__executeServer(opts, signal); -}); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx b/packages/solid-start-plugin/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx deleted file mode 100644 index e2735ea5d1..0000000000 --- a/packages/solid-start-plugin/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import * as TanStackStart from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = TanStackStart.createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withUseServer.__executeServer(opts, signal); -}); -export const withoutUseServer = TanStackStart.createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withoutUseServer.__executeServer(opts, signal); -}); -export const withVariable = TanStackStart.createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withVariable.__executeServer(opts, signal); -}); -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { - return async (input: unknown) => { - return fn(schema.parse(input)); - }; -} -export const withZodValidator = TanStackStart.createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withZodValidator.__executeServer(opts, signal); -}); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createServerFn/snapshots/client/createServerFnValidator.tsx b/packages/solid-start-plugin/tests/createServerFn/snapshots/client/createServerFnValidator.tsx deleted file mode 100644 index f43f06ee88..0000000000 --- a/packages/solid-start-plugin/tests/createServerFn/snapshots/client/createServerFnValidator.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { createServerFn } from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withUseServer.__executeServer(opts, signal); -}); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createServerFn/snapshots/server/createServerFnDestructured.tsx b/packages/solid-start-plugin/tests/createServerFn/snapshots/server/createServerFnDestructured.tsx deleted file mode 100644 index 673c4e90fe..0000000000 --- a/packages/solid-start-plugin/tests/createServerFn/snapshots/server/createServerFnDestructured.tsx +++ /dev/null @@ -1,77 +0,0 @@ -import { createServerFn } from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withUseServer.__executeServer(opts, signal); -}, async function () { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -export const withArrowFunction = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withArrowFunction.__executeServer(opts, signal); -}, async () => null); -export const withArrowFunctionAndFunction = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withArrowFunctionAndFunction.__executeServer(opts, signal); -}, async () => test()); -export const withoutUseServer = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withoutUseServer.__executeServer(opts, signal); -}, async () => { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -export const withVariable = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withVariable.__executeServer(opts, signal); -}, abstractedFunction); -async function abstractedFunction() { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -} -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { - return async (input: unknown) => { - return fn(schema.parse(input)); - }; -} -export const withZodValidator = createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withZodValidator.__executeServer(opts, signal); -}, zodValidator(z.number(), input => { - return { - 'you gave': input - }; -})); -export const withValidatorFn = createServerFn({ - method: 'GET' -}).validator(z.number()).handler((opts, signal) => { - "use server"; - - return withValidatorFn.__executeServer(opts, signal); -}, async ({ - input -}) => { - return null; -}); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createServerFn/snapshots/server/createServerFnDestructuredRename.tsx b/packages/solid-start-plugin/tests/createServerFn/snapshots/server/createServerFnDestructuredRename.tsx deleted file mode 100644 index d9902417f5..0000000000 --- a/packages/solid-start-plugin/tests/createServerFn/snapshots/server/createServerFnDestructuredRename.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { createServerFn as serverFn } from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = serverFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withUseServer.__executeServer(opts, signal); -}, async function () { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -export const withoutUseServer = serverFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withoutUseServer.__executeServer(opts, signal); -}, async () => { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -export const withVariable = serverFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withVariable.__executeServer(opts, signal); -}, abstractedFunction); -async function abstractedFunction() { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -} -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { - return async (input: unknown) => { - return fn(schema.parse(input)); - }; -} -export const withZodValidator = serverFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withZodValidator.__executeServer(opts, signal); -}, zodValidator(z.number(), input => { - return { - 'you gave': input - }; -})); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createServerFn/snapshots/server/createServerFnStarImport.tsx b/packages/solid-start-plugin/tests/createServerFn/snapshots/server/createServerFnStarImport.tsx deleted file mode 100644 index 83964ecc5c..0000000000 --- a/packages/solid-start-plugin/tests/createServerFn/snapshots/server/createServerFnStarImport.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import * as TanStackStart from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = TanStackStart.createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withUseServer.__executeServer(opts, signal); -}, async function () { - 'use server'; - - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -export const withoutUseServer = TanStackStart.createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withoutUseServer.__executeServer(opts, signal); -}, async () => { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -export const withVariable = TanStackStart.createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withVariable.__executeServer(opts, signal); -}, abstractedFunction); -async function abstractedFunction() { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -} -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { - return async (input: unknown) => { - return fn(schema.parse(input)); - }; -} -export const withZodValidator = TanStackStart.createServerFn({ - method: 'GET' -}).handler((opts, signal) => { - "use server"; - - return withZodValidator.__executeServer(opts, signal); -}, zodValidator(z.number(), input => { - return { - 'you gave': input - }; -})); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createServerFn/snapshots/server/createServerFnValidator.tsx b/packages/solid-start-plugin/tests/createServerFn/snapshots/server/createServerFnValidator.tsx deleted file mode 100644 index 364f8354fa..0000000000 --- a/packages/solid-start-plugin/tests/createServerFn/snapshots/server/createServerFnValidator.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { createServerFn } from '@tanstack/solid-start'; -import { z } from 'zod'; -export const withUseServer = createServerFn({ - method: 'GET' -}).validator(z.number()).handler((opts, signal) => { - "use server"; - - return withUseServer.__executeServer(opts, signal); -}, ({ - input -}) => input + 1); \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/createServerFn/test-files/createServerFnDestructured.tsx b/packages/solid-start-plugin/tests/createServerFn/test-files/createServerFnDestructured.tsx deleted file mode 100644 index fd7f48510d..0000000000 --- a/packages/solid-start-plugin/tests/createServerFn/test-files/createServerFnDestructured.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import { createServerFn } from '@tanstack/solid-start' -import { z } from 'zod' - -export const withUseServer = createServerFn({ - method: 'GET', -}).handler(async function () { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withArrowFunction = createServerFn({ - method: 'GET', -}).handler(async () => null) - -export const withArrowFunctionAndFunction = createServerFn({ - method: 'GET', -}).handler(async () => test()) - -export const withoutUseServer = createServerFn({ - method: 'GET', -}).handler(async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withVariable = createServerFn({ - method: 'GET', -}).handler(abstractedFunction) - -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} - -function zodValidator( - schema: TSchema, - fn: (input: z.output) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} - -export const withZodValidator = createServerFn({ - method: 'GET', -}).handler( - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) - -export const withValidatorFn = createServerFn({ - method: 'GET', -}) - .validator(z.number()) - .handler(async ({ input }) => { - return null - }) diff --git a/packages/solid-start-plugin/tests/createServerFn/test-files/createServerFnDestructuredRename.tsx b/packages/solid-start-plugin/tests/createServerFn/test-files/createServerFnDestructuredRename.tsx deleted file mode 100644 index 823339b3ac..0000000000 --- a/packages/solid-start-plugin/tests/createServerFn/test-files/createServerFnDestructuredRename.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { createServerFn as serverFn } from '@tanstack/solid-start' -import { z } from 'zod' - -export const withUseServer = serverFn({ - method: 'GET', -}).handler(async function () { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withoutUseServer = serverFn({ - method: 'GET', -}).handler(async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withVariable = serverFn({ method: 'GET' }).handler( - abstractedFunction, -) - -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} - -function zodValidator( - schema: TSchema, - fn: (input: z.output) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} - -export const withZodValidator = serverFn({ - method: 'GET', -}).handler( - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) diff --git a/packages/solid-start-plugin/tests/createServerFn/test-files/createServerFnStarImport.tsx b/packages/solid-start-plugin/tests/createServerFn/test-files/createServerFnStarImport.tsx deleted file mode 100644 index d4ecddb304..0000000000 --- a/packages/solid-start-plugin/tests/createServerFn/test-files/createServerFnStarImport.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import * as TanStackStart from '@tanstack/solid-start' -import { z } from 'zod' - -export const withUseServer = TanStackStart.createServerFn({ - method: 'GET', -}).handler(async function () { - 'use server' - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withoutUseServer = TanStackStart.createServerFn({ - method: 'GET', -}).handler(async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withVariable = TanStackStart.createServerFn({ - method: 'GET', -}).handler(abstractedFunction) - -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} - -function zodValidator( - schema: TSchema, - fn: (input: z.output) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} - -export const withZodValidator = TanStackStart.createServerFn({ - method: 'GET', -}).handler( - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) diff --git a/packages/solid-start-plugin/tests/createServerFn/test-files/createServerFnValidator.tsx b/packages/solid-start-plugin/tests/createServerFn/test-files/createServerFnValidator.tsx deleted file mode 100644 index 0d535eb369..0000000000 --- a/packages/solid-start-plugin/tests/createServerFn/test-files/createServerFnValidator.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { createServerFn } from '@tanstack/solid-start' -import { z } from 'zod' - -export const withUseServer = createServerFn({ - method: 'GET', -}) - .validator(z.number()) - .handler(({ input }) => input + 1) diff --git a/packages/solid-start-plugin/tests/envOnly/envOnly.test.ts b/packages/solid-start-plugin/tests/envOnly/envOnly.test.ts deleted file mode 100644 index 00c9786170..0000000000 --- a/packages/solid-start-plugin/tests/envOnly/envOnly.test.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { readFile, readdir } from 'node:fs/promises' -import path from 'node:path' -import { describe, expect, test } from 'vitest' - -import { compileStartOutput } from '../../src/compilers' - -async function getFilenames() { - return await readdir(path.resolve(import.meta.dirname, './test-files')) -} - -describe('envOnly functions compile correctly', async () => { - const filenames = await getFilenames() - - describe.each(filenames)('should handle "%s"', async (filename) => { - const file = await readFile( - path.resolve(import.meta.dirname, `./test-files/${filename}`), - ) - const code = file.toString() - - test.each(['client', 'server'] as const)( - `should compile for ${filename} %s`, - async (env) => { - const compiledResult = compileStartOutput({ - env, - code, - root: './test-files', - filename, - dce: false, - }) - - await expect(compiledResult.code).toMatchFileSnapshot( - `./snapshots/${env}/${filename}`, - ) - }, - ) - }) - test('should error if implementation not provided', () => { - expect(() => { - compileStartOutput({ - env: 'client', - code: ` - import { clientOnly } from '@tanstack/solid-start' - const fn = clientOnly()`, - root: './test-files', - filename: 'no-fn.ts', - dce: false, - }) - }).toThrowError() - expect(() => { - compileStartOutput({ - env: 'server', - code: ` - import { serverOnly } from '@tanstack/solid-start' - const fn = serverOnly()`, - root: './test-files', - filename: 'no-fn.ts', - dce: false, - }) - }).toThrowError() - }) -}) diff --git a/packages/solid-start-plugin/tests/envOnly/snapshots/client/envOnlyDestructured.tsx b/packages/solid-start-plugin/tests/envOnly/snapshots/client/envOnlyDestructured.tsx deleted file mode 100644 index 8080d677e6..0000000000 --- a/packages/solid-start-plugin/tests/envOnly/snapshots/client/envOnlyDestructured.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { serverOnly, clientOnly } from '@tanstack/solid-start'; -const serverFunc = () => { - throw new Error("serverOnly() functions can only be called on the server!"); -}; -const clientFunc = () => 'client'; \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx b/packages/solid-start-plugin/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx deleted file mode 100644 index c3e67e045b..0000000000 --- a/packages/solid-start-plugin/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { serverOnly as serverFn, clientOnly as clientFn } from '@tanstack/solid-start'; -const serverFunc = () => { - throw new Error("serverOnly() functions can only be called on the server!"); -}; -const clientFunc = () => 'client'; \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/envOnly/snapshots/client/envOnlyStarImport.tsx b/packages/solid-start-plugin/tests/envOnly/snapshots/client/envOnlyStarImport.tsx deleted file mode 100644 index d860ab6d21..0000000000 --- a/packages/solid-start-plugin/tests/envOnly/snapshots/client/envOnlyStarImport.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import * as TanstackStart from '@tanstack/solid-start'; -const serverFunc = () => { - throw new Error("serverOnly() functions can only be called on the server!"); -}; -const clientFunc = () => 'client'; \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/envOnly/snapshots/server/envOnlyDestructured.tsx b/packages/solid-start-plugin/tests/envOnly/snapshots/server/envOnlyDestructured.tsx deleted file mode 100644 index 35bf2907cc..0000000000 --- a/packages/solid-start-plugin/tests/envOnly/snapshots/server/envOnlyDestructured.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { serverOnly, clientOnly } from '@tanstack/solid-start'; -const serverFunc = () => 'server'; -const clientFunc = () => { - throw new Error("clientOnly() functions can only be called on the client!"); -}; \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx b/packages/solid-start-plugin/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx deleted file mode 100644 index 31c1c2a23b..0000000000 --- a/packages/solid-start-plugin/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { serverOnly as serverFn, clientOnly as clientFn } from '@tanstack/solid-start'; -const serverFunc = () => 'server'; -const clientFunc = () => { - throw new Error("clientOnly() functions can only be called on the client!"); -}; \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/envOnly/snapshots/server/envOnlyStarImport.tsx b/packages/solid-start-plugin/tests/envOnly/snapshots/server/envOnlyStarImport.tsx deleted file mode 100644 index 318b47dd64..0000000000 --- a/packages/solid-start-plugin/tests/envOnly/snapshots/server/envOnlyStarImport.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import * as TanstackStart from '@tanstack/solid-start'; -const serverFunc = () => 'server'; -const clientFunc = () => { - throw new Error("clientOnly() functions can only be called on the client!"); -}; \ No newline at end of file diff --git a/packages/solid-start-plugin/tests/envOnly/test-files/envOnlyDestructured.tsx b/packages/solid-start-plugin/tests/envOnly/test-files/envOnlyDestructured.tsx deleted file mode 100644 index c4513f737d..0000000000 --- a/packages/solid-start-plugin/tests/envOnly/test-files/envOnlyDestructured.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { serverOnly, clientOnly } from '@tanstack/solid-start' - -const serverFunc = serverOnly(() => 'server') - -const clientFunc = clientOnly(() => 'client') diff --git a/packages/solid-start-plugin/tests/envOnly/test-files/envOnlyDestructuredRename.tsx b/packages/solid-start-plugin/tests/envOnly/test-files/envOnlyDestructuredRename.tsx deleted file mode 100644 index 4b48ba3b58..0000000000 --- a/packages/solid-start-plugin/tests/envOnly/test-files/envOnlyDestructuredRename.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { - serverOnly as serverFn, - clientOnly as clientFn, -} from '@tanstack/solid-start' - -const serverFunc = serverFn(() => 'server') - -const clientFunc = clientFn(() => 'client') diff --git a/packages/solid-start-plugin/tests/envOnly/test-files/envOnlyStarImport.tsx b/packages/solid-start-plugin/tests/envOnly/test-files/envOnlyStarImport.tsx deleted file mode 100644 index adeab52616..0000000000 --- a/packages/solid-start-plugin/tests/envOnly/test-files/envOnlyStarImport.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import * as TanstackStart from '@tanstack/solid-start' - -const serverFunc = TanstackStart.serverOnly(() => 'server') - -const clientFunc = TanstackStart.clientOnly(() => 'client') diff --git a/packages/solid-start-plugin/tsconfig.json b/packages/solid-start-plugin/tsconfig.json index 37d21ef6ca..090ec3917d 100644 --- a/packages/solid-start-plugin/tsconfig.json +++ b/packages/solid-start-plugin/tsconfig.json @@ -3,6 +3,8 @@ "include": ["src", "vite.config.ts", "tests"], "exclude": ["tests/**/test-files/**", "tests/**/snapshots/**"], "compilerOptions": { - "jsx": "react-jsx" + "outDir": "dist/esm", + "target": "esnext", + "noEmit": true } } diff --git a/packages/solid-start-plugin/vite.config.ts b/packages/solid-start-plugin/vite.config.ts index 5389f0f739..2c711fd181 100644 --- a/packages/solid-start-plugin/vite.config.ts +++ b/packages/solid-start-plugin/vite.config.ts @@ -16,5 +16,6 @@ export default mergeConfig( tanstackViteConfig({ entry: './src/index.ts', srcDir: './src', + outDir: './dist', }), ) diff --git a/packages/solid-start-router-manifest/README.md b/packages/solid-start-router-manifest/README.md deleted file mode 100644 index bb009b0c87..0000000000 --- a/packages/solid-start-router-manifest/README.md +++ /dev/null @@ -1,33 +0,0 @@ -> 🤫 we're cooking up something special! - - - -# TanStack Start - -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) - -🤖 Type-safe router w/ built-in caching & URL state management for React! - - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - - -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! diff --git a/packages/solid-start-router-manifest/eslint.config.js b/packages/solid-start-router-manifest/eslint.config.js deleted file mode 100644 index 931f0ec774..0000000000 --- a/packages/solid-start-router-manifest/eslint.config.js +++ /dev/null @@ -1,31 +0,0 @@ -// @ts-check - -import pluginReact from '@eslint-react/eslint-plugin' -import pluginReactHooks from 'eslint-plugin-react-hooks' -import rootConfig from '../../eslint.config.js' - -export default [ - ...rootConfig, - { - ...pluginReact.configs.recommended, - files: ['**/*.{ts,tsx}'], - }, - { - plugins: { - 'react-hooks': pluginReactHooks, - }, - rules: { - '@eslint-react/no-unstable-context-value': 'off', - '@eslint-react/no-unstable-default-props': 'off', - '@eslint-react/dom/no-missing-button-type': 'off', - 'react-hooks/exhaustive-deps': 'error', - 'react-hooks/rules-of-hooks': 'error', - }, - }, - { - files: ['**/__tests__/**'], - rules: { - '@typescript-eslint/no-unnecessary-condition': 'off', - }, - }, -] diff --git a/packages/solid-start-router-manifest/package.json b/packages/solid-start-router-manifest/package.json deleted file mode 100644 index 3ee031b8e0..0000000000 --- a/packages/solid-start-router-manifest/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@tanstack/solid-start-router-manifest", - "version": "1.120.3", - "description": "Modern and scalable routing for Solid applications", - "author": "Tanner Linsley", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/TanStack/router.git", - "directory": "packages/start" - }, - "homepage": "https://tanstack.com/start", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/tannerlinsley" - }, - "keywords": [ - "solid", - "location", - "router", - "routing", - "async", - "async router", - "typescript" - ], - "scripts": { - "clean": "rimraf ./dist && rimraf ./coverage", - "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit", - "test:unit": "exit 0; vitest", - "test:eslint": "eslint ./src", - "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"", - "test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js", - "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js", - "test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js", - "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js", - "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js", - "test:types:ts58": "tsc", - "test:build": "publint --strict && attw --ignore-rules no-resolution --pack .", - "build": "tsc" - }, - "type": "module", - "types": "dist/esm/index.d.ts", - "exports": { - ".": { - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - } - }, - "./package.json": "./package.json" - }, - "sideEffects": false, - "files": [ - "dist", - "src" - ], - "engines": { - "node": ">=12" - }, - "dependencies": { - "@tanstack/router-core": "workspace:^", - "tiny-invariant": "^1.3.3", - "vinxi": "0.5.3" - }, - "devDependencies": { - "typescript": "^5.7.2" - } -} diff --git a/packages/solid-start-router-manifest/src/index.ts b/packages/solid-start-router-manifest/src/index.ts deleted file mode 100644 index 9a41e3f788..0000000000 --- a/packages/solid-start-router-manifest/src/index.ts +++ /dev/null @@ -1,83 +0,0 @@ -// @ts-expect-error -import tsrGetManifest from 'tsr:routes-manifest' -import { getManifest } from 'vinxi/manifest' -import { default as invariant } from 'tiny-invariant' -import type { Manifest } from '@tanstack/router-core' - -function sanitizeBase(base: string) { - return base.replace(/^\/|\/$/g, '') -} - -/** - * @description Returns the full, unfiltered router manifest. This includes relationships - * between routes, assets, and preloads and is NOT what you want to serialize and - * send to the client. - */ -export function getFullRouterManifest() { - const routerManifest = tsrGetManifest() as Manifest - - const rootRoute = (routerManifest.routes.__root__ = - routerManifest.routes.__root__ || {}) - - rootRoute.assets = rootRoute.assets || [] - - const script = '' - // Always fake that HMR is ready - if (process.env.NODE_ENV === 'development') { - const CLIENT_BASE = sanitizeBase(process.env.TSS_CLIENT_BASE || '') - - if (!CLIENT_BASE) { - throw new Error( - 'tanstack/solid-start-router-manifest: TSS_CLIENT_BASE must be defined in your environment for getFullRouterManifest()', - ) - } - } - - // Get the entry for the client from vinxi - const vinxiClientManifest = getManifest('client') - - const importPath = - vinxiClientManifest.inputs[vinxiClientManifest.handler]?.output.path - if (!importPath) { - invariant(importPath, 'Could not find client entry in vinxi manifest') - } - - rootRoute.assets.push({ - tag: 'script', - attrs: { - type: 'module', - suppressHydrationWarning: true, - async: true, - }, - children: `${script}import("${importPath}")`, - }) - - return routerManifest -} - -/** - * @description Returns the router manifest that should be sent to the client. - * This includes only the assets and preloads for the current route and any - * special assets that are needed for the client. It does not include relationships - * between routes or any other data that is not needed for the client. - */ -export function getRouterManifest() { - const routerManifest = getFullRouterManifest() - - // Strip out anything that isn't needed for the client - return { - ...routerManifest, - routes: Object.fromEntries( - Object.entries(routerManifest.routes).map(([k, v]: any) => { - const { preloads, assets } = v - return [ - k, - { - preloads, - assets, - }, - ] - }), - ), - } -} diff --git a/packages/solid-start-router-manifest/tsconfig.json b/packages/solid-start-router-manifest/tsconfig.json deleted file mode 100644 index 940a9cce0a..0000000000 --- a/packages/solid-start-router-manifest/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["src/index.ts"], - "compilerOptions": { - "rootDir": "src", - "outDir": "dist/esm", - "target": "esnext", - "noEmit": false - } -} diff --git a/packages/solid-start-router-manifest/vite.config.ts b/packages/solid-start-router-manifest/vite.config.ts deleted file mode 100644 index d6472068fb..0000000000 --- a/packages/solid-start-router-manifest/vite.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { defineConfig, mergeConfig } from 'vitest/config' -import { tanstackViteConfig } from '@tanstack/config/vite' -import packageJson from './package.json' -import type { ViteUserConfig } from 'vitest/config' - -const config = defineConfig({ - plugins: [] as ViteUserConfig['plugins'], - test: { - name: packageJson.name, - watch: false, - environment: 'jsdom', - }, -}) - -export default mergeConfig( - config, - tanstackViteConfig({ - entry: './src/index.ts', - srcDir: './src', - externalDeps: ['tsr:routes-manifest'], - }), -) diff --git a/packages/solid-start-server/README.md b/packages/solid-start-server/README.md index fd6e98ac6d..46a245ec2d 100644 --- a/packages/solid-start-server/README.md +++ b/packages/solid-start-server/README.md @@ -1,33 +1,9 @@ -> 🤫 we're cooking up something special! - -# TanStack Start +# TanStack Solid Start - Server -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) +This package is not meant to be used directly. It is a dependency of [`@tanstack/solid-start`](https://www.npmjs.com/package/@tanstack/solid-start). -🤖 Type-safe router w/ built-in caching & URL state management for React! +TanStack Solid Start is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router). - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - - -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! +Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started. diff --git a/packages/solid-start-server/src/index.tsx b/packages/solid-start-server/src/index.tsx index f4573955c8..b0dda10b7a 100644 --- a/packages/solid-start-server/src/index.tsx +++ b/packages/solid-start-server/src/index.tsx @@ -1,4 +1,5 @@ export { StartServer } from './StartServer' export { defaultStreamHandler } from './defaultStreamHandler' export { defaultRenderHandler } from './defaultRenderHandler' + export * from '@tanstack/start-server-core' diff --git a/packages/solid-start-server/vite.config.ts b/packages/solid-start-server/vite.config.ts index c0a7454291..d973bb3b08 100644 --- a/packages/solid-start-server/vite.config.ts +++ b/packages/solid-start-server/vite.config.ts @@ -22,5 +22,6 @@ export default mergeConfig( tanstackViteConfig({ srcDir: './src', entry: './src/index.tsx', + externalDeps: ['tanstack:server-fn-manifest', 'tanstack:start-manifest'], }), ) diff --git a/packages/solid-start/README.md b/packages/solid-start/README.md index 5745ba8bf0..c44c19422c 100644 --- a/packages/solid-start/README.md +++ b/packages/solid-start/README.md @@ -1,33 +1,42 @@ -> 🤫 we're cooking up something special! - -# TanStack Start +# TanStack Solid Start -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) +![TanStack Solid Start Header](https://github.com/tanstack/router/raw/main/media/header.png) -🤖 Type-safe router w/ built-in caching & URL state management for Solid! (Experimental) +SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router) and Vite. Ready to deploy to your favorite hosting provider. #TanStack - + + - - - - - - semantic-release - + + + + + + + + + semantic-release + + Join the discussion on Github -Best of JS + + + Best of JS + + - + + - + + Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! +Visit [tanstack.com/start](https://tanstack.com/start) for docs, guides, API and more! diff --git a/packages/solid-start/package.json b/packages/solid-start/package.json index 228c931c61..9aa9e35df1 100644 --- a/packages/solid-start/package.json +++ b/packages/solid-start/package.json @@ -62,34 +62,14 @@ "default": "./dist/cjs/server.cjs" } }, - "./config": { + "./plugin": { "import": { - "types": "./dist/esm/config.d.ts", - "default": "./dist/esm/config.js" + "types": "./dist/esm/plugin.d.ts", + "default": "./dist/esm/plugin.js" }, "require": { - "types": "./dist/cjs/config.d.cts", - "default": "./dist/cjs/config.cjs" - } - }, - "./api": { - "import": { - "types": "./dist/esm/api.d.ts", - "default": "./dist/esm/api.js" - }, - "require": { - "types": "./dist/cjs/api.d.cts", - "default": "./dist/cjs/api.cjs" - } - }, - "./router-manifest": { - "import": { - "types": "./dist/esm/router-manifest.d.ts", - "default": "./dist/esm/router-manifest.js" - }, - "require": { - "types": "./dist/cjs/router-manifest.d.cts", - "default": "./dist/cjs/router-manifest.cjs" + "types": "./dist/cjs/plugin.d.cts", + "default": "./dist/cjs/plugin.cjs" } }, "./server-functions-client": { @@ -122,16 +102,6 @@ "default": "./dist/cjs/server-functions-handler.cjs" } }, - "./server-functions-ssr": { - "import": { - "types": "./dist/esm/server-functions-ssr.d.ts", - "default": "./dist/esm/server-functions-ssr.js" - }, - "require": { - "types": "./dist/cjs/server-functions-ssr.d.cts", - "default": "./dist/cjs/server-functions-ssr.cjs" - } - }, "./package.json": "./package.json" }, "sideEffects": false, @@ -145,13 +115,9 @@ "dependencies": { "@tanstack/solid-start-client": "workspace:^", "@tanstack/solid-start-server": "workspace:^", - "@tanstack/solid-start-config": "workspace:^", - "@tanstack/solid-start-router-manifest": "workspace:^", + "@tanstack/solid-start-plugin": "workspace:^", "@tanstack/start-server-functions-client": "workspace:^", - "@tanstack/start-server-functions-server": "workspace:^", - "@tanstack/start-server-functions-handler": "workspace:^", - "@tanstack/start-server-functions-ssr": "workspace:^", - "@tanstack/start-api-routes": "workspace:^" + "@tanstack/start-server-functions-server": "workspace:^" }, "peerDependencies": { "solid-js": ">=1.0.0", diff --git a/packages/solid-start/src/api.tsx b/packages/solid-start/src/api.tsx deleted file mode 100644 index fff3bec5ea..0000000000 --- a/packages/solid-start/src/api.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from '@tanstack/start-api-routes' diff --git a/packages/solid-start/src/config.tsx b/packages/solid-start/src/config.tsx deleted file mode 100644 index 5a71360c3a..0000000000 --- a/packages/solid-start/src/config.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from '@tanstack/solid-start-config' diff --git a/packages/solid-start/src/plugin.tsx b/packages/solid-start/src/plugin.tsx new file mode 100644 index 0000000000..24c76d5516 --- /dev/null +++ b/packages/solid-start/src/plugin.tsx @@ -0,0 +1 @@ +export * from '@tanstack/solid-start-plugin' diff --git a/packages/solid-start/src/router-manifest.tsx b/packages/solid-start/src/router-manifest.tsx deleted file mode 100644 index 4e939be275..0000000000 --- a/packages/solid-start/src/router-manifest.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from '@tanstack/solid-start-router-manifest' diff --git a/packages/solid-start/src/server-functions-handler.tsx b/packages/solid-start/src/server-functions-handler.tsx deleted file mode 100644 index c3cc9770d2..0000000000 --- a/packages/solid-start/src/server-functions-handler.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from '@tanstack/start-server-functions-handler' diff --git a/packages/solid-start/src/server-functions-ssr.tsx b/packages/solid-start/src/server-functions-ssr.tsx deleted file mode 100644 index 7359e26f45..0000000000 --- a/packages/solid-start/src/server-functions-ssr.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from '@tanstack/start-server-functions-ssr' diff --git a/packages/solid-start/vite.config.ts b/packages/solid-start/vite.config.ts index dfcd5b4b41..56af20d909 100644 --- a/packages/solid-start/vite.config.ts +++ b/packages/solid-start/vite.config.ts @@ -17,22 +17,16 @@ export default mergeConfig( entry: [ './src/client.tsx', './src/server.tsx', - './src/config.tsx', - './src/router-manifest.tsx', + './src/plugin.tsx', './src/server-functions-client.tsx', './src/server-functions-server.tsx', - './src/server-functions-ssr.tsx', - './src/api.tsx', ], externalDeps: [ '@tanstack/solid-start-client', '@tanstack/solid-start-server', - '@tanstack/solid-start-config', - '@tanstack/solid-start-router-manifest', + '@tanstack/solid-start-plugin', '@tanstack/start-server-functions-client', '@tanstack/start-server-functions-server', - '@tanstack/start-server-functions-ssr', - '@tanstack/start-api-routes', ], }), ) diff --git a/packages/start-api-routes/README.md b/packages/start-api-routes/README.md deleted file mode 100644 index bb009b0c87..0000000000 --- a/packages/start-api-routes/README.md +++ /dev/null @@ -1,33 +0,0 @@ -> 🤫 we're cooking up something special! - - - -# TanStack Start - -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) - -🤖 Type-safe router w/ built-in caching & URL state management for React! - - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - - -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! diff --git a/packages/start-api-routes/eslint.config.js b/packages/start-api-routes/eslint.config.js deleted file mode 100644 index 931f0ec774..0000000000 --- a/packages/start-api-routes/eslint.config.js +++ /dev/null @@ -1,31 +0,0 @@ -// @ts-check - -import pluginReact from '@eslint-react/eslint-plugin' -import pluginReactHooks from 'eslint-plugin-react-hooks' -import rootConfig from '../../eslint.config.js' - -export default [ - ...rootConfig, - { - ...pluginReact.configs.recommended, - files: ['**/*.{ts,tsx}'], - }, - { - plugins: { - 'react-hooks': pluginReactHooks, - }, - rules: { - '@eslint-react/no-unstable-context-value': 'off', - '@eslint-react/no-unstable-default-props': 'off', - '@eslint-react/dom/no-missing-button-type': 'off', - 'react-hooks/exhaustive-deps': 'error', - 'react-hooks/rules-of-hooks': 'error', - }, - }, - { - files: ['**/__tests__/**'], - rules: { - '@typescript-eslint/no-unnecessary-condition': 'off', - }, - }, -] diff --git a/packages/start-api-routes/src/index.ts b/packages/start-api-routes/src/index.ts deleted file mode 100644 index dbfba63cce..0000000000 --- a/packages/start-api-routes/src/index.ts +++ /dev/null @@ -1,369 +0,0 @@ -import { eventHandler, toWebRequest } from '@tanstack/start-server-core' -import vinxiFileRoutes from 'vinxi/routes' -import type { ResolveParams } from '@tanstack/router-core' - -export type StartAPIHandlerCallback = (ctx: { - request: Request -}) => Response | Promise - -export type StartAPIMethodCallback = (ctx: { - request: Request - params: ResolveParams -}) => Response | Promise - -const HTTP_API_METHODS = [ - 'GET', - 'POST', - 'PUT', - 'PATCH', - 'DELETE', - 'OPTIONS', - 'HEAD', -] as const -export type HTTP_API_METHOD = (typeof HTTP_API_METHODS)[number] - -/** - * - * @param cb The callback function that will be called when the API handler is invoked - * @returns The response from the callback function - */ -export function createStartAPIHandler(cb: StartAPIHandlerCallback) { - return eventHandler(async (event) => { - const request = toWebRequest(event)! - const res = await cb({ request }) - return res - }) -} - -type APIRoute = { - path: TPath - methods: Partial>> -} - -type CreateAPIRouteFn = ( - methods: Partial>>, -) => APIRoute - -type CreateAPIRoute = ( - path: TPath, -) => CreateAPIRouteFn - -type APIRouteReturnType = ReturnType> - -/** - * This function is used to create an API route that will be listening on a specific path when you are not using the file-based routes. - * - * @param path The path that the API route will be listening on. You need to make sure that this is a valid TanStack Router path in order for the route to be matched. This means that you can use the following syntax: - * /api/foo/$bar/name/$ - * - The `$bar` is a parameter that will be extracted from the URL and passed to the handler - * - The `$` is a wildcard that will match any number of segments in the URL - * @returns A function that takes the methods that the route will be listening on and returns the API route object - */ -export const createAPIRoute: CreateAPIRoute = (path) => (methods) => ({ - path, - methods, -}) - -/** - * This function is used to create an API route that will be listening on a specific path when you are using the file-based routes. - * - * @param filePath The path that the API file route will be listening on. This filePath should automatically be generated by the TSR plugin and should be a valid TanStack Router path - * @returns A function that takes the methods that the route will be listening on and returns the API route object - */ -export const createAPIFileRoute: CreateAPIRoute = (filePath) => (methods) => ({ - path: filePath, - methods, -}) - -/** - * This function takes a URL object and a list of routes and finds the route that matches the URL. - * - * @param url URL object - * @param entryRoutes List of routes entries in the TSR format to find the current match by the URL - * @returns Returns the route that matches the URL or undefined if no route matches - */ -function findRoute( - url: URL, - entryRoutes: Array<{ routePath: string; payload: TPayload }>, -): - | { - routePath: string - params: Record - payload: TPayload - } - | undefined { - const urlSegments = url.pathname.split('/').filter(Boolean) - - const routes = entryRoutes - .sort((a, b) => { - const aParts = a.routePath.split('/').filter(Boolean) - const bParts = b.routePath.split('/').filter(Boolean) - - return bParts.length - aParts.length - }) - .filter((r) => { - const routeSegments = r.routePath.split('/').filter(Boolean) - return urlSegments.length >= routeSegments.length - }) - - for (const route of routes) { - const routeSegments = route.routePath.split('/').filter(Boolean) - const params: Record = {} - let matches = true - for (let i = 0; i < routeSegments.length; i++) { - const routeSegment = routeSegments[i] as string - const urlSegment = urlSegments[i] as string - if (routeSegment.startsWith('$')) { - if (routeSegment === '$') { - const wildcardValue = urlSegments.slice(i).join('/') - if (wildcardValue !== '') { - params['*'] = wildcardValue - params['_splat'] = wildcardValue - } else { - matches = false - break - } - } else { - const paramName = routeSegment.slice(1) - params[paramName] = urlSegment - } - } else if (routeSegment !== urlSegment) { - matches = false - break - } - } - if (matches) { - return { routePath: route.routePath, params, payload: route.payload } - } - } - - return undefined -} - -/** - * You should only be using this function if you are not using the file-based routes. - * - * - * @param opts - A map of TSR routes with the values being the route handlers - * @returns The handler for the incoming request - * - * @example - * ```ts - * // app/foo.ts - * import { createAPIRoute } from '@tanstack/start-api-routes' - * const fooBarRoute = createAPIRoute('/api/foo/$bar')({ - * GET: ({ params }) => { - * return new Response(JSON.stringify({ params })) - * } - * }) - * - * // app/api.ts - * import { - * createStartAPIHandler, - * defaultAPIRoutesHandler - * } from '@tanstack/start-api-routes' - * - * export default createStartAPIHandler( - * defaultAPIRoutesHandler({ - * '/api/foo/$bar': fooBarRoute - * }) - * ) - * ``` - */ -export const defaultAPIRoutesHandler: (opts: { - routes: { [TPath in string]: APIRoute } -}) => StartAPIHandlerCallback = (opts) => { - return async ({ request }) => { - if (!HTTP_API_METHODS.includes(request.method as HTTP_API_METHOD)) { - return new Response('Method not allowed', { status: 405 }) - } - - const url = new URL(request.url, 'http://localhost:3000') - - const routes = Object.entries(opts.routes).map(([routePath, route]) => ({ - routePath, - payload: route, - })) - - // Find the route that matches the request by the request URL - const match = findRoute(url, routes) - - // If we don't have a route that could possibly handle the request, return a 404 - if (!match) { - return new Response('Not found', { status: 404 }) - } - - // If the route path doesn't match the payload path, return a 404 - if (match.routePath !== match.payload.path) { - console.error( - `Route path mismatch: ${match.routePath} !== ${match.payload.path}. Please make sure that the route path in \`createAPIRoute\` matches the path in the handler map in \`defaultAPIRoutesHandler\``, - ) - return new Response('Not found', { status: 404 }) - } - - const method = request.method as HTTP_API_METHOD - - // Get the handler for the request method based on the Request Method - const handler = match.payload.methods[method] - - // If the handler is not defined, return a 405 - if (!handler) { - return new Response('Method not allowed', { status: 405 }) - } - - return await handler({ request, params: match.params }) - } -} - -interface CustomizedVinxiFileRoute { - path: string // this path adheres to the h3 router path format - filePath: string // this is the file path on the system - $APIRoute?: { - src: string // this is the path to the source file - import: () => Promise<{ - APIRoute: APIRouteReturnType - }> - } -} - -/** - * This is populated by the work done in the config file using the tsrFileRouter - */ -const vinxiRoutes = ( - vinxiFileRoutes as unknown as Array -).filter((route) => route['$APIRoute']) - -/** - * This function takes the vinxi routes and interpolates them into a format that can be worked with in the API handler - * - * @param routes The vinxi routes that have been filtered to only include those with a $APIRoute property - * @returns An array of objects where the path `key` is interpolated to a valid TanStack Router path, with the `payload` being the original route object - * - * @example - * ``` - * const input = [ - * { - * path: '/api/boo/:$id?/name/*splat', - * filePath: '..../code/tanstack/router/examples/react/start-basic/app/routes/api.boo.$id.name.$.tsx', - * '$APIRoute': [Object] - * } - * ] - * - * toTSRFileBasedRoutes(input) - * [ - * { - * path: '/api/boo/$id/name/$', - * route: { - * path: '/api/boo/:$id?/name/*splat', - * filePath: '..../code/tanstack/router/examples/react/start-basic/app/routes/api.boo.$id.name.$.tsx', - * '$APIRoute': [Object] - * } - * } - * ] - * ``` - */ -function toTSRFileBasedRoutes( - routes: Array, -): Array<{ routePath: string; payload: CustomizedVinxiFileRoute }> { - const pairs: Array<{ - routePath: string - payload: CustomizedVinxiFileRoute - }> = [] - - routes.forEach((route) => { - const parts = route.path.split('/').filter(Boolean) - - const path = parts - .map((part) => { - if (part === '*splat') { - return '$' - } - - if (part.startsWith(':$') && part.endsWith('?')) { - return part.slice(1, -1) - } - - return part - }) - .join('/') - - pairs.push({ routePath: `/${path}`, payload: route }) - }) - - return pairs -} - -/** - * This function is the default handler for the API routes when using file-based routes. - * - * @param StartAPIHandlerCallbackContext - * @returns The handler for the incoming request - * - * @example - * ```ts - * // app/api.ts - * import { - * createStartAPIHandler, - * defaultAPIFileRouteHandler - * } from '@tanstack/start-api-routes' - * - * export default createStartAPIHandler(defaultAPIFileRouteHandler) - * ``` - */ -export const defaultAPIFileRouteHandler: StartAPIHandlerCallback = async ({ - request, -}) => { - // Simple early abort if there are no routes - if (!vinxiRoutes.length) { - return new Response('No routes found', { status: 404 }) - } - - if (!HTTP_API_METHODS.includes(request.method as HTTP_API_METHOD)) { - return new Response('Method not allowed', { status: 405 }) - } - - const routes = toTSRFileBasedRoutes(vinxiRoutes) - - const url = new URL(request.url, 'http://localhost:3000') - - // Find the route that file that matches the request by the request URL - const match = findRoute(url, routes) - - // If we don't have a route that could possibly handle the request, return a 404 - if (!match) { - return new Response('Not found', { status: 404 }) - } - - // The action is the route file that we need to import - // which contains the possible handlers for the incoming request - let action: APIRouteReturnType | undefined = undefined - - try { - // We can guarantee that action is defined since we filtered for it earlier - action = await match.payload.$APIRoute!.import().then((m) => m.APIRoute) - } catch (err) { - // If we can't import the route file, return a 500 - console.error('Error importing route file:', err) - return new Response('Internal server error', { status: 500 }) - } - - // If we don't have an action, return a 500 - if (!action) { - return new Response('Internal server error', { status: 500 }) - } - - const method = request.method as HTTP_API_METHOD - - // Get the handler for the request method based on the Request Method - const handler = action.methods[method] - - // If the handler is not defined, return a 405 - // What this means is that we have a route that matches the request - // but we don't have a handler for the request method - // i.e we have a route that matches /api/foo/$ but we don't have a POST handler - if (!handler) { - return new Response('Method not allowed', { status: 405 }) - } - - return await handler({ request, params: match.params }) -} diff --git a/packages/start-api-routes/tsconfig.json b/packages/start-api-routes/tsconfig.json deleted file mode 100644 index 51dda9abf2..0000000000 --- a/packages/start-api-routes/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "jsx": "react-jsx", - "module": "esnext" - }, - "include": ["src", "vite.config.ts"] -} diff --git a/packages/start-api-routes/vite.config.ts b/packages/start-api-routes/vite.config.ts deleted file mode 100644 index 976bb5c87f..0000000000 --- a/packages/start-api-routes/vite.config.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { defineConfig, mergeConfig } from 'vitest/config' -import { tanstackViteConfig } from '@tanstack/config/vite' -import packageJson from './package.json' -import type { ViteUserConfig } from 'vitest/config' - -const config = defineConfig({ - plugins: [] as ViteUserConfig['plugins'], - test: { - name: packageJson.name, - watch: false, - environment: 'jsdom', - }, -}) - -export default mergeConfig( - config, - tanstackViteConfig({ - entry: './src/index.ts', - srcDir: './src', - }), -) diff --git a/packages/start-client-core/README.md b/packages/start-client-core/README.md index fd6e98ac6d..6c9085433a 100644 --- a/packages/start-client-core/README.md +++ b/packages/start-client-core/README.md @@ -1,33 +1,12 @@ -> 🤫 we're cooking up something special! - -# TanStack Start +# TanStack Start - Client Core -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) +This package is not meant to be used directly. It is a dependency of the TanStack Start framework-specific packages: -🤖 Type-safe router w/ built-in caching & URL state management for React! +- [`@tanstack/react-start`](https://www.npmjs.com/package/@tanstack/react-start) +- [`@tanstack/solid-start`](https://www.npmjs.com/package/@tanstack/solid-start). - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - +It provides the core functionality for TanStack Start, which is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router). -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! +Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started. diff --git a/packages/start-client-core/src/createMiddleware.ts b/packages/start-client-core/src/createMiddleware.ts index 654fe78271..357adea2f2 100644 --- a/packages/start-client-core/src/createMiddleware.ts +++ b/packages/start-client-core/src/createMiddleware.ts @@ -14,313 +14,128 @@ import type { SerializerStringify, } from '@tanstack/router-core' -export type AssignAllMiddleware< +export function createMiddleware( + options: { + type: TType + validateClient?: boolean + }, + __opts?: FunctionMiddlewareOptions< + unknown, + undefined, + undefined, + undefined, + ServerFnResponseType + >, +): CreateMiddlewareResult { + // const resolvedOptions = (__opts || options) as MiddlewareOptions< + const resolvedOptions = { + type: 'function', + ...(__opts || + (options as FunctionMiddlewareOptions< + unknown, + undefined, + undefined, + undefined, + ServerFnResponseType + >)), + } + + return { + options: resolvedOptions, + middleware: (middleware: any) => { + return createMiddleware( + {} as any, + Object.assign(resolvedOptions, { middleware }), + ) as any + }, + validator: (validator: any) => { + return createMiddleware( + {} as any, + Object.assign(resolvedOptions, { validator }), + ) as any + }, + client: (client: any) => { + return createMiddleware( + {} as any, + Object.assign(resolvedOptions, { client }), + ) as any + }, + server: (server: any) => { + return createMiddleware( + {} as any, + Object.assign(resolvedOptions, { server }), + ) as any + }, + } as unknown as CreateMiddlewareResult +} + +export type MiddlewareType = 'request' | 'function' + +export type CreateMiddlewareResult = + 'function' extends TType + ? FunctionMiddleware + : RequestMiddleware + +export interface FunctionMiddleware< + TServerFnResponseType extends ServerFnResponseType, +> extends FunctionMiddlewareAfterMiddleware { + middleware: ( + middlewares: Constrain< + TNewMiddlewares, + ReadonlyArray + >, + ) => FunctionMiddlewareAfterMiddleware +} + +export interface FunctionMiddlewareAfterMiddleware< TMiddlewares, - TType extends keyof AnyMiddleware['_types'], - TAcc = undefined, -> = TMiddlewares extends readonly [ - infer TMiddleware extends AnyMiddleware, - ...infer TRest, -] - ? AssignAllMiddleware< - TRest, - TType, - Assign - > - : TAcc + TServerFnResponseType extends ServerFnResponseType, +> extends FunctionMiddlewareWithTypes< + TMiddlewares, + undefined, + undefined, + undefined, + undefined, + undefined, + TServerFnResponseType + >, + FunctionMiddlewareServer< + TMiddlewares, + undefined, + undefined, + undefined, + TServerFnResponseType + >, + FunctionMiddlewareClient, + FunctionMiddlewareValidator {} -/** - * Recursively resolve the client context type produced by a sequence of middleware - */ -export type AssignAllClientContextBeforeNext< +export interface FunctionMiddlewareWithTypes< TMiddlewares, - TClientContext = undefined, -> = unknown extends TClientContext - ? TClientContext - : Assign< - AssignAllMiddleware, - TClientContext - > - -export type AssignAllClientSendContext< - TMiddlewares, - TSendContext = undefined, -> = unknown extends TSendContext - ? TSendContext - : Assign< - AssignAllMiddleware, - TSendContext - > - -export type AssignAllClientContextAfterNext< - TMiddlewares, - TClientContext = undefined, - TSendContext = undefined, -> = unknown extends TClientContext - ? Assign - : Assign< - AssignAllMiddleware, - Assign - > - -/** - * Recursively resolve the server context type produced by a sequence of middleware - */ -export type AssignAllServerContext< - TMiddlewares, - TSendContext = undefined, - TServerContext = undefined, -> = unknown extends TSendContext - ? Assign - : Assign< - AssignAllMiddleware, - Assign - > - -export type AssignAllServerSendContext< - TMiddlewares, - TSendContext = undefined, -> = unknown extends TSendContext - ? TSendContext - : Assign< - AssignAllMiddleware, - TSendContext - > - -export type IntersectAllMiddleware< - TMiddlewares, - TType extends keyof AnyMiddleware['_types'], - TAcc = undefined, -> = TMiddlewares extends readonly [ - infer TMiddleware extends AnyMiddleware, - ...infer TRest, -] - ? IntersectAllMiddleware< - TRest, - TType, - IntersectAssign - > - : TAcc - -/** - * Recursively resolve the input type produced by a sequence of middleware - */ -export type IntersectAllValidatorInputs = - unknown extends TValidator - ? TValidator - : IntersectAssign< - IntersectAllMiddleware, - TValidator extends undefined - ? undefined - : ResolveValidatorInput - > -/** - * Recursively merge the output type produced by a sequence of middleware - */ -export type IntersectAllValidatorOutputs = - unknown extends TValidator - ? TValidator - : IntersectAssign< - IntersectAllMiddleware, - TValidator extends undefined - ? undefined - : ResolveValidatorOutput - > - -export interface MiddlewareOptions< - in out TMiddlewares, - in out TValidator, - in out TServerContext, - in out TClientContext, - in out TServerFnResponseType extends ServerFnResponseType, + TValidator, + TServerContext, + TServerSendContext, + TClientContext, + TClientSendContext, + TServerFnResponseType extends ServerFnResponseType, > { - validateClient?: boolean - middleware?: TMiddlewares - validator?: ConstrainValidator - client?: MiddlewareClientFn< + _types: FunctionMiddlewareTypes< + TMiddlewares, + TValidator, + TServerContext, + TServerSendContext, + TClientContext, + TClientSendContext + > + options: FunctionMiddlewareOptions< TMiddlewares, TValidator, TServerContext, TClientContext, TServerFnResponseType > - server?: MiddlewareServerFn< - TMiddlewares, - TValidator, - TServerContext, - unknown, - unknown, - TServerFnResponseType - > } -export type MiddlewareServerNextFn = < - TNewServerContext = undefined, - TSendContext = undefined, ->(ctx?: { - context?: TNewServerContext - sendContext?: SerializerStringify -}) => Promise< - ServerResultWithContext< - TMiddlewares, - TServerSendContext, - TNewServerContext, - TSendContext - > -> - -export interface MiddlewareServerFnOptions< - in out TMiddlewares, - in out TValidator, - in out TServerSendContext, - in out TServerFnResponseType, -> { - data: Expand> - context: Expand> - next: MiddlewareServerNextFn - response: TServerFnResponseType - method: Method - filename: string - functionId: string - signal: AbortSignal -} - -export type MiddlewareServerFn< - TMiddlewares, - TValidator, - TServerSendContext, - TNewServerContext, - TSendContext, - TServerFnResponseType extends ServerFnResponseType, -> = ( - options: MiddlewareServerFnOptions< - TMiddlewares, - TValidator, - TServerSendContext, - TServerFnResponseType - >, -) => MiddlewareServerFnResult< - TMiddlewares, - TServerSendContext, - TNewServerContext, - TSendContext -> - -export type MiddlewareServerFnResult< - TMiddlewares, - TServerSendContext, - TServerContext, - TSendContext, -> = - | Promise< - ServerResultWithContext< - TMiddlewares, - TServerSendContext, - TServerContext, - TSendContext - > - > - | ServerResultWithContext< - TMiddlewares, - TServerSendContext, - TServerContext, - TSendContext - > - -export type MiddlewareClientNextFn = < - TSendContext = undefined, - TNewClientContext = undefined, ->(ctx?: { - context?: TNewClientContext - sendContext?: SerializerStringify - headers?: HeadersInit -}) => Promise< - ClientResultWithContext -> - -export interface MiddlewareClientFnOptions< - in out TMiddlewares, - in out TValidator, - in out TServerFnResponseType extends ServerFnResponseType, -> { - data: Expand> - context: Expand> - sendContext: Expand> - method: Method - response: TServerFnResponseType - signal: AbortSignal - next: MiddlewareClientNextFn - filename: string - functionId: string - type: ServerFnTypeOrTypeFn< - Method, - TServerFnResponseType, - TMiddlewares, - TValidator - > -} - -export type MiddlewareClientFn< - TMiddlewares, - TValidator, - TSendContext, - TClientContext, - TServerFnResponseType extends ServerFnResponseType, -> = ( - options: MiddlewareClientFnOptions< - TMiddlewares, - TValidator, - TServerFnResponseType - >, -) => MiddlewareClientFnResult - -export type MiddlewareClientFnResult< - TMiddlewares, - TSendContext, - TClientContext, -> = - | Promise> - | ClientResultWithContext - -export type ServerResultWithContext< - in out TMiddlewares, - in out TServerSendContext, - in out TServerContext, - in out TSendContext, -> = { - 'use functions must return the result of next()': true - _types: { - context: TServerContext - sendContext: TSendContext - } - context: Expand< - AssignAllServerContext - > - sendContext: Expand> -} - -export type ClientResultWithContext< - in out TMiddlewares, - in out TSendContext, - in out TClientContext, -> = { - 'use functions must return the result of next()': true - context: Expand> - sendContext: Expand> - headers: HeadersInit -} - -export type AnyMiddleware = MiddlewareWithTypes< - any, - any, - any, - any, - any, - any, - any -> - -export interface MiddlewareTypes< +export interface FunctionMiddlewareTypes< in out TMiddlewares, in out TValidator, in out TServerContext, @@ -328,6 +143,7 @@ export interface MiddlewareTypes< in out TClientContext, in out TClientSendContext, > { + type: 'function' middlewares: TMiddlewares input: ResolveValidatorInput allInput: IntersectAllValidatorInputs @@ -362,86 +178,174 @@ export interface MiddlewareTypes< validator: TValidator } -export interface MiddlewareWithTypes< +/** + * Recursively resolve the input type produced by a sequence of middleware + */ +export type IntersectAllValidatorInputs = + unknown extends TValidator + ? TValidator + : TValidator extends undefined + ? IntersectAllMiddleware + : IntersectAssign< + IntersectAllMiddleware, + ResolveValidatorInput + > + +export type IntersectAllMiddleware< TMiddlewares, - TValidator, - TServerContext, - TServerSendContext, - TClientContext, - TClientSendContext, - TServerFnResponseType extends ServerFnResponseType, + TType extends + | keyof AnyFunctionMiddleware['_types'] + | keyof AnyRequestMiddleware['_types'], + TAcc = undefined, +> = TMiddlewares extends readonly [infer TMiddleware, ...infer TRest] + ? TMiddleware extends AnyFunctionMiddleware | AnyRequestMiddleware + ? IntersectAllMiddleware< + TRest, + TType, + IntersectAssign< + TAcc, + TMiddleware['_types'][TType & keyof TMiddleware['_types']] + > + > + : TAcc + : TAcc + +export type AnyFunctionMiddleware = FunctionMiddlewareWithTypes< + any, + any, + any, + any, + any, + any, + any +> + +/** + * Recursively merge the output type produced by a sequence of middleware + */ +export type IntersectAllValidatorOutputs = + unknown extends TValidator + ? TValidator + : TValidator extends undefined + ? IntersectAllMiddleware + : IntersectAssign< + IntersectAllMiddleware, + ResolveValidatorOutput + > + +/** + * Recursively resolve the client context type produced by a sequence of middleware + */ +export type AssignAllClientContextBeforeNext< + TMiddlewares, + TClientContext = undefined, +> = unknown extends TClientContext + ? TClientContext + : Assign< + AssignAllMiddleware, + TClientContext + > + +export type AssignAllMiddleware< + TMiddlewares, + TType extends + | keyof AnyFunctionMiddleware['_types'] + | keyof AnyRequestMiddleware['_types'], + TAcc = undefined, +> = TMiddlewares extends readonly [infer TMiddleware, ...infer TRest] + ? TMiddleware extends AnyFunctionMiddleware | AnyRequestMiddleware + ? AssignAllMiddleware< + TRest, + TType, + Assign + > + : TAcc + : TAcc + +export type AssignAllClientContextAfterNext< + TMiddlewares, + TClientContext = undefined, + TSendContext = undefined, +> = unknown extends TClientContext + ? Assign + : Assign< + AssignAllMiddleware, + Assign + > + +export type AssignAllServerSendContext< + TMiddlewares, + TSendContext = undefined, +> = unknown extends TSendContext + ? TSendContext + : Assign< + AssignAllMiddleware, + TSendContext + > + +/** + * Recursively resolve the server context type produced by a sequence of middleware + */ +export type AssignAllServerContext< + TMiddlewares, + TSendContext = undefined, + TServerContext = undefined, +> = unknown extends TSendContext + ? Assign + : Assign< + AssignAllMiddleware, + Assign + > + +export type AssignAllClientSendContext< + TMiddlewares, + TSendContext = undefined, +> = unknown extends TSendContext + ? TSendContext + : Assign< + AssignAllMiddleware, + TSendContext + > + +export interface FunctionMiddlewareOptions< + in out TMiddlewares, + in out TValidator, + in out TServerContext, + in out TClientContext, + in out TServerFnResponseType extends ServerFnResponseType, > { - _types: MiddlewareTypes< + validateClient?: boolean + middleware?: TMiddlewares + validator?: ConstrainValidator + client?: FunctionMiddlewareClientFn< TMiddlewares, TValidator, TServerContext, - TServerSendContext, TClientContext, - TClientSendContext + TServerFnResponseType > - options: MiddlewareOptions< + server?: FunctionMiddlewareServerFn< TMiddlewares, TValidator, TServerContext, - TClientContext, + unknown, + unknown, TServerFnResponseType > } -export interface MiddlewareAfterValidator< - TMiddlewares, - TValidator, - TServerFnResponseType extends ServerFnResponseType, -> extends MiddlewareWithTypes< - TMiddlewares, - TValidator, - undefined, - undefined, - undefined, - undefined, - ServerFnResponseType - >, - MiddlewareServer< - TMiddlewares, - TValidator, - undefined, - undefined, - TServerFnResponseType - >, - MiddlewareClient {} +export type FunctionMiddlewareClientNextFn = < + TSendContext = undefined, + TNewClientContext = undefined, +>(ctx?: { + context?: TNewClientContext + sendContext?: SerializerStringify + headers?: HeadersInit +}) => Promise< + FunctionClientResultWithContext +> -export interface MiddlewareValidator< - TMiddlewares, - TServerFnResponseType extends ServerFnResponseType, -> { - validator: ( - input: ConstrainValidator, - ) => MiddlewareAfterValidator< - TMiddlewares, - TNewValidator, - TServerFnResponseType - > -} - -export interface MiddlewareAfterServer< - TMiddlewares, - TValidator, - TServerContext, - TServerSendContext, - TClientContext, - TClientSendContext, - TServerFnResponseType extends ServerFnResponseType, -> extends MiddlewareWithTypes< - TMiddlewares, - TValidator, - TServerContext, - TServerSendContext, - TClientContext, - TClientSendContext, - TServerFnResponseType - > {} - -export interface MiddlewareServer< +export interface FunctionMiddlewareServer< TMiddlewares, TValidator, TServerSendContext, @@ -449,7 +353,7 @@ export interface MiddlewareServer< TServerFnResponseType extends ServerFnResponseType, > { server: ( - server: MiddlewareServerFn< + server: FunctionMiddlewareServerFn< TMiddlewares, TValidator, TServerSendContext, @@ -457,7 +361,7 @@ export interface MiddlewareServer< TSendContext, TServerFnResponseType >, - ) => MiddlewareAfterServer< + ) => FunctionMiddlewareAfterServer< TMiddlewares, TValidator, TNewServerContext, @@ -467,44 +371,140 @@ export interface MiddlewareServer< ServerFnResponseType > } - -export interface MiddlewareAfterClient< +export type FunctionMiddlewareServerFn< TMiddlewares, TValidator, TServerSendContext, - TClientContext, + TNewServerContext, + TSendContext, TServerFnResponseType extends ServerFnResponseType, -> extends MiddlewareWithTypes< - TMiddlewares, - TValidator, - undefined, - TServerSendContext, - TClientContext, - undefined, - TServerFnResponseType - >, - MiddlewareServer< - TMiddlewares, - TValidator, - TServerSendContext, - TClientContext, - TServerFnResponseType - > {} +> = ( + options: FunctionMiddlewareServerFnOptions< + TMiddlewares, + TValidator, + TServerSendContext, + TServerFnResponseType + >, +) => FunctionMiddlewareServerFnResult< + TMiddlewares, + TServerSendContext, + TNewServerContext, + TSendContext +> -export interface MiddlewareClient< +export interface RequestMiddlewareServerFnOptions< + in out TMiddlewares, + in out TServerSendContext, +> { + request: Request + context: Expand> + next: FunctionMiddlewareServerNextFn + response: Response + method: Method + signal: AbortSignal +} + +export type FunctionMiddlewareServerNextFn = < + TNewServerContext = undefined, + TSendContext = undefined, +>(ctx?: { + context?: TNewServerContext + sendContext?: SerializerStringify +}) => Promise< + FunctionServerResultWithContext< + TMiddlewares, + TServerSendContext, + TNewServerContext, + TSendContext + > +> + +export type FunctionServerResultWithContext< + in out TMiddlewares, + in out TServerSendContext, + in out TServerContext, + in out TSendContext, +> = { + 'use functions must return the result of next()': true + _types: { + context: TServerContext + sendContext: TSendContext + } + context: Expand< + AssignAllServerContext + > + sendContext: Expand> +} + +export interface FunctionMiddlewareServerFnOptions< + in out TMiddlewares, + in out TValidator, + in out TServerSendContext, + in out TServerFnResponseType, +> { + data: Expand> + context: Expand> + next: FunctionMiddlewareServerNextFn + response: TServerFnResponseType + method: Method + filename: string + functionId: string + signal: AbortSignal +} + +export type FunctionMiddlewareServerFnResult< + TMiddlewares, + TServerSendContext, + TServerContext, + TSendContext, +> = + | Promise< + FunctionServerResultWithContext< + TMiddlewares, + TServerSendContext, + TServerContext, + TSendContext + > + > + | FunctionServerResultWithContext< + TMiddlewares, + TServerSendContext, + TServerContext, + TSendContext + > + +export interface FunctionMiddlewareAfterServer< + TMiddlewares, + TValidator, + TServerContext, + TServerSendContext, + TClientContext, + TClientSendContext, + TServerFnResponseType extends ServerFnResponseType, +> extends FunctionMiddlewareWithTypes< + TMiddlewares, + TValidator, + TServerContext, + TServerSendContext, + TClientContext, + TClientSendContext, + TServerFnResponseType + > {} + +export interface FunctionMiddlewareClient< TMiddlewares, TValidator, TServerFnResponseType extends ServerFnResponseType, > { client: ( - client: MiddlewareClientFn< + client: FunctionMiddlewareClientFn< TMiddlewares, TValidator, TSendServerContext, TNewClientContext, TServerFnResponseType >, - ) => MiddlewareAfterClient< + ) => FunctionMiddlewareAfterClient< TMiddlewares, TValidator, TSendServerContext, @@ -513,83 +513,194 @@ export interface MiddlewareClient< > } -export interface MiddlewareAfterMiddleware< +export type FunctionMiddlewareClientFn< TMiddlewares, + TValidator, + TSendContext, + TClientContext, TServerFnResponseType extends ServerFnResponseType, -> extends MiddlewareWithTypes< - TMiddlewares, - undefined, - undefined, - undefined, - undefined, - undefined, - TServerFnResponseType - >, - MiddlewareServer< - TMiddlewares, - undefined, - undefined, - undefined, - TServerFnResponseType - >, - MiddlewareClient, - MiddlewareValidator {} +> = ( + options: FunctionMiddlewareClientFnOptions< + TMiddlewares, + TValidator, + TServerFnResponseType + >, +) => FunctionMiddlewareClientFnResult< + TMiddlewares, + TSendContext, + TClientContext +> -export interface Middleware - extends MiddlewareAfterMiddleware { - middleware: ( - middlewares: Constrain>, - ) => MiddlewareAfterMiddleware +export interface FunctionMiddlewareClientFnOptions< + in out TMiddlewares, + in out TValidator, + in out TServerFnResponseType extends ServerFnResponseType, +> { + data: Expand> + context: Expand> + sendContext: Expand> + method: Method + response: TServerFnResponseType + signal: AbortSignal + next: FunctionMiddlewareClientNextFn + filename: string + functionId: string + type: ServerFnTypeOrTypeFn< + Method, + TServerFnResponseType, + TMiddlewares, + TValidator + > } -export function createMiddleware( - options?: { - validateClient?: boolean - }, - __opts?: MiddlewareOptions< - unknown, - undefined, - undefined, - undefined, - ServerFnResponseType - >, -): Middleware { - // const resolvedOptions = (__opts || options) as MiddlewareOptions< - const resolvedOptions = - __opts || - ((options || {}) as MiddlewareOptions< - unknown, +export type FunctionMiddlewareClientFnResult< + TMiddlewares, + TSendContext, + TClientContext, +> = + | Promise< + FunctionClientResultWithContext< + TMiddlewares, + TSendContext, + TClientContext + > + > + | FunctionClientResultWithContext + +export type FunctionClientResultWithContext< + in out TMiddlewares, + in out TSendContext, + in out TClientContext, +> = { + 'use functions must return the result of next()': true + context: Expand> + sendContext: Expand> + headers: HeadersInit +} + +export interface FunctionMiddlewareAfterClient< + TMiddlewares, + TValidator, + TServerSendContext, + TClientContext, + TServerFnResponseType extends ServerFnResponseType, +> extends FunctionMiddlewareWithTypes< + TMiddlewares, + TValidator, + undefined, + TServerSendContext, + TClientContext, + undefined, + TServerFnResponseType + >, + FunctionMiddlewareServer< + TMiddlewares, + TValidator, + TServerSendContext, + TClientContext, + TServerFnResponseType + > {} + +export interface FunctionMiddlewareValidator< + TMiddlewares, + TServerFnResponseType extends ServerFnResponseType, +> { + validator: ( + input: ConstrainValidator, + ) => FunctionMiddlewareAfterValidator< + TMiddlewares, + TNewValidator, + TServerFnResponseType + > +} + +export interface FunctionMiddlewareAfterValidator< + TMiddlewares, + TValidator, + TServerFnResponseType extends ServerFnResponseType, +> extends FunctionMiddlewareWithTypes< + TMiddlewares, + TValidator, + undefined, undefined, undefined, undefined, ServerFnResponseType - >) + >, + FunctionMiddlewareServer< + TMiddlewares, + TValidator, + undefined, + undefined, + TServerFnResponseType + >, + FunctionMiddlewareClient {} - return { - options: resolvedOptions as any, - middleware: (middleware: any) => { - return createMiddleware( - undefined, - Object.assign(resolvedOptions, { middleware }), - ) as any - }, - validator: (validator: any) => { - return createMiddleware( - undefined, - Object.assign(resolvedOptions, { validator }), - ) as any - }, - client: (client: any) => { - return createMiddleware( - undefined, - Object.assign(resolvedOptions, { client }), - ) as any - }, - server: (server: any) => { - return createMiddleware( - undefined, - Object.assign(resolvedOptions, { server }), - ) as any - }, - } as unknown as Middleware +export interface RequestMiddleware + extends RequestMiddlewareAfterMiddleware { + middleware: ( + middlewares: Constrain>, + ) => RequestMiddlewareAfterMiddleware } + +export type AnyRequestMiddleware = RequestMiddlewareWithTypes + +export interface RequestMiddlewareWithTypes { + _types: RequestMiddlewareTypes +} + +export interface RequestMiddlewareTypes { + type: 'request' + middlewares: TMiddlewares + serverContext: TServerContext + allServerContext: AssignAllServerContext< + TMiddlewares, + undefined, + TServerContext + > +} + +export interface RequestMiddlewareAfterMiddleware + extends RequestMiddlewareWithTypes, + RequestMiddlewareServer {} + +export interface RequestMiddlewareServer { + server: ( + fn: RequestServerFn, + ) => RequestMiddlewareAfterServer +} + +export type RequestServerFn = ( + options: RequestServerOptions, +) => RequestMiddlewareServerFnResult + +export interface RequestServerOptions { + request: Request + pathname: string + context: AssignAllServerContext + next: RequestServerNextFn +} + +export type RequestServerNextFn = ( + options?: RequestServerNextFnOptions, +) => RequestMiddlewareServerFnResult + +export interface RequestServerNextFnOptions { + context?: TServerContext +} + +export type RequestMiddlewareServerFnResult = + | Promise> + | RequestServerResult + +export interface RequestServerResult { + request: Request + pathname: string + context: Expand< + AssignAllServerContext + > + response: Response +} + +export interface RequestMiddlewareAfterServer + extends RequestMiddlewareWithTypes {} diff --git a/packages/start-client-core/src/createServerFn.ts b/packages/start-client-core/src/createServerFn.ts index a84995097e..14c1b26001 100644 --- a/packages/start-client-core/src/createServerFn.ts +++ b/packages/start-client-core/src/createServerFn.ts @@ -16,15 +16,17 @@ import type { } from '@tanstack/router-core' import type { Readable } from 'node:stream' import type { - AnyMiddleware, + AnyFunctionMiddleware, AssignAllClientSendContext, AssignAllServerContext, + FunctionMiddlewareClientFnResult, + FunctionMiddlewareServerFnResult, IntersectAllValidatorInputs, IntersectAllValidatorOutputs, - MiddlewareClientFnResult, - MiddlewareServerFnResult, } from './createMiddleware' +type TODO = any + export function createServerFn< TMethod extends Method, TServerFnResponseType extends ServerFnResponseType = 'data', @@ -215,8 +217,8 @@ export function createServerFn< } } -async function executeMiddleware( - middlewares: Array, +export async function executeMiddleware( + middlewares: Array, env: 'client' | 'server', opts: ServerFnMiddlewareOptions, ): Promise { @@ -398,6 +400,7 @@ export type ServerFnReturnType< > = TServerFnResponseType extends 'raw' ? RawResponse | Promise : Promise> | SerializerStringify + export type ServerFn< TMethod, TServerFnResponseType extends ServerFnResponseType, @@ -442,7 +445,7 @@ export type ServerFnBaseOptions< method: TMethod response?: TServerFnResponseType validateClient?: boolean - middleware?: Constrain> + middleware?: Constrain> validator?: ConstrainValidator extractedFn?: CompiledFetcherFn serverFn?: ServerFn< @@ -485,7 +488,10 @@ export interface ServerFnMiddleware< TValidator, > { middleware: ( - middlewares: Constrain>, + middlewares: Constrain< + TNewMiddlewares, + ReadonlyArray + >, ) => ServerFnAfterMiddleware< TMethod, TServerFnResponseType, @@ -812,12 +818,12 @@ export function extractFormDataContext(formData: FormData) { } export function flattenMiddlewares( - middlewares: Array, -): Array { - const seen = new Set() - const flattened: Array = [] + middlewares: Array, +): Array { + const seen = new Set() + const flattened: Array = [] - const recurse = (middleware: Array) => { + const recurse = (middleware: Array) => { middleware.forEach((m) => { if (m.options.middleware) { recurse(m.options.middleware) @@ -929,7 +935,7 @@ export function execValidator( export function serverFnBaseToMiddleware( options: ServerFnBaseOptions, -): AnyMiddleware { +): AnyFunctionMiddleware { return { _types: undefined!, options: { @@ -973,16 +979,25 @@ export function serverFnBaseToMiddleware( // but not before serializing the context const res = await options.extractedFn?.(payload) - return next(res) as unknown as MiddlewareClientFnResult + return next(res) as unknown as FunctionMiddlewareClientFnResult< + any, + any, + any + > }, server: async ({ next, ...ctx }) => { // Execute the server function - const result = await options.serverFn?.(ctx) + const result = await options.serverFn?.(ctx as TODO) return next({ ...ctx, result, - } as any) as unknown as MiddlewareServerFnResult + } as any) as unknown as FunctionMiddlewareServerFnResult< + any, + any, + any, + any + > }, }, } diff --git a/packages/start-client-core/src/index.tsx b/packages/start-client-core/src/index.tsx index fb50145dee..5c409dab00 100644 --- a/packages/start-client-core/src/index.tsx +++ b/packages/start-client-core/src/index.tsx @@ -25,30 +25,30 @@ export { createMiddleware, type IntersectAllValidatorInputs, type IntersectAllValidatorOutputs, - type MiddlewareServerFn, - type AnyMiddleware, - type MiddlewareOptions, - type MiddlewareWithTypes, - type MiddlewareValidator, - type MiddlewareServer, - type MiddlewareAfterClient, - type MiddlewareAfterMiddleware, - type MiddlewareAfterServer, - type Middleware, - type MiddlewareClientFnOptions, - type MiddlewareClientFnResult, - type MiddlewareClientNextFn, - type ClientResultWithContext, + type FunctionMiddlewareServerFn, + type AnyFunctionMiddleware, + type FunctionMiddlewareOptions, + type FunctionMiddlewareWithTypes, + type FunctionMiddlewareValidator, + type FunctionMiddlewareServer, + type FunctionMiddlewareAfterClient, + type FunctionMiddlewareAfterServer, + type FunctionMiddleware, + type FunctionMiddlewareClientFnOptions, + type FunctionMiddlewareClientFnResult, + type FunctionMiddlewareClientNextFn, + type FunctionClientResultWithContext, type AssignAllClientContextBeforeNext, type AssignAllMiddleware, type AssignAllServerContext, - type MiddlewareAfterValidator, - type MiddlewareClientFn, - type MiddlewareServerFnResult, - type MiddlewareClient, - type MiddlewareServerFnOptions, - type MiddlewareServerNextFn, - type ServerResultWithContext, + type FunctionMiddlewareAfterValidator, + type FunctionMiddlewareClientFn, + type FunctionMiddlewareServerFnResult, + type FunctionMiddlewareClient, + type FunctionMiddlewareServerFnOptions, + type FunctionMiddlewareServerNextFn, + type FunctionServerResultWithContext, + type AnyRequestMiddleware, } from './createMiddleware' export { registerGlobalMiddleware, @@ -84,4 +84,5 @@ export { extractFormDataContext, flattenMiddlewares, serverFnStaticCache, + executeMiddleware, } from './createServerFn' diff --git a/packages/start-client-core/src/registerGlobalMiddleware.ts b/packages/start-client-core/src/registerGlobalMiddleware.ts index 3d7effc85b..ab13d981ad 100644 --- a/packages/start-client-core/src/registerGlobalMiddleware.ts +++ b/packages/start-client-core/src/registerGlobalMiddleware.ts @@ -1,9 +1,9 @@ -import type { AnyMiddleware } from './createMiddleware' +import type { AnyFunctionMiddleware } from './createMiddleware' -export const globalMiddleware: Array = [] +export const globalMiddleware: Array = [] export function registerGlobalMiddleware(options: { - middleware: Array + middleware: Array }) { globalMiddleware.push(...options.middleware) } diff --git a/packages/start-client-core/src/tests/createServerFn.test-d.ts b/packages/start-client-core/src/tests/createServerFn.test-d.ts index 5cb1305ebe..2abc7a409b 100644 --- a/packages/start-client-core/src/tests/createServerFn.test-d.ts +++ b/packages/start-client-core/src/tests/createServerFn.test-d.ts @@ -60,21 +60,25 @@ test('createServerFn with validator', () => { }) test('createServerFn with middleware and context', () => { - const middleware1 = createMiddleware().server(({ next }) => { - return next({ context: { a: 'a' } as const }) - }) + const middleware1 = createMiddleware({ type: 'function' }).server( + ({ next }) => { + return next({ context: { a: 'a' } as const }) + }, + ) - const middleware2 = createMiddleware().server(({ next }) => { - return next({ context: { b: 'b' } as const }) - }) + const middleware2 = createMiddleware({ type: 'function' }).server( + ({ next }) => { + return next({ context: { b: 'b' } as const }) + }, + ) - const middleware3 = createMiddleware() + const middleware3 = createMiddleware({ type: 'function' }) .middleware([middleware1, middleware2]) .client(({ next }) => { return next({ context: { c: 'c' } as const }) }) - const middleware4 = createMiddleware() + const middleware4 = createMiddleware({ type: 'function' }) .middleware([middleware3]) .client(({ context, next }) => { return next({ sendContext: context }) @@ -113,21 +117,24 @@ test('createServerFn with middleware and context', () => { }) describe('createServerFn with middleware and validator', () => { - const middleware1 = createMiddleware().validator( + const middleware1 = createMiddleware({ type: 'function' }).validator( (input: { readonly inputA: 'inputA' }) => ({ outputA: 'outputA', }) as const, ) - const middleware2 = createMiddleware().validator( + const middleware2 = createMiddleware({ type: 'function' }).validator( (input: { readonly inputB: 'inputB' }) => ({ outputB: 'outputB', }) as const, ) - const middleware3 = createMiddleware().middleware([middleware1, middleware2]) + const middleware3 = createMiddleware({ type: 'function' }).middleware([ + middleware1, + middleware2, + ]) test(`response: 'data'`, () => { const fn = createServerFn({ method: 'GET', response: 'data' }) @@ -222,7 +229,7 @@ describe('createServerFn with middleware and validator', () => { }) test('createServerFn overrides properties', () => { - const middleware1 = createMiddleware() + const middleware1 = createMiddleware({ type: 'function' }) .validator( () => ({ @@ -246,7 +253,7 @@ test('createServerFn overrides properties', () => { return next({ sendContext: newContext, context: newContext }) }) - const middleware2 = createMiddleware() + const middleware2 = createMiddleware({ type: 'function' }) .middleware([middleware1]) .validator( () => diff --git a/packages/start-client-core/src/tests/createServerMiddleware.test-d.ts b/packages/start-client-core/src/tests/createServerMiddleware.test-d.ts index 8ca1eaca36..5e61c970c8 100644 --- a/packages/start-client-core/src/tests/createServerMiddleware.test-d.ts +++ b/packages/start-client-core/src/tests/createServerMiddleware.test-d.ts @@ -1,10 +1,11 @@ import { expectTypeOf, test } from 'vitest' import { createMiddleware } from '../createMiddleware' +import type { RequestServerNextFn } from '../createMiddleware' import type { Constrain, Validator } from '@tanstack/router-core' import type { ConstrainValidator } from '../createServerFn' test('createServeMiddleware removes middleware after middleware,', () => { - const middleware = createMiddleware() + const middleware = createMiddleware({ type: 'function' }) expectTypeOf(middleware).toHaveProperty('middleware') expectTypeOf(middleware).toHaveProperty('server') @@ -45,51 +46,55 @@ test('createServeMiddleware removes middleware after middleware,', () => { }) test('createMiddleware merges server context', () => { - const middleware1 = createMiddleware().server(async (options) => { - expectTypeOf(options.context).toEqualTypeOf() - expectTypeOf(options.data).toEqualTypeOf() - expectTypeOf(options.method).toEqualTypeOf<'GET' | 'POST'>() + const middleware1 = createMiddleware({ type: 'function' }).server( + async (options) => { + expectTypeOf(options.context).toEqualTypeOf() + expectTypeOf(options.data).toEqualTypeOf() + expectTypeOf(options.method).toEqualTypeOf<'GET' | 'POST'>() - const result = await options.next({ context: { a: true } }) + const result = await options.next({ context: { a: true } }) - expectTypeOf(result).toEqualTypeOf<{ - 'use functions must return the result of next()': true - _types: { - context: { - a: boolean + expectTypeOf(result).toEqualTypeOf<{ + 'use functions must return the result of next()': true + _types: { + context: { + a: boolean + } + sendContext: undefined } + context: { a: boolean } sendContext: undefined - } - context: { a: boolean } - sendContext: undefined - }>() + }>() - return result - }) + return result + }, + ) - const middleware2 = createMiddleware().server(async (options) => { - expectTypeOf(options.context).toEqualTypeOf() - expectTypeOf(options.data).toEqualTypeOf() - expectTypeOf(options.method).toEqualTypeOf<'GET' | 'POST'>() + const middleware2 = createMiddleware({ type: 'function' }).server( + async (options) => { + expectTypeOf(options.context).toEqualTypeOf() + expectTypeOf(options.data).toEqualTypeOf() + expectTypeOf(options.method).toEqualTypeOf<'GET' | 'POST'>() - const result = await options.next({ context: { b: 'test' } }) + const result = await options.next({ context: { b: 'test' } }) - expectTypeOf(result).toEqualTypeOf<{ - 'use functions must return the result of next()': true - _types: { - context: { - b: string + expectTypeOf(result).toEqualTypeOf<{ + 'use functions must return the result of next()': true + _types: { + context: { + b: string + } + sendContext: undefined } + context: { b: string } sendContext: undefined - } - context: { b: string } - sendContext: undefined - }>() + }>() - return result - }) + return result + }, + ) - const middleware3 = createMiddleware() + const middleware3 = createMiddleware({ type: 'function' }) .middleware([middleware1, middleware2]) .server(async (options) => { expectTypeOf(options.context).toEqualTypeOf<{ a: boolean; b: string }>() @@ -111,7 +116,7 @@ test('createMiddleware merges server context', () => { return result }) - createMiddleware() + createMiddleware({ type: 'function' }) .middleware([middleware3]) .server(async (options) => { expectTypeOf(options.context).toEqualTypeOf<{ @@ -139,37 +144,41 @@ test('createMiddleware merges server context', () => { }) test('createMiddleware merges client context and sends to the server', () => { - const middleware1 = createMiddleware().client(async (options) => { - expectTypeOf(options.context).toEqualTypeOf() + const middleware1 = createMiddleware({ type: 'function' }).client( + async (options) => { + expectTypeOf(options.context).toEqualTypeOf() - const result = await options.next({ context: { a: true } }) + const result = await options.next({ context: { a: true } }) - expectTypeOf(result).toEqualTypeOf<{ - 'use functions must return the result of next()': true - context: { a: boolean } - sendContext: undefined - headers: HeadersInit - }>() + expectTypeOf(result).toEqualTypeOf<{ + 'use functions must return the result of next()': true + context: { a: boolean } + sendContext: undefined + headers: HeadersInit + }>() - return result - }) + return result + }, + ) - const middleware2 = createMiddleware().client(async (options) => { - expectTypeOf(options.context).toEqualTypeOf() + const middleware2 = createMiddleware({ type: 'function' }).client( + async (options) => { + expectTypeOf(options.context).toEqualTypeOf() - const result = await options.next({ context: { b: 'test' } }) + const result = await options.next({ context: { b: 'test' } }) - expectTypeOf(result).toEqualTypeOf<{ - 'use functions must return the result of next()': true - context: { b: string } - sendContext: undefined - headers: HeadersInit - }>() + expectTypeOf(result).toEqualTypeOf<{ + 'use functions must return the result of next()': true + context: { b: string } + sendContext: undefined + headers: HeadersInit + }>() - return result - }) + return result + }, + ) - const middleware3 = createMiddleware() + const middleware3 = createMiddleware({ type: 'function' }) .middleware([middleware1, middleware2]) .client(async (options) => { expectTypeOf(options.context).toEqualTypeOf<{ a: boolean; b: string }>() @@ -186,7 +195,7 @@ test('createMiddleware merges client context and sends to the server', () => { return result }) - const middleware4 = createMiddleware() + const middleware4 = createMiddleware({ type: 'function' }) .middleware([middleware3]) .client(async (options) => { expectTypeOf(options.context).toEqualTypeOf<{ @@ -209,7 +218,7 @@ test('createMiddleware merges client context and sends to the server', () => { return result }) - createMiddleware() + createMiddleware({ type: 'function' }) .middleware([middleware4]) .server(async (options) => { expectTypeOf(options.context).toEqualTypeOf<{ @@ -242,7 +251,7 @@ test('createMiddleware merges client context and sends to the server', () => { }) test('createMiddleware merges input', () => { - const middleware1 = createMiddleware() + const middleware1 = createMiddleware({ type: 'function' }) .validator(() => { return { a: 'a', @@ -253,7 +262,7 @@ test('createMiddleware merges input', () => { return next() }) - const middleware2 = createMiddleware() + const middleware2 = createMiddleware({ type: 'function' }) .middleware([middleware1]) .validator(() => { return { @@ -265,7 +274,7 @@ test('createMiddleware merges input', () => { return next() }) - createMiddleware() + createMiddleware({ type: 'function' }) .middleware([middleware2]) .validator(() => ({ c: 'c' }) as const) .server(({ next, data }) => { @@ -279,7 +288,7 @@ test('createMiddleware merges input', () => { }) test('createMiddleware merges server context and client context, sends server context to the client and merges ', () => { - const middleware1 = createMiddleware() + const middleware1 = createMiddleware({ type: 'function' }) .client(async (options) => { expectTypeOf(options.context).toEqualTypeOf() @@ -318,7 +327,7 @@ test('createMiddleware merges server context and client context, sends server co return result }) - const middleware2 = createMiddleware() + const middleware2 = createMiddleware({ type: 'function' }) .client(async (options) => { expectTypeOf(options.context).toEqualTypeOf() @@ -357,7 +366,7 @@ test('createMiddleware merges server context and client context, sends server co return result }) - const middleware3 = createMiddleware() + const middleware3 = createMiddleware({ type: 'function' }) .middleware([middleware1, middleware2]) .client(async (options) => { expectTypeOf(options.context).toEqualTypeOf<{ @@ -411,7 +420,7 @@ test('createMiddleware merges server context and client context, sends server co return result }) - const middleware4 = createMiddleware() + const middleware4 = createMiddleware({ type: 'function' }) .middleware([middleware3]) .client(async (options) => { expectTypeOf(options.context).toEqualTypeOf<{ @@ -475,7 +484,7 @@ test('createMiddleware merges server context and client context, sends server co return result }) - createMiddleware() + createMiddleware({ type: 'function' }) .middleware([middleware4]) .client(async (options) => { expectTypeOf(options.context).toEqualTypeOf<{ @@ -548,7 +557,7 @@ test('createMiddleware merges server context and client context, sends server co }) test('createMiddleware sendContext cannot send a function', () => { - createMiddleware() + createMiddleware({ type: 'function' }) .client(({ next }) => { expectTypeOf(next<{ func: () => 'func' }>) .parameter(0) @@ -570,7 +579,7 @@ test('createMiddleware sendContext cannot send a function', () => { }) test('createMiddleware cannot validate function', () => { - const validator = createMiddleware().validator< + const validator = createMiddleware({ type: 'function' }).validator< (input: { func: () => 'string' }) => { output: 'string' } > @@ -585,7 +594,7 @@ test('createMiddleware cannot validate function', () => { }) test('createMiddleware can validate Date', () => { - const validator = createMiddleware().validator< + const validator = createMiddleware({ type: 'function' }).validator< (input: Date) => { output: 'string' } > @@ -595,7 +604,7 @@ test('createMiddleware can validate Date', () => { }) test('createMiddleware can validate FormData', () => { - const validator = createMiddleware().validator< + const validator = createMiddleware({ type: 'function' }).validator< (input: FormData) => { output: 'string' } > @@ -606,8 +615,22 @@ test('createMiddleware can validate FormData', () => { >() }) +test('createMiddleware merging from parent with undefined validator', () => { + const middleware1 = createMiddleware({ type: 'function' }).validator( + (input: { test: string }) => input.test, + ) + + createMiddleware({ type: 'function' }) + .middleware([middleware1]) + .server((ctx) => { + expectTypeOf(ctx.data).toEqualTypeOf() + + return ctx.next() + }) +}) + test('createMiddleware validator infers unknown for default input type', () => { - createMiddleware() + createMiddleware({ type: 'function' }) .validator((input) => { expectTypeOf(input).toEqualTypeOf() @@ -621,3 +644,93 @@ test('createMiddleware validator infers unknown for default input type', () => { return next() }) }) + +test('createMiddleware with type request, no middleware or context', () => { + createMiddleware({ type: 'request' }).server(async (options) => { + expectTypeOf(options).toEqualTypeOf<{ + request: Request + next: RequestServerNextFn + pathname: string + context: undefined + }>() + + const result = await options.next() + + expectTypeOf(result).toEqualTypeOf<{ + context: undefined + pathname: string + request: Request + response: Response + }>() + + return result + }) +}) + +test('createMiddleware with type request, no middleware with context', () => { + createMiddleware({ type: 'request' }).server(async (options) => { + expectTypeOf(options).toEqualTypeOf<{ + request: Request + next: RequestServerNextFn + pathname: string + context: undefined + }>() + + const result = await options.next({ context: { a: 'a' } }) + + expectTypeOf(result).toEqualTypeOf<{ + context: { a: string } + pathname: string + request: Request + response: Response + }>() + + return result + }) +}) + +test('createMiddleware with type request, middleware and context', () => { + const middleware1 = createMiddleware({ type: 'request' }).server( + async (options) => { + expectTypeOf(options).toEqualTypeOf<{ + request: Request + next: RequestServerNextFn + pathname: string + context: undefined + }>() + + const result = await options.next({ context: { a: 'a' } }) + + expectTypeOf(result).toEqualTypeOf<{ + context: { a: string } + pathname: string + request: Request + response: Response + }>() + + return result + }, + ) + + createMiddleware({ type: 'request' }) + .middleware([middleware1]) + .server(async (options) => { + expectTypeOf(options).toEqualTypeOf<{ + request: Request + next: RequestServerNextFn + pathname: string + context: { a: string } + }>() + + const result = await options.next({ context: { b: 'b' } }) + + expectTypeOf(result).toEqualTypeOf<{ + context: { a: string; b: string } + pathname: string + request: Request + response: Response + }>() + + return result + }) +}) diff --git a/packages/start-client-core/vite.config.ts b/packages/start-client-core/vite.config.ts index ac2026fbb7..fb0b2664aa 100644 --- a/packages/start-client-core/vite.config.ts +++ b/packages/start-client-core/vite.config.ts @@ -16,5 +16,6 @@ export default mergeConfig( tanstackViteConfig({ srcDir: './src', entry: './src/index.tsx', + // externalDeps: ['node:fs', 'node:path', 'node:os', 'node:crypto'], }), ) diff --git a/packages/start-config/README.md b/packages/start-config/README.md deleted file mode 100644 index e3131543bd..0000000000 --- a/packages/start-config/README.md +++ /dev/null @@ -1,33 +0,0 @@ -> 🤫 we're cooking up something special! - - - -# TanStack Start - -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) - -🤖 Type-safe router w/ built-in caching & URL state management for React applications! - - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - - -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! diff --git a/packages/start-config/eslint.config.js b/packages/start-config/eslint.config.js deleted file mode 100644 index 931f0ec774..0000000000 --- a/packages/start-config/eslint.config.js +++ /dev/null @@ -1,31 +0,0 @@ -// @ts-check - -import pluginReact from '@eslint-react/eslint-plugin' -import pluginReactHooks from 'eslint-plugin-react-hooks' -import rootConfig from '../../eslint.config.js' - -export default [ - ...rootConfig, - { - ...pluginReact.configs.recommended, - files: ['**/*.{ts,tsx}'], - }, - { - plugins: { - 'react-hooks': pluginReactHooks, - }, - rules: { - '@eslint-react/no-unstable-context-value': 'off', - '@eslint-react/no-unstable-default-props': 'off', - '@eslint-react/dom/no-missing-button-type': 'off', - 'react-hooks/exhaustive-deps': 'error', - 'react-hooks/rules-of-hooks': 'error', - }, - }, - { - files: ['**/__tests__/**'], - rules: { - '@typescript-eslint/no-unnecessary-condition': 'off', - }, - }, -] diff --git a/packages/start-config/package.json b/packages/start-config/package.json deleted file mode 100644 index 8c5bb24691..0000000000 --- a/packages/start-config/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@tanstack/start-config", - "version": "1.120.3", - "description": "Modern and scalable routing for React applications", - "author": "Tanner Linsley", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/TanStack/router.git", - "directory": "packages/start-config" - }, - "homepage": "https://tanstack.com/start", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/tannerlinsley" - }, - "keywords": [ - "react", - "location", - "router", - "routing", - "async", - "async router", - "typescript" - ], - "scripts": { - "clean": "rimraf ./dist && rimraf ./coverage", - "build": "tsc", - "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit", - "test:unit": "exit 0;vitest", - "test:eslint": "eslint ./src", - "test:types": "exit 0; vitest" - }, - "type": "module", - "types": "dist/esm/index.d.ts", - "exports": { - ".": { - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - } - }, - "./package.json": "./package.json" - }, - "sideEffects": false, - "files": [ - "dist", - "src" - ], - "engines": { - "node": ">=12" - }, - "dependencies": { - "@tanstack/react-router": "workspace:^", - "@tanstack/router-generator": "workspace:^", - "@tanstack/router-plugin": "workspace:^", - "@tanstack/server-functions-plugin": "workspace:^", - "@tanstack/react-start-plugin": "workspace:^", - "@tanstack/start-server-functions-handler": "workspace:^", - "@vitejs/plugin-react": "^4.3.4", - "import-meta-resolve": "^4.1.0", - "nitropack": "^2.10.4", - "ofetch": "^1.4.1", - "vite": "^6.1.0", - "vinxi": "0.5.3", - "zod": "^3.24.2" - }, - "peerDependencies": { - "react": ">=18.0.0 || >=19.0.0", - "react-dom": ">=18.0.0 || >=19.0.0", - "vite": "^6.0.0" - } -} diff --git a/packages/start-config/src/index.ts b/packages/start-config/src/index.ts deleted file mode 100644 index 4f67610504..0000000000 --- a/packages/start-config/src/index.ts +++ /dev/null @@ -1,663 +0,0 @@ -import path from 'node:path' -import { existsSync, readFileSync } from 'node:fs' -import { readFile } from 'node:fs/promises' -import { fileURLToPath } from 'node:url' -import viteReact from '@vitejs/plugin-react' -import { resolve } from 'import-meta-resolve' -import { TanStackRouterVite } from '@tanstack/router-plugin/vite' -import { getConfig } from '@tanstack/router-generator' -import { createApp } from 'vinxi' -import { config } from 'vinxi/plugins/config' -// // @ts-expect-error -// import { serverComponents } from '@vinxi/server-components/plugin' -import { createTanStackServerFnPlugin } from '@tanstack/server-functions-plugin' -import { createTanStackStartPlugin } from '@tanstack/react-start-plugin' -import { createFetch } from 'ofetch' -import { createNitro } from 'nitropack' -import { tanstackStartVinxiFileRouter } from './vinxi-file-router.js' -import { - checkDeploymentPresetInput, - getUserViteConfig, - inlineConfigSchema, - serverSchema, -} from './schema.js' -import type { configSchema } from '@tanstack/router-generator' -import type { z } from 'zod' -import type { - TanStackStartInputConfig, - TanStackStartOutputConfig, -} from './schema.js' -import type { App as VinxiApp } from 'vinxi' -import type { Manifest } from '@tanstack/react-router' -import type * as vite from 'vite' - -export type { - TanStackStartInputConfig, - TanStackStartOutputConfig, -} from './schema.js' - -function setTsrDefaults(config: TanStackStartOutputConfig['tsr']) { - // Normally these are `./src/___`, but we're using `./app/___` for Start stuff - const appDirectory = config?.appDirectory ?? './app' - return { - ...config, - appDirectory: config?.appDirectory ?? appDirectory, - routesDirectory: - config?.routesDirectory ?? path.join(appDirectory, 'routes'), - generatedRouteTree: - config?.generatedRouteTree ?? path.join(appDirectory, 'routeTree.gen.ts'), - } -} - -function mergeSsrOptions(options: Array) { - let ssrOptions: vite.SSROptions = {} - let noExternal: vite.SSROptions['noExternal'] = [] - for (const option of options) { - if (!option) { - continue - } - - if (option.noExternal) { - if (option.noExternal === true) { - noExternal = true - } else if (noExternal !== true) { - if (Array.isArray(option.noExternal)) { - noExternal.push(...option.noExternal) - } else { - noExternal.push(option.noExternal) - } - } - } - - ssrOptions = { - ...ssrOptions, - ...option, - noExternal, - } - } - - return ssrOptions -} - -export async function defineConfig( - inlineConfig: TanStackStartInputConfig = {}, -): Promise { - const opts = inlineConfigSchema.parse(inlineConfig) - - const { preset: configDeploymentPreset, ...serverOptions } = - serverSchema.parse(opts.server || {}) - - const deploymentPreset = checkDeploymentPresetInput(configDeploymentPreset) - const tsr = setTsrDefaults(opts.tsr) - const tsrConfig = getConfig(tsr) - - const appDirectory = tsr.appDirectory - const publicDir = opts.routers?.public?.dir || './public' - - const publicBase = opts.routers?.public?.base || '/' - const clientBase = opts.routers?.client?.base || '/_build' - const apiBase = opts.tsr?.apiBase || '/api' - const serverBase = opts.routers?.server?.base || '/_server' - - const apiMiddleware = opts.routers?.api?.middleware || undefined - const serverMiddleware = opts.routers?.server?.middleware || undefined - const ssrMiddleware = opts.routers?.ssr?.middleware || undefined - - const clientEntry = - opts.routers?.client?.entry || path.join(appDirectory, 'client.tsx') - const ssrEntry = - opts.routers?.ssr?.entry || path.join(appDirectory, 'ssr.tsx') - const apiEntry = opts.routers?.api?.entry || path.join(appDirectory, 'api.ts') - const globalMiddlewareEntry = - opts.routers?.server?.globalMiddlewareEntry || - path.join(appDirectory, 'global-middleware.ts') - const apiEntryExists = existsSync(apiEntry) - - const viteConfig = getUserViteConfig(opts.vite) - - const TanStackServerFnsPlugin = createTanStackServerFnPlugin({ - // This is the ID that will be available to look up and import - // our server function manifest and resolve its module - manifestVirtualImportId: 'tsr:server-fn-manifest', - client: { - getRuntimeCode: () => - `import { createClientRpc } from '@tanstack/start/server-functions-client'`, - replacer: (opts) => - `createClientRpc('${opts.functionId}', '${serverBase}')`, - }, - ssr: { - getRuntimeCode: () => - `import { createSsrRpc } from '@tanstack/start/server-functions-ssr'`, - replacer: (opts) => `createSsrRpc('${opts.functionId}', '${serverBase}')`, - }, - server: { - getRuntimeCode: () => - `import { createServerRpc } from '@tanstack/start/server-functions-server'`, - replacer: (opts) => - `createServerRpc('${opts.functionId}', '${serverBase}', ${opts.fn})`, - }, - }) - - const TanStackStartPlugin = createTanStackStartPlugin({ - globalMiddlewareEntry, - }) - - // Create a dummy nitro app to get the resolved public output path - const dummyNitroApp = await createNitro({ - preset: deploymentPreset, - compatibilityDate: '2024-12-01', - }) - - const nitroOutputPublicDir = dummyNitroApp.options.output.publicDir - await dummyNitroApp.close() - - let vinxiApp = createApp({ - server: { - ...serverOptions, - preset: deploymentPreset, - experimental: { - ...serverOptions.experimental, - asyncContext: true, - }, - }, - routers: [ - { - name: 'public', - type: 'static', - dir: publicDir, - base: publicBase, - }, - { - name: 'client', - type: 'client', - target: 'browser', - handler: clientEntry, - base: clientBase, - // @ts-expect-error - build: { - sourcemap: true, - }, - plugins: () => { - const routerType = 'client' - const clientViteConfig = getUserViteConfig( - opts.routers?.[routerType]?.vite, - ) - - return [ - config('tss-vite-config-client', { - ...viteConfig.userConfig, - ...clientViteConfig.userConfig, - define: { - ...(viteConfig.userConfig.define || {}), - ...(clientViteConfig.userConfig.define || {}), - ...injectDefineEnv('TSS_PUBLIC_BASE', publicBase), - ...injectDefineEnv('TSS_CLIENT_BASE', clientBase), - ...injectDefineEnv('TSS_API_BASE', apiBase), - ...injectDefineEnv( - 'TSS_OUTPUT_PUBLIC_DIR', - nitroOutputPublicDir, - ), - }, - ssr: mergeSsrOptions([ - viteConfig.userConfig.ssr, - clientViteConfig.userConfig.ssr, - { - noExternal, - }, - ]), - optimizeDeps: { - entries: [], - ...(viteConfig.userConfig.optimizeDeps || {}), - ...(clientViteConfig.userConfig.optimizeDeps || {}), - }, - }), - TanStackRouterVite({ - ...tsrConfig, - enableRouteGeneration: true, - autoCodeSplitting: true, - __enableAPIRoutesGeneration: true, - experimental: { - ...tsrConfig.experimental, - }, - }), - TanStackStartPlugin.client, - TanStackServerFnsPlugin.client, - ...(viteConfig.plugins || []), - ...(clientViteConfig.plugins || []), - viteReact(opts.react), - // TODO: RSCS - enable this - // serverComponents.client(), - ] - }, - }, - { - name: 'ssr', - type: 'http', - target: 'server', - handler: ssrEntry, - middleware: ssrMiddleware, - // @ts-expect-error - link: { - client: 'client', - }, - plugins: () => { - const routerType = 'ssr' - const ssrViteConfig = getUserViteConfig( - opts.routers?.[routerType]?.vite, - ) - - return [ - config('tss-vite-config-ssr', { - ...viteConfig.userConfig, - ...ssrViteConfig.userConfig, - define: { - ...(viteConfig.userConfig.define || {}), - ...(ssrViteConfig.userConfig.define || {}), - ...injectDefineEnv('TSS_PUBLIC_BASE', publicBase), - ...injectDefineEnv('TSS_CLIENT_BASE', clientBase), - ...injectDefineEnv('TSS_API_BASE', apiBase), - ...injectDefineEnv( - 'TSS_OUTPUT_PUBLIC_DIR', - nitroOutputPublicDir, - ), - }, - ssr: mergeSsrOptions([ - viteConfig.userConfig.ssr, - ssrViteConfig.userConfig.ssr, - { - noExternal, - external: ['@vinxi/react-server-dom/client'], - }, - ]), - optimizeDeps: { - entries: [], - ...(viteConfig.userConfig.optimizeDeps || {}), - ...(ssrViteConfig.userConfig.optimizeDeps || {}), - }, - }), - TanStackRouterVite({ - ...tsrConfig, - enableRouteGeneration: false, - autoCodeSplitting: true, - __enableAPIRoutesGeneration: true, - experimental: { - ...tsrConfig.experimental, - }, - }), - TanStackStartPlugin.ssr, - TanStackServerFnsPlugin.ssr, - tsrRoutesManifest({ - tsrConfig, - clientBase, - }), - ...(getUserViteConfig(opts.vite).plugins || []), - ...(getUserViteConfig(opts.routers?.ssr?.vite).plugins || []), - viteReact(opts.react), - ] - }, - }, - { - name: 'server', - type: 'http', - target: 'server', - base: serverBase, - middleware: serverMiddleware, - // TODO: RSCS - enable this - // worker: true, - handler: importToProjectRelative( - '@tanstack/start-server-functions-handler', - ), - plugins: () => { - const routerType = 'server' - const serverViteConfig = getUserViteConfig( - opts.routers?.[routerType]?.vite, - ) - - return [ - config('tss-vite-config-server', { - ...viteConfig.userConfig, - ...serverViteConfig.userConfig, - define: { - ...(viteConfig.userConfig.define || {}), - ...(serverViteConfig.userConfig.define || {}), - ...injectDefineEnv('TSS_PUBLIC_BASE', publicBase), - ...injectDefineEnv('TSS_CLIENT_BASE', clientBase), - ...injectDefineEnv('TSS_API_BASE', apiBase), - ...injectDefineEnv('TSS_SERVER_FN_BASE', serverBase), - ...injectDefineEnv( - 'TSS_OUTPUT_PUBLIC_DIR', - nitroOutputPublicDir, - ), - }, - ssr: mergeSsrOptions([ - viteConfig.userConfig.ssr, - serverViteConfig.userConfig.ssr, - { - noExternal, - }, - ]), - optimizeDeps: { - entries: [], - ...(viteConfig.userConfig.optimizeDeps || {}), - ...(serverViteConfig.userConfig.optimizeDeps || {}), - }, - }), - TanStackRouterVite({ - ...tsrConfig, - enableRouteGeneration: false, - autoCodeSplitting: true, - __enableAPIRoutesGeneration: true, - experimental: { - ...tsrConfig.experimental, - }, - }), - TanStackStartPlugin.server, - TanStackServerFnsPlugin.server, - // TODO: RSCS - remove this - // resolve: { - // conditions: [], - // }, - // TODO: RSCs - add this - // serverComponents.serverActions({ - // resolve: { - // conditions: [ - // 'react-server', - // // 'node', - // 'import', - // process.env.NODE_ENV, - // ], - // }, - // runtime: '@vinxi/react-server-dom/runtime', - // transpileDeps: ['react', 'react-dom', '@vinxi/react-server-dom'], - // }), - ...(viteConfig.plugins || []), - ...(serverViteConfig.plugins || []), - ] - }, - }, - ], - }) - - const noExternal = [ - '@tanstack/start', - '@tanstack/react-start', - '@tanstack/react-start/server', - '@tanstack/react-start-client', - '@tanstack/react-start-server', - '@tanstack/start-server-functions-fetcher', - '@tanstack/start-server-functions-handler', - '@tanstack/start-server-functions-client', - '@tanstack/start-server-functions-ssr', - '@tanstack/start-server-functions-server', - '@tanstack/react-start-router-manifest', - '@tanstack/start-config', - '@tanstack/start-api-routes', - '@tanstack/server-functions-plugin', - 'tsr:routes-manifest', - 'tsr:server-fn-manifest', - ] - - // If API routes handler exists, add a router for it - if (apiEntryExists) { - vinxiApp = vinxiApp.addRouter({ - name: 'api', - type: 'http', - target: 'server', - base: apiBase, - handler: apiEntry, - middleware: apiMiddleware, - routes: tanstackStartVinxiFileRouter({ tsrConfig, apiBase }), - plugins: () => { - const viteConfig = getUserViteConfig(opts.vite) - const apiViteConfig = getUserViteConfig(opts.routers?.api?.vite) - - return [ - config('tsr-vite-config-api', { - ...viteConfig.userConfig, - ...apiViteConfig.userConfig, - ssr: mergeSsrOptions([ - viteConfig.userConfig.ssr, - apiViteConfig.userConfig.ssr, - { - noExternal, - }, - ]), - optimizeDeps: { - entries: [], - ...(viteConfig.userConfig.optimizeDeps || {}), - ...(apiViteConfig.userConfig.optimizeDeps || {}), - }, - define: { - ...(viteConfig.userConfig.define || {}), - ...(apiViteConfig.userConfig.define || {}), - ...injectDefineEnv('TSS_PUBLIC_BASE', publicBase), - ...injectDefineEnv('TSS_CLIENT_BASE', clientBase), - ...injectDefineEnv('TSS_API_BASE', apiBase), - ...injectDefineEnv('TSS_OUTPUT_PUBLIC_DIR', nitroOutputPublicDir), - }, - }), - TanStackRouterVite({ - ...tsrConfig, - enableRouteGeneration: false, - autoCodeSplitting: true, - __enableAPIRoutesGeneration: true, - experimental: { - ...tsrConfig.experimental, - }, - }), - ...(viteConfig.plugins || []), - ...(apiViteConfig.plugins || []), - ] - }, - }) - } - - // Because Vinxi doesn't use the normal nitro dev server, it doesn't - // supply $fetch during dev. We need to hook into the dev server creation, - // nab the proper utils from the custom nitro instance that is used - // during dev and supply the $fetch to app. - // Hopefully and likely, this will just get removed when we move to - // Nitro directly. - vinxiApp.hooks.hook('app:dev:nitro:config', (devServer) => { - vinxiApp.hooks.hook( - 'app:dev:server:created', - ({ devApp: { localFetch } }) => { - const $fetch = createFetch({ - fetch: localFetch, - defaults: { - baseURL: devServer.nitro.options.runtimeConfig.app.baseURL, - }, - }) - - // @ts-expect-error - globalThis.$fetch = $fetch - }, - ) - }) - - return vinxiApp -} - -function importToProjectRelative(p: string) { - const resolved = fileURLToPath(resolve(p, import.meta.url)) - - const relative = path.relative(process.cwd(), resolved) - - return relative -} - -function tsrRoutesManifest(opts: { - tsrConfig: z.infer - clientBase: string -}): vite.Plugin { - let config: vite.ResolvedConfig - - return { - name: 'tsr-routes-manifest', - configResolved(resolvedConfig) { - config = resolvedConfig - }, - resolveId(id) { - if (id === 'tsr:routes-manifest') { - return id - } - return - }, - async load(id) { - if (id === 'tsr:routes-manifest') { - // If we're in development, return a dummy manifest - - if (config.command === 'serve') { - return `export default () => ({ - routes: {} - })` - } - - const clientViteManifestPath = path.resolve( - config.build.outDir, - `../client/${opts.clientBase}/.vite/manifest.json`, - ) - - type ViteManifest = Record< - string, - { - file: string - isEntry: boolean - imports: Array - } - > - - let manifest: ViteManifest - try { - manifest = JSON.parse(await readFile(clientViteManifestPath, 'utf-8')) - } catch (err) { - console.error(err) - throw new Error( - `Could not find the production client vite manifest at '${clientViteManifestPath}'!`, - ) - } - - const routeTreePath = path.resolve(opts.tsrConfig.generatedRouteTree) - - let routeTreeContent: string - try { - routeTreeContent = readFileSync(routeTreePath, 'utf-8') - } catch (err) { - console.error(err) - throw new Error( - `Could not find the generated route tree at '${routeTreePath}'!`, - ) - } - - // Extract the routesManifest JSON from the route tree file. - // It's located between the /* ROUTE_MANIFEST_START and ROUTE_MANIFEST_END */ comment block. - - const routerManifest = JSON.parse( - routeTreeContent.match( - /\/\* ROUTE_MANIFEST_START([\s\S]*?)ROUTE_MANIFEST_END \*\//, - )?.[1] || '{ routes: {} }', - ) as Manifest - - const routes = routerManifest.routes - - let entryFile: - | { - file: string - imports: Array - } - | undefined - - const filesByRouteFilePath: ViteManifest = Object.fromEntries( - Object.entries(manifest).map(([k, v]) => { - if (v.isEntry) { - entryFile = v - } - - const rPath = k.split('?')[0] - - return [rPath, v] - }, {}), - ) - - // Add preloads to the routes from the vite manifest - Object.entries(routes).forEach(([k, v]) => { - const file = - filesByRouteFilePath[ - path.join(opts.tsrConfig.routesDirectory, v.filePath as string) - ] - - if (file) { - const preloads = file.imports.map((d) => - path.join(opts.clientBase, manifest[d]!.file), - ) - - preloads.unshift(path.join(opts.clientBase, file.file)) - - routes[k] = { - ...v, - preloads, - } - } - }) - - if (entryFile) { - routes.__root__!.preloads = [ - path.join(opts.clientBase, entryFile.file), - ...entryFile.imports.map((d) => - path.join(opts.clientBase, manifest[d]!.file), - ), - ] - } - - const recurseRoute = ( - route: { - preloads?: Array - children?: Array - }, - seenPreloads = {} as Record, - ) => { - route.preloads = route.preloads?.filter((preload) => { - if (seenPreloads[preload]) { - return false - } - seenPreloads[preload] = true - return true - }) - - if (route.children) { - route.children.forEach((child) => { - const childRoute = routes[child]! - recurseRoute(childRoute, { ...seenPreloads }) - }) - } - } - - // @ts-expect-error - recurseRoute(routes.__root__) - - const routesManifest = { - routes, - } - - if (process.env.TSR_VITE_DEBUG) { - console.info( - 'Routes Manifest: \n' + JSON.stringify(routesManifest, null, 2), - ) - } - - return `export default () => (${JSON.stringify(routesManifest)})` - } - return - }, - } -} - -function injectDefineEnv( - key: TKey, - value: TValue, -): { [P in `process.env.${TKey}` | `import.meta.env.${TKey}`]: TValue } { - return { - [`process.env.${key}`]: JSON.stringify(value), - [`import.meta.env.${key}`]: JSON.stringify(value), - } as { [P in `process.env.${TKey}` | `import.meta.env.${TKey}`]: TValue } -} diff --git a/packages/start-config/src/schema.ts b/packages/start-config/src/schema.ts deleted file mode 100644 index 4529483793..0000000000 --- a/packages/start-config/src/schema.ts +++ /dev/null @@ -1,198 +0,0 @@ -import { configSchema } from '@tanstack/router-generator' -import { z } from 'zod' -import type { PluginOption } from 'vite' -import type { AppOptions as VinxiAppOptions } from 'vinxi' -import type { NitroOptions } from 'nitropack' -import type { Options as ViteReactOptions } from '@vitejs/plugin-react' -import type { CustomizableConfig } from 'vinxi/dist/types/lib/vite-dev' - -type StartUserViteConfig = CustomizableConfig | (() => CustomizableConfig) - -export function getUserViteConfig(config?: StartUserViteConfig): { - plugins: Array | undefined - userConfig: CustomizableConfig -} { - const { plugins, ...userConfig } = - typeof config === 'function' ? config() : { ...config } - return { plugins, userConfig } -} - -/** - * Not all the deployment presets are fully functional or tested. - * @see https://github.com/TanStack/router/pull/2002 - */ -const vinxiDeploymentPresets = [ - 'alwaysdata', // untested - 'aws-amplify', // untested - 'aws-lambda', // untested - 'azure', // untested - 'azure-functions', // untested - 'base-worker', // untested - 'bun', // ✅ working - 'cleavr', // untested - 'cli', // untested - 'cloudflare', // untested - 'cloudflare-module', // untested - 'cloudflare-pages', // ✅ working - 'cloudflare-pages-static', // untested - 'deno', // untested - 'deno-deploy', // untested - 'deno-server', // untested - 'digital-ocean', // untested - 'edgio', // untested - 'firebase', // untested - 'flight-control', // untested - 'github-pages', // untested - 'heroku', // untested - 'iis', // untested - 'iis-handler', // untested - 'iis-node', // untested - 'koyeb', // untested - 'layer0', // untested - 'netlify', // ✅ working - 'netlify-builder', // untested - 'netlify-edge', // untested - 'netlify-static', // untested - 'nitro-dev', // untested - 'nitro-prerender', // untested - 'node', // partially working - 'node-cluster', // untested - 'node-server', // ✅ working - 'platform-sh', // untested - 'service-worker', // untested - 'static', // 🟧 partially working - 'stormkit', // untested - 'vercel', // ✅ working - 'vercel-edge', // untested - 'vercel-static', // untested - 'winterjs', // untested - 'zeabur', // untested - 'zeabur-static', // untested -] as const - -type DeploymentPreset = (typeof vinxiDeploymentPresets)[number] | (string & {}) - -const testedDeploymentPresets: Array = [ - 'bun', - 'netlify', - 'vercel', - 'cloudflare-pages', - 'node-server', -] - -export function checkDeploymentPresetInput( - preset?: string, -): DeploymentPreset | undefined { - if (preset) { - if (!vinxiDeploymentPresets.includes(preset as any)) { - console.warn( - `Invalid deployment preset "${preset}". Available presets are: ${vinxiDeploymentPresets - .map((p) => `"${p}"`) - .join(', ')}.`, - ) - } - - if (!testedDeploymentPresets.includes(preset as any)) { - console.warn( - `The deployment preset '${preset}' is not fully supported yet and may not work as expected.`, - ) - } - } - - return preset -} - -type HTTPSOptions = { - cert?: string - key?: string - pfx?: string - passphrase?: string - validityDays?: number - domains?: Array -} - -type ServerOptions_ = VinxiAppOptions['server'] & { - https?: boolean | HTTPSOptions -} - -type ServerOptions = { - [K in keyof ServerOptions_]: ServerOptions_[K] -} - -export const serverSchema = z - .object({ - routeRules: z.custom().optional(), - preset: z.custom().optional(), - static: z.boolean().optional(), - prerender: z - .object({ - routes: z.array(z.string()), - ignore: z - .array( - z.custom< - string | RegExp | ((path: string) => undefined | null | boolean) - >(), - ) - .optional(), - crawlLinks: z.boolean().optional(), - }) - .optional(), - }) - .and(z.custom()) - -const viteSchema = z.custom() - -const viteReactSchema = z.custom() - -const routersSchema = z.object({ - ssr: z - .object({ - entry: z.string().optional(), - middleware: z.string().optional(), - vite: viteSchema.optional(), - }) - .optional(), - client: z - .object({ - entry: z.string().optional(), - base: z.string().optional(), - vite: viteSchema.optional(), - }) - .optional(), - server: z - .object({ - base: z.string().optional(), - globalMiddlewareEntry: z.string().optional(), - middleware: z.string().optional(), - vite: viteSchema.optional(), - }) - .optional(), - api: z - .object({ - entry: z.string().optional(), - middleware: z.string().optional(), - vite: viteSchema.optional(), - }) - .optional(), - public: z - .object({ - dir: z.string().optional(), - base: z.string().optional(), - }) - .optional(), -}) - -const tsrConfig = configSchema.partial().extend({ - appDirectory: z.string().optional(), -}) - -export const inlineConfigSchema = z.object({ - react: viteReactSchema.optional(), - vite: viteSchema.optional(), - tsr: tsrConfig.optional(), - routers: routersSchema.optional(), - server: serverSchema.optional(), -}) - -export type TanStackStartInputConfig = z.input -export type TanStackStartOutputConfig = z.infer diff --git a/packages/start-config/src/vinxi-file-router.ts b/packages/start-config/src/vinxi-file-router.ts deleted file mode 100644 index 9e6d829d1b..0000000000 --- a/packages/start-config/src/vinxi-file-router.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { - BaseFileSystemRouter as VinxiBaseFileSystemRouter, - analyzeModule as vinxiFsRouterAnalyzeModule, - cleanPath as vinxiFsRouterCleanPath, -} from 'vinxi/fs-router' -import { - CONSTANTS as GENERATOR_CONSTANTS, - startAPIRouteSegmentsFromTSRFilePath, -} from '@tanstack/router-generator' -import type { configSchema } from '@tanstack/router-generator' -import type { - AppOptions as VinxiAppOptions, - RouterSchemaInput as VinxiRouterSchemaInput, -} from 'vinxi' -import type { z } from 'zod' - -export function tanstackStartVinxiFileRouter(opts: { - tsrConfig: z.infer - apiBase: string -}) { - const apiBaseSegment = opts.apiBase.split('/').filter(Boolean).join('/') - const isAPIPath = new RegExp(`/${apiBaseSegment}/`) - - return function (router: VinxiRouterSchemaInput, app: VinxiAppOptions) { - // Our own custom File Router that extends the VinxiBaseFileSystemRouter - // for splitting the API routes into its own "bundle" - // and adding the $APIRoute metadata to the route object - // This could be customized in future to support more complex splits - class TanStackStartFsRouter extends VinxiBaseFileSystemRouter { - toPath(src: string): string { - const inputPath = vinxiFsRouterCleanPath(src, this.config) - - const segments = startAPIRouteSegmentsFromTSRFilePath( - inputPath, - opts.tsrConfig, - ) - - const pathname = segments - .map((part) => { - if (part.type === 'splat') { - return `*splat` - } - - if (part.type === 'param') { - return `:${part.value}?` - } - - return part.value - }) - .join('/') - - return pathname.length > 0 ? `/${pathname}` : '/' - } - - toRoute(src: string) { - const webPath = this.toPath(src) - - const [_, exports] = vinxiFsRouterAnalyzeModule(src) - - const hasAPIRoute = exports.find( - (exp) => exp.n === GENERATOR_CONSTANTS.APIRouteExportVariable, - ) - - return { - path: webPath, - filePath: src, - $APIRoute: - isAPIPath.test(webPath) && hasAPIRoute - ? { - src, - pick: [GENERATOR_CONSTANTS.APIRouteExportVariable], - } - : undefined, - } - } - } - - return new TanStackStartFsRouter( - { - dir: opts.tsrConfig.routesDirectory, - extensions: ['js', 'jsx', 'ts', 'tsx'], - }, - router, - app, - ) - } -} diff --git a/packages/start-config/tsconfig.json b/packages/start-config/tsconfig.json deleted file mode 100644 index 940a9cce0a..0000000000 --- a/packages/start-config/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["src/index.ts"], - "compilerOptions": { - "rootDir": "src", - "outDir": "dist/esm", - "target": "esnext", - "noEmit": false - } -} diff --git a/packages/start-plugin-core/README.md b/packages/start-plugin-core/README.md new file mode 100644 index 0000000000..fd4ca0fd33 --- /dev/null +++ b/packages/start-plugin-core/README.md @@ -0,0 +1,12 @@ + + +# TanStack Start - Plugin Core + +This package is not meant to be used directly. It is a dependency of the TanStack Start framework-specific packages: + +- [`@tanstack/react-start`](https://www.npmjs.com/package/@tanstack/react-start) +- [`@tanstack/solid-start`](https://www.npmjs.com/package/@tanstack/solid-start). + +It provides the core functionality for TanStack Start, which is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router). + +Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started. diff --git a/packages/start-plugin-core/eslint.config.js b/packages/start-plugin-core/eslint.config.js new file mode 100644 index 0000000000..8ce6ad05fc --- /dev/null +++ b/packages/start-plugin-core/eslint.config.js @@ -0,0 +1,5 @@ +// @ts-check + +import rootConfig from '../../eslint.config.js' + +export default [...rootConfig] diff --git a/packages/start-api-routes/package.json b/packages/start-plugin-core/package.json similarity index 66% rename from packages/start-api-routes/package.json rename to packages/start-plugin-core/package.json index 3c2acd77ee..74d4f84b75 100644 --- a/packages/start-api-routes/package.json +++ b/packages/start-plugin-core/package.json @@ -1,13 +1,13 @@ { - "name": "@tanstack/start-api-routes", - "version": "1.120.3", - "description": "Modern and scalable routing for applications", + "name": "@tanstack/start-plugin-core", + "version": "1.114.12", + "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", "repository": { "type": "git", "url": "https://github.com/TanStack/router.git", - "directory": "packages/start-api-routes" + "directory": "packages/start-plugin-core" }, "homepage": "https://tanstack.com/start", "funding": { @@ -15,6 +15,7 @@ "url": "https://github.com/sponsors/tannerlinsley" }, "keywords": [ + "solid", "react", "location", "router", @@ -25,8 +26,9 @@ ], "scripts": { "clean": "rimraf ./dist && rimraf ./coverage", + "clean:snapshots": "rimraf **/*snapshot* --glob", "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit", - "test:unit": "exit 0; vitest", + "test:unit": "vitest", "test:eslint": "eslint ./src", "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"", "test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js", @@ -40,6 +42,8 @@ }, "type": "module", "types": "dist/esm/index.d.ts", + "main": "dist/cjs/index.cjs", + "module": "dist/esm/index.js", "exports": { ".": { "import": { @@ -62,11 +66,22 @@ "node": ">=12" }, "dependencies": { + "@babel/code-frame": "7.26.2", + "@babel/core": "^7.26.8", + "@babel/types": "^7.26.8", "@tanstack/router-core": "workspace:^", - "@tanstack/start-server-core": "workspace:^", - "vinxi": "0.5.3" - }, - "devDependencies": { - "typescript": "^5.7.2" + "@tanstack/router-generator": "workspace:^", + "@tanstack/router-utils": "workspace:^", + "@types/babel__code-frame": "^7.0.6", + "@types/babel__core": "^7.20.5", + "babel-dead-code-elimination": "^1.0.9", + "cheerio": "^1.0.0", + "h3": "1.13.0", + "nitropack": "^2.11.8", + "pathe": "^2.0.3", + "ufo": "^1.5.4", + "vite": "6.1.0", + "xmlbuilder2": "^3.1.1", + "zod": "^3.24.2" } } diff --git a/packages/start-plugin-core/src/compilers.ts b/packages/start-plugin-core/src/compilers.ts new file mode 100644 index 0000000000..c589fe4b13 --- /dev/null +++ b/packages/start-plugin-core/src/compilers.ts @@ -0,0 +1,759 @@ +import * as babel from '@babel/core' +import * as t from '@babel/types' +import { codeFrameColumns } from '@babel/code-frame' + +import { + deadCodeElimination, + findReferencedIdentifiers, +} from 'babel-dead-code-elimination' +import { generateFromAst, parseAst } from '@tanstack/router-utils' +import type { GeneratorResult, ParseAstOptions } from '@tanstack/router-utils' + +export type CompileStartFrameworkOptions = 'react' | 'solid' + +export function compileStartOutputFactory( + framework: CompileStartFrameworkOptions, +) { + return function compileStartOutput(opts: CompileOptions): GeneratorResult { + const ast = parseAst(opts) + + const doDce = opts.dce ?? true + // find referenced identifiers *before* we transform anything + const refIdents = doDce ? findReferencedIdentifiers(ast) : undefined + + babel.traverse(ast, { + Program: { + enter(programPath) { + const identifiers: { + createServerFileRoute: IdentifierConfig + createServerFn: IdentifierConfig + createMiddleware: IdentifierConfig + serverOnly: IdentifierConfig + clientOnly: IdentifierConfig + createIsomorphicFn: IdentifierConfig + } = { + createServerFileRoute: { + name: 'createServerFileRoute', + handleCallExpression: + handleCreateServerFileRouteCallExpressionFactory(framework), + paths: [], + }, + createServerFn: { + name: 'createServerFn', + handleCallExpression: handleCreateServerFnCallExpression, + paths: [], + }, + createMiddleware: { + name: 'createMiddleware', + handleCallExpression: handleCreateMiddlewareCallExpression, + paths: [], + }, + serverOnly: { + name: 'serverOnly', + handleCallExpression: handleServerOnlyCallExpression, + paths: [], + }, + clientOnly: { + name: 'clientOnly', + handleCallExpression: handleClientOnlyCallExpression, + paths: [], + }, + createIsomorphicFn: { + name: 'createIsomorphicFn', + handleCallExpression: handleCreateIsomorphicFnCallExpression, + paths: [], + }, + } + + const identifierKeys = Object.keys(identifiers) as Array< + keyof typeof identifiers + > + + programPath.traverse({ + ImportDeclaration: (path) => { + if ( + path.node.source.value !== '@tanstack/react-start' && + path.node.source.value !== '@tanstack/solid-start' + ) { + return + } + + // handle a destructured imports being renamed like "import { createServerFn as myCreateServerFn } from '@tanstack/react-start';" + path.node.specifiers.forEach((specifier) => { + identifierKeys.forEach((identifierKey) => { + const identifier = identifiers[identifierKey] + + if ( + specifier.type === 'ImportSpecifier' && + specifier.imported.type === 'Identifier' + ) { + if (specifier.imported.name === identifierKey) { + identifier.name = specifier.local.name + } + } + + // handle namespace imports like "import * as TanStackStart from '@tanstack/react-start';" + if (specifier.type === 'ImportNamespaceSpecifier') { + identifier.name = `${specifier.local.name}.${identifierKey}` + } + }) + }) + }, + CallExpression: (path) => { + identifierKeys.forEach((identifierKey) => { + // Check to see if the call expression is a call to the + // identifiers[identifierKey].name + if ( + t.isIdentifier(path.node.callee) && + path.node.callee.name === identifiers[identifierKey].name + ) { + // The identifier could be a call to the original function + // in the source code. If this is case, we need to ignore it. + // Check the scope to see if the identifier is a function declaration. + // if it is, then we can ignore it. + + if ( + path.scope.getBinding(identifiers[identifierKey].name)?.path + .node.type === 'FunctionDeclaration' + ) { + return + } + + return identifiers[identifierKey].paths.push(path) + } + + if (t.isMemberExpression(path.node.callee)) { + if ( + t.isIdentifier(path.node.callee.object) && + t.isIdentifier(path.node.callee.property) + ) { + const callname = [ + path.node.callee.object.name, + path.node.callee.property.name, + ].join('.') + + if (callname === identifiers[identifierKey].name) { + identifiers[identifierKey].paths.push(path) + } + } + } + + return + }) + }, + }) + + identifierKeys.forEach((identifierKey) => { + identifiers[identifierKey].paths.forEach((path) => { + identifiers[identifierKey].handleCallExpression( + path as babel.NodePath, + opts, + ) + }) + }) + }, + }, + }) + + if (doDce) { + deadCodeElimination(ast, refIdents) + } + + return generateFromAst(ast, { + sourceMaps: true, + sourceFileName: opts.filename, + filename: opts.filename, + }) + } +} + +function handleCreateServerFileRouteCallExpressionFactory( + factory: CompileStartFrameworkOptions, +) { + return function handleCreateServerFileRouteCallExpression( + path: babel.NodePath, + opts: CompileOptions, + ) { + const PACKAGES = { start: `@tanstack/${factory}-start/server` } + + let highestParent: babel.NodePath = path + + while (highestParent.parentPath && !highestParent.parentPath.isProgram()) { + highestParent = highestParent.parentPath + } + + const programPath = highestParent.parentPath as babel.NodePath + + // // Find the root call expression and all of the methods that are called on it + // const rootCallExpression = getRootCallExpression(path) + + // const callExpressionPaths = { + // validator: null as babel.NodePath | null, + // middleware: null as babel.NodePath | null, + // methods: null as babel.NodePath | null, + // } + + // const validMethods = Object.keys(callExpressionPaths) + + // rootCallExpression.traverse({ + // MemberExpression(memberExpressionPath) { + // if (t.isIdentifier(memberExpressionPath.node.property)) { + // const name = memberExpressionPath.node.property + // .name as keyof typeof callExpressionPaths + + // if ( + // validMethods.includes(name) && + // memberExpressionPath.parentPath.isCallExpression() + // ) { + // callExpressionPaths[name] = memberExpressionPath.parentPath + // } + // } + // }, + // }) + + // const manifest = { middleware: false, methods: {} as any } + + // Object.entries(callExpressionPaths).forEach(([key, callPath]) => { + // if (callPath && t.isMemberExpression(callPath.node.callee)) { + // if (key === 'middleware') { + // manifest.middleware = true + // } else if (key === 'methods') { + // // Get the methods object from the methods call + // const methodsArg = callPath.node.arguments[0] + + // // Handle the case where methods is a function that returns an object + // if ( + // t.isArrowFunctionExpression(methodsArg) && + // t.isObjectExpression(methodsArg.body) + // ) { + // methodsArg.body.properties.forEach((prop) => { + // if (t.isObjectProperty(prop) && t.isIdentifier(prop.key)) { + // const methodName = prop.key.name + // manifest.methods[methodName] = { + // middleware: false, + // } + + // // Check if this method has a middleware + // if (t.isCallExpression(prop.value)) { + // const method = prop.value + // method.arguments.forEach((arg) => { + // if (t.isObjectExpression(arg)) { + // arg.properties.forEach((methodProp) => { + // if ( + // t.isObjectProperty(methodProp) && + // t.isIdentifier(methodProp.key) + // ) { + // if (methodProp.key.name === 'middleware') { + // manifest.methods[methodName].middleware = true + // } + // } + // }) + // } + // }) + // } + // } + // }) + // } + // // Handle the case where methods is a direct object + // else if (t.isObjectExpression(methodsArg)) { + // methodsArg.properties.forEach((prop) => { + // if (t.isObjectProperty(prop) && t.isIdentifier(prop.key)) { + // const methodName = prop.key.name + // manifest.methods[methodName] = { + // middleware: false, + // } + // } + // }) + // } + // } + + // if (opts.env === 'client') { + // callPath.replaceWith(callPath.node.callee.object) + // } + // } + // }) + + // If we're on the client, remove the entire variable + if (opts.env === 'client') { + // console.debug('createServerFileRoute -> manifest:\n', manifest) + highestParent.remove() + return + } + + // path.replaceWith( + // t.callExpression(t.identifier('createServerFileRoute'), [ + // t.identifier('undefined'), + // t.callExpression( + // t.memberExpression(t.identifier('Object'), t.identifier('assign')), + // [ + // t.objectExpression( + // path.node.arguments + // .map((arg) => { + // if (t.isIdentifier(arg)) { + // return t.objectProperty(t.identifier(arg.name), arg) + // } + // // Handle other cases or return a default value if necessary + // return null // or throw an error, or handle accordingly + // }) + // .filter( + // (property): property is t.ObjectProperty => property !== null, + // ), + // ), + // t.objectExpression([ + // t.objectProperty( + // t.identifier('manifest'), + // t.valueToNode(manifest), + // ), + // ]), + // ], + // ), + // ]), + // ) + + let isCreateServerFileRouteImported = false as boolean + + programPath.traverse({ + ImportDeclaration(importPath) { + const importSource = importPath.node.source.value + if (importSource === PACKAGES.start) { + const specifiers = importPath.node.specifiers + isCreateServerFileRouteImported = specifiers.some((specifier) => { + return ( + t.isImportSpecifier(specifier) && + t.isIdentifier(specifier.imported) && + specifier.imported.name === 'createServerFileRoute' + ) + }) + } + }, + }) + + if (!isCreateServerFileRouteImported) { + const importDeclaration = t.importDeclaration( + [ + t.importSpecifier( + t.identifier('createServerFileRoute'), + t.identifier('createServerFileRoute'), + ), + ], + t.stringLiteral(PACKAGES.start), + ) + programPath.node.body.unshift(importDeclaration) + } + } +} + +// build these once and reuse them +export const handleServerOnlyCallExpression = + buildEnvOnlyCallExpressionHandler('server') +export const handleClientOnlyCallExpression = + buildEnvOnlyCallExpressionHandler('client') + +export type CompileOptions = ParseAstOptions & { + env: 'server' | 'client' + dce?: boolean + filename: string +} + +export type IdentifierConfig = { + name: string + handleCallExpression: ( + path: babel.NodePath, + opts: CompileOptions, + ) => void + paths: Array +} + +export function handleCreateServerFnCallExpression( + path: babel.NodePath, + opts: CompileOptions, +) { + // The function is the 'fn' property of the object passed to createServerFn + + // const firstArg = path.node.arguments[0] + // if (t.isObjectExpression(firstArg)) { + // // Was called with some options + // } + + // Traverse the member expression and find the call expressions for + // the validator, handler, and middleware methods. Check to make sure they + // are children of the createServerFn call expression. + + const calledOptions = path.node.arguments[0] + ? (path.get('arguments.0') as babel.NodePath) + : null + + const shouldValidateClient = !!calledOptions?.node.properties.find((prop) => { + return ( + t.isObjectProperty(prop) && + t.isIdentifier(prop.key) && + prop.key.name === 'validateClient' && + t.isBooleanLiteral(prop.value) && + prop.value.value === true + ) + }) + + const callExpressionPaths = { + middleware: null as babel.NodePath | null, + validator: null as babel.NodePath | null, + handler: null as babel.NodePath | null, + } + + const validMethods = Object.keys(callExpressionPaths) + + const rootCallExpression = getRootCallExpression(path) + + // if (debug) + // console.info( + // 'Handling createServerFn call expression:', + // rootCallExpression.toString(), + // ) + + // Check if the call is assigned to a variable + if (!rootCallExpression.parentPath.isVariableDeclarator()) { + throw new Error('createServerFn must be assigned to a variable!') + } + + // Get the identifier name of the variable + const variableDeclarator = rootCallExpression.parentPath.node + const existingVariableName = (variableDeclarator.id as t.Identifier).name + + rootCallExpression.traverse({ + MemberExpression(memberExpressionPath) { + if (t.isIdentifier(memberExpressionPath.node.property)) { + const name = memberExpressionPath.node.property + .name as keyof typeof callExpressionPaths + + if ( + validMethods.includes(name) && + memberExpressionPath.parentPath.isCallExpression() + ) { + callExpressionPaths[name] = memberExpressionPath.parentPath + } + } + }, + }) + + if (callExpressionPaths.validator) { + const innerInputExpression = callExpressionPaths.validator.node.arguments[0] + + if (!innerInputExpression) { + throw new Error( + 'createServerFn().validator() must be called with a validator!', + ) + } + + // If we're on the client, and we're not validating the client, remove the validator call expression + if ( + opts.env === 'client' && + !shouldValidateClient && + t.isMemberExpression(callExpressionPaths.validator.node.callee) + ) { + callExpressionPaths.validator.replaceWith( + callExpressionPaths.validator.node.callee.object, + ) + } + } + + // First, we need to move the handler function to a nested function call + // that is applied to the arguments passed to the server function. + + const handlerFnPath = callExpressionPaths.handler?.get( + 'arguments.0', + ) as babel.NodePath + + if (!callExpressionPaths.handler || !handlerFnPath.node) { + throw codeFrameError( + opts.code, + path.node.callee.loc!, + `createServerFn must be called with a "handler" property!`, + ) + } + + const handlerFn = handlerFnPath.node + + // So, the way we do this is we give the handler function a way + // to access the serverFn ctx on the server via function scope. + // The 'use server' extracted function will be called with the + // payload from the client, then use the scoped serverFn ctx + // to execute the handler function. + // This way, we can do things like data and middleware validation + // in the __execute function without having to AST transform the + // handler function too much itself. + + // .handler((optsOut, ctx) => { + // return ((optsIn) => { + // 'use server' + // ctx.__execute(handlerFn, optsIn) + // })(optsOut) + // }) + + // If the handler function is an identifier and we're on the client, we need to + // remove the bound function from the file. + // If we're on the server, you can leave it, since it will get referenced + // as a second argument. + + if (t.isIdentifier(handlerFn)) { + if (opts.env === 'client') { + // Find the binding for the handler function + const binding = handlerFnPath.scope.getBinding(handlerFn.name) + // Remove it + if (binding) { + binding.path.remove() + } + } + // If the env is server, just leave it alone + } + + handlerFnPath.replaceWith( + t.arrowFunctionExpression( + [t.identifier('opts'), t.identifier('signal')], + t.blockStatement( + // Everything in here is server-only, since the client + // will strip out anything in the 'use server' directive. + [ + t.returnStatement( + t.callExpression( + t.identifier(`${existingVariableName}.__executeServer`), + [t.identifier('opts'), t.identifier('signal')], + ), + ), + ], + [t.directive(t.directiveLiteral('use server'))], + ), + ), + ) + + if (opts.env === 'server') { + callExpressionPaths.handler.node.arguments.push(handlerFn) + } +} + +export function handleCreateMiddlewareCallExpression( + path: babel.NodePath, + opts: CompileOptions, +) { + const rootCallExpression = getRootCallExpression(path) + + // if (debug) + // console.info( + // 'Handling createMiddleware call expression:', + // rootCallExpression.toString(), + // ) + + const callExpressionPaths = { + middleware: null as babel.NodePath | null, + validator: null as babel.NodePath | null, + client: null as babel.NodePath | null, + server: null as babel.NodePath | null, + } + + const validMethods = Object.keys(callExpressionPaths) + + rootCallExpression.traverse({ + MemberExpression(memberExpressionPath) { + if (t.isIdentifier(memberExpressionPath.node.property)) { + const name = memberExpressionPath.node.property + .name as keyof typeof callExpressionPaths + + if ( + validMethods.includes(name) && + memberExpressionPath.parentPath.isCallExpression() + ) { + callExpressionPaths[name] = memberExpressionPath.parentPath + } + } + }, + }) + + if (callExpressionPaths.validator) { + const innerInputExpression = callExpressionPaths.validator.node.arguments[0] + + if (!innerInputExpression) { + throw new Error( + 'createMiddleware().validator() must be called with a validator!', + ) + } + + // If we're on the client, remove the validator call expression + if (opts.env === 'client') { + if (t.isMemberExpression(callExpressionPaths.validator.node.callee)) { + callExpressionPaths.validator.replaceWith( + callExpressionPaths.validator.node.callee.object, + ) + } + } + } + + const serverFnPath = callExpressionPaths.server?.get( + 'arguments.0', + ) as babel.NodePath + + if ( + callExpressionPaths.server && + serverFnPath.node && + opts.env === 'client' + ) { + // If we're on the client, remove the server call expression + if (t.isMemberExpression(callExpressionPaths.server.node.callee)) { + callExpressionPaths.server.replaceWith( + callExpressionPaths.server.node.callee.object, + ) + } + } +} + +function buildEnvOnlyCallExpressionHandler(env: 'client' | 'server') { + return function envOnlyCallExpressionHandler( + path: babel.NodePath, + opts: CompileOptions, + ) { + // if (debug) + // console.info(`Handling ${env}Only call expression:`, path.toString()) + + const isEnvMatch = + env === 'client' ? opts.env === 'client' : opts.env === 'server' + + if (isEnvMatch) { + // extract the inner function from the call expression + const innerInputExpression = path.node.arguments[0] + + if (!t.isExpression(innerInputExpression)) { + throw new Error( + `${env}Only() functions must be called with a function!`, + ) + } + + path.replaceWith(innerInputExpression) + return + } + + // If we're on the wrong environment, replace the call expression + // with a function that always throws an error. + path.replaceWith( + t.arrowFunctionExpression( + [], + t.blockStatement([ + t.throwStatement( + t.newExpression(t.identifier('Error'), [ + t.stringLiteral( + `${env}Only() functions can only be called on the ${env}!`, + ), + ]), + ), + ]), + ), + ) + } +} + +export function handleCreateIsomorphicFnCallExpression( + path: babel.NodePath, + opts: CompileOptions, +) { + const rootCallExpression = getRootCallExpression(path) + + // if (debug) + // console.info( + // 'Handling createIsomorphicFn call expression:', + // rootCallExpression.toString(), + // ) + + const callExpressionPaths = { + client: null as babel.NodePath | null, + server: null as babel.NodePath | null, + } + + const validMethods = Object.keys(callExpressionPaths) + + rootCallExpression.traverse({ + MemberExpression(memberExpressionPath) { + if (t.isIdentifier(memberExpressionPath.node.property)) { + const name = memberExpressionPath.node.property + .name as keyof typeof callExpressionPaths + + if ( + validMethods.includes(name) && + memberExpressionPath.parentPath.isCallExpression() + ) { + callExpressionPaths[name] = memberExpressionPath.parentPath + } + } + }, + }) + + if ( + validMethods.every( + (method) => + !callExpressionPaths[method as keyof typeof callExpressionPaths], + ) + ) { + const variableId = rootCallExpression.parentPath.isVariableDeclarator() + ? rootCallExpression.parentPath.node.id + : null + console.warn( + 'createIsomorphicFn called without a client or server implementation!', + 'This will result in a no-op function.', + 'Variable name:', + t.isIdentifier(variableId) ? variableId.name : 'unknown', + ) + } + + const envCallExpression = callExpressionPaths[opts.env] + + if (!envCallExpression) { + // if we don't have an implementation for this environment, default to a no-op + rootCallExpression.replaceWith( + t.arrowFunctionExpression([], t.blockStatement([])), + ) + return + } + + const innerInputExpression = envCallExpression.node.arguments[0] + + if (!t.isExpression(innerInputExpression)) { + throw new Error( + `createIsomorphicFn().${opts.env}(func) must be called with a function!`, + ) + } + + rootCallExpression.replaceWith(innerInputExpression) +} + +export function getRootCallExpression(path: babel.NodePath) { + // Find the highest callExpression parent + let rootCallExpression: babel.NodePath = path + + // Traverse up the chain of CallExpressions + while (rootCallExpression.parentPath.isMemberExpression()) { + const parent = rootCallExpression.parentPath + if (parent.parentPath.isCallExpression()) { + rootCallExpression = parent.parentPath + } + } + + return rootCallExpression +} + +function codeFrameError( + code: string, + loc: { + start: { line: number; column: number } + end: { line: number; column: number } + }, + message: string, +) { + const frame = codeFrameColumns( + code, + { + start: loc.start, + end: loc.end, + }, + { + highlightCode: true, + message, + }, + ) + + return new Error(frame) +} diff --git a/packages/start-plugin-core/src/extractHtmlScripts.ts b/packages/start-plugin-core/src/extractHtmlScripts.ts new file mode 100644 index 0000000000..41e3ac44a9 --- /dev/null +++ b/packages/start-plugin-core/src/extractHtmlScripts.ts @@ -0,0 +1,19 @@ +import * as cheerio from 'cheerio' + +export function extractHtmlScripts( + html: string, +): Array<{ content?: string; src?: string }> { + const $ = cheerio.load(html) + const scripts: Array<{ content?: string; src?: string }> = [] + + $('script').each((_, element) => { + const src = $(element).attr('src') + const content = $(element).html() ?? undefined + scripts.push({ + src, + content, + }) + }) + + return scripts +} diff --git a/packages/start-plugin-core/src/index.ts b/packages/start-plugin-core/src/index.ts new file mode 100644 index 0000000000..28b8cbdab0 --- /dev/null +++ b/packages/start-plugin-core/src/index.ts @@ -0,0 +1,15 @@ +export type { CompileOptions, IdentifierConfig } from './compilers' + +export { compileStartOutputFactory } from './compilers' + +export type { PagesJson } from './nitro/build-sitemap' +export { buildSitemap } from './nitro/build-sitemap' + +export { + createTanStackConfig, + createTanStackStartOptionsSchema, + pageSchema, +} from './schema' + +export { TanStackStartVitePluginCore } from './plugin' +export { TanStackStartServerRoutesVite } from './start-server-routes-plugin/plugin' diff --git a/packages/start-plugin-core/src/nitro/build-nitro.ts b/packages/start-plugin-core/src/nitro/build-nitro.ts new file mode 100644 index 0000000000..918248c3a9 --- /dev/null +++ b/packages/start-plugin-core/src/nitro/build-nitro.ts @@ -0,0 +1,27 @@ +import { promises as fsp } from 'node:fs' +import path from 'node:path' +import { copyPublicAssets, prepare } from 'nitropack' +import type { Nitro } from 'nitropack' + +export async function buildNitroEnvironment( + nitro: Nitro, + build: () => Promise, +) { + await prepare(nitro) + await copyPublicAssets(nitro) + await build() + + const publicDir = nitro.options.output.publicDir + + // As a part of the build process, the `.vite/` directory + // is copied over from `.tanstack-start/build/client-dist/` + // to the `publicDir` (e.g. `.output/public/`). + // This directory (containing the vite manifest) should not be + // included in the final build, so we remove it here. + const viteDir = path.resolve(publicDir, '.vite') + if (await fsp.stat(viteDir).catch(() => false)) { + await fsp.rm(viteDir, { recursive: true, force: true }) + } + + await nitro.close() +} diff --git a/packages/start-plugin-core/src/nitro/build-sitemap.ts b/packages/start-plugin-core/src/nitro/build-sitemap.ts new file mode 100644 index 0000000000..c06ed77d0e --- /dev/null +++ b/packages/start-plugin-core/src/nitro/build-sitemap.ts @@ -0,0 +1,79 @@ +import { writeFileSync } from 'node:fs' +import { resolve } from 'node:path' +import { create } from 'xmlbuilder2' +import type { XMLBuilder } from 'xmlbuilder2/lib/interfaces' + +export type PagesJson = { + page: string + lastMod: string +} + +export async function buildSitemap({ + host, + routes, + outputDir, +}: { + host: string + routes: Array | (() => Promise>) + outputDir: string +}) { + const routeList: Array = await optionHasRoutes(routes) + + if (routeList.length) { + const slash = checkSlash(host) + const sitemapData: Array = routeList.map((page: string) => ({ + page: `${host}${slash}${page.replace(/^\/+/g, '')}`, + lastMod: new Date().toISOString().split('T')[0]!, + })) + + const sitemap = createXml('urlset') + + for (const item of sitemapData) { + const page = sitemap.ele('url') + page.ele('loc').txt(item.page) + page.ele('lastmod').txt(item.lastMod) + } + + const mapPath = `${resolve(outputDir)}/sitemap.xml` + try { + console.log(`Writing sitemap at ${mapPath}`) + writeFileSync(mapPath, sitemap.end({ prettyPrint: true })) + } catch (e) { + console.error(`Unable to write file at ${mapPath}`, e) + } + } +} + +function createXml(elementName: 'urlset' | 'sitemapindex'): XMLBuilder { + return create({ version: '1.0', encoding: 'UTF-8' }) + .ele(elementName, { + xmlns: 'https://www.sitemaps.org/schemas/sitemap/0.9', + }) + .com(`This file was automatically generated by Analog.`) +} + +function checkSlash(host: string): string { + const finalChar = host.slice(-1) + return finalChar === '/' ? '' : '/' +} + +async function optionHasRoutes( + routes: + | Array + | (() => Promise>), +): Promise> { + let routeList: Array + + if (typeof routes === 'function') { + // returns an array or undefined + routeList = await routes() + } else if (Array.isArray(routes)) { + // returns an array of strings + routeList = routes + } else { + // default it to an empty of array + routeList = [] + } + + return routeList.filter(Boolean) as Array +} diff --git a/packages/start-plugin-core/src/nitro/dev-server-plugin.ts b/packages/start-plugin-core/src/nitro/dev-server-plugin.ts new file mode 100644 index 0000000000..1f868d4440 --- /dev/null +++ b/packages/start-plugin-core/src/nitro/dev-server-plugin.ts @@ -0,0 +1,159 @@ +import { createEvent, getHeader, sendWebResponse } from 'h3' +import { isRunnableDevEnvironment } from 'vite' +import { extractHtmlScripts } from '../extractHtmlScripts' +import type { Connect, Plugin, ViteDevServer } from 'vite' + +declare global { + // eslint-disable-next-line no-var + var TSS_INJECTED_HEAD_SCRIPTS: string | undefined +} + +export function devServerPlugin(): Plugin { + // let config: UserConfig + let isTest = false + + return { + name: 'start-dev-ssr-plugin', + config(userConfig, { mode }) { + // config = userConfig + isTest = isTest ? isTest : mode === 'test' + }, + configureServer(viteDevServer) { + if (isTest) { + return + } + + ;(globalThis as any).viteDevServer = viteDevServer + + return () => { + remove_html_middlewares(viteDevServer.middlewares) + let cachedScripts: string | undefined + viteDevServer.middlewares.use(async (req, res) => { + const event = createEvent(req, res) + const serverEnv = viteDevServer.environments['server'] + + try { + if (!serverEnv || !isRunnableDevEnvironment(serverEnv)) { + throw new Error('Server environment not found') + } + if (cachedScripts === undefined) { + const templateHtml = `` + const transformedHtml = await viteDevServer.transformIndexHtml( + req.url || '/', + templateHtml, + ) + const scripts = extractHtmlScripts(transformedHtml) + globalThis.TSS_INJECTED_HEAD_SCRIPTS = scripts + .map((script) => script.content ?? '') + .join(';') + } + const serverEntry = await serverEnv.runner.import( + '/~start/server-entry', + ) + const response = await serverEntry['default'](event) + + return sendWebResponse(event, response) + } catch (e) { + console.error(e) + viteDevServer.ssrFixStacktrace(e as Error) + + if ( + getHeader(event, 'content-type')?.includes('application/json') + ) { + return sendWebResponse( + event, + new Response( + JSON.stringify( + { + status: 500, + error: 'Internal Server Error', + message: + 'An unexpected error occurred. Please try again later.', + timestamp: new Date().toISOString(), + }, + null, + 2, + ), + { + status: 500, + headers: { + 'Content-Type': 'application/json', + }, + }, + ), + ) + } + + return sendWebResponse( + event, + new Response( + ` + + + + + Error + + + + + + `, + { + status: 500, + headers: { + 'Content-Type': 'text/html', + }, + }, + ), + ) + } + }) + } + }, + } +} + +/** + * Removes Vite internal middleware + * + * @param server + */ +function remove_html_middlewares(server: ViteDevServer['middlewares']) { + const html_middlewares = [ + 'viteIndexHtmlMiddleware', + 'vite404Middleware', + 'viteSpaFallbackMiddleware', + ] + for (let i = server.stack.length - 1; i > 0; i--) { + if ( + html_middlewares.includes( + // @ts-expect-error + server.stack[i].handle.name, + ) + ) { + server.stack.splice(i, 1) + } + } +} + +/** + * Formats error for SSR message in error overlay + * @param req + * @param error + * @returns + */ +function prepareError(req: Connect.IncomingMessage, error: unknown) { + const e = error as Error + return { + message: `An error occured while server rendering ${req.url}:\n\n\t${ + typeof e === 'string' ? e : e.message + } `, + stack: typeof e === 'string' ? '' : e.stack, + } +} diff --git a/packages/start-plugin-core/src/nitro/nitro-plugin.ts b/packages/start-plugin-core/src/nitro/nitro-plugin.ts new file mode 100644 index 0000000000..c61be21144 --- /dev/null +++ b/packages/start-plugin-core/src/nitro/nitro-plugin.ts @@ -0,0 +1,161 @@ +import path from 'node:path' +import { rmSync } from 'node:fs' +import { build, createNitro } from 'nitropack' +import { dirname, resolve } from 'pathe' +import { clientDistDir, ssrEntryFile } from '../plugin' +import { prerender } from '../prerender' +import { devServerPlugin } from './dev-server-plugin' +import { buildNitroEnvironment } from './build-nitro' +import type { EnvironmentOptions, PluginOption, Rollup } from 'vite' +import type { NitroConfig } from 'nitropack' +import type { TanStackStartOutputConfig } from '../plugin' + +export function nitroPlugin( + options: TanStackStartOutputConfig, + getSsrBundle: () => Rollup.OutputBundle, +): Array { + const buildPreset = + process.env['START_TARGET'] ?? (options.target as string | undefined) + + return [ + devServerPlugin(), + { + name: 'tanstack-vite-plugin-nitro', + configEnvironment(name) { + if (name === 'server') { + return { + build: { + commonjsOptions: { + include: [], + }, + ssr: true, + sourcemap: true, + rollupOptions: { + input: '/~start/server-entry', + }, + }, + } satisfies EnvironmentOptions + } + + return null + }, + config() { + return { + builder: { + sharedPlugins: true, + async buildApp(builder) { + const clientEnv = builder.environments['client'] + const serverEnv = builder.environments['server'] + + if (!clientEnv) { + throw new Error('Client environment not found') + } + + if (!serverEnv) { + throw new Error('SSR environment not found') + } + + const clientOutputDir = resolve(options.root, clientDistDir) + rmSync(clientOutputDir, { recursive: true, force: true }) + await builder.build(clientEnv) + + await builder.build(serverEnv) + + const nitroConfig: NitroConfig = { + dev: false, + // TODO do we need this? should this be made configurable? + compatibilityDate: '2024-11-19', + logLevel: 3, + preset: buildPreset, + publicAssets: [ + { + dir: path.resolve(options.root, clientDistDir), + }, + ], + typescript: { + generateTsConfig: false, + }, + prerender: undefined, + renderer: ssrEntryFile, + rollupConfig: { + plugins: [virtualBundlePlugin(getSsrBundle())], + }, + } + + const nitro = await createNitro(nitroConfig) + + await buildNitroEnvironment(nitro, () => build(nitro)) + + if (options.prerender?.enabled) { + await prerender({ + options, + nitro, + builder, + }) + } + + // if (nitroConfig.prerender?.routes?.length && options.sitemap) { + // console.log('Building Sitemap...') + // // sitemap needs to be built after all directories are built + // await buildSitemap({ + // host: options.sitemap.host, + // routes: nitroConfig.prerender.routes, + // outputDir: resolve(options.root, 'dist/public'), + // }) + // } + + // console.log( + // `\n\n✅ Client and server bundles successfully built.`, + // ) + }, + }, + } + }, + }, + ] +} + +function virtualBundlePlugin(ssrBundle: Rollup.OutputBundle): Rollup.Plugin { + type VirtualModule = { code: string; map: string | null } + const _modules = new Map() + + // group chunks and source maps + for (const [fileName, content] of Object.entries(ssrBundle)) { + if (content.type === 'chunk') { + const virtualModule: VirtualModule = { + code: content.code, + map: null, + } + const maybeMap = ssrBundle[`${fileName}.map`] + if (maybeMap && maybeMap.type === 'asset') { + virtualModule.map = maybeMap.source as string + } + _modules.set(fileName, virtualModule) + _modules.set(resolve(fileName), virtualModule) + } + } + + return { + name: 'virtual-bundle', + resolveId(id, importer) { + if (_modules.has(id)) { + return resolve(id) + } + + if (importer) { + const resolved = resolve(dirname(importer), id) + if (_modules.has(resolved)) { + return resolved + } + } + return null + }, + load(id) { + const m = _modules.get(id) + if (!m) { + return null + } + return m + }, + } +} diff --git a/packages/start-plugin-core/src/plugin.ts b/packages/start-plugin-core/src/plugin.ts new file mode 100644 index 0000000000..fde7ea057f --- /dev/null +++ b/packages/start-plugin-core/src/plugin.ts @@ -0,0 +1,145 @@ +import path from 'node:path' +import { createNitro } from 'nitropack' +import { + createTanStackConfig, + createTanStackStartOptionsSchema, +} from './schema' +import { nitroPlugin } from './nitro/nitro-plugin' +import { startManifestPlugin } from './routesManifestPlugin' +import { TanStackStartCompilerPlugin } from './start-compiler-plugin' +import type { PluginOption, Rollup } from 'vite' +import type { z } from 'zod' +import type { CompileStartFrameworkOptions } from './compilers' + +const TanStackStartOptionsSchema = createTanStackStartOptionsSchema() +export type TanStackStartInputConfig = z.input< + typeof TanStackStartOptionsSchema +> + +const defaultConfig = createTanStackConfig() +export function getTanStackStartOptions(opts?: TanStackStartInputConfig) { + return defaultConfig.parse(opts) +} + +export type TanStackStartOutputConfig = ReturnType< + typeof getTanStackStartOptions +> + +export const clientDistDir = '.tanstack-start/build/client-dist' +export const ssrEntryFile = 'ssr.mjs' + +// this needs to live outside of the TanStackStartVitePluginCore since it will be invoked multiple times by vite +let ssrBundle: Rollup.OutputBundle + +export function TanStackStartVitePluginCore( + framework: CompileStartFrameworkOptions, + opts: TanStackStartOutputConfig, +): Array { + return [ + { + name: 'tanstack-start-core:config-client', + async config() { + const nitroOutputPublicDir = await (async () => { + // Create a dummy nitro app to get the resolved public output path + const dummyNitroApp = await createNitro({ + preset: opts.target, + compatibilityDate: '2024-12-01', + }) + + const nitroOutputPublicDir = dummyNitroApp.options.output.publicDir + await dummyNitroApp.close() + + return nitroOutputPublicDir + })() + + return { + environments: { + client: { + consumer: 'client', + build: { + manifest: true, + rollupOptions: { + input: { + main: opts.clientEntryPath, + }, + output: { + dir: path.resolve(opts.root, clientDistDir), + }, + // TODO this should be removed + external: ['node:fs', 'node:path', 'node:os', 'node:crypto'], + }, + }, + }, + server: { + consumer: 'server', + build: { + ssr: true, + // we don't write to the file system as the below 'capture-output' plugin will + // capture the output and write it to the virtual file system + write: false, + copyPublicDir: false, + rollupOptions: { + output: { + entryFileNames: ssrEntryFile, + }, + plugins: [ + { + name: 'capture-output', + generateBundle(options, bundle) { + // TODO can this hook be called more than once? + ssrBundle = bundle + }, + }, + ], + }, + commonjsOptions: { + include: [/node_modules/], + }, + }, + }, + }, + resolve: { + noExternal: [ + '@tanstack/start-client', + '@tanstack/start-client-core', + '@tanstack/start-server', + '@tanstack/start-server-core', + '@tanstack/start-server-functions-fetcher', + '@tanstack/start-server-functions-client', + '@tanstack/start-server-functions-server', + '@tanstack/start-router-manifest', + '@tanstack/start-config', + '@tanstack/server-functions-plugin', + 'tanstack:start-manifest', + 'tanstack:server-fn-manifest', + 'nitropack', + '@tanstack/**', + ], + external: ['undici'], + }, + /* prettier-ignore */ + define: { + ...injectDefineEnv('TSS_PUBLIC_BASE', opts.public.base), + ...injectDefineEnv('TSS_CLIENT_BASE', opts.client.base), + ...injectDefineEnv('TSS_CLIENT_ENTRY', opts.clientEntryPath), + ...injectDefineEnv('TSS_SERVER_FN_BASE', opts.serverFns.base), + ...injectDefineEnv('TSS_OUTPUT_PUBLIC_DIR', nitroOutputPublicDir), + }, + } + }, + }, + TanStackStartCompilerPlugin(framework), + startManifestPlugin(opts), + nitroPlugin(opts, () => ssrBundle), + ] +} + +function injectDefineEnv( + key: TKey, + value: TValue, +): { [P in `process.env.${TKey}` | `import.meta.env.${TKey}`]: TValue } { + return { + [`process.env.${key}`]: JSON.stringify(value), + [`import.meta.env.${key}`]: JSON.stringify(value), + } as { [P in `process.env.${TKey}` | `import.meta.env.${TKey}`]: TValue } +} diff --git a/packages/start-plugin-core/src/prerender.ts b/packages/start-plugin-core/src/prerender.ts new file mode 100644 index 0000000000..afb252431a --- /dev/null +++ b/packages/start-plugin-core/src/prerender.ts @@ -0,0 +1,245 @@ +import { promises as fsp } from 'node:fs' +import os from 'node:os' +import path from 'node:path' +import { getRollupConfig } from 'nitropack/rollup' +import { build as buildNitro, createNitro } from 'nitropack' +import { joinURL, withBase, withoutBase } from 'ufo' +import { Queue } from './queue' +import { buildNitroEnvironment } from './nitro/build-nitro' +import type { ViteBuilder } from 'vite' +import type { $Fetch, Nitro } from 'nitropack' +import type { TanStackStartOutputConfig } from './plugin' +import type { Page } from './schema' + +export async function prerender({ + options, + nitro, + builder, +}: { + options: TanStackStartOutputConfig + nitro: Nitro + builder: ViteBuilder +}) { + nitro.logger.info('Prendering pages...') + + // If prerender is enabled but no pages are provided, default to prerendering the root page + if (options.prerender?.enabled && !options.pages.length) { + options.pages = [ + { + path: '/', + }, + ] + } + + const serverEnv = builder.environments['server'] + + if (!serverEnv) { + throw new Error(`Vite's "server" environment not found`) + } + + const prerenderOutputDir = path.resolve( + options.root, + '.tanstack-start/build/prerenderer', + ) + + const nodeNitro = await createNitro({ + ...nitro.options._config, + preset: 'nitro-prerender', + logLevel: 0, + output: { + dir: prerenderOutputDir, + serverDir: path.resolve(prerenderOutputDir, 'server'), + publicDir: path.resolve(prerenderOutputDir, 'public'), + }, + }) + + const nodeNitroRollupOptions = getRollupConfig(nodeNitro) + + const build = serverEnv.config.build + + build.outDir = prerenderOutputDir + + build.rollupOptions = { + ...build.rollupOptions, + ...nodeNitroRollupOptions, + output: { + ...build.rollupOptions.output, + ...nodeNitroRollupOptions.output, + sourcemap: undefined, + }, + } + + await buildNitroEnvironment(nodeNitro, () => buildNitro(nodeNitro)) + + // Import renderer entry + const serverFilename = + typeof nodeNitroRollupOptions.output.entryFileNames === 'string' + ? nodeNitroRollupOptions.output.entryFileNames + : 'index.mjs' + + const serverEntrypoint = path.resolve( + path.join(nodeNitro.options.output.serverDir, serverFilename), + ) + + const { closePrerenderer, localFetch } = (await import(serverEntrypoint)) as { + closePrerenderer: () => void + localFetch: $Fetch + } + + try { + // Crawl all pages + const pages = await prerenderPages() + + nitro.logger.info(`Prerendered ${pages.length} pages:`) + pages.forEach((page) => { + nitro.logger.info(`- ${page}`) + }) + + // TODO: Write the prerendered pages to the output directory + } catch (error) { + nitro.logger.error(error) + } finally { + // Ensure server is always closed + // server.process.kill() + closePrerenderer() + } + + function extractLinks(html: string): Array { + const linkRegex = /]+href=["']([^"']+)["'][^>]*>/g + const links: Array = [] + let match + + while ((match = linkRegex.exec(html)) !== null) { + const href = match[1] + if (href && (href.startsWith('/') || href.startsWith('./'))) { + links.push(href) + } + } + + return links + } + + async function prerenderPages() { + const seen = new Set() + const retriesByPath = new Map() + const concurrency = options.prerender?.concurrency ?? os.cpus().length + nitro.logger.info(`Concurrency: ${concurrency}`) + const queue = new Queue({ concurrency }) + + options.pages.forEach((_page) => { + let page = _page as Page + + if (typeof _page === 'string') { + page = { path: _page } + } + + addCrawlPageTask(page) + }) + + await queue.start() + + return Array.from(seen) + + function addCrawlPageTask(page: Page) { + // Was the page already seen? + if (seen.has(page.path)) return + + // Add the page to the seen set + seen.add(page.path) + + if (page.fromCrawl) { + options.pages.push(page) + } + + // If not enabled, skip + if (!(page.prerender?.enabled ?? true)) return + + // If there is a filter link, check if the page should be prerendered + if (options.prerender?.filter && !options.prerender.filter(page)) return + + // Resolve the merged default and page-specific prerender options + const prerenderOptions = { + ...options.prerender, + ...page.prerender, + } + + // Add the task + queue.add(async () => { + nitro.logger.info(`Crawling: ${page.path}`) + const retries = retriesByPath.get(page.path) || 0 + try { + // Fetch the route + const encodedRoute = encodeURI(page.path) + + const res = await localFetch( + withBase(encodedRoute, nodeNitro.options.baseURL), + { + headers: { 'x-nitro-prerender': encodedRoute }, + }, + ) + + if (!res.ok) { + throw new Error(`Failed to fetch ${page.path}: ${res.statusText}`) + } + + // Guess route type and populate fileName + const contentType = res.headers.get('content-type') || '' + const isImplicitHTML = + !page.path.endsWith('.html') && contentType.includes('html') + // && + // !JsonSigRx.test(dataBuff.subarray(0, 32).toString('utf8')) + const routeWithIndex = page.path.endsWith('/') + ? page.path + 'index' + : page.path + + const htmlPath = + page.path.endsWith('/') || prerenderOptions.autoSubfolderIndex + ? joinURL(page.path, 'index.html') + : page.path + '.html' + + const filename = withoutBase( + isImplicitHTML ? htmlPath : routeWithIndex, + nitro.options.baseURL, + ) + + const html = await res.text() + + const filepath = path.join(nitro.options.output.publicDir, filename) + + await fsp.mkdir(path.dirname(filepath), { + recursive: true, + }) + + await fsp.writeFile(filepath, html) + + const newPage = await prerenderOptions.onSuccess?.({ page, html }) + + if (newPage) { + Object.assign(page, newPage) + } + + // Find new links + if (prerenderOptions.crawlLinks ?? true) { + const links = extractLinks(html) + for (const link of links) { + addCrawlPageTask({ path: link, fromCrawl: true }) + } + } + } catch (error) { + if (retries < (prerenderOptions.retryCount ?? 0)) { + nitro.logger.warn( + `Encountered error, retrying: ${page.path} in 500ms`, + ) + await new Promise((resolve) => + setTimeout(resolve, prerenderOptions.retryDelay), + ) + retriesByPath.set(page.path, retries + 1) + addCrawlPageTask(page) + } else { + throw error + } + } + }) + } + } +} diff --git a/packages/start-plugin-core/src/queue.ts b/packages/start-plugin-core/src/queue.ts new file mode 100644 index 0000000000..279146fdb2 --- /dev/null +++ b/packages/start-plugin-core/src/queue.ts @@ -0,0 +1,153 @@ +interface PoolConfig { + concurrency?: number + started?: boolean + tasks?: Array<() => Promise> +} + +const defaultConfig: PoolConfig = { + concurrency: 5, + started: false, + tasks: [], +} + +export class Queue { + private onSettles: Array<(res: any, error: any) => void> = [] + private onErrors: Array<(error: any, task: () => Promise) => void> = [] + private onSuccesses: Array<(result: any, task: () => Promise) => void> = + [] + private running: boolean + private active: Array<() => Promise> = [] + private pending: Array<() => Promise> + private currentConcurrency: number + + constructor(config: PoolConfig = defaultConfig) { + const { concurrency, started, tasks } = { + ...defaultConfig, + ...config, + } + this.running = started! + this.pending = tasks as Array<() => Promise> + this.currentConcurrency = concurrency! + } + + private tick() { + if (!this.running) { + return + } + while ( + this.active.length < this.currentConcurrency && + this.pending.length + ) { + const nextFn = this.pending.shift() + if (!nextFn) { + throw new Error('Found task that is not a function') + } + this.active.push(nextFn) + ;(async () => { + let success = false + let res!: T + let error: any + try { + res = await nextFn() + success = true + } catch (e) { + error = e + } + this.active = this.active.filter((d) => d !== nextFn) + if (success) { + this.onSuccesses.forEach((d) => d(res, nextFn)) + } else { + this.onErrors.forEach((d) => d(error, nextFn)) + } + this.onSettles.forEach((d) => d(res, error)) + this.tick() + })() + } + } + + add(fn: () => Promise | T, { priority }: { priority?: boolean } = {}) { + return new Promise((resolve, reject) => { + const task = () => + Promise.resolve(fn()) + .then((res) => { + resolve(res) + return res + }) + .catch((err) => { + reject(err) + throw err + }) + if (priority) { + this.pending.unshift(task) + } else { + this.pending.push(task) + } + this.tick() + }) + } + + throttle(n: number) { + this.currentConcurrency = n + } + + onSettled(cb: () => void) { + this.onSettles.push(cb) + return () => { + this.onSettles = this.onSettles.filter((d) => d !== cb) + } + } + + onError(cb: (error: any, task: () => Promise) => void) { + this.onErrors.push(cb) + return () => { + this.onErrors = this.onErrors.filter((d) => d !== cb) + } + } + + onSuccess(cb: (result: any, task: () => Promise) => void) { + this.onSuccesses.push(cb) + return () => { + this.onSuccesses = this.onSuccesses.filter((d) => d !== cb) + } + } + + stop() { + this.running = false + } + + start() { + this.running = true + this.tick() + return new Promise((resolve) => { + this.onSettled(() => { + if (this.isSettled()) { + resolve() + } + }) + }) + } + + clear() { + this.pending = [] + } + + getActive() { + return this.active + } + + getPending() { + return this.pending + } + + getAll() { + return [...this.active, ...this.pending] + } + + isRunning() { + return this.running + } + + isSettled() { + return !this.active.length && !this.pending.length + } +} diff --git a/packages/start-plugin-core/src/routesManifestPlugin.ts b/packages/start-plugin-core/src/routesManifestPlugin.ts new file mode 100644 index 0000000000..e323dc792d --- /dev/null +++ b/packages/start-plugin-core/src/routesManifestPlugin.ts @@ -0,0 +1,216 @@ +import { readFileSync } from 'node:fs' +import path from 'node:path' +import { joinURL } from 'ufo' +import { rootRouteId } from '@tanstack/router-core' +import type { + PluginOption, + ResolvedConfig, + Manifest as ViteManifest, + ManifestChunk as ViteManifestChunk, +} from 'vite' +import type { Manifest, RouterManagedTag } from '@tanstack/router-core' +import type { TanStackStartOutputConfig } from './plugin' + +export function startManifestPlugin( + opts: TanStackStartOutputConfig, +): PluginOption { + let config: ResolvedConfig + + return { + name: 'tsr-routes-manifest', + enforce: 'pre', + + configResolved(resolvedConfig) { + config = resolvedConfig + }, + // configEnvironment(env, envConfig) { + // config = envConfig. + // }, + resolveId(id) { + if (id === 'tanstack:start-manifest') { + return id + } + return + }, + load(id) { + if (id === 'tanstack:start-manifest') { + if (this.environment.config.consumer !== 'server') { + // this will ultimately fail the build if the plugin is used outside the server environment + // TODO: do we need special handling for `serve`? + return `export default {}` + } + // If we're in development, return a dummy manifest + + if (config.command === 'serve') { + return `export const tsrStartManifest = () => ({ + entry: "$${process.env.TSS_CLIENT_BASE}/", + routes: {} + })` + } + + const clientViteManifestPath = path.resolve( + opts.root, + '.tanstack-start/build/client-dist/.vite/manifest.json', + ) + + let viteManifest: ViteManifest + try { + viteManifest = JSON.parse( + readFileSync(clientViteManifestPath, 'utf-8'), + ) + } catch (err) { + console.error(err) + throw new Error( + `Could not find the production client vite manifest at '${clientViteManifestPath}'!`, + ) + } + + const routeTreePath = path.resolve(opts.tsr.generatedRouteTree) + + let routeTreeContent: string + try { + routeTreeContent = readFileSync(routeTreePath, 'utf-8') + } catch (err) { + console.error(err) + throw new Error( + `Could not find the generated route tree at '${routeTreePath}'!`, + ) + } + + // Extract the routesManifest JSON from the route tree file. + // It's located between the /* ROUTE_MANIFEST_START and ROUTE_MANIFEST_END */ comment block. + + const routerManifest = JSON.parse( + routeTreeContent.match( + /\/\* ROUTE_MANIFEST_START([\s\S]*?)ROUTE_MANIFEST_END \*\//, + )?.[1] || '{ routes: {} }', + ) as Manifest + + const routes = routerManifest.routes + + let entryFile: ViteManifestChunk | undefined + + const filesByRouteFilePath: ViteManifest = Object.fromEntries( + Object.entries(viteManifest).map(([k, v]) => { + if (v.isEntry) { + entryFile = v + } + + const rPath = k.split('?')[0] + + return [rPath, v] + }, {}), + ) + + const routesDirectoryFromRoot = path.relative( + opts.root, + opts.tsr.routesDirectory, + ) + + // Add preloads to the routes from the vite manifest + Object.entries(routes).forEach(([k, v]) => { + const file = + filesByRouteFilePath[ + path.join(routesDirectoryFromRoot, v.filePath as string) + ] + + if (file) { + const preloads = (file.imports ?? []).map((d) => + path.join('/', viteManifest[d]!.file), + ) + + if (file.file) { + preloads.unshift(path.join('/', file.file)) + } + + const cssFiles = file.css ?? [] + const cssAssetsList: Array = cssFiles.map( + (cssFile) => ({ + tag: 'link', + attrs: { + rel: 'stylesheet', + href: joinURL('/', cssFile), + type: 'text/css', + }, + }), + ) + + routes[k] = { + ...v, + assets: [...(v.assets || []), ...cssAssetsList], + preloads, + } + } + }) + + if (entryFile) { + routes[rootRouteId]!.preloads = [ + path.join('/', entryFile.file), + ...(entryFile.imports?.map((d) => + path.join('/', viteManifest[d]!.file), + ) || []), + ] + + // Gather all the CSS files from the entry file in + // the `css` key and add them to the root route + const entryCssFiles = entryFile.css ?? [] + const entryCssAssetsList: Array = entryCssFiles.map( + (cssFile) => ({ + tag: 'link', + attrs: { + rel: 'stylesheet', + href: joinURL('/', cssFile), + type: 'text/css', + }, + }), + ) + + routes[rootRouteId]!.assets = [ + ...(routes[rootRouteId]!.assets || []), + ...entryCssAssetsList, + { + tag: 'script', + attrs: { + src: joinURL('/', entryFile.file), + type: 'module', + }, + }, + ] + } + + const recurseRoute = ( + route: { + preloads?: Array + children?: Array + }, + seenPreloads = {} as Record, + ) => { + route.preloads = route.preloads?.filter((preload) => { + if (seenPreloads[preload]) { + return false + } + seenPreloads[preload] = true + return true + }) + + if (route.children) { + route.children.forEach((child) => { + const childRoute = routes[child]! + recurseRoute(childRoute, { ...seenPreloads }) + }) + } + } + + // @ts-expect-error + recurseRoute(routes[rootRouteId]) + + const routesManifest = { + routes, + } + + return `export const tsrStartManifest = () => (${JSON.stringify(routesManifest)})` + } + return + }, + } +} diff --git a/packages/start-plugin-core/src/schema.ts b/packages/start-plugin-core/src/schema.ts new file mode 100644 index 0000000000..b2f135d0c7 --- /dev/null +++ b/packages/start-plugin-core/src/schema.ts @@ -0,0 +1,193 @@ +import path from 'node:path' +import { existsSync } from 'node:fs' +import { z } from 'zod' +import { configSchema, getConfig } from '@tanstack/router-generator' +import type { NitroConfig } from 'nitropack' + +const tsrConfig = configSchema.partial().extend({ + srcDirectory: z.string().optional().default('src'), +}) + +export function createTanStackConfig< + TFrameworkPlugin extends Record, +>(frameworkPlugin?: TFrameworkPlugin) { + const schema = createTanStackStartOptionsSchema(frameworkPlugin) + + return { + schema, + parse: (opts?: z.input) => { + const options = schema.parse(opts) + + const srcDirectory = options.tsr.srcDirectory + + const routesDirectory = + options.tsr.routesDirectory ?? path.join(srcDirectory, 'routes') + + const generatedRouteTree = + options.tsr.generatedRouteTree ?? + path.join(srcDirectory, 'routeTree.gen.ts') + + const clientEntryPath = (() => { + if (options.client.entry) { + return path.join(srcDirectory, options.client.entry) + } + + if (existsSync(path.join(srcDirectory, 'client.tsx'))) { + return path.join(srcDirectory, 'client.tsx') + } + + return '/~start/default-client-entry' + })() + + const serverEntryPath = (() => { + if (options.server.entry) { + return path.join(srcDirectory, options.server.entry) + } + + if (existsSync(path.join(srcDirectory, 'server.tsx'))) { + return path.join(srcDirectory, 'server.tsx') + } + + return '/~start/default-server-entry' + })() + + return { + ...options, + tsr: { + ...options.tsr, + ...getConfig({ + ...options.tsr, + routesDirectory, + generatedRouteTree, + }), + }, + clientEntryPath, + serverEntryPath, + } + }, + } +} + +export function createTanStackStartOptionsSchema( + frameworkPlugin: Record = {}, +) { + return z + .object({ + root: z.string().optional().default(process.cwd()), + target: z.custom().optional(), + ...frameworkPlugin, + tsr: tsrConfig.optional().default({}), + client: z + .object({ + entry: z.string().optional(), + base: z.string().optional().default('/_build'), + }) + .optional() + .default({}), + server: z + .object({ + entry: z.string().optional(), + }) + .optional() + .default({}), + serverFns: z + .object({ + base: z.string().optional().default('/_server'), + }) + .optional() + .default({}), + public: z + .object({ + dir: z.string().optional().default('public'), + base: z.string().optional().default('/'), + }) + .optional() + .default({}), + pages: z + .array(z.union([z.string(), pageSchema])) + .optional() + .default([]), + sitemap: pagePrerenderOptionsSchema + .extend({ + host: z.string().optional(), + }) + .optional(), + prerender: z + .object({ + enabled: z.boolean().optional(), + concurrency: z.number().optional(), + filter: z.function().args(pageSchema).returns(z.any()).optional(), + failOnError: z.boolean().optional(), + }) + .and(pagePrerenderOptionsSchema.optional()) + .optional(), + }) + .optional() + .default({}) +} + +const pageSitemapOptionsSchema = z.object({ + exclude: z.boolean().optional(), + priority: z.number().min(0).max(1).optional(), + changefreq: z + .enum(['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never']) + .optional(), + lastmod: z.union([z.string(), z.date()]).optional(), + alternateRefs: z + .array( + z.object({ + href: z.string(), + hreflang: z.string(), + }), + ) + .optional(), + images: z + .array( + z.object({ + loc: z.string(), + caption: z.string().optional(), + title: z.string().optional(), + }), + ) + .optional(), + news: z + .object({ + publication: z.object({ + name: z.string(), + language: z.string(), + }), + publicationDate: z.union([z.string(), z.date()]), + title: z.string(), + }) + .optional(), +}) + +const pageBaseSchema = z.object({ + path: z.string(), + sitemap: pageSitemapOptionsSchema.optional(), + fromCrawl: z.boolean().optional(), +}) + +const pagePrerenderOptionsSchema = z.object({ + enabled: z.boolean().optional(), + autoSubfolderIndex: z.boolean().optional(), + crawlLinks: z.boolean().optional(), + retryCount: z.number().optional(), + retryDelay: z.number().optional(), + onSuccess: z + .function() + .args( + z.object({ + page: pageBaseSchema, + html: z.string(), + }), + ) + .returns(z.any()) + .optional(), +}) + +export const pageSchema = pageBaseSchema.extend({ + prerender: pagePrerenderOptionsSchema.optional(), +}) + +export type Page = z.infer diff --git a/packages/start-plugin-core/src/start-compiler-plugin.ts b/packages/start-plugin-core/src/start-compiler-plugin.ts new file mode 100644 index 0000000000..e381536c4b --- /dev/null +++ b/packages/start-plugin-core/src/start-compiler-plugin.ts @@ -0,0 +1,111 @@ +import { fileURLToPath, pathToFileURL } from 'node:url' +import { logDiff } from '@tanstack/router-utils' + +import { compileStartOutputFactory } from './compilers' +import type { Plugin } from 'vite' +import type { CompileStartFrameworkOptions } from './compilers' + +const debug = + process.env.TSR_VITE_DEBUG && + ['true', 'start-plugin'].includes(process.env.TSR_VITE_DEBUG) + +export type TanStackStartViteOptions = { + globalMiddlewareEntry: string +} + +const transformFuncs = [ + 'createServerFn', + 'createMiddleware', + 'serverOnly', + 'clientOnly', + 'createIsomorphicFn', + 'createServerFileRoute', +] + +const tokenRegex = new RegExp(transformFuncs.join('|')) + +export function TanStackStartCompilerPlugin( + framework: CompileStartFrameworkOptions, + inputOpts?: { + client?: { + envName?: string + } + server?: { + envName?: string + } + }, +): Plugin { + const opts = { + client: { + envName: 'client', + ...inputOpts?.client, + }, + server: { + envName: 'server', + ...inputOpts?.server, + }, + } + + return { + name: 'vite-plugin-tanstack-start-create-server-fn', + enforce: 'pre', + applyToEnvironment(env) { + return [opts.client.envName, opts.server.envName].includes(env.name) + }, + transform(code, id) { + const env = + this.environment.name === opts.client.envName + ? 'client' + : this.environment.name === opts.server.envName + ? 'server' + : (() => { + throw new Error( + `Environment ${this.environment.name} not configured`, + ) + })() + + return transformCode({ + code, + id, + env, + framework, + }) + }, + } +} + +function transformCode(opts: { + code: string + id: string + env: 'server' | 'client' + framework: CompileStartFrameworkOptions +}) { + const { code, env, framework } = opts + let { id } = opts + + const url = pathToFileURL(id) + url.searchParams.delete('v') + id = fileURLToPath(url).replace(/\\/g, '/') + + const includesToken = tokenRegex.test(code) + + if (!includesToken) { + return null + } + + if (debug) console.info(`${env} Compiling Start: `, id) + + const compileStartOutput = compileStartOutputFactory(framework) + const compiled = compileStartOutput({ + code, + filename: id, + env, + }) + + if (debug) { + logDiff(code, compiled.code) + console.log('Output:\n', compiled.code + '\n\n') + } + + return compiled +} diff --git a/packages/start-plugin-core/src/start-server-routes-plugin/config.ts b/packages/start-plugin-core/src/start-server-routes-plugin/config.ts new file mode 100644 index 0000000000..59b34eb6bd --- /dev/null +++ b/packages/start-plugin-core/src/start-server-routes-plugin/config.ts @@ -0,0 +1,6 @@ +import { baseConfigSchema } from '@tanstack/router-generator' +import type { z } from 'zod' + +export const configSchema = baseConfigSchema.extend({}) + +export type Config = z.infer diff --git a/packages/start-plugin-core/src/start-server-routes-plugin/plugin.ts b/packages/start-plugin-core/src/start-server-routes-plugin/plugin.ts new file mode 100644 index 0000000000..b3011e0fa0 --- /dev/null +++ b/packages/start-plugin-core/src/start-server-routes-plugin/plugin.ts @@ -0,0 +1,841 @@ +import path, { isAbsolute, join, normalize } from 'node:path' +import fs from 'node:fs' +import fsp from 'node:fs/promises' +import { + format, + logging, + multiSortBy, + physicalGetRouteNodes, + removeExt, + removeUnderscores, + replaceBackslash, + resetRegex, + rootPathId, + routePathToVariable, + trimPathLeft, + virtualGetRouteNodes, + writeIfDifferent, +} from '@tanstack/router-generator' +import { rootRouteId } from '@tanstack/router-core' +import { fillTemplate, getTargetTemplate } from './template' +import type { GetRouteNodesResult, RouteNode } from '@tanstack/router-generator' +import type { Config } from './config' +import type { Plugin } from 'vite' + +let lock = false +const checkLock = () => lock +const setLock = (bool: boolean) => { + lock = bool +} + +export function TanStackStartServerRoutesVite(config: Config): Plugin { + let ROOT: string = process.cwd() + + const getRoutesDirectoryPath = () => { + return isAbsolute(config.routesDirectory) + ? config.routesDirectory + : join(ROOT, config.routesDirectory) + } + + const generate = async () => { + if (checkLock()) { + return + } + + setLock(true) + + try { + await generator(config, ROOT) + } catch (err) { + console.error(err) + console.info() + } finally { + setLock(false) + } + } + + const handleFile = async (file: string) => { + const filePath = normalize(file) + + const routesDirectoryPath = getRoutesDirectoryPath() + if (filePath.startsWith(routesDirectoryPath)) { + await generate() + } + } + + return { + name: 'tanstack-start-server-routes-plugin', + configureServer(server) { + server.watcher.on('all', (event, path) => { + handleFile(path) + }) + }, + configResolved(config) { + ROOT = config.root + }, + async buildStart() { + await generate() + // if (this.environment.name === 'server') { + // } + }, + sharedDuringBuild: true, + resolveId(id) { + if (id === 'tanstack:server-routes') { + const generatedRouteTreePath = getGeneratedRouteTreePath(ROOT) + return generatedRouteTreePath + } + return null + }, + } +} + +// Maybe import this from `@tanstack/router-core` in the future??? +let latestTask = 0 +const routeGroupPatternRegex = /\(.+\)/g +const possiblyNestedRouteGroupPatternRegex = /\([^/]+\)\/?/g + +let isFirst = false +let skipMessage = false + +function getGeneratedRouteTreePath(root: string) { + return path.resolve(root, '.tanstack-start/server-routes/routeTree.gen.ts') +} + +async function generator(config: Config, root: string) { + const generatedRouteTreePath = getGeneratedRouteTreePath(root) + const ROUTE_TEMPLATE = getTargetTemplate(config.target) + const logger = logging({ disabled: config.disableLogging }) + + if (!isFirst) { + // logger.log('♻️ Generating server routes...') + isFirst = true + } else if (skipMessage) { + skipMessage = false + } else { + // logger.log('♻️ Regenerating server routes...') + } + + const taskId = latestTask + 1 + latestTask = taskId + + const checkLatest = () => { + if (latestTask !== taskId) { + skipMessage = true + return false + } + + return true + } + + const start = Date.now() + + let getRouteNodesResult: GetRouteNodesResult + + if (config.virtualRouteConfig) { + getRouteNodesResult = await virtualGetRouteNodes(config, root) + } else { + getRouteNodesResult = await physicalGetRouteNodes(config, root) + } + + const { rootRouteNode, routeNodes: beforeRouteNodes } = getRouteNodesResult + if (rootRouteNode === undefined) { + let errorMessage = `rootRouteNode must not be undefined. Make sure you've added your root route into the route-tree.` + if (!config.virtualRouteConfig) { + errorMessage += `\nMake sure that you add a "${rootPathId}.tsx" file to your routes directory.\nAdd the file in: "${config.routesDirectory}/${rootPathId}.tsx"` + } + throw new Error(errorMessage) + } + + const preRouteNodes = multiSortBy(beforeRouteNodes, [ + (d) => (d.routePath === '/' ? -1 : 1), + (d) => d.routePath?.split('/').length, + (d) => + d.filePath.match(new RegExp(`[./]${config.indexToken}[.]`)) ? 1 : -1, + (d) => + d.filePath.match( + /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/, + ) + ? 1 + : -1, + (d) => + d.filePath.match(new RegExp(`[./]${config.routeToken}[.]`)) ? -1 : 1, + (d) => (d.routePath?.endsWith('/') ? -1 : 1), + (d) => d.routePath, + ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || '')) + + const routeTree: Array = [] + + // Loop over the flat list of routeNodes and + // build up a tree based on the routeNodes' routePath + const routeNodes: Array = [] + + // the handleRootNode function is not being collapsed into the handleNode function + // because it requires only a subset of the logic that the handleNode function requires + // and it's easier to read and maintain this way + const handleRootNode = async (node?: RouteNode) => { + if (!node) { + // currently this is not being handled, but it could be in the future + // for example to handle a virtual root route + return + } + + // from here on, we are only handling the root node that's present in the file system + const routeCode = fs.readFileSync(node.fullPath, 'utf-8') + + if (!routeCode) { + const _rootTemplate = ROUTE_TEMPLATE.rootRoute + const replaced = await fillTemplate(config, _rootTemplate.template(), { + tsrImports: _rootTemplate.imports.tsrImports(), + tsrPath: rootPathId, + tsrExportStart: _rootTemplate.imports.tsrExportStart(), + tsrExportEnd: _rootTemplate.imports.tsrExportEnd(), + }) + + await writeIfDifferent( + node.fullPath, + '', // Empty string because the file doesn't exist yet + replaced, + { + beforeWrite: () => { + // logger.log(`🟡 Creating ${node.fullPath}`) + }, + }, + ) + } + } + + await handleRootNode(rootRouteNode) + + const handleNode = async (node: RouteNode) => { + // Do not remove this as we need to set the lastIndex to 0 as it + // is necessary to reset the regex's index when using the global flag + // otherwise it might not match the next time it's used + resetRegex(routeGroupPatternRegex) + + let parentRoute = hasParentRoute(routeNodes, node, node.routePath) + + // if the parent route is a virtual parent route, we need to find the real parent route + if (parentRoute?.isVirtualParentRoute && parentRoute.children?.length) { + // only if this sub-parent route returns a valid parent route, we use it, if not leave it as it + const possibleParentRoute = hasParentRoute( + parentRoute.children, + node, + node.routePath, + ) + if (possibleParentRoute) { + parentRoute = possibleParentRoute + } + } + + if (parentRoute) node.parent = parentRoute + + node.path = determineNodePath(node) + + const trimmedPath = trimPathLeft(node.path ?? '') + + const split = trimmedPath.split('/') + const lastRouteSegment = split[split.length - 1] ?? trimmedPath + + node.isNonPath = + lastRouteSegment.startsWith('_') || + routeGroupPatternRegex.test(lastRouteSegment) + + node.cleanedPath = removeGroups( + removeUnderscores(removeLayoutSegments(node.path)) ?? '', + ) + + const routeCode = fs.readFileSync(node.fullPath, 'utf-8') + + // Ensure the boilerplate for the route exists, which can be skipped for virtual parent routes and virtual routes + if (!node.isVirtualParentRoute && !node.isVirtual) { + // const escapedRoutePath = node.routePath?.replaceAll('$', '$$') ?? '' + // let replaced = routeCode + // await writeIfDifferent(node.fullPath, routeCode, replaced, { + // beforeWrite: () => { + // // logger.log(`🟡 Updating ${node.fullPath}`) + // }, + // }) + } + + const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0 + const nonPathRoute = + node._fsRouteType === 'pathless_layout' && node.isNonPath + + node.isVirtualParentRequired = + node._fsRouteType === 'pathless_layout' || nonPathRoute + ? !cleanedPathIsEmpty + : false + + if (!node.isVirtual && node.isVirtualParentRequired) { + const parentRoutePath = removeLastSegmentFromPath(node.routePath) || '/' + const parentVariableName = routePathToVariable(parentRoutePath) + + const anchorRoute = routeNodes.find( + (d) => d.routePath === parentRoutePath, + ) + + if (!anchorRoute) { + const parentNode: RouteNode = { + ...node, + path: removeLastSegmentFromPath(node.path) || '/', + filePath: removeLastSegmentFromPath(node.filePath) || '/', + fullPath: removeLastSegmentFromPath(node.fullPath) || '/', + routePath: parentRoutePath, + variableName: parentVariableName, + isVirtual: true, + _fsRouteType: 'layout', // layout since this route will wrap other routes + isVirtualParentRoute: true, + isVirtualParentRequired: false, + } + + parentNode.children = parentNode.children ?? [] + parentNode.children.push(node) + + node.parent = parentNode + + if (node._fsRouteType === 'pathless_layout') { + // since `node.path` is used as the `id` on the route definition, we need to update it + node.path = determineNodePath(node) + } + + await handleNode(parentNode) + } else { + anchorRoute.children = anchorRoute.children ?? [] + anchorRoute.children.push(node) + + node.parent = anchorRoute + } + } + + if ( + !routeCode + .split('\n') + .some((line) => line.trim().startsWith('export const ServerRoute')) + ) { + return + } + + if (node.parent) { + if (!node.isVirtualParentRequired) { + node.parent.children = node.parent.children ?? [] + node.parent.children.push(node) + } + } else { + routeTree.push(node) + } + + routeNodes.push(node) + } + + for (const node of preRouteNodes) { + await handleNode(node) + } + + // This is run against the `routeNodes` array since it + // has the accumulated (intended) Server Route nodes + // Since TSR allows multiple way of defining a route, + // we need to ensure that a user hasn't defined the + // same route in multiple ways (i.e. `flat`, `nested`, `virtual`) + checkRouteFullPathUniqueness(routeNodes, config) + + function buildRouteTreeConfig(nodes: Array, depth = 1): string { + const children = nodes.map((node) => { + if (node._fsRouteType === '__root') { + return + } + + if (node._fsRouteType === 'pathless_layout' && !node.children?.length) { + return + } + + const route = `${node.variableName}Route` + + if (node.children?.length) { + const childConfigs = buildRouteTreeConfig(node.children, depth + 1) + + const childrenDeclaration = `interface ${route}Children { + ${node.children.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')} +}` + + const children = `const ${route}Children: ${route}Children = { + ${node.children.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')} +}` + + const routeWithChildren = `const ${route}WithChildren = ${route}._addFileChildren(${route}Children)` + + return [ + childConfigs, + childrenDeclaration, + children, + routeWithChildren, + ].join('\n\n') + } + + return undefined + }) + + return children.filter(Boolean).join('\n\n') + } + + const routeConfigChildrenText = buildRouteTreeConfig(routeTree) + + const sortedRouteNodes = multiSortBy(routeNodes, [ + (d) => (d.routePath?.includes(`/${rootPathId}`) ? -1 : 1), + (d) => d.routePath?.split('/').length, + (d) => (d.routePath?.endsWith(config.indexToken) ? -1 : 1), + (d) => d, + ]) + + const imports = Object.entries({ + createFileRoute: sortedRouteNodes.some((d) => d.isVirtual), + }) + .filter((d) => d[1]) + .map((d) => d[0]) + + const virtualRouteNodes = sortedRouteNodes.filter((d) => d.isVirtual) + + function getImportPath(node: RouteNode) { + return replaceBackslash( + removeExt( + path.relative( + path.dirname(generatedRouteTreePath), + path.resolve(config.routesDirectory, node.filePath), + ), + ), + ) + } + + const rootRouteExists = fs.existsSync(rootRouteNode.fullPath) + const rootRouteCode = rootRouteExists + ? fs.readFileSync(rootRouteNode.fullPath, 'utf-8') + : '' + const hasServerRootRoute = + rootRouteExists && rootRouteCode.includes('export const ServerRoute') + + const routeImports = [ + ...config.routeTreeFileHeader, + `// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.`, + imports.length + ? `import { ${imports.join(', ')} } from '${ROUTE_TEMPLATE.fullPkg}'\n` + : '', + '// Import Routes', + [ + `import type { FileRoutesByPath, CreateServerFileRoute } from '${ROUTE_TEMPLATE.fullPkg}'`, + `import { createServerRoute, createServerFileRoute } from '${ROUTE_TEMPLATE.fullPkg}'`, + // ` + // if (typeof globalThis !== 'undefined') { + // ;(globalThis as any).createServerFileRoute = createServerFileRoute + // } else if (typeof window !== 'undefined') { + // ;(window as any).createServerFileRoute = createServerFileRoute + // }`, + hasServerRootRoute + ? `import { ServerRoute as rootRouteImport } from './${getImportPath(rootRouteNode)}'` + : '', + ...sortedRouteNodes + .filter((d) => !d.isVirtual) + .map((node) => { + return `import { ServerRoute as ${ + node.variableName + }RouteImport } from './${getImportPath(node)}'` + }), + ].join('\n'), + virtualRouteNodes.length ? '// Create Virtual Routes' : '', + virtualRouteNodes + .map((node) => { + return `const ${ + node.variableName + }RouteImport = createFileRoute('${node.routePath}')()` + }) + .join('\n'), + '// Create/Update Routes', + !hasServerRootRoute + ? ` + const rootRoute = createServerRoute() + ` + : '', + sortedRouteNodes + .map((node) => { + return [ + [ + `const ${node.variableName}Route = ${node.variableName}RouteImport.update({ + ${[ + `id: '${node.path}'`, + !node.isNonPath ? `path: '${node.cleanedPath}'` : undefined, + `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`, + ] + .filter(Boolean) + .join(',')} + } as any)`, + ].join(''), + ].join('\n\n') + }) + .join('\n\n'), + '', + + '// Populate the FileRoutesByPath interface', + `declare module '${ROUTE_TEMPLATE.fullPkg}' { + interface FileRoutesByPath { + ${routeNodes + .map((routeNode) => { + const filePathId = routeNode.routePath + + return `'${filePathId}': { + id: '${filePathId}' + path: '${inferPath(routeNode)}' + fullPath: '${inferFullPath(routeNode)}' + preLoaderRoute: typeof ${routeNode.variableName}RouteImport + parentRoute: typeof ${ + routeNode.isVirtualParentRequired + ? `${routeNode.parent?.variableName}Route` + : routeNode.parent?.variableName + ? `${routeNode.parent.variableName}RouteImport` + : 'rootRoute' + } + }` + }) + .join('\n')} + } +}`, + `// Add type-safety to the createFileRoute function across the route tree`, + routeNodes + .map((routeNode) => { + return `declare module './${getImportPath(routeNode)}' { +const createServerFileRoute: CreateServerFileRoute< +FileRoutesByPath['${routeNode.routePath}']['parentRoute'], +FileRoutesByPath['${routeNode.routePath}']['id'], +FileRoutesByPath['${routeNode.routePath}']['path'], +FileRoutesByPath['${routeNode.routePath}']['fullPath'], +${routeNode.children?.length ? `${routeNode.variableName}RouteChildren` : 'unknown'} +> +}` + }) + .join('\n'), + '// Create and export the route tree', + routeConfigChildrenText, + `export interface FileRoutesByFullPath { + ${[...createRouteNodesByFullPath(routeNodes).entries()].map( + ([fullPath, routeNode]) => { + return `'${fullPath}': typeof ${getResolvedRouteNodeVariableName(routeNode)}` + }, + )} +}`, + `export interface FileRoutesByTo { + ${[...createRouteNodesByTo(routeNodes).entries()].map(([to, routeNode]) => { + return `'${to}': typeof ${getResolvedRouteNodeVariableName(routeNode)}` + })} +}`, + `export interface FileRoutesById { + '${rootRouteId}': typeof rootRoute, + ${[...createRouteNodesById(routeNodes).entries()].map(([id, routeNode]) => { + return `'${id}': typeof ${getResolvedRouteNodeVariableName(routeNode)}` + })} +}`, + `export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: ${routeNodes.length > 0 ? [...createRouteNodesByFullPath(routeNodes).keys()].map((fullPath) => `'${fullPath}'`).join('|') : 'never'} + fileRoutesByTo: FileRoutesByTo + to: ${routeNodes.length > 0 ? [...createRouteNodesByTo(routeNodes).keys()].map((to) => `'${to}'`).join('|') : 'never'} + id: ${[`'${rootRouteId}'`, ...[...createRouteNodesById(routeNodes).keys()].map((id) => `'${id}'`)].join('|')} + fileRoutesById: FileRoutesById +}`, + `export interface RootRouteChildren { + ${routeTree.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')} +}`, + `const rootRouteChildren: RootRouteChildren = { + ${routeTree.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')} +}`, + `export const routeTree = rootRoute._addFileChildren(rootRouteChildren)._addFileTypes()`, + ] + .filter(Boolean) + .join('\n\n') + + const createRouteManifest = () => { + const routesManifest = { + [rootRouteId]: { + filePath: rootRouteNode.filePath, + children: routeTree.map((d) => d.routePath), + }, + ...Object.fromEntries( + routeNodes.map((d) => { + const filePathId = d.routePath + + return [ + filePathId, + { + filePath: d.filePath, + parent: d.parent?.routePath ? d.parent.routePath : undefined, + children: d.children?.map((childRoute) => childRoute.routePath), + }, + ] + }), + ), + } + + return JSON.stringify( + { + routes: routesManifest, + }, + null, + 2, + ) + } + + const includeManifest = ['react', 'solid'] + const routeConfigFileContent = !includeManifest.includes(config.target) + ? routeImports + : [ + routeImports, + '\n', + '/* ROUTE_MANIFEST_START', + createRouteManifest(), + 'ROUTE_MANIFEST_END */', + ].join('\n') + + if (!checkLatest()) return + + const existingRouteTreeContent = await fsp + .readFile(path.resolve(generatedRouteTreePath), 'utf-8') + .catch((err) => { + if (err.code === 'ENOENT') { + return '' + } + + throw err + }) + + if (!checkLatest()) return + + // Ensure the directory exists + await fsp.mkdir(path.dirname(path.resolve(generatedRouteTreePath)), { + recursive: true, + }) + + if (!checkLatest()) return + + // Write the route tree file, if it has changed + const routeTreeWriteResult = await writeIfDifferent( + path.resolve(generatedRouteTreePath), + await format(existingRouteTreeContent, config), + await format(routeConfigFileContent, config), + { + beforeWrite: () => { + // logger.log(`🟡 Updating ${generatedRouteTreePath}`) + }, + }, + ) + if (routeTreeWriteResult && !checkLatest()) { + return + } + + // logger.log( + // `✅ Processed ${routeNodes.length === 1 ? 'server route' : 'server routes'} in ${ + // Date.now() - start + // }ms`, + // ) +} + +function removeGroups(s: string) { + return s.replace(possiblyNestedRouteGroupPatternRegex, '') +} + +/** + * The `node.path` is used as the `id` in the route definition. + * This function checks if the given node has a parent and if so, it determines the correct path for the given node. + * @param node - The node to determine the path for. + * @returns The correct path for the given node. + */ +function determineNodePath(node: RouteNode) { + return (node.path = node.parent + ? node.routePath?.replace(node.parent.routePath ?? '', '') || '/' + : node.routePath) +} + +/** + * Removes the last segment from a given path. Segments are considered to be separated by a '/'. + * + * @param {string} routePath - The path from which to remove the last segment. Defaults to '/'. + * @returns {string} The path with the last segment removed. + * @example + * removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth' + */ +function removeLastSegmentFromPath(routePath: string = '/'): string { + const segments = routePath.split('/') + segments.pop() // Remove the last segment + return segments.join('/') +} + +/** + * Removes all segments from a given path that start with an underscore ('_'). + * + * @param {string} routePath - The path from which to remove segments. Defaults to '/'. + * @returns {string} The path with all underscore-prefixed segments removed. + * @example + * removeLayoutSegments('/workspace/_auth/foo') // '/workspace/foo' + */ +function removeLayoutSegments(routePath: string = '/'): string { + const segments = routePath.split('/') + const newSegments = segments.filter((segment) => !segment.startsWith('_')) + return newSegments.join('/') +} + +function hasParentRoute( + routes: Array, + node: RouteNode, + routePathToCheck: string | undefined, +): RouteNode | null { + if (!routePathToCheck || routePathToCheck === '/') { + return null + } + + const sortedNodes = multiSortBy(routes, [ + (d) => d.routePath!.length * -1, + (d) => d.variableName, + ]).filter((d) => d.routePath !== `/${rootPathId}`) + + for (const route of sortedNodes) { + if (route.routePath === '/') continue + + if ( + routePathToCheck.startsWith(`${route.routePath}/`) && + route.routePath !== routePathToCheck + ) { + return route + } + } + + const segments = routePathToCheck.split('/') + segments.pop() // Remove the last segment + const parentRoutePath = segments.join('/') + + return hasParentRoute(routes, node, parentRoutePath) +} + +/** + * Gets the final variable name for a route + */ +const getResolvedRouteNodeVariableName = (routeNode: RouteNode): string => { + return routeNode.children?.length + ? `${routeNode.variableName}RouteWithChildren` + : `${routeNode.variableName}Route` +} + +/** + * Creates a map from fullPath to routeNode + */ +const createRouteNodesByFullPath = ( + routeNodes: Array, +): Map => { + return new Map( + routeNodes.map((routeNode) => [inferFullPath(routeNode), routeNode]), + ) +} + +/** + * Create a map from 'to' to a routeNode + */ +const createRouteNodesByTo = ( + routeNodes: Array, +): Map => { + return new Map( + dedupeBranchesAndIndexRoutes(routeNodes).map((routeNode) => [ + inferTo(routeNode), + routeNode, + ]), + ) +} + +/** + * Create a map from 'id' to a routeNode + */ +const createRouteNodesById = ( + routeNodes: Array, +): Map => { + return new Map( + routeNodes.map((routeNode) => { + const id = routeNode.routePath ?? '' + return [id, routeNode] + }), + ) +} + +/** + * Infers the full path for use by TS + */ +const inferFullPath = (routeNode: RouteNode): string => { + const fullPath = removeGroups( + removeUnderscores(removeLayoutSegments(routeNode.routePath)) ?? '', + ) + + return routeNode.cleanedPath === '/' ? fullPath : fullPath.replace(/\/$/, '') +} + +/** + * Infers the path for use by TS + */ +const inferPath = (routeNode: RouteNode): string => { + return routeNode.cleanedPath === '/' + ? routeNode.cleanedPath + : (routeNode.cleanedPath?.replace(/\/$/, '') ?? '') +} + +/** + * Infers to path + */ +const inferTo = (routeNode: RouteNode): string => { + const fullPath = inferFullPath(routeNode) + + if (fullPath === '/') return fullPath + + return fullPath.replace(/\/$/, '') +} + +/** + * Dedupes branches and index routes + */ +const dedupeBranchesAndIndexRoutes = ( + routes: Array, +): Array => { + return routes.filter((route) => { + if (route.children?.find((child) => child.cleanedPath === '/')) return false + return true + }) +} + +function checkUnique(routes: Array, key: keyof TElement) { + // Check no two routes have the same `key` + // if they do, throw an error with the conflicting filePaths + const keys = routes.map((d) => d[key]) + const uniqueKeys = new Set(keys) + if (keys.length !== uniqueKeys.size) { + const duplicateKeys = keys.filter((d, i) => keys.indexOf(d) !== i) + const conflictingFiles = routes.filter((d) => + duplicateKeys.includes(d[key]), + ) + return conflictingFiles + } + return undefined +} + +function checkRouteFullPathUniqueness( + _routes: Array, + config: Config, +) { + const routes = _routes.map((d) => { + const inferredFullPath = inferFullPath(d) + return { ...d, inferredFullPath } + }) + + const conflictingFiles = checkUnique(routes, 'inferredFullPath') + + if (conflictingFiles !== undefined) { + const errorMessage = `Conflicting configuration paths were found for the following route${conflictingFiles.length > 1 ? 's' : ''}: ${conflictingFiles + .map((p) => `"${p.inferredFullPath}"`) + .join(', ')}. +Please ensure each Server Route has a unique full path. +Conflicting files: \n ${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join('\n ')}\n` + console.error(errorMessage) + process.exit(1) + } +} diff --git a/packages/start-plugin-core/src/start-server-routes-plugin/template.ts b/packages/start-plugin-core/src/start-server-routes-plugin/template.ts new file mode 100644 index 0000000000..9599efeb2a --- /dev/null +++ b/packages/start-plugin-core/src/start-server-routes-plugin/template.ts @@ -0,0 +1,164 @@ +import { format } from '@tanstack/router-generator' +import type { Config } from './config' + +type TemplateTag = 'tsrImports' | 'tsrPath' | 'tsrExportStart' | 'tsrExportEnd' + +export function fillTemplate( + config: Config, + template: string, + values: Record, +) { + const replaced = template.replace( + /%%(\w+)%%/g, + (_, key) => values[key as TemplateTag] || '', + ) + return format(replaced, config) +} + +type TargetTemplate = { + fullPkg: string + subPkg: string + rootRoute: { + template: () => string + imports: { + tsrImports: () => string + tsrExportStart: () => string + tsrExportEnd: () => string + } + } + route: { + template: () => string + imports: { + tsrImports: () => string + tsrExportStart: (routePath: string) => string + tsrExportEnd: () => string + } + } + lazyRoute: { + template: () => string + imports: { + tsrImports: () => string + tsrExportStart: (routePath: string) => string + tsrExportEnd: () => string + } + } +} + +export function getTargetTemplate(target: Config['target']): TargetTemplate { + switch (target) { + // TODO: Remove this disabled eslint rule when more target types are added. + + case 'react': + return { + fullPkg: '@tanstack/react-start/server', + subPkg: 'react-start/server', + // TODO: Clean this up if it's not used + rootRoute: { + template: () => + [ + 'import * as React from "react"\n', + '%%tsrImports%%', + '\n\n', + '%%tsrExportStart%%{\n component: RootComponent\n }%%tsrExportEnd%%\n\n', + 'function RootComponent() { return (
Hello "%%tsrPath%%"!
) };\n', + ].join(''), + imports: { + tsrImports: () => + "import { Outlet, createRootRoute } from '@tanstack/react-router';", + tsrExportStart: () => 'export const Route = createRootRoute(', + tsrExportEnd: () => ');', + }, + }, + route: { + template: () => + [ + '%%tsrImports%%', + '\n\n', + '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n', + 'function RouteComponent() { return
Hello "%%tsrPath%%"!
};\n', + ].join(''), + imports: { + tsrImports: () => '', + tsrExportStart: () => `export const Route = createFileRoute(`, + tsrExportEnd: () => ');', + }, + }, + lazyRoute: { + template: () => + [ + '%%tsrImports%%', + '\n\n', + '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n', + 'function RouteComponent() { return
Hello "%%tsrPath%%"!
};\n', + ].join(''), + imports: { + tsrImports: () => + "import { createLazyFileRoute } from '@tanstack/react-router';", + tsrExportStart: (routePath) => + `export const Route = createLazyFileRoute('${routePath}')(`, + tsrExportEnd: () => ');', + }, + }, + } + case 'solid': + return { + fullPkg: '@tanstack/solid-start/server', + subPkg: 'solid-start/server', + rootRoute: { + template: () => + [ + 'import * as Solid from "solid-js"\n', + '%%tsrImports%%', + '\n\n', + '%%tsrExportStart%%{\n component: RootComponent\n }%%tsrExportEnd%%\n\n', + 'function RootComponent() { return (<>
Hello "%%tsrPath%%"!
) };\n', + ].join(''), + imports: { + tsrImports: () => + "import { Outlet, createRootRoute } from '@tanstack/solid-router';", + tsrExportStart: () => 'export const Route = createRootRoute(', + tsrExportEnd: () => ');', + }, + }, + route: { + template: () => + [ + '%%tsrImports%%', + '\n\n', + '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n', + 'function RouteComponent() { return
Hello "%%tsrPath%%"!
};\n', + ].join(''), + imports: { + tsrImports: () => '', + tsrExportStart: () => `export const Route = createFileRoute(`, + tsrExportEnd: () => ');', + }, + }, + lazyRoute: { + template: () => + [ + '%%tsrImports%%', + '\n\n', + '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n', + 'function RouteComponent() { return
Hello "%%tsrPath%%"!
};\n', + ].join(''), + imports: { + tsrImports: () => + "import { createLazyFileRoute } from '@tanstack/solid-router';", + tsrExportStart: (routePath) => + `export const Route = createLazyFileRoute('${routePath}')(`, + tsrExportEnd: () => ');', + }, + }, + } + default: + throw new Error(`router-generator: Unknown target type: ${target}`) + } +} + +export const defaultServerRouteTemplate = [ + 'import { json } from "@tanstack/react-start";\n', + '%%tsrImports%%', + '\n\n', + '%%tsrExportStart%%{ GET: ({ request, params }) => { return json({ message:\'Hello "%%tsrPath%%"!\' }) }}%%tsrExportEnd%%\n', +].join('') diff --git a/packages/react-start-plugin/tests/createIsomorphicFn/createIsomorphicFn.test.ts b/packages/start-plugin-core/tests/createIsomorphicFn/createIsomorphicFn.test.ts similarity index 93% rename from packages/react-start-plugin/tests/createIsomorphicFn/createIsomorphicFn.test.ts rename to packages/start-plugin-core/tests/createIsomorphicFn/createIsomorphicFn.test.ts index 32a31d401c..249a3851fc 100644 --- a/packages/react-start-plugin/tests/createIsomorphicFn/createIsomorphicFn.test.ts +++ b/packages/start-plugin-core/tests/createIsomorphicFn/createIsomorphicFn.test.ts @@ -2,7 +2,9 @@ import { readFile, readdir } from 'node:fs/promises' import path from 'node:path' import { afterAll, describe, expect, test, vi } from 'vitest' -import { compileStartOutput } from '../../src/compilers' +import { compileStartOutputFactory } from '../../src/compilers' + +const compileStartOutput = compileStartOutputFactory('react') async function getFilenames() { return await readdir(path.resolve(import.meta.dirname, './test-files')) @@ -39,7 +41,6 @@ describe('createIsomorphicFn compiles correctly', async () => { const compiledResult = compileStartOutput({ env, code, - root: './test-files', filename, dce: false, }) @@ -57,7 +58,6 @@ describe('createIsomorphicFn compiles correctly', async () => { code: ` import { createIsomorphicFn } from '@tanstack/react-start' const clientOnly = createIsomorphicFn().client()`, - root: './test-files', filename: 'no-fn.ts', dce: false, }) @@ -68,7 +68,6 @@ describe('createIsomorphicFn compiles correctly', async () => { code: ` import { createIsomorphicFn } from '@tanstack/react-start' const serverOnly = createIsomorphicFn().server()`, - root: './test-files', filename: 'no-fn.ts', dce: false, }) @@ -80,7 +79,6 @@ describe('createIsomorphicFn compiles correctly', async () => { code: ` import { createIsomorphicFn } from '@tanstack/react-start' const noImpl = createIsomorphicFn()`, - root: './test-files', filename: 'no-fn.ts', dce: false, }) diff --git a/packages/react-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx similarity index 100% rename from packages/react-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx rename to packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx diff --git a/packages/react-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx similarity index 100% rename from packages/react-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx rename to packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx diff --git a/packages/react-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx similarity index 100% rename from packages/react-start-plugin/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx rename to packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx diff --git a/packages/react-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx similarity index 100% rename from packages/react-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx rename to packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx diff --git a/packages/react-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx similarity index 100% rename from packages/react-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx rename to packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx diff --git a/packages/react-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx similarity index 100% rename from packages/react-start-plugin/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx rename to packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx diff --git a/packages/react-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructured.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructured.tsx similarity index 100% rename from packages/react-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructured.tsx rename to packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructured.tsx diff --git a/packages/react-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructuredRename.tsx similarity index 100% rename from packages/react-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructuredRename.tsx rename to packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructuredRename.tsx diff --git a/packages/react-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnStarImport.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnStarImport.tsx similarity index 100% rename from packages/react-start-plugin/tests/createIsomorphicFn/test-files/createIsomorphicFnStarImport.tsx rename to packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnStarImport.tsx diff --git a/packages/react-start-plugin/tests/createMiddleware/createMiddleware.test.ts b/packages/start-plugin-core/tests/createMiddleware/createMiddleware.test.ts similarity index 88% rename from packages/react-start-plugin/tests/createMiddleware/createMiddleware.test.ts rename to packages/start-plugin-core/tests/createMiddleware/createMiddleware.test.ts index 05d57dd32d..92af2feb31 100644 --- a/packages/react-start-plugin/tests/createMiddleware/createMiddleware.test.ts +++ b/packages/start-plugin-core/tests/createMiddleware/createMiddleware.test.ts @@ -2,7 +2,9 @@ import { readFile, readdir } from 'node:fs/promises' import path from 'node:path' import { describe, expect, test } from 'vitest' -import { compileStartOutput } from '../../src/compilers' +import { compileStartOutputFactory } from '../../src/compilers' + +const compileStartOutput = compileStartOutputFactory('react') async function getFilenames() { return await readdir(path.resolve(import.meta.dirname, './test-files')) @@ -23,7 +25,6 @@ describe('createMiddleware compiles correctly', async () => { const compiledResult = compileStartOutput({ env, code, - root: './test-files', filename, dce: false, }) diff --git a/packages/react-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx similarity index 100% rename from packages/react-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx rename to packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx diff --git a/packages/react-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx similarity index 100% rename from packages/react-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx rename to packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx diff --git a/packages/react-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx similarity index 100% rename from packages/react-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx rename to packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx diff --git a/packages/react-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx similarity index 100% rename from packages/react-start-plugin/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx rename to packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx diff --git a/packages/react-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareDestructured.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/server/createMiddlewareDestructured.tsx similarity index 100% rename from packages/react-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareDestructured.tsx rename to packages/start-plugin-core/tests/createMiddleware/snapshots/server/createMiddlewareDestructured.tsx diff --git a/packages/react-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareDestructuredRename.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/server/createMiddlewareDestructuredRename.tsx similarity index 100% rename from packages/react-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareDestructuredRename.tsx rename to packages/start-plugin-core/tests/createMiddleware/snapshots/server/createMiddlewareDestructuredRename.tsx diff --git a/packages/react-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareStarImport.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/server/createMiddlewareStarImport.tsx similarity index 100% rename from packages/react-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareStarImport.tsx rename to packages/start-plugin-core/tests/createMiddleware/snapshots/server/createMiddlewareStarImport.tsx diff --git a/packages/react-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareValidator.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/server/createMiddlewareValidator.tsx similarity index 100% rename from packages/react-start-plugin/tests/createMiddleware/snapshots/server/createMiddlewareValidator.tsx rename to packages/start-plugin-core/tests/createMiddleware/snapshots/server/createMiddlewareValidator.tsx diff --git a/packages/react-start-plugin/tests/createMiddleware/test-files/createMiddlewareDestructured.tsx b/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareDestructured.tsx similarity index 100% rename from packages/react-start-plugin/tests/createMiddleware/test-files/createMiddlewareDestructured.tsx rename to packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareDestructured.tsx diff --git a/packages/react-start-plugin/tests/createMiddleware/test-files/createMiddlewareDestructuredRename.tsx b/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareDestructuredRename.tsx similarity index 100% rename from packages/react-start-plugin/tests/createMiddleware/test-files/createMiddlewareDestructuredRename.tsx rename to packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareDestructuredRename.tsx diff --git a/packages/react-start-plugin/tests/createMiddleware/test-files/createMiddlewareStarImport.tsx b/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareStarImport.tsx similarity index 100% rename from packages/react-start-plugin/tests/createMiddleware/test-files/createMiddlewareStarImport.tsx rename to packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareStarImport.tsx diff --git a/packages/react-start-plugin/tests/createMiddleware/test-files/createMiddlewareValidator.tsx b/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareValidator.tsx similarity index 100% rename from packages/react-start-plugin/tests/createMiddleware/test-files/createMiddlewareValidator.tsx rename to packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareValidator.tsx diff --git a/packages/react-start-plugin/tests/createServerFn/createServerFn.test.ts b/packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts similarity index 95% rename from packages/react-start-plugin/tests/createServerFn/createServerFn.test.ts rename to packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts index 5c93ae90bc..c8c013dc99 100644 --- a/packages/react-start-plugin/tests/createServerFn/createServerFn.test.ts +++ b/packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts @@ -2,7 +2,9 @@ import { readFile, readdir } from 'node:fs/promises' import path from 'node:path' import { describe, expect, test } from 'vitest' -import { compileStartOutput } from '../../src/compilers' +import { compileStartOutputFactory } from '../../src/compilers' + +const compileStartOutput = compileStartOutputFactory('react') async function getFilenames() { return await readdir(path.resolve(import.meta.dirname, './test-files')) @@ -23,7 +25,6 @@ describe('createServerFn compiles correctly', async () => { const compiledResult = compileStartOutput({ env, code, - root: './test-files', filename, dce: false, }) @@ -42,7 +43,6 @@ describe('createServerFn compiles correctly', async () => { code: ` import { createServerFn } from '@tanstack/react-start' createServerFn()`, - root: './test-files', filename: 'no-fn.ts', dce: false, }) @@ -56,7 +56,6 @@ describe('createServerFn compiles correctly', async () => { code: ` import { createServerFn } from '@tanstack/react-start' createServerFn().handler(async () => {})`, - root: './test-files', filename: 'no-fn.ts', dce: false, }) @@ -72,7 +71,6 @@ describe('createServerFn compiles correctly', async () => { const myServerFn = createServerFn().handler(myFunc)` const compiledResultClient = compileStartOutput({ - root: '/test', filename: 'test.ts', code, env: 'client', @@ -80,7 +78,6 @@ describe('createServerFn compiles correctly', async () => { }) const compiledResultServer = compileStartOutput({ - root: '/test', filename: 'test.ts', code, env: 'server', @@ -123,7 +120,6 @@ describe('createServerFn compiles correctly', async () => { // Client const compiledResult = compileStartOutput({ - root: '/test', filename: 'test.ts', code, env: 'client', @@ -146,7 +142,6 @@ describe('createServerFn compiles correctly', async () => { // Server const compiledResultServer = compileStartOutput({ - root: '/test', filename: 'test.ts', code, env: 'server', diff --git a/packages/react-start-plugin/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx similarity index 100% rename from packages/react-start-plugin/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx rename to packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx diff --git a/packages/react-start-plugin/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx similarity index 100% rename from packages/react-start-plugin/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx rename to packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx diff --git a/packages/react-start-plugin/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx similarity index 100% rename from packages/react-start-plugin/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx rename to packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx diff --git a/packages/react-start-plugin/tests/createServerFn/snapshots/client/createServerFnValidator.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnValidator.tsx similarity index 100% rename from packages/react-start-plugin/tests/createServerFn/snapshots/client/createServerFnValidator.tsx rename to packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnValidator.tsx diff --git a/packages/react-start-plugin/tests/createServerFn/snapshots/server/createServerFnDestructured.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server/createServerFnDestructured.tsx similarity index 100% rename from packages/react-start-plugin/tests/createServerFn/snapshots/server/createServerFnDestructured.tsx rename to packages/start-plugin-core/tests/createServerFn/snapshots/server/createServerFnDestructured.tsx diff --git a/packages/react-start-plugin/tests/createServerFn/snapshots/server/createServerFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server/createServerFnDestructuredRename.tsx similarity index 100% rename from packages/react-start-plugin/tests/createServerFn/snapshots/server/createServerFnDestructuredRename.tsx rename to packages/start-plugin-core/tests/createServerFn/snapshots/server/createServerFnDestructuredRename.tsx diff --git a/packages/react-start-plugin/tests/createServerFn/snapshots/server/createServerFnStarImport.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server/createServerFnStarImport.tsx similarity index 100% rename from packages/react-start-plugin/tests/createServerFn/snapshots/server/createServerFnStarImport.tsx rename to packages/start-plugin-core/tests/createServerFn/snapshots/server/createServerFnStarImport.tsx diff --git a/packages/react-start-plugin/tests/createServerFn/snapshots/server/createServerFnValidator.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server/createServerFnValidator.tsx similarity index 100% rename from packages/react-start-plugin/tests/createServerFn/snapshots/server/createServerFnValidator.tsx rename to packages/start-plugin-core/tests/createServerFn/snapshots/server/createServerFnValidator.tsx diff --git a/packages/react-start-plugin/tests/createServerFn/test-files/createServerFnDestructured.tsx b/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnDestructured.tsx similarity index 100% rename from packages/react-start-plugin/tests/createServerFn/test-files/createServerFnDestructured.tsx rename to packages/start-plugin-core/tests/createServerFn/test-files/createServerFnDestructured.tsx diff --git a/packages/react-start-plugin/tests/createServerFn/test-files/createServerFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnDestructuredRename.tsx similarity index 100% rename from packages/react-start-plugin/tests/createServerFn/test-files/createServerFnDestructuredRename.tsx rename to packages/start-plugin-core/tests/createServerFn/test-files/createServerFnDestructuredRename.tsx diff --git a/packages/react-start-plugin/tests/createServerFn/test-files/createServerFnStarImport.tsx b/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnStarImport.tsx similarity index 100% rename from packages/react-start-plugin/tests/createServerFn/test-files/createServerFnStarImport.tsx rename to packages/start-plugin-core/tests/createServerFn/test-files/createServerFnStarImport.tsx diff --git a/packages/react-start-plugin/tests/createServerFn/test-files/createServerFnValidator.tsx b/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnValidator.tsx similarity index 100% rename from packages/react-start-plugin/tests/createServerFn/test-files/createServerFnValidator.tsx rename to packages/start-plugin-core/tests/createServerFn/test-files/createServerFnValidator.tsx diff --git a/packages/solid-start-plugin/tests/createMiddleware/createMiddleware.test.ts b/packages/start-plugin-core/tests/createServerRoute/createServerRoute.test.ts similarity index 86% rename from packages/solid-start-plugin/tests/createMiddleware/createMiddleware.test.ts rename to packages/start-plugin-core/tests/createServerRoute/createServerRoute.test.ts index 05d57dd32d..6ab449670d 100644 --- a/packages/solid-start-plugin/tests/createMiddleware/createMiddleware.test.ts +++ b/packages/start-plugin-core/tests/createServerRoute/createServerRoute.test.ts @@ -2,7 +2,9 @@ import { readFile, readdir } from 'node:fs/promises' import path from 'node:path' import { describe, expect, test } from 'vitest' -import { compileStartOutput } from '../../src/compilers' +import { compileStartOutputFactory } from '../../src/compilers' + +const compileStartOutput = compileStartOutputFactory('react') async function getFilenames() { return await readdir(path.resolve(import.meta.dirname, './test-files')) @@ -23,9 +25,8 @@ describe('createMiddleware compiles correctly', async () => { const compiledResult = compileStartOutput({ env, code, - root: './test-files', filename, - dce: false, + dce: true, }) await expect(compiledResult.code).toMatchFileSnapshot( diff --git a/packages/react-start-client/src/routesManifest.ts b/packages/start-plugin-core/tests/createServerRoute/snapshots/client/nonImported.tsx similarity index 100% rename from packages/react-start-client/src/routesManifest.ts rename to packages/start-plugin-core/tests/createServerRoute/snapshots/client/nonImported.tsx diff --git a/packages/start-plugin-core/tests/createServerRoute/snapshots/server/nonImported.tsx b/packages/start-plugin-core/tests/createServerRoute/snapshots/server/nonImported.tsx new file mode 100644 index 0000000000..265eba8dbc --- /dev/null +++ b/packages/start-plugin-core/tests/createServerRoute/snapshots/server/nonImported.tsx @@ -0,0 +1,11 @@ +import { createServerFileRoute } from "@tanstack/react-start/server"; +import { z } from 'zod'; +export const ServerRoute = createServerFileRoute().validator(z.number()).middleware(({ + input +}) => input + 1).methods({ + GET: async ({ + input + }) => { + return input + 1; + } +}); \ No newline at end of file diff --git a/packages/start-plugin-core/tests/createServerRoute/test-files/nonImported.tsx b/packages/start-plugin-core/tests/createServerRoute/test-files/nonImported.tsx new file mode 100644 index 0000000000..d782a05448 --- /dev/null +++ b/packages/start-plugin-core/tests/createServerRoute/test-files/nonImported.tsx @@ -0,0 +1,10 @@ +import { z } from 'zod' + +export const ServerRoute = createServerFileRoute() + .validator(z.number()) + .middleware(({ input }) => input + 1) + .methods({ + GET: async ({ input }) => { + return input + 1 + }, + }) diff --git a/packages/react-start-plugin/tests/envOnly/envOnly.test.ts b/packages/start-plugin-core/tests/envOnly/envOnly.test.ts similarity index 91% rename from packages/react-start-plugin/tests/envOnly/envOnly.test.ts rename to packages/start-plugin-core/tests/envOnly/envOnly.test.ts index 0fae21d3af..4ce873cc23 100644 --- a/packages/react-start-plugin/tests/envOnly/envOnly.test.ts +++ b/packages/start-plugin-core/tests/envOnly/envOnly.test.ts @@ -2,7 +2,9 @@ import { readFile, readdir } from 'node:fs/promises' import path from 'node:path' import { describe, expect, test } from 'vitest' -import { compileStartOutput } from '../../src/compilers' +import { compileStartOutputFactory } from '../../src/compilers' + +const compileStartOutput = compileStartOutputFactory('react') async function getFilenames() { return await readdir(path.resolve(import.meta.dirname, './test-files')) @@ -23,7 +25,6 @@ describe('envOnly functions compile correctly', async () => { const compiledResult = compileStartOutput({ env, code, - root: './test-files', filename, dce: false, }) @@ -41,7 +42,6 @@ describe('envOnly functions compile correctly', async () => { code: ` import { clientOnly } from '@tanstack/react-start' const fn = clientOnly()`, - root: './test-files', filename: 'no-fn.ts', dce: false, }) @@ -52,7 +52,6 @@ describe('envOnly functions compile correctly', async () => { code: ` import { serverOnly } from '@tanstack/react-start' const fn = serverOnly()`, - root: './test-files', filename: 'no-fn.ts', dce: false, }) diff --git a/packages/react-start-plugin/tests/envOnly/snapshots/client/envOnlyDestructured.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructured.tsx similarity index 100% rename from packages/react-start-plugin/tests/envOnly/snapshots/client/envOnlyDestructured.tsx rename to packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructured.tsx diff --git a/packages/react-start-plugin/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx similarity index 100% rename from packages/react-start-plugin/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx rename to packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx diff --git a/packages/react-start-plugin/tests/envOnly/snapshots/client/envOnlyStarImport.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyStarImport.tsx similarity index 100% rename from packages/react-start-plugin/tests/envOnly/snapshots/client/envOnlyStarImport.tsx rename to packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyStarImport.tsx diff --git a/packages/react-start-plugin/tests/envOnly/snapshots/server/envOnlyDestructured.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructured.tsx similarity index 100% rename from packages/react-start-plugin/tests/envOnly/snapshots/server/envOnlyDestructured.tsx rename to packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructured.tsx diff --git a/packages/react-start-plugin/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx similarity index 100% rename from packages/react-start-plugin/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx rename to packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx diff --git a/packages/react-start-plugin/tests/envOnly/snapshots/server/envOnlyStarImport.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyStarImport.tsx similarity index 100% rename from packages/react-start-plugin/tests/envOnly/snapshots/server/envOnlyStarImport.tsx rename to packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyStarImport.tsx diff --git a/packages/react-start-plugin/tests/envOnly/test-files/envOnlyDestructured.tsx b/packages/start-plugin-core/tests/envOnly/test-files/envOnlyDestructured.tsx similarity index 100% rename from packages/react-start-plugin/tests/envOnly/test-files/envOnlyDestructured.tsx rename to packages/start-plugin-core/tests/envOnly/test-files/envOnlyDestructured.tsx diff --git a/packages/react-start-plugin/tests/envOnly/test-files/envOnlyDestructuredRename.tsx b/packages/start-plugin-core/tests/envOnly/test-files/envOnlyDestructuredRename.tsx similarity index 100% rename from packages/react-start-plugin/tests/envOnly/test-files/envOnlyDestructuredRename.tsx rename to packages/start-plugin-core/tests/envOnly/test-files/envOnlyDestructuredRename.tsx diff --git a/packages/react-start-plugin/tests/envOnly/test-files/envOnlyStarImport.tsx b/packages/start-plugin-core/tests/envOnly/test-files/envOnlyStarImport.tsx similarity index 100% rename from packages/react-start-plugin/tests/envOnly/test-files/envOnlyStarImport.tsx rename to packages/start-plugin-core/tests/envOnly/test-files/envOnlyStarImport.tsx diff --git a/packages/start-plugin-core/tsconfig.json b/packages/start-plugin-core/tsconfig.json new file mode 100644 index 0000000000..3ed8e1dc0f --- /dev/null +++ b/packages/start-plugin-core/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src", "vite.config.ts", "tests"], + "exclude": ["tests/**/test-files/**", "tests/**/snapshots/**"], + "compilerOptions": { + "target": "esnext", + "noEmit": true + } +} diff --git a/packages/start-server-functions-ssr/vite.config.ts b/packages/start-plugin-core/vite.config.ts similarity index 75% rename from packages/start-server-functions-ssr/vite.config.ts rename to packages/start-plugin-core/vite.config.ts index 976bb5c87f..2c711fd181 100644 --- a/packages/start-server-functions-ssr/vite.config.ts +++ b/packages/start-plugin-core/vite.config.ts @@ -1,14 +1,13 @@ import { defineConfig, mergeConfig } from 'vitest/config' import { tanstackViteConfig } from '@tanstack/config/vite' import packageJson from './package.json' -import type { ViteUserConfig } from 'vitest/config' const config = defineConfig({ - plugins: [] as ViteUserConfig['plugins'], test: { name: packageJson.name, + dir: './tests', watch: false, - environment: 'jsdom', + typecheck: { enabled: true }, }, }) @@ -17,5 +16,6 @@ export default mergeConfig( tanstackViteConfig({ entry: './src/index.ts', srcDir: './src', + outDir: './dist', }), ) diff --git a/packages/start-server-core/README.md b/packages/start-server-core/README.md index bb009b0c87..0c0d4cc215 100644 --- a/packages/start-server-core/README.md +++ b/packages/start-server-core/README.md @@ -1,33 +1,12 @@ -> 🤫 we're cooking up something special! - -# TanStack Start +# TanStack Start - Server Core -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) +This package is not meant to be used directly. It is a dependency of the TanStack Start framework-specific packages: -🤖 Type-safe router w/ built-in caching & URL state management for React! +- [`@tanstack/react-start`](https://www.npmjs.com/package/@tanstack/react-start) +- [`@tanstack/solid-start`](https://www.npmjs.com/package/@tanstack/solid-start). - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - +It provides the core functionality for TanStack Start, which is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router). -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! +Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started. diff --git a/packages/start-server-core/package.json b/packages/start-server-core/package.json index 95f7e6799a..09f7b9a02b 100644 --- a/packages/start-server-core/package.json +++ b/packages/start-server-core/package.json @@ -65,15 +65,18 @@ "@tanstack/history": "workspace:^", "@tanstack/router-core": "workspace:^", "@tanstack/start-client-core": "workspace:^", - "tiny-warning": "^1.0.3", "h3": "1.13.0", "isbot": "^5.1.22", "jsesc": "^3.1.0", - "unctx": "^2.4.1" + "tiny-invariant": "^1.3.3", + "tiny-warning": "^1.0.3", + "unctx": "^2.4.1", + "undici": "^7.8.0" }, "devDependencies": { "@types/jsesc": "^3.0.3", "esbuild": "^0.25.0", - "typescript": "^5.7.2" + "typescript": "^5.7.2", + "vite": "6.1.4" } } diff --git a/packages/start-server-core/src/createRequestHandler.ts b/packages/start-server-core/src/createRequestHandler.ts index 0e7b975d13..061e458468 100644 --- a/packages/start-server-core/src/createRequestHandler.ts +++ b/packages/start-server-core/src/createRequestHandler.ts @@ -66,9 +66,7 @@ function getRequestHeaders(opts: { router: AnyRouter }): Headers { const { redirect } = opts.router.state if (redirect) { - headers = mergeHeaders(headers, redirect.headers, { - Location: redirect.href, - }) + headers = mergeHeaders(headers, redirect.headers) } return headers diff --git a/packages/start-server-core/src/createStartHandler.ts b/packages/start-server-core/src/createStartHandler.ts index 7604efbdef..181cdb5c67 100644 --- a/packages/start-server-core/src/createStartHandler.ts +++ b/packages/start-server-core/src/createStartHandler.ts @@ -1,67 +1,35 @@ +import path from 'node:path' import { createMemoryHistory } from '@tanstack/history' -import { mergeHeaders } from '@tanstack/start-client-core' -import { eventHandler, getResponseHeaders, toWebRequest } from 'h3' +import { + flattenMiddlewares, + json, + mergeHeaders, +} from '@tanstack/start-client-core' +import { + getMatchedRoutes, + isRedirect, + processRouteTree, + rootRouteId, + tsrRedirectHeaderKey, +} from '@tanstack/router-core' +import { getResponseHeaders, requestHandler } from './h3' import { attachRouterServerSsrUtils, dehydrateRouter } from './ssr-server' +import { getStartManifest } from './router-manifest' +import { handleServerAction } from './server-functions-handler' +import type { AnyServerRoute, AnyServerRouteWithTypes } from './serverRoute' +import type { RequestHandler } from './h3' +import type { AnyRouter } from '@tanstack/router-core' import type { HandlerCallback } from './handlerCallback' -import type { EventHandlerResponse, H3Event } from 'h3' -import type { AnyRouter, Manifest } from '@tanstack/router-core' -export type CustomizeStartHandler< - TRouter extends AnyRouter, - TResponse extends EventHandlerResponse = EventHandlerResponse, -> = (cb: HandlerCallback) => ReturnType +type TODO = any -export function createStartHandler< - TRouter extends AnyRouter, - TResponse extends EventHandlerResponse = EventHandlerResponse, ->({ - createRouter, - getRouterManifest, -}: { - createRouter: () => TRouter - getRouterManifest?: () => Manifest | Promise -}): CustomizeStartHandler { - return (cb) => { - return eventHandler(async (event) => { - const request = toWebRequest(event) +export type CustomizeStartHandler = ( + cb: HandlerCallback, +) => RequestHandler - const url = new URL(request.url) - const href = url.href.replace(url.origin, '') - - // Create a history for the router - const history = createMemoryHistory({ - initialEntries: [href], - }) - - const router = createRouter() - - attachRouterServerSsrUtils(router, await getRouterManifest?.()) - - // Update the router with the history and context - router.update({ - history, - }) - - await router.load() - - dehydrateRouter(router) - - const responseHeaders = getStartResponseHeaders({ event, router }) - const response = await cb({ - request, - router, - responseHeaders, - }) - - return response - }) - } -} - -function getStartResponseHeaders(opts: { event: H3Event; router: AnyRouter }) { +export function getStartResponseHeaders(opts: { router: AnyRouter }) { let headers = mergeHeaders( - getResponseHeaders(opts.event), - (opts.event as any).___ssrRpcResponseHeaders, + getResponseHeaders(), { 'Content-Type': 'text/html; charset=UTF-8', }, @@ -69,14 +37,309 @@ function getStartResponseHeaders(opts: { event: H3Event; router: AnyRouter }) { return match.headers }), ) - // Handle Redirects const { redirect } = opts.router.state if (redirect) { - headers = mergeHeaders(headers, redirect.headers, { - Location: redirect.href, - }) + headers = mergeHeaders(headers, redirect.headers) } return headers } + +export function createStartHandler({ + createRouter, +}: { + createRouter: () => TRouter +}): CustomizeStartHandler { + return (cb) => { + return requestHandler(async ({ request }) => { + const url = new URL(request.url) + const href = url.href.replace(url.origin, '') + + // Create a history for the client-side router + const history = createMemoryHistory({ + initialEntries: [href], + }) + + // Create the client-side router + const router = createRouter() + + // Attach the server-side SSR utils to the client-side router + attachRouterServerSsrUtils(router, getStartManifest()) + + // Update the client-side router with the history and context + router.update({ + history, + }) + + const response = await (async () => { + try { + if (!process.env.TSS_SERVER_FN_BASE) { + throw new Error( + 'tanstack/start-server-core: TSS_SERVER_FN_BASE must be defined in your environment for createStartHandler()', + ) + } + + // First, let's attempt to handle server functions + if ( + href.startsWith(path.join('/', process.env.TSS_SERVER_FN_BASE, '/')) + ) { + return await handleServerAction({ request }) + } + + // Then move on to attempting to load server routes + const serverRouteTreeModule = await (async () => { + try { + // @ts-expect-error + return (await import('tanstack:server-routes')) as { + routeTree: AnyServerRoute + } + } catch (e) { + console.log(e) + return undefined + } + })() + + // If we have a server route tree, then we try matching to see if we have a + // server route that matches the request. + if (serverRouteTreeModule) { + const [matchedRoutes, response] = await handleServerRoutes({ + routeTree: serverRouteTreeModule.routeTree, + request, + }) + + if (response) return response + } + + const requestAcceptHeader = request.headers.get('Accept') || '*/*' + const splitRequestAcceptHeader = requestAcceptHeader.split(',') + + const supportedMimeTypes = ['*/*', 'text/html'] + const isRouterAcceptSupported = supportedMimeTypes.some((mimeType) => + splitRequestAcceptHeader.some((acceptedMimeType) => + acceptedMimeType.trim().startsWith(mimeType), + ), + ) + + if (!isRouterAcceptSupported) { + return json( + { + error: 'Only HTML requests are supported here', + }, + { + status: 500, + }, + ) + } + + // If no Server Routes were found, so fallback to normal SSR matching using + // the router + + await router.load() + + dehydrateRouter(router) + + const responseHeaders = getStartResponseHeaders({ router }) + const response = await cb({ + request, + router, + responseHeaders, + }) + + return response + } catch (err) { + if (err instanceof Response) { + return err + } + + throw err + } + })() + + if (isRedirect(response)) { + if ( + response.options.to && + typeof response.options.to === 'string' && + !response.options.to.startsWith('/') + ) { + throw new Error( + `Server side redirects must use absolute paths via the 'href' or 'to' options. Received: ${JSON.stringify(response.options)}`, + ) + } + + if ( + ['params', 'search', 'hash'].some( + (d) => typeof (response.options as any)[d] === 'function', + ) + ) { + throw new Error( + `Server side redirects must use static search, params, and hash values and do not support functional values. Received functional values for: ${Object.keys( + response.options, + ) + .filter((d) => typeof (response.options as any)[d] === 'function') + .map((d) => `"${d}"`) + .join(', ')}`, + ) + } + + const redirect = router.resolveRedirect(response) + + if (request.headers.get('x-tsr-redirect') === 'manual') { + return json( + { + ...response.options, + isSerializedRedirect: true, + }, + { + headers: redirect.headers, + }, + ) + } + + return redirect + } + + response.headers.append( + 'Access-Control-Expose-Headers', + tsrRedirectHeaderKey, + ) + + return response + }) + } +} + +async function handleServerRoutes({ + routeTree, + request, +}: { + routeTree: AnyServerRouteWithTypes + request: Request +}) { + const { flatRoutes, routesById, routesByPath } = processRouteTree({ + routeTree, + initRoute: (route, i) => { + route.init({ + originalIndex: i, + }) + }, + }) + + const url = new URL(request.url) + const pathname = url.pathname + + const history = createMemoryHistory({ + initialEntries: [pathname], + }) + + const { matchedRoutes, foundRoute, routeParams } = + getMatchedRoutes({ + pathname: history.location.pathname, + basepath: '/', + caseSensitive: true, + routesByPath, + routesById, + flatRoutes, + }) + + let response: Response | undefined + + if (foundRoute && foundRoute.id !== rootRouteId) { + // We've found a server route that matches the request, so we can call it. + // TODO: Get the input type-signature correct + // TODO: Perform the middlewares? + // TODO: Error handling? What happens when its `throw redirect()` vs `throw new Error()`? + + const method = Object.keys(foundRoute.options.methods).find( + (method) => method.toLowerCase() === request.method.toLowerCase(), + ) + + if (method) { + const handler = foundRoute.options.methods[method] + + if (handler) { + const middlewares = flattenMiddlewares( + matchedRoutes.flatMap((r) => r.options.middleware).filter(Boolean), + ).map((d) => d.options.server) + + middlewares.push(handlerToMiddleware(handler) as TODO) + + // TODO: This is starting to feel too much like a server function + // Do generalize the existing middleware execution? Or do we need to + // build a new middleware execution system for server routes? + const ctx = await executeMiddleware(middlewares, { + request, + context: {}, + params: routeParams, + pathname: history.location.pathname, + }) + + response = ctx.response + } + } + } + + // We return the matched routes too so if + // the app router happens to match the same path, + // it can use any request middleware from server routes + return [matchedRoutes, response] as const +} + +function handlerToMiddleware( + handler: AnyServerRouteWithTypes['options']['methods'][string], +) { + return async ({ next, ...rest }: TODO) => ({ + response: await handler(rest), + }) +} + +function executeMiddleware(middlewares: TODO, ctx: TODO) { + let index = -1 + + const next = async (ctx: TODO) => { + index++ + const middleware = middlewares[index] + if (!middleware) return ctx + + const result = await middleware({ + ...ctx, + // Allow the middleware to call the next middleware in the chain + next: async (nextCtx: TODO) => { + // Allow the caller to extend the context for the next middleware + const nextResult = await next({ ...ctx, ...nextCtx }) + + // Merge the result into the context\ + return Object.assign(ctx, handleCtxResult(nextResult)) + }, + // Allow the middleware result to extend the return context + }).catch((err: TODO) => { + if (isSpecialResponse(err)) { + return { + response: err, + } + } + + throw err + }) + + // Merge the middleware result into the context, just in case it + // returns a partial context + return Object.assign(ctx, handleCtxResult(result)) + } + + return handleCtxResult(next(ctx)) +} + +function handleCtxResult(result: TODO) { + if (isSpecialResponse(result)) { + return { + response: result, + } + } + + return result +} + +function isSpecialResponse(err: TODO) { + return err instanceof Response || isRedirect(err) +} diff --git a/packages/start-server-core/src/h3.ts b/packages/start-server-core/src/h3.ts index d5a2c94844..72108f0c2d 100644 --- a/packages/start-server-core/src/h3.ts +++ b/packages/start-server-core/src/h3.ts @@ -11,7 +11,9 @@ import { clearResponseHeaders as _clearResponseHeaders, clearSession as _clearSession, defaultContentType as _defaultContentType, + defineEventHandler as _defineEventHandler, deleteCookie as _deleteCookie, + eventHandler as _eventHandler, fetchWithEvent as _fetchWithEvent, getCookie as _getCookie, getHeader as _getHeader, @@ -61,20 +63,24 @@ import { setResponseHeader as _setResponseHeader, setResponseHeaders as _setResponseHeaders, setResponseStatus as _setResponseStatus, + toWebRequest as _toWebRequest, unsealSession as _unsealSession, updateSession as _updateSession, useSession as _useSession, writeEarlyHints as _writeEarlyHints, } from 'h3' -import { getContext as getUnctxContext } from 'unctx' + import type { Encoding, + EventHandler, HTTPHeaderName, InferEventInput, _RequestMiddleware, _ResponseMiddleware, } from 'h3' +const eventStorage = new AsyncLocalStorage() + function _setContext(event: H3Event, key: string, value: any) { event.context[key] = value } @@ -90,46 +96,38 @@ export function defineMiddleware(options: { return options } -function toWebRequestH3(event: H3Event) { - /** - * @type {ReadableStream | undefined} - */ - let readableStream: ReadableStream | undefined +// function toWebRequestH3(event: H3Event) { +// /** +// * @type {ReadableStream | undefined} +// */ +// let readableStream: ReadableStream | undefined - const url = getRequestURL(event) - const base = { - // @ts-ignore Undici option - duplex: 'half', - method: event.method, - headers: event.headers, - } +// const url = _getRequestURL(event) +// const base = { +// // @ts-ignore Undici option +// duplex: 'half', +// method: event.method, +// headers: event.headers, +// } - if ((event.node.req as any).body instanceof ArrayBuffer) { - return new Request(url, { - ...base, - body: (event.node.req as any).body, - }) - } +// if ((event.node.req as any).body instanceof ArrayBuffer) { +// return new Request(url, { +// ...base, +// body: (event.node.req as any).body, +// }) +// } - return new Request(url, { - ...base, - get body() { - if (readableStream) { - return readableStream - } - readableStream = getRequestWebStream(event) - return readableStream - }, - }) -} - -export function toWebRequest(event: H3Event) { - event.web ??= { - request: toWebRequestH3(event), - url: getRequestURL(event), - } - return event.web.request -} +// return new Request(url, { +// ...base, +// get body() { +// if (readableStream) { +// return readableStream +// } +// readableStream = _getRequestWebStream(event) +// return readableStream +// }, +// }) +// } export { H3Error, @@ -140,7 +138,6 @@ export { createAppEventHandler, createEvent, createRouter, - defineEventHandler, defineLazyEventHandler, defineNodeListener, defineNodeMiddleware, @@ -148,7 +145,6 @@ export { defineResponseMiddleware, dynamicEventHandler, defineWebSocket, - eventHandler, splitCookiesString, fromNodeMiddleware, fromPlainHandler, @@ -163,6 +159,7 @@ export { toNodeListener, toPlainHandler, toWebHandler, + toWebRequest, isCorsOriginAllowed, isStream, createError, @@ -221,8 +218,33 @@ export { type _ResponseMiddleware, } from 'h3' -function getHTTPEvent() { - return getEvent() +export function defineEventHandler(handler: EventHandler) { + return _defineEventHandler((event) => { + return runWithEvent(event, () => handler(event)) + }) +} + +export function eventHandler(handler: EventHandler) { + return _eventHandler((event) => { + return runWithEvent(event, () => handler(event)) + }) +} + +export async function runWithEvent( + event: H3Event, + fn: () => T | Promise, +): Promise { + return eventStorage.run(event, fn) +} + +export function getEvent() { + const event = eventStorage.getStore() as H3Event | undefined + if (!event) { + throw new Error( + `No HTTPEvent found in AsyncLocalStorage. Make sure you are using the function within the server runtime.`, + ) + } + return event } export const HTTPEventSymbol = Symbol('$HTTPEvent') @@ -262,12 +284,7 @@ function createWrapperFunction) => any>( return function (...args: Array) { const event = args[0] if (!isEvent(event)) { - if (!(globalThis as any).app.config.server.experimental?.asyncContext) { - throw new Error( - 'AsyncLocalStorage was not enabled. Use the `server.experimental.asyncContext: true` option in your app configuration to enable it. Or, pass the instance of HTTPEvent that you have as the first argument to the function.', - ) - } - args.unshift(getHTTPEvent()) + args.unshift(getEvent()) } else { args[0] = event instanceof H3Event || (event as any).__is_event__ @@ -463,37 +480,13 @@ export const readValidatedBody: PrependOverload< export const removeResponseHeader = createWrapperFunction(_removeResponseHeader) export const getContext = createWrapperFunction(_getContext) export const setContext = createWrapperFunction(_setContext) - export const clearResponseHeaders = createWrapperFunction(_clearResponseHeaders) +export const getWebRequest = createWrapperFunction(_toWebRequest) -export const getWebRequest = createWrapperFunction(toWebRequest) +export type RequestHandler = (ctx: { + request: Request +}) => Promise | Response -export { createApp as createServer } from 'h3' - -function getNitroAsyncContext() { - const nitroAsyncContext = getUnctxContext('nitro-app', { - asyncContext: (globalThis as any).app.config.server.experimental - ?.asyncContext - ? true - : false, - AsyncLocalStorage, - }) - - return nitroAsyncContext -} - -export function getEvent() { - const event = (getNitroAsyncContext().use() as any).event as - | H3Event - | undefined - if (!event) { - throw new Error( - `No HTTPEvent found in AsyncLocalStorage. Make sure you are using the function within the server runtime.`, - ) - } - return event -} - -export async function handleHTTPEvent(event: H3Event) { - return await (globalThis as any).$handle(event) +export function requestHandler(handler: RequestHandler) { + return handler } diff --git a/packages/start-server-core/src/handlerCallback.ts b/packages/start-server-core/src/handlerCallback.ts index a109f9b94a..a167955389 100644 --- a/packages/start-server-core/src/handlerCallback.ts +++ b/packages/start-server-core/src/handlerCallback.ts @@ -1,22 +1,15 @@ -import type { EventHandlerResponse } from 'h3' import type { AnyRouter } from '@tanstack/router-core' -export interface HandlerCallback< - TRouter extends AnyRouter, - TResponse extends EventHandlerResponse = EventHandlerResponse, -> { +export interface HandlerCallback { (ctx: { request: Request router: TRouter responseHeaders: Headers - }): TResponse + }): Response | Promise } -export function defineHandlerCallback< - TRouter extends AnyRouter, - TResponse = EventHandlerResponse, ->( - handler: HandlerCallback, -): HandlerCallback { +export function defineHandlerCallback( + handler: HandlerCallback, +): HandlerCallback { return handler } diff --git a/packages/start-server-core/src/index.tsx b/packages/start-server-core/src/index.tsx index d24477934d..4803124cfa 100644 --- a/packages/start-server-core/src/index.tsx +++ b/packages/start-server-core/src/index.tsx @@ -3,10 +3,22 @@ export { transformPipeableStreamWithRouter, } from './transformStreamWithRouter' -export { createStartHandler } from './createStartHandler' +export { + getStartResponseHeaders, + createStartHandler, +} from './createStartHandler' +export type { CustomizeStartHandler } from './createStartHandler' export { createRequestHandler } from './createRequestHandler' export { defineHandlerCallback } from './handlerCallback' export type { HandlerCallback } from './handlerCallback' +export { attachRouterServerSsrUtils, dehydrateRouter } from './ssr-server' +export { handleServerAction } from './server-functions-handler' + export * from './h3' + +export { createServerRoute, createServerFileRoute } from './serverRoute' +export type { CreateServerFileRoute } from './serverRoute' + +export { __getAbsoluteUrl, __setGlobalOrigin } from './undici' diff --git a/packages/start-server-core/src/router-manifest.ts b/packages/start-server-core/src/router-manifest.ts new file mode 100644 index 0000000000..444c19287d --- /dev/null +++ b/packages/start-server-core/src/router-manifest.ts @@ -0,0 +1,79 @@ +import { tsrStartManifest } from 'tanstack:start-manifest' +import { rootRouteId } from '@tanstack/router-core' + +declare global { + // eslint-disable-next-line no-var + var TSS_INJECTED_HEAD_SCRIPTS: string | undefined +} + +/** + * @description Returns the router manifest that should be sent to the client. + * This includes only the assets and preloads for the current route and any + * special assets that are needed for the client. It does not include relationships + * between routes or any other data that is not needed for the client. + */ +export function getStartManifest() { + const startManifest = tsrStartManifest() + + const rootRoute = (startManifest.routes[rootRouteId] = + startManifest.routes[rootRouteId] || {}) + + rootRoute.assets = rootRoute.assets || [] + + // Get the entry for the client from vinxi + // const vinxiClientManifest = getManifest('client') + + // const importPath = + // vinxiClientManifest.inputs[vinxiClientManifest.handler]?.output.path + // if (!importPath) { + // invariant(importPath, 'Could not find client entry in vinxi manifest') + // } + + if (process.env.NODE_ENV === 'development' && !process.env.TSS_CLIENT_ENTRY) { + throw new Error( + 'tanstack/start-server-core: TSS_CLIENT_ENTRY must be defined in your environment for getStartManifest()', + ) + } + + if (process.env.NODE_ENV === 'development') { + // Always fake that HMR is ready + // const CLIENT_BASE = sanitizeBase(process.env.TSS_CLIENT_BASE || '') + + // if (!CLIENT_BASE) { + // throw new Error( + // 'tanstack/start-router-manifest: TSS_CLIENT_BASE must be defined in your environment for getFullRouterManifest()', + // ) + // } + + const script = `${globalThis.TSS_INJECTED_HEAD_SCRIPTS ? globalThis.TSS_INJECTED_HEAD_SCRIPTS + '; ' : ''}import(${JSON.stringify(process.env.TSS_CLIENT_ENTRY)})` + + rootRoute.assets.push({ + tag: 'script', + attrs: { + type: 'module', + suppressHydrationWarning: true, + async: true, + }, + children: script, + }) + } + + const manifest = { + ...startManifest, + routes: Object.fromEntries( + Object.entries(startManifest.routes).map(([k, v]) => { + const { preloads, assets } = v + return [ + k, + { + preloads, + assets, + }, + ] + }), + ), + } + + // Strip out anything that isn't needed for the client + return manifest +} diff --git a/packages/start-server-functions-handler/src/index.ts b/packages/start-server-core/src/server-functions-handler.ts similarity index 76% rename from packages/start-server-functions-handler/src/index.ts rename to packages/start-server-core/src/server-functions-handler.ts index 85cbe87783..7643e0aa4b 100644 --- a/packages/start-server-functions-handler/src/index.ts +++ b/packages/start-server-core/src/server-functions-handler.ts @@ -1,21 +1,13 @@ -import { isNotFound, isRedirect } from '@tanstack/router-core' +import { isNotFound } from '@tanstack/router-core' import invariant from 'tiny-invariant' -import { - eventHandler, - getEvent, - getResponseStatus, - toWebRequest, -} from '@tanstack/start-server-core' import { startSerializer } from '@tanstack/start-client-core' // @ts-expect-error -import _serverFnManifest from 'tsr:server-fn-manifest' -import type { H3Event } from '@tanstack/start-server-core' +import _serverFnManifest from 'tanstack:server-fn-manifest' +import { getEvent, getResponseStatus } from './h3' // NOTE: This is a dummy export to silence warnings about // only having a default export. -export const dummy = 1 - -export default eventHandler(handleServerAction) +export const dummy = 2 const serverFnManifest = _serverFnManifest as Record< string, @@ -26,16 +18,6 @@ const serverFnManifest = _serverFnManifest as Record< } > -async function handleServerAction(event: H3Event) { - const request = toWebRequest(event)! - - const response = await handleServerRequest({ - request, - event, - }) - return response -} - function sanitizeBase(base: string | undefined) { if (!base) { throw new Error( @@ -46,17 +28,11 @@ function sanitizeBase(base: string | undefined) { return base.replace(/^\/|\/$/g, '') } -async function handleServerRequest({ - request, - event, -}: { - request: Request - event: H3Event -}) { +export const handleServerAction = async ({ request }: { request: Request }) => { const controller = new AbortController() const signal = controller.signal const abort = () => controller.abort() - event.node.req.on('close', abort) + request.signal.addEventListener('abort', abort) const method = request.method const url = new URL(request.url, 'http://localhost:3000') @@ -84,33 +60,32 @@ async function handleServerRequest({ const serverFnInfo = serverFnManifest[serverFnId] if (!serverFnInfo) { - console.log('serverFnManifest', serverFnManifest) + console.info('serverFnManifest', serverFnManifest) throw new Error('Server function info not found for ' + serverFnId) } - if (process.env.NODE_ENV === 'development') - console.info(`\nServerFn Request: ${serverFnId}`) - let fnModule: undefined | { [key: string]: any } if (process.env.NODE_ENV === 'development') { - fnModule = await (globalThis as any).app - .getRouter('server') - .internals.devServer.ssrLoadModule(serverFnInfo.extractedFilename) + const serverEnv = (globalThis as any).viteDevServer.environments['server'] + if (!serverEnv) { + throw new Error(`'server' vite dev environment not found`) + } + fnModule = await serverEnv.runner.import(serverFnInfo.extractedFilename) } else { fnModule = await serverFnInfo.importer() } if (!fnModule) { - console.log('serverFnManifest', serverFnManifest) + console.info('serverFnInfo', serverFnInfo) throw new Error('Server function module not resolved for ' + serverFnId) } const action = fnModule[serverFnInfo.functionName] if (!action) { - console.log('serverFnManifest', serverFnManifest) - console.log('fnModule', fnModule) + console.info('serverFnInfo', serverFnInfo) + console.info('fnModule', fnModule) throw new Error( `Server function module export not resolved for serverFn ID: ${serverFnId}`, ) @@ -208,11 +183,11 @@ async function handleServerRequest({ // return result.result // } - // TODO: RSCs + // TODO: RSCs Where are we getting this package? // if (isValidElement(result)) { // const { renderToPipeableStream } = await import( // // @ts-expect-error - // '@vinxi/react-server-dom/server' + // 'react-server-dom/server' // ) // const pipeableStream = renderToPipeableStream(result) @@ -227,8 +202,8 @@ async function handleServerRequest({ // return new Response(null, { status: 200 }) // } - if (isRedirect(result) || isNotFound(result)) { - return redirectOrNotFoundResponse(result) + if (isNotFound(result)) { + return isNotFoundResponse(result) } return new Response( @@ -257,8 +232,8 @@ async function handleServerRequest({ // The client will check for __redirect and __notFound keys, // and if they exist, it will handle them appropriately. - if (isRedirect(error) || isNotFound(error)) { - return redirectOrNotFoundResponse(error) + if (isNotFound(error)) { + return isNotFoundResponse(error) } console.info() @@ -275,30 +250,17 @@ async function handleServerRequest({ }) } })() - event.node.req.removeListener('close', abort) + + request.signal.removeEventListener('abort', abort) if (isRaw) { return response } - if (process.env.NODE_ENV === 'development') - console.info(`ServerFn Response: ${response.status}`) - - if (response.headers.get('Content-Type') === 'application/json') { - const cloned = response.clone() - const text = await cloned.text() - const payload = text ? JSON.stringify(JSON.parse(text)) : 'undefined' - - if (process.env.NODE_ENV === 'development') - console.info( - ` - Payload: ${payload.length > 100 ? payload.substring(0, 100) + '...' : payload}`, - ) - } - if (process.env.NODE_ENV === 'development') console.info() return response } -function redirectOrNotFoundResponse(error: any) { +function isNotFoundResponse(error: any) { const { headers, ...rest } = error return new Response(JSON.stringify(rest), { diff --git a/packages/start-server-core/src/serverRoute.ts b/packages/start-server-core/src/serverRoute.ts new file mode 100644 index 0000000000..65fa00c8b2 --- /dev/null +++ b/packages/start-server-core/src/serverRoute.ts @@ -0,0 +1,661 @@ +import { joinPaths, rootRouteId, trimPathLeft } from '@tanstack/router-core' +import type { + Assign, + Constrain, + Expand, + ResolveParams, + RouteConstraints, + TrimPathRight, +} from '@tanstack/router-core' +import type { + AnyRequestMiddleware, + AssignAllServerContext, +} from '@tanstack/start-client-core' + +type TODO = any + +export function createServerFileRoute< + TParentRoute extends AnyServerRouteWithTypes, + TId extends RouteConstraints['TId'], + TPath extends RouteConstraints['TPath'], + TFullPath extends RouteConstraints['TFullPath'], + TChildren, +>(__?: never): ServerRoute { + return createServerRoute( + undefined, + ) +} + +export interface ServerRouteOptions< + TParentRoute extends AnyServerRouteWithTypes, + TId extends RouteConstraints['TId'], + TPath extends RouteConstraints['TPath'], + TFullPath extends RouteConstraints['TFullPath'], + TMiddlewares, +> { + id: TId + path: TPath + pathname: TFullPath + originalIndex: number + getParentRoute?: () => TParentRoute + middleware: Constrain> + methods: Record< + string, + ServerRouteMethodHandlerFn + > + caseSensitive?: boolean +} + +export type ServerRouteManifest = { + middleware: boolean + methods: Record +} + +export function createServerRoute< + TParentRoute extends AnyServerRouteWithTypes, + TId extends RouteConstraints['TId'], + TPath extends RouteConstraints['TPath'], + TFullPath extends RouteConstraints['TFullPath'], + TChildren, +>( + __?: never, + __opts?: Partial< + ServerRouteOptions + >, +): ServerRoute { + const options = __opts || {} + + const route: ServerRoute = { + path: '' as TPath, + id: '' as TId, + fullPath: '' as TFullPath, + to: '' as TrimPathRight, + options: options as TODO, + parentRoute: undefined as unknown as TParentRoute, + _types: {} as TODO, + // children: undefined as TChildren, + middleware: (middlewares: TODO) => + createServerRoute(undefined, { + ...options, + middleware: middlewares, + }) as TODO, + methods: (methodsOrGetMethods: TODO) => { + const methods = (() => { + if (typeof methodsOrGetMethods === 'function') { + return methodsOrGetMethods(createMethodBuilder()) + } + + return methodsOrGetMethods + })() + + return createServerRoute(undefined, { + ...__opts, + methods, + }) as TODO + }, + update: (opts) => + createServerRoute(undefined, { + ...options, + ...opts, + }) as TODO, + init: (opts: { originalIndex: number }): void => { + options.originalIndex = opts.originalIndex + + const isRoot = !options.path && !options.id + + route.parentRoute = options.getParentRoute?.() as TParentRoute + + if (isRoot) { + route.path = rootRouteId as TPath + } else if (!(route.parentRoute as any)) { + throw new Error( + `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a ServerRoute instance.`, + ) + } + + let path: undefined | string = isRoot ? rootRouteId : options.path + + // If the path is anything other than an index path, trim it up + if (path && path !== '/') { + path = trimPathLeft(path) + } + + const customId = options.id || path + + // Strip the parentId prefix from the first level of children + let id = isRoot + ? rootRouteId + : joinPaths([ + route.parentRoute.id === rootRouteId ? '' : route.parentRoute.id, + customId, + ]) + + if (path === rootRouteId) { + path = '/' + } + + if (id !== rootRouteId) { + id = joinPaths(['/', id]) + } + + const fullPath = + id === rootRouteId ? '/' : joinPaths([route.parentRoute.fullPath, path]) + + route.path = path as TPath + route.id = id as TId + route.fullPath = fullPath as TFullPath + route.to = fullPath as TrimPathRight + }, + + _addFileChildren: (children) => { + if (Array.isArray(children)) { + route.children = children as TChildren as TODO + } + + if (typeof children === 'object' && children !== null) { + route.children = Object.values(children) as TChildren as TODO + } + + return route as any + }, + + _addFileTypes: () => route, + } + + return route +} + +export type ServerRouteAddFileChildrenFn< + in out TParentRoute extends AnyServerRouteWithTypes, + in out TId extends RouteConstraints['TId'], + in out TPath extends RouteConstraints['TPath'], + in out TFullPath extends RouteConstraints['TFullPath'], + in out TMiddlewares, + in out TMethods, + in out TChildren, +> = ( + children: TChildren, +) => ServerRouteWithTypes< + TParentRoute, + TId, + TPath, + TFullPath, + TMiddlewares, + TMethods, + TChildren +> + +const createMethodBuilder = < + TParentRoute extends AnyServerRouteWithTypes, + TFullPath extends string, + TMiddlewares, +>( + __opts?: TODO, +): ServerRouteMethodBuilder => { + return { + _options: __opts || {}, + _types: {} as TODO, + middleware: (middlewares) => + createMethodBuilder({ + ...__opts, + middlewares, + }) as TODO, + handler: (handler) => + createMethodBuilder({ + ...__opts, + handler, + }) as TODO, + } +} + +export type CreateServerFileRoute< + TParentRoute extends AnyServerRouteWithTypes, + TId extends RouteConstraints['TId'], + TPath extends RouteConstraints['TPath'], + TFullPath extends RouteConstraints['TFullPath'], + TChildren, +> = ( + options?: undefined, +) => ServerRoute + +export type AnyServerRouteWithTypes = ServerRouteWithTypes< + any, + any, + any, + any, + any, + any, + any +> + +export interface ServerRouteWithTypes< + TParentRoute extends AnyServerRouteWithTypes, + TId extends RouteConstraints['TId'], + TPath extends RouteConstraints['TPath'], + TFullPath extends RouteConstraints['TFullPath'], + TMiddlewares, + TMethods, + TChildren, +> { + _types: ServerRouteTypes< + TParentRoute, + TId, + TPath, + TFullPath, + TMiddlewares, + TMethods + > + path: TPath + id: TId + fullPath: TFullPath + to: TrimPathRight + parentRoute: TParentRoute + children?: TChildren + options: ServerRouteOptions + update: ( + opts: ServerRouteOptions, + ) => ServerRoute + init: (opts: { originalIndex: number }) => void + _addFileChildren: ServerRouteAddFileChildrenFn< + TParentRoute, + TId, + TPath, + TFullPath, + TMiddlewares, + TMethods, + TChildren + > + _addFileTypes: () => ServerRouteWithTypes< + TParentRoute, + TId, + TPath, + TFullPath, + TMiddlewares, + TMethods, + TChildren + > +} + +export interface ServerRouteTypes< + TParentRoute extends AnyServerRouteWithTypes, + TId extends RouteConstraints['TId'], + TPath extends RouteConstraints['TPath'], + TFullPath extends RouteConstraints['TFullPath'], + TMiddlewares, + TMethods, +> { + id: TId + path: TPath + fullPath: TFullPath + middlewares: TMiddlewares + methods: TMethods + parentRoute: TParentRoute + allContext: ResolveAllServerContext +} + +export type ResolveAllServerContext< + TParentRoute extends AnyServerRouteWithTypes, + TMiddlewares, +> = unknown extends TParentRoute + ? AssignAllServerContext + : Assign< + TParentRoute['_types']['allContext'], + AssignAllServerContext + > + +export type AnyServerRoute = AnyServerRouteWithTypes + +export interface ServerRoute< + TParentRoute extends AnyServerRouteWithTypes, + TId extends RouteConstraints['TId'], + TPath extends RouteConstraints['TPath'], + TFullPath extends RouteConstraints['TFullPath'], + TChildren, +> extends ServerRouteWithTypes< + TParentRoute, + TId, + TPath, + TFullPath, + undefined, + undefined, + TChildren + >, + ServerRouteMiddleware, + ServerRouteMethods< + TParentRoute, + TId, + TPath, + TFullPath, + undefined, + TChildren + > {} + +export interface ServerRouteMiddleware< + TParentRoute extends AnyServerRouteWithTypes, + TId extends RouteConstraints['TId'], + TPath extends RouteConstraints['TPath'], + TFullPath extends RouteConstraints['TFullPath'], + TChildren, +> { + middleware: ( + middleware: Constrain>, + ) => ServerRouteAfterMiddleware< + TParentRoute, + TId, + TPath, + TFullPath, + TNewMiddleware, + TChildren + > +} + +export interface ServerRouteAfterMiddleware< + TParentRoute extends AnyServerRouteWithTypes, + TId extends RouteConstraints['TId'], + TPath extends RouteConstraints['TPath'], + TFullPath extends RouteConstraints['TFullPath'], + TMiddlewares, + TChildren, +> extends ServerRouteWithTypes< + TParentRoute, + TId, + TPath, + TFullPath, + TMiddlewares, + undefined, + TChildren + >, + ServerRouteMethods< + TParentRoute, + TId, + TPath, + TFullPath, + TMiddlewares, + TChildren + > {} + +export interface ServerRouteMethods< + TParentRoute extends AnyServerRouteWithTypes, + TId extends RouteConstraints['TId'], + TPath extends RouteConstraints['TPath'], + TFullPath extends RouteConstraints['TFullPath'], + TMiddlewares, + TChildren, +> { + methods: ( + methodsOrGetMethods: Constrain< + TMethods, + ServerRouteMethodsOptions + >, + ) => ServerRouteAfterMethods< + TParentRoute, + TId, + TPath, + TFullPath, + TMiddlewares, + TMethods, + TChildren + > +} + +export type ServerRouteMethodsOptions< + TParentRoute extends AnyServerRouteWithTypes, + TFullPath extends string, + TMiddlewares, +> = + | ServerRouteMethodsRecord + | (( + api: ServerRouteMethodBuilder, + ) => ServerRouteMethodsRecord) + +export interface ServerRouteMethodsRecord< + TParentRoute extends AnyServerRouteWithTypes, + TFullPath extends string, + TMiddlewares, +> { + GET?: ServerRouteMethodRecordValue + POST?: ServerRouteMethodRecordValue + PUT?: ServerRouteMethodRecordValue + PATCH?: ServerRouteMethodRecordValue + DELETE?: ServerRouteMethodRecordValue + OPTIONS?: ServerRouteMethodRecordValue + HEAD?: ServerRouteMethodRecordValue +} + +export type ServerRouteMethodRecordValue< + TParentRoute extends AnyServerRouteWithTypes, + TFullPath extends string, + TMiddlewares, +> = + | ServerRouteMethodHandlerFn< + TParentRoute, + TFullPath, + TMiddlewares, + undefined, + any + > + | AnyRouteMethodsBuilder + +export type ServerRouteVerb = (typeof ServerRouteVerbs)[number] + +export const ServerRouteVerbs = [ + 'GET', + 'POST', + 'PUT', + 'PATCH', + 'DELETE', + 'OPTIONS', + 'HEAD', +] as const + +export type ServerRouteMethodHandlerFn< + TParentRoute extends AnyServerRouteWithTypes, + TFullPath extends string, + TMiddlewares, + TMethodMiddlewares, + TResponse, +> = ( + ctx: ServerRouteMethodHandlerCtx< + TParentRoute, + TFullPath, + TMiddlewares, + TMethodMiddlewares + >, +) => TResponse | Promise + +export interface ServerRouteMethodHandlerCtx< + in out TParentRoute extends AnyServerRouteWithTypes, + in out TFullPath extends string, + in out TMiddlewares, + in out TMethodMiddlewares, +> { + context: Expand< + AssignAllMethodContext + > + request: Request + params: ResolveParams + pathname: TFullPath +} + +export type MergeMethodMiddlewares = + TMiddlewares extends ReadonlyArray + ? TMethodMiddlewares extends ReadonlyArray + ? readonly [...TMiddlewares, ...TMethodMiddlewares] + : TMiddlewares + : TMethodMiddlewares + +export type AssignAllMethodContext< + TParentRoute extends AnyServerRouteWithTypes, + TMiddlewares, + TMethodMiddlewares, +> = ResolveAllServerContext< + TParentRoute, + MergeMethodMiddlewares +> + +export type AnyRouteMethodsBuilder = ServerRouteMethodBuilderWithTypes< + any, + any, + any, + any +> + +export interface ServerRouteMethodBuilder< + TParentRoute extends AnyServerRouteWithTypes, + TFullPath extends string, + TMiddlewares, +> extends ServerRouteMethodBuilderWithTypes< + TFullPath, + TMiddlewares, + undefined, + undefined + >, + ServerRouteMethodBuilderMiddleware, + ServerRouteMethodBuilderHandler< + TParentRoute, + TFullPath, + TMiddlewares, + undefined + > {} + +export interface ServerRouteMethodBuilderWithTypes< + TFullPath extends string, + TMiddlewares, + TMethodMiddlewares, + TResponse, +> { + _options: TODO + _types: ServerRouteMethodBuilderTypes< + TFullPath, + TMiddlewares, + TMethodMiddlewares, + TResponse + > +} + +export interface ServerRouteMethodBuilderTypes< + in out TFullPath extends string, + in out TMiddlewares, + in out TMethodMiddlewares, + in out TResponse, +> { + middlewares: TMiddlewares + methodMiddleware: TMethodMiddlewares + fullPath: TFullPath + response: TResponse +} + +export interface ServerRouteMethodBuilderMiddleware< + TParentRoute extends AnyServerRouteWithTypes, + TFullPath extends string, + TMiddlewares, +> { + middleware: ( + middleware: Constrain< + TNewMethodMiddlewares, + ReadonlyArray + >, + ) => ServerRouteMethodBuilderAfterMiddleware< + TParentRoute, + TFullPath, + TMiddlewares, + TNewMethodMiddlewares + > +} + +export interface ServerRouteMethodBuilderAfterMiddleware< + TParentRoute extends AnyServerRouteWithTypes, + TFullPath extends string, + TMiddlewares, + TMethodMiddlewares, +> extends ServerRouteMethodBuilderWithTypes< + TFullPath, + TMiddlewares, + TMethodMiddlewares, + undefined + >, + ServerRouteMethodBuilderHandler< + TParentRoute, + TFullPath, + TMiddlewares, + TMethodMiddlewares + > {} + +export interface ServerRouteMethodBuilderHandler< + TParentRoute extends AnyServerRouteWithTypes, + TFullPath extends string, + TMiddlewares, + TMethodMiddlewares, +> { + handler: ( + handler: ServerRouteMethodHandlerFn< + TParentRoute, + TFullPath, + TMiddlewares, + TMethodMiddlewares, + TResponse + >, + ) => ServerRouteMethodBuilderAfterHandler< + TParentRoute, + TFullPath, + TMiddlewares, + TMethodMiddlewares, + TResponse + > +} + +export interface ServerRouteMethodBuilderAfterHandler< + TParentRoute extends AnyServerRouteWithTypes, + TFullPath extends string, + TMiddlewares, + TMethodMiddlewares, + TResponse, +> extends ServerRouteMethodBuilderWithTypes< + TFullPath, + TMiddlewares, + TMethodMiddlewares, + TResponse + > { + opts: ServerRouteMethod< + TParentRoute, + TFullPath, + TMiddlewares, + TMethodMiddlewares + > +} + +export interface ServerRouteMethod< + TParentRoute extends AnyServerRouteWithTypes, + TFullPath extends string, + TMiddlewares, + TMethodMiddlewares, +> { + middleware?: Constrain> + handler?: ServerRouteMethodHandlerFn< + TParentRoute, + TFullPath, + TMiddlewares, + TMethodMiddlewares, + undefined + > +} + +export interface ServerRouteAfterMethods< + TParentRoute extends AnyServerRouteWithTypes, + TId extends RouteConstraints['TId'], + TPath extends RouteConstraints['TPath'], + TFullPath extends RouteConstraints['TFullPath'], + TMiddlewares, + TMethods, + TChildren, +> extends ServerRouteWithTypes< + TParentRoute, + TId, + TPath, + TFullPath, + TMiddlewares, + TMethods, + TChildren + > { + options: ServerRouteOptions +} diff --git a/packages/start-server-core/src/tanstack-start.d.ts b/packages/start-server-core/src/tanstack-start.d.ts new file mode 100644 index 0000000000..760f7c0a5a --- /dev/null +++ b/packages/start-server-core/src/tanstack-start.d.ts @@ -0,0 +1,5 @@ +declare module 'tanstack:start-manifest' { + import type { Manifest } from '@tanstack/router-core' + + export const tsrStartManifest: () => Manifest +} diff --git a/packages/start-server-core/src/undici.ts b/packages/start-server-core/src/undici.ts new file mode 100644 index 0000000000..8a3a638acb --- /dev/null +++ b/packages/start-server-core/src/undici.ts @@ -0,0 +1,60 @@ +import { setGlobalOrigin } from 'undici' + +/** + * DO NOT USE THIS FUNCTION. THIS FUNCTION IS FOR INTERNAL USE ONLY. + * + * @internal + */ +export const __setGlobalOrigin = setGlobalOrigin + +/** + * DO NOT USE THIS FUNCTION. THIS FUNCTION IS FOR INTERNAL USE ONLY. + * + * Constructs an absolute URL from the given request object and options. + * + * @internal + * @param req - The `Request` object containing the headers to extract the host and protocol. + * @param options - Configuration options for determining the trust level of proxy headers. + * @param options.trustProxy - If `true`, the function will trust the `x-forwarded-host` and `x-forwarded-proto` headers + * to determine the host and protocol. Defaults to `false`. + * @returns The absolute URL constructed from the request headers as a string. + * @throws Will throw an error if the `host` cannot be determined from the request headers. + * + * @example + * ```ts + * // Example usage: + * const req = new Request('http://example.com', { + * headers: { + * 'host': 'example.com', + * 'x-forwarded-host': 'proxy.example.com', + * 'x-forwarded-proto': 'https', + * }, + * }); + * + * // Without trusting proxy headers + * const url1 = getAbsoluteUrl(req); + * console.log(url1); // Output: "http://example.com" + * + * // With trusting proxy headers + * const url2 = getAbsoluteUrl(req, { trustProxy: true }); + * console.log(url2); // Output: "https://proxy.example.com" + * ``` + */ +export function __getAbsoluteUrl( + req: Request, + options: { trustProxy: boolean } = { trustProxy: false }, +): string { + const headers = req.headers + + const host = options.trustProxy + ? headers.get('x-forwarded-host') || headers.get('host') + : headers.get('host') + + const protocol = options.trustProxy + ? headers.get('x-forwarded-proto') || 'http' + : 'http' + + if (!host) throw new Error('Cannot determine host from request headers') + + return `${protocol}://${host}` +} diff --git a/packages/start-server-core/tests/serverRoute.test-d.ts b/packages/start-server-core/tests/serverRoute.test-d.ts new file mode 100644 index 0000000000..1934238b06 --- /dev/null +++ b/packages/start-server-core/tests/serverRoute.test-d.ts @@ -0,0 +1,286 @@ +import { expectTypeOf, test } from 'vitest' +import { json } from '../../start-client-core/src/json' +import { createMiddleware } from '../../start-client-core/src/createMiddleware' +import { createServerFileRoute as defaultCreateServerFileRoute } from '../src/serverRoute' +import type { CreateServerFileRoute } from '../src/serverRoute' + +test('createServerFileRoute with methods with no middleware', () => { + type Path = '$detailId' + const createServerFileRoute: CreateServerFileRoute< + any, + Path, + Path, + Path, + unknown + > = defaultCreateServerFileRoute + + const serverFileRoute = createServerFileRoute() + + expectTypeOf(serverFileRoute).toHaveProperty('methods') + expectTypeOf(serverFileRoute).toHaveProperty('middleware') + + serverFileRoute.methods({ + GET: (ctx) => { + expectTypeOf(ctx).toEqualTypeOf<{ + context: undefined + params: { detailId: string } + pathname: '$detailId' + request: Request + }>() + + return json({ + test: 'test', + }) + }, + }) + + serverFileRoute.methods((r) => ({ + GET: r.handler((ctx) => { + expectTypeOf(ctx).toEqualTypeOf<{ + context: undefined + params: { detailId: string } + pathname: '$detailId' + request: Request + }>() + + return json({ + test: 'test', + }) + }), + })) +}) + +test('createServerFileRoute with methods and route middleware context', () => { + type Path = '$detailId' + const createServerFileRoute: CreateServerFileRoute< + any, + Path, + Path, + Path, + unknown + > = defaultCreateServerFileRoute + + const routeMiddleware = createMiddleware({ type: 'request' }).server( + ({ next }) => next({ context: { a: 'a' } }), + ) + + const serverFileRoute = createServerFileRoute().middleware([routeMiddleware]) + + serverFileRoute.methods({ + GET: (ctx) => { + expectTypeOf(ctx).toEqualTypeOf<{ + context: { a: string } + params: { detailId: string } + pathname: '$detailId' + request: Request + }>() + + return json({ + test: 'test', + }) + }, + }) + + serverFileRoute.methods((r) => ({ + GET: r.handler((ctx) => { + expectTypeOf(ctx).toEqualTypeOf<{ + context: { a: string } + params: { detailId: string } + pathname: '$detailId' + request: Request + }>() + + return json({ + test: 'test', + }) + }), + })) +}) + +test('createServerFileRoute with methods middleware and route middleware', () => { + type Path = '$detailId' + const createServerFileRoute: CreateServerFileRoute< + any, + Path, + Path, + Path, + unknown + > = defaultCreateServerFileRoute + + const routeMiddleware = createMiddleware({ type: 'request' }).server( + ({ next }) => next({ context: { a: 'a' } }), + ) + + const serverFileRoute = createServerFileRoute().middleware([routeMiddleware]) + + const methodMiddleware = createMiddleware({ type: 'request' }).server( + ({ next }) => next({ context: { b: 'b' } }), + ) + + serverFileRoute.methods((r) => ({ + GET: r.middleware([methodMiddleware]).handler((ctx) => { + expectTypeOf(ctx).toEqualTypeOf<{ + context: { a: string; b: string } + params: { detailId: string } + pathname: '$detailId' + request: Request + }>() + + return json({ + test: 'test', + }) + }), + })) +}) + +test('createServerFileRoute with a parent middleware context', () => { + const createDetailsServerFileRoute: CreateServerFileRoute< + any, + 'details', + 'details', + 'details', + unknown + > = defaultCreateServerFileRoute + + const routeMiddleware1 = createMiddleware({ type: 'request' }).server( + ({ next }) => { + return next({ context: { a: 'a' } }) + }, + ) + + const _detailsServerRoute = createDetailsServerFileRoute().middleware([ + routeMiddleware1, + ]) + + const createDetailServerFileRoute: CreateServerFileRoute< + typeof _detailsServerRoute, + 'details/$detailId', + '$detailId', + 'details/$detailId', + unknown + > = defaultCreateServerFileRoute + + const routeMiddleware2 = createMiddleware({ type: 'request' }).server( + ({ next }) => { + return next({ context: { b: 'b' } }) + }, + ) + + createDetailServerFileRoute() + .middleware([routeMiddleware2]) + .methods({ + GET: (ctx) => { + expectTypeOf(ctx).toEqualTypeOf<{ + context: { a: string; b: string } + params: { detailId: string } + pathname: 'details/$detailId' + request: Request + }>() + + return json({ test: 'test' }) + }, + }) + + const methodMiddleware = createMiddleware({ type: 'request' }).server( + ({ next }) => { + return next({ context: { c: 'c' } }) + }, + ) + + createDetailServerFileRoute() + .middleware([routeMiddleware2]) + .methods((r) => ({ + GET: r.middleware([methodMiddleware]).handler((ctx) => { + expectTypeOf(ctx).toEqualTypeOf<{ + context: { a: string; b: string; c: string } + params: { detailId: string } + pathname: 'details/$detailId' + request: Request + }>() + + return json({ test: 'test' }) + }), + })) +}) + +test('createServerFileRoute with parent middleware params', () => { + const createDetailsServerFileRoute: CreateServerFileRoute< + any, + '$userId', + '$userId', + '$userId', + unknown + > = defaultCreateServerFileRoute + + const _detailsServerRoute = createDetailsServerFileRoute() + + const createDetailServerFileRoute: CreateServerFileRoute< + typeof _detailsServerRoute, + '$userId/$detailId', + '$detailId', + '$userId/$detailId', + unknown + > = defaultCreateServerFileRoute + + createDetailServerFileRoute().methods({ + GET: (ctx) => { + expectTypeOf(ctx).toEqualTypeOf<{ + context: undefined + params: { userId: string; detailId: string } + pathname: '$userId/$detailId' + request: Request + }>() + + return json({ test: 'test' }) + }, + }) + + createDetailServerFileRoute().methods((r) => ({ + GET: r.handler((ctx) => { + expectTypeOf(ctx).toEqualTypeOf<{ + context: undefined + params: { userId: string; detailId: string } + pathname: '$userId/$detailId' + request: Request + }>() + + return json({ test: 'test' }) + }), + })) +}) + +test('createServerFileRoute with no params', () => { + const createDetailsServerFileRoute: CreateServerFileRoute< + any, + 'details', + 'details', + 'details', + unknown + > = defaultCreateServerFileRoute + + createDetailsServerFileRoute().methods({ + GET: (ctx) => { + expectTypeOf(ctx).toEqualTypeOf<{ + context: undefined + params: {} + pathname: 'details' + request: Request + }>() + + return json({ test: 'test' }) + }, + }) + + createDetailsServerFileRoute().methods((r) => ({ + GET: r.handler((ctx) => { + expectTypeOf(ctx).toEqualTypeOf<{ + context: undefined + params: {} + pathname: 'details' + request: Request + }>() + + return json({ test: 'test' }) + }), + })) +}) diff --git a/packages/start-server-core/vite.config.ts b/packages/start-server-core/vite.config.ts index 2f1ffffb80..edc06db539 100644 --- a/packages/start-server-core/vite.config.ts +++ b/packages/start-server-core/vite.config.ts @@ -19,5 +19,10 @@ export default mergeConfig( tanstackViteConfig({ srcDir: './src', entry: './src/index.tsx', + externalDeps: [ + 'tanstack:server-fn-manifest', + 'tanstack:start-manifest', + 'tanstack:server-routes', + ], }), ) diff --git a/packages/start-server-functions-client/README.md b/packages/start-server-functions-client/README.md index bb009b0c87..68beb4f16b 100644 --- a/packages/start-server-functions-client/README.md +++ b/packages/start-server-functions-client/README.md @@ -1,33 +1,12 @@ -> 🤫 we're cooking up something special! - -# TanStack Start +# TanStack Start - Server Functions Client -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) +This package is not meant to be used directly. It is a dependency of the TanStack Start framework-specific packages: -🤖 Type-safe router w/ built-in caching & URL state management for React! +- [`@tanstack/react-start`](https://www.npmjs.com/package/@tanstack/react-start) +- [`@tanstack/solid-start`](https://www.npmjs.com/package/@tanstack/solid-start). - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - +It provides the core functionality for TanStack Start, which is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router). -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! +Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started. diff --git a/packages/start-server-functions-fetcher/README.md b/packages/start-server-functions-fetcher/README.md index bb009b0c87..9039fddc7c 100644 --- a/packages/start-server-functions-fetcher/README.md +++ b/packages/start-server-functions-fetcher/README.md @@ -1,33 +1,12 @@ -> 🤫 we're cooking up something special! - -# TanStack Start +# TanStack Start - Server Functions Fetcher -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) +This package is not meant to be used directly. It is a dependency of the TanStack Start framework-specific packages: -🤖 Type-safe router w/ built-in caching & URL state management for React! +- [`@tanstack/react-start`](https://www.npmjs.com/package/@tanstack/react-start) +- [`@tanstack/solid-start`](https://www.npmjs.com/package/@tanstack/solid-start). - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - +It provides the core functionality for TanStack Start, which is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router). -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! +Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started. diff --git a/packages/start-server-functions-fetcher/package.json b/packages/start-server-functions-fetcher/package.json index e8e5ec5828..781de68e42 100644 --- a/packages/start-server-functions-fetcher/package.json +++ b/packages/start-server-functions-fetcher/package.json @@ -66,6 +66,7 @@ "@tanstack/start-client-core": "workspace:^" }, "devDependencies": { - "typescript": "^5.7.2" + "typescript": "^5.7.2", + "vite": "6.1.4" } } diff --git a/packages/start-server-functions-fetcher/src/index.ts b/packages/start-server-functions-fetcher/src/index.ts index f12e725a2f..8908d0652c 100644 --- a/packages/start-server-functions-fetcher/src/index.ts +++ b/packages/start-server-functions-fetcher/src/index.ts @@ -3,9 +3,10 @@ import { isNotFound, isPlainObject, isRedirect, + parseRedirect, } from '@tanstack/router-core' import { startSerializer } from '@tanstack/start-client-core' -import type { MiddlewareClientFnOptions } from '@tanstack/start-client-core' +import type { FunctionMiddlewareClientFnOptions } from '@tanstack/start-client-core' export async function serverFnFetcher( url: string, @@ -17,7 +18,7 @@ export async function serverFnFetcher( // If createServerFn was used to wrap the fetcher, // We need to handle the arguments differently if (isPlainObject(_first) && _first.method) { - const first = _first as MiddlewareClientFnOptions & { + const first = _first as FunctionMiddlewareClientFnOptions & { headers: HeadersInit } const type = first.data instanceof FormData ? 'formData' : 'payload' @@ -28,6 +29,7 @@ export async function serverFnFetcher( ? { 'content-type': 'application/json', accept: 'application/json', + 'x-tsr-redirect': 'manual', } : {}), ...(first.headers instanceof Headers @@ -63,62 +65,34 @@ export async function serverFnFetcher( url += `&raw` } - const handlerResponse = await handler(url, { - method: first.method, - headers, - signal: first.signal, - ...getFetcherRequestOptions(first), - }) - - const response = await handleResponseErrors(handlerResponse) - - // Check if the response is JSON - if (response.headers.get('content-type')?.includes('application/json')) { - // Even though the response is JSON, we need to decode it - // because the server may have transformed it - const json = startSerializer.decode(await response.json()) - - // If the response is a redirect or not found, throw it - // for the router to handle - if (isRedirect(json) || isNotFound(json) || json instanceof Error) { - throw json - } - - return json - } - - // Must be a raw response - return response + return await getResponse(() => + handler(url, { + method: first.method, + headers, + signal: first.signal, + ...getFetcherRequestOptions(first), + }), + ) } // If not a custom fetcher, it was probably // a `use server` function, so just proxy the arguments // through as a POST request - const response = await handleResponseErrors( - await handler(url, { + return await getResponse(() => + handler(url, { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify(args), + redirect: 'manual', }), ) - - // If the response is JSON, return it parsed - const contentType = response.headers.get('content-type') - if (contentType && contentType.includes('application/json')) { - return startSerializer.decode(await response.json()) - } else { - // Otherwise, return the text as a fallback - // If the user wants more than this, they can pass a - // request instead - return response.text() - } } function getFetcherRequestOptions( - opts: MiddlewareClientFnOptions, + opts: FunctionMiddlewareClientFnOptions, ) { if (opts.method === 'POST') { if (opts.data instanceof FormData) { @@ -139,17 +113,58 @@ function getFetcherRequestOptions( return {} } -async function handleResponseErrors(response: Response) { +/** + * Retrieves a response from a given function and manages potential errors + * and special response types including redirects and not found errors. + * + * @param fn - The function to execute for obtaining the response. + * @returns The processed response from the function. + * @throws If the response is invalid or an error occurs during processing. + */ +async function getResponse(fn: () => Promise) { + const response = await (async () => { + try { + return await fn() + } catch (error) { + if (error instanceof Response) { + return error + } + + throw error + } + })() + + // If the response is not ok, throw an error if (!response.ok) { const contentType = response.headers.get('content-type') const isJson = contentType && contentType.includes('application/json') if (isJson) { + // If it's JSON, decode it and throw it throw startSerializer.decode(await response.json()) } throw new Error(await response.text()) } + // Check if the response is JSON + if (response.headers.get('content-type')?.includes('application/json')) { + // Even though the response is JSON, we need to decode it + // because the server may have transformed it + let json = startSerializer.decode(await response.json()) + + const redirect = parseRedirect(json) + + if (redirect) json = redirect + + // If the response is a redirect or not found, throw it + // for the router to handle + if (isRedirect(json) || isNotFound(json) || json instanceof Error) { + throw json + } + + return json + } + return response } diff --git a/packages/start-server-functions-handler/README.md b/packages/start-server-functions-handler/README.md deleted file mode 100644 index bb009b0c87..0000000000 --- a/packages/start-server-functions-handler/README.md +++ /dev/null @@ -1,33 +0,0 @@ -> 🤫 we're cooking up something special! - - - -# TanStack Start - -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) - -🤖 Type-safe router w/ built-in caching & URL state management for React! - - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - - -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! diff --git a/packages/start-server-functions-handler/eslint.config.js b/packages/start-server-functions-handler/eslint.config.js deleted file mode 100644 index bd7118fa1a..0000000000 --- a/packages/start-server-functions-handler/eslint.config.js +++ /dev/null @@ -1,20 +0,0 @@ -// @ts-check - -import rootConfig from '../../eslint.config.js' - -export default [ - ...rootConfig, - { - files: ['**/*.{ts,tsx}'], - }, - { - plugins: {}, - rules: {}, - }, - { - files: ['**/__tests__/**'], - rules: { - '@typescript-eslint/no-unnecessary-condition': 'off', - }, - }, -] diff --git a/packages/start-server-functions-handler/package.json b/packages/start-server-functions-handler/package.json deleted file mode 100644 index cec8c3d19a..0000000000 --- a/packages/start-server-functions-handler/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@tanstack/start-server-functions-handler", - "version": "1.120.3", - "description": "Modern and scalable routing for applications", - "author": "Tanner Linsley", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/TanStack/router.git", - "directory": "packages/start-server-functions-handler" - }, - "homepage": "https://tanstack.com/start", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/tannerlinsley" - }, - "keywords": [ - "react", - "location", - "router", - "routing", - "async", - "async router", - "typescript" - ], - "scripts": { - "clean": "rimraf ./dist && rimraf ./coverage", - "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit", - "test:unit": "exit 0; vitest", - "test:eslint": "eslint ./src", - "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"", - "test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js", - "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js", - "test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js", - "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js", - "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js", - "test:types:ts58": "tsc", - "test:build": "publint --strict && attw --ignore-rules no-resolution --pack .", - "build": "vite build" - }, - "type": "module", - "types": "dist/esm/index.d.ts", - "exports": { - ".": { - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - }, - "require": { - "types": "./dist/cjs/index.d.cts", - "default": "./dist/cjs/index.cjs" - } - }, - "./package.json": "./package.json" - }, - "sideEffects": false, - "files": [ - "dist", - "src" - ], - "engines": { - "node": ">=12" - }, - "dependencies": { - "@tanstack/router-core": "workspace:^", - "@tanstack/start-client-core": "workspace:^", - "@tanstack/start-server-core": "workspace:^", - "tiny-invariant": "^1.3.3" - }, - "devDependencies": { - "typescript": "^5.7.2" - } -} diff --git a/packages/start-server-functions-handler/tsconfig.json b/packages/start-server-functions-handler/tsconfig.json deleted file mode 100644 index 0484835e6b..0000000000 --- a/packages/start-server-functions-handler/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "module": "esnext" - }, - "include": ["src", "vite.config.ts"] -} diff --git a/packages/start-server-functions-handler/vite.config.ts b/packages/start-server-functions-handler/vite.config.ts deleted file mode 100644 index cc9124d7d8..0000000000 --- a/packages/start-server-functions-handler/vite.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { defineConfig, mergeConfig } from 'vitest/config' -import { tanstackViteConfig } from '@tanstack/config/vite' -import packageJson from './package.json' -import type { ViteUserConfig } from 'vitest/config' - -const config = defineConfig({ - plugins: [] as ViteUserConfig['plugins'], - test: { - name: packageJson.name, - watch: false, - environment: 'jsdom', - }, -}) - -export default mergeConfig( - config, - tanstackViteConfig({ - entry: './src/index.ts', - srcDir: './src', - externalDeps: ['tsr:server-fn-manifest'], - }), -) diff --git a/packages/start-server-functions-server/README.md b/packages/start-server-functions-server/README.md index 2e1cf02055..5037151f69 100644 --- a/packages/start-server-functions-server/README.md +++ b/packages/start-server-functions-server/README.md @@ -1,33 +1,12 @@ -> 🤫 we're cooking up something special! - -# TanStack Start +# TanStack Start - Server Functions Server -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) +This package is not meant to be used directly. It is a dependency of the TanStack Start framework-specific packages: -🤖 Type-safe router w/ built-in caching & URL state management! +- [`@tanstack/react-start`](https://www.npmjs.com/package/@tanstack/react-start) +- [`@tanstack/solid-start`](https://www.npmjs.com/package/@tanstack/solid-start). - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - +It provides the core functionality for TanStack Start, which is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router). -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! +Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started. diff --git a/packages/start-server-functions-server/package.json b/packages/start-server-functions-server/package.json index d7011d4a02..dfc8ca60ff 100644 --- a/packages/start-server-functions-server/package.json +++ b/packages/start-server-functions-server/package.json @@ -63,7 +63,8 @@ }, "dependencies": { "@tanstack/server-functions-plugin": "workspace:^", - "tiny-invariant": "^1.3.3" + "tiny-invariant": "^1.3.3", + "vite": "6.1.0" }, "devDependencies": { "typescript": "^5.7.2" diff --git a/packages/start-server-functions-ssr/README.md b/packages/start-server-functions-ssr/README.md deleted file mode 100644 index bb009b0c87..0000000000 --- a/packages/start-server-functions-ssr/README.md +++ /dev/null @@ -1,33 +0,0 @@ -> 🤫 we're cooking up something special! - - - -# TanStack Start - -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) - -🤖 Type-safe router w/ built-in caching & URL state management for React! - - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - - -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! diff --git a/packages/start-server-functions-ssr/eslint.config.js b/packages/start-server-functions-ssr/eslint.config.js deleted file mode 100644 index bd7118fa1a..0000000000 --- a/packages/start-server-functions-ssr/eslint.config.js +++ /dev/null @@ -1,20 +0,0 @@ -// @ts-check - -import rootConfig from '../../eslint.config.js' - -export default [ - ...rootConfig, - { - files: ['**/*.{ts,tsx}'], - }, - { - plugins: {}, - rules: {}, - }, - { - files: ['**/__tests__/**'], - rules: { - '@typescript-eslint/no-unnecessary-condition': 'off', - }, - }, -] diff --git a/packages/start-server-functions-ssr/package.json b/packages/start-server-functions-ssr/package.json deleted file mode 100644 index b9feda56bc..0000000000 --- a/packages/start-server-functions-ssr/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@tanstack/start-server-functions-ssr", - "version": "1.120.3", - "description": "Modern and scalable routing for applications", - "author": "Tanner Linsley", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/TanStack/router.git", - "directory": "packages/start-server-functions-ssr" - }, - "homepage": "https://tanstack.com/start", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/tannerlinsley" - }, - "keywords": [ - "location", - "router", - "routing", - "async", - "async router", - "typescript" - ], - "scripts": { - "clean": "rimraf ./dist && rimraf ./coverage", - "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit", - "test:unit": "exit 0; vitest", - "test:eslint": "eslint ./src", - "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"", - "test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js", - "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js", - "test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js", - "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js", - "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js", - "test:types:ts58": "tsc", - "test:build": "publint --strict && attw --ignore-rules no-resolution --pack .", - "build": "vite build" - }, - "type": "module", - "types": "dist/esm/index.d.ts", - "exports": { - ".": { - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - }, - "require": { - "types": "./dist/cjs/index.d.cts", - "default": "./dist/cjs/index.cjs" - } - }, - "./package.json": "./package.json" - }, - "sideEffects": false, - "files": [ - "dist", - "src" - ], - "engines": { - "node": ">=12" - }, - "dependencies": { - "@tanstack/server-functions-plugin": "workspace:^", - "@tanstack/start-server-functions-fetcher": "workspace:^", - "@tanstack/start-client-core": "workspace:^", - "@tanstack/start-server-core": "workspace:^", - "tiny-invariant": "^1.3.3" - }, - "devDependencies": { - "typescript": "^5.7.2" - } -} diff --git a/packages/start-server-functions-ssr/src/index.ts b/packages/start-server-functions-ssr/src/index.ts deleted file mode 100644 index 0d3430fe71..0000000000 --- a/packages/start-server-functions-ssr/src/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// -import { serverFnFetcher } from '@tanstack/start-server-functions-fetcher' -import { mergeHeaders } from '@tanstack/start-client-core' -import { getEvent, getHeaders } from '@tanstack/start-server-core' -import type { CreateRpcFn } from '@tanstack/server-functions-plugin' - -function sanitizeBase(base: string) { - return base.replace(/^\/|\/$/g, '') -} - -export const createSsrRpc: CreateRpcFn = (functionId, serverBase) => { - const url = `/${sanitizeBase(serverBase)}/${functionId}` - - const ssrFn = (...args: Array) => { - return serverFnFetcher(url, args, async (url, requestInit) => { - // pass on the headers from the document request to the server function fetch - requestInit.headers = mergeHeaders(getHeaders(), requestInit.headers) - // @ts-expect-error The $fetch.native method is not typed yet - const res: Response = await $fetch.native(url, requestInit) - const event = getEvent() - const mergedHeaders = mergeHeaders( - res.headers, - (event as any).___ssrRpcResponseHeaders, - ) - - // any response headers set in the server function need to be set on the document response - // we attach the headers to the event so we can later set them - ;(event as any).___ssrRpcResponseHeaders = mergedHeaders - return res - }) - } - - return Object.assign(ssrFn, { - url, - functionId, - }) -} diff --git a/packages/start-server-functions-ssr/tsconfig.json b/packages/start-server-functions-ssr/tsconfig.json deleted file mode 100644 index 51dda9abf2..0000000000 --- a/packages/start-server-functions-ssr/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "jsx": "react-jsx", - "module": "esnext" - }, - "include": ["src", "vite.config.ts"] -} diff --git a/packages/start-server-functions-ssr/tsconfigs/config.tsconfig.json b/packages/start-server-functions-ssr/tsconfigs/config.tsconfig.json deleted file mode 100644 index 58fc33fb0a..0000000000 --- a/packages/start-server-functions-ssr/tsconfigs/config.tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../../tsconfig.json", - "include": ["../src/config/index.ts"], - "compilerOptions": { - "rootDir": "../src/config", - "outDir": "../dist/esm/config", - "target": "esnext", - "noEmit": false - } -} diff --git a/packages/start-server-functions-ssr/tsconfigs/router-manifest.tsconfig.json b/packages/start-server-functions-ssr/tsconfigs/router-manifest.tsconfig.json deleted file mode 100644 index cc108d2494..0000000000 --- a/packages/start-server-functions-ssr/tsconfigs/router-manifest.tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../../tsconfig.json", - "include": ["../src/router-manifest/index.ts"], - "compilerOptions": { - "rootDir": "../src/router-manifest", - "outDir": "../dist/esm/router-manifest", - "target": "esnext", - "noEmit": false - } -} diff --git a/packages/start/README.md b/packages/start/README.md deleted file mode 100644 index bb009b0c87..0000000000 --- a/packages/start/README.md +++ /dev/null @@ -1,33 +0,0 @@ -> 🤫 we're cooking up something special! - - - -# TanStack Start - -![TanStack Router Header](https://github.com/tanstack/router/raw/main/media/header.png) - -🤖 Type-safe router w/ built-in caching & URL state management for React! - - - #TanStack - - - - - - - - semantic-release - - Join the discussion on Github -Best of JS - - - - - - - -Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual) - -## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more! diff --git a/packages/start/eslint.config.js b/packages/start/eslint.config.js deleted file mode 100644 index 931f0ec774..0000000000 --- a/packages/start/eslint.config.js +++ /dev/null @@ -1,31 +0,0 @@ -// @ts-check - -import pluginReact from '@eslint-react/eslint-plugin' -import pluginReactHooks from 'eslint-plugin-react-hooks' -import rootConfig from '../../eslint.config.js' - -export default [ - ...rootConfig, - { - ...pluginReact.configs.recommended, - files: ['**/*.{ts,tsx}'], - }, - { - plugins: { - 'react-hooks': pluginReactHooks, - }, - rules: { - '@eslint-react/no-unstable-context-value': 'off', - '@eslint-react/no-unstable-default-props': 'off', - '@eslint-react/dom/no-missing-button-type': 'off', - 'react-hooks/exhaustive-deps': 'error', - 'react-hooks/rules-of-hooks': 'error', - }, - }, - { - files: ['**/__tests__/**'], - rules: { - '@typescript-eslint/no-unnecessary-condition': 'off', - }, - }, -] diff --git a/packages/start/package.json b/packages/start/package.json deleted file mode 100644 index 2a4f92a117..0000000000 --- a/packages/start/package.json +++ /dev/null @@ -1,156 +0,0 @@ -{ - "name": "@tanstack/start", - "version": "1.120.3", - "description": "Modern and scalable routing for React applications", - "author": "Tanner Linsley", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/TanStack/router.git", - "directory": "packages/start" - }, - "homepage": "https://tanstack.com/start", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/tannerlinsley" - }, - "keywords": [ - "react", - "location", - "router", - "routing", - "async", - "async router", - "typescript" - ], - "scripts": { - "clean": "rimraf ./dist && rimraf ./coverage", - "test": "pnpm test:build", - "test:build": "exit 0; vitest", - "build": "vite build" - }, - "type": "module", - "types": "dist/esm/client.d.ts", - "exports": { - ".": { - "import": { - "types": "./dist/esm/client.d.ts", - "default": "./dist/esm/client.js" - }, - "require": { - "types": "./dist/cjs/client.d.cts", - "default": "./dist/cjs/client.cjs" - } - }, - "./client": { - "import": { - "types": "./dist/esm/client.d.ts", - "default": "./dist/esm/client.js" - }, - "require": { - "types": "./dist/cjs/client.d.cts", - "default": "./dist/cjs/client.cjs" - } - }, - "./server": { - "import": { - "types": "./dist/esm/server.d.ts", - "default": "./dist/esm/server.js" - }, - "require": { - "types": "./dist/cjs/server.d.cts", - "default": "./dist/cjs/server.cjs" - } - }, - "./config": { - "import": { - "types": "./dist/esm/config.d.ts", - "default": "./dist/esm/config.js" - }, - "require": { - "types": "./dist/cjs/config.d.cts", - "default": "./dist/cjs/config.cjs" - } - }, - "./api": { - "import": { - "types": "./dist/esm/api.d.ts", - "default": "./dist/esm/api.js" - }, - "require": { - "types": "./dist/cjs/api.d.cts", - "default": "./dist/cjs/api.cjs" - } - }, - "./router-manifest": { - "import": { - "types": "./dist/esm/router-manifest.d.ts", - "default": "./dist/esm/router-manifest.js" - }, - "require": { - "types": "./dist/cjs/router-manifest.d.cts", - "default": "./dist/cjs/router-manifest.cjs" - } - }, - "./server-functions-client": { - "import": { - "types": "./dist/esm/server-functions-client.d.ts", - "default": "./dist/esm/server-functions-client.js" - }, - "require": { - "types": "./dist/cjs/server-functions-client.d.cts", - "default": "./dist/cjs/server-functions-client.cjs" - } - }, - "./server-functions-server": { - "import": { - "types": "./dist/esm/server-functions-server.d.ts", - "default": "./dist/esm/server-functions-server.js" - }, - "require": { - "types": "./dist/cjs/server-functions-server.d.cts", - "default": "./dist/cjs/server-functions-server.cjs" - } - }, - "./server-functions-handler": { - "import": { - "types": "./dist/esm/server-functions-handler.d.ts", - "default": "./dist/esm/server-functions-handler.js" - }, - "require": { - "types": "./dist/cjs/server-functions-handler.d.cts", - "default": "./dist/cjs/server-functions-handler.cjs" - } - }, - "./server-functions-ssr": { - "import": { - "types": "./dist/esm/server-functions-ssr.d.ts", - "default": "./dist/esm/server-functions-ssr.js" - }, - "require": { - "types": "./dist/cjs/server-functions-ssr.d.cts", - "default": "./dist/cjs/server-functions-ssr.cjs" - } - }, - "./package.json": "./package.json" - }, - "sideEffects": false, - "files": [ - "dist", - "src" - ], - "engines": { - "node": ">=12" - }, - "dependencies": { - "@tanstack/react-start-client": "workspace:^", - "@tanstack/react-start-server": "workspace:^", - "@tanstack/start-config": "workspace:^", - "@tanstack/react-start-router-manifest": "workspace:^", - "@tanstack/start-server-functions-client": "workspace:^", - "@tanstack/start-server-functions-server": "workspace:^", - "@tanstack/start-server-functions-handler": "workspace:^", - "@tanstack/start-server-functions-ssr": "workspace:^", - "@tanstack/start-api-routes": "workspace:^" - } -} diff --git a/packages/start/src/api.tsx b/packages/start/src/api.tsx deleted file mode 100644 index a28d259a44..0000000000 --- a/packages/start/src/api.tsx +++ /dev/null @@ -1,4 +0,0 @@ -console.warn( - '[@tanstack/start] Warning: This package has moved to @tanstack/react-start. Please switch to the new package, as this package will be dropped soon.', -) -export * from '@tanstack/start-api-routes' diff --git a/packages/start/src/client.tsx b/packages/start/src/client.tsx deleted file mode 100644 index e2a9aa5466..0000000000 --- a/packages/start/src/client.tsx +++ /dev/null @@ -1,4 +0,0 @@ -console.warn( - '[@tanstack/start] Warning: This package has moved to @tanstack/react-start. Please switch to the new package, as this package will be dropped soon.', -) -export * from '@tanstack/react-start-client' diff --git a/packages/start/src/config.tsx b/packages/start/src/config.tsx deleted file mode 100644 index 262bac966c..0000000000 --- a/packages/start/src/config.tsx +++ /dev/null @@ -1,4 +0,0 @@ -console.warn( - '[@tanstack/start] Warning: This package has moved to @tanstack/react-start. Please switch to the new package, as this package will be dropped soon.', -) -export * from '@tanstack/start-config' diff --git a/packages/start/src/router-manifest.tsx b/packages/start/src/router-manifest.tsx deleted file mode 100644 index 10e98ba06d..0000000000 --- a/packages/start/src/router-manifest.tsx +++ /dev/null @@ -1,4 +0,0 @@ -console.warn( - '[@tanstack/start] Warning: This package has moved to @tanstack/react-start. Please switch to the new package, as this package will be dropped soon.', -) -export * from '@tanstack/react-start-router-manifest' diff --git a/packages/start/src/server-functions-client.tsx b/packages/start/src/server-functions-client.tsx deleted file mode 100644 index d7baf052e5..0000000000 --- a/packages/start/src/server-functions-client.tsx +++ /dev/null @@ -1,4 +0,0 @@ -console.warn( - '[@tanstack/start] Warning: This package has moved to @tanstack/react-start. Please switch to the new package, as this package will be dropped soon.', -) -export * from '@tanstack/start-server-functions-client' diff --git a/packages/start/src/server-functions-handler.tsx b/packages/start/src/server-functions-handler.tsx deleted file mode 100644 index 9e7afcffff..0000000000 --- a/packages/start/src/server-functions-handler.tsx +++ /dev/null @@ -1,4 +0,0 @@ -console.warn( - '[@tanstack/start] Warning: This package has moved to @tanstack/react-start. Please switch to the new package, as this package will be dropped soon.', -) -export * from '@tanstack/start-server-functions-handler' diff --git a/packages/start/src/server-functions-server.tsx b/packages/start/src/server-functions-server.tsx deleted file mode 100644 index b78ff17125..0000000000 --- a/packages/start/src/server-functions-server.tsx +++ /dev/null @@ -1,4 +0,0 @@ -console.warn( - '[@tanstack/start] Warning: This package has moved to @tanstack/react-start. Please switch to the new package, as this package will be dropped soon.', -) -export * from '@tanstack/start-server-functions-server' diff --git a/packages/start/src/server-functions-ssr.tsx b/packages/start/src/server-functions-ssr.tsx deleted file mode 100644 index e66ed969c8..0000000000 --- a/packages/start/src/server-functions-ssr.tsx +++ /dev/null @@ -1,4 +0,0 @@ -console.warn( - '[@tanstack/start] Warning: This package has moved to @tanstack/react-start. Please switch to the new package, as this package will be dropped soon.', -) -export * from '@tanstack/start-server-functions-ssr' diff --git a/packages/start/src/server.tsx b/packages/start/src/server.tsx deleted file mode 100644 index 502e50b680..0000000000 --- a/packages/start/src/server.tsx +++ /dev/null @@ -1,4 +0,0 @@ -console.warn( - '[@tanstack/start] Warning: This package has moved to @tanstack/react-start. Please switch to the new package, as this package will be dropped soon.', -) -export * from '@tanstack/react-start-server' diff --git a/packages/start/tsconfig.json b/packages/start/tsconfig.json deleted file mode 100644 index 51dda9abf2..0000000000 --- a/packages/start/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "jsx": "react-jsx", - "module": "esnext" - }, - "include": ["src", "vite.config.ts"] -} diff --git a/packages/start/vite.config.ts b/packages/start/vite.config.ts deleted file mode 100644 index 7c6fa9afe4..0000000000 --- a/packages/start/vite.config.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { defineConfig, mergeConfig } from 'vitest/config' -import { tanstackViteConfig } from '@tanstack/config/vite' -import packageJson from './package.json' - -const config = defineConfig({ - test: { - name: packageJson.name, - watch: false, - environment: 'jsdom', - }, -}) - -export default mergeConfig( - config, - tanstackViteConfig({ - srcDir: './src', - entry: [ - './src/client.tsx', - './src/server.tsx', - './src/config.tsx', - './src/router-manifest.tsx', - './src/server-functions-client.tsx', - './src/server-functions-server.tsx', - './src/server-functions-ssr.tsx', - './src/api.tsx', - ], - externalDeps: [ - '@tanstack/react-start-client', - '@tanstack/react-start-server', - '@tanstack/start-config', - '@tanstack/react-start-router-manifest', - '@tanstack/start-server-functions-client', - '@tanstack/start-server-functions-server', - '@tanstack/start-server-functions-ssr', - '@tanstack/start-api-routes', - ], - }), -) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 93f882fd74..3d8e788d0c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -42,12 +42,10 @@ overrides: '@tanstack/solid-start-plugin': workspace:* '@tanstack/solid-start-router-manifest': workspace:* '@tanstack/solid-start-server': workspace:* - '@tanstack/start-api-routes': workspace:* '@tanstack/start-server-functions-fetcher': workspace:* - '@tanstack/start-server-functions-handler': workspace:* '@tanstack/start-server-functions-client': workspace:* - '@tanstack/start-server-functions-ssr': workspace:* '@tanstack/start-server-functions-server': workspace:* + '@tanstack/start-plugin-core': workspace:* '@tanstack/start-client-core': workspace:* '@tanstack/start-server-core': workspace:* '@tanstack/eslint-plugin-router': workspace:* @@ -70,7 +68,7 @@ importers: version: 1.52.0 '@tanstack/config': specifier: ^0.16.1 - version: 0.16.1(@types/node@22.13.4)(esbuild@0.25.0)(eslint@9.22.0(jiti@2.4.2))(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + version: 0.16.1(@types/node@22.13.4)(esbuild@0.25.2)(eslint@9.22.0(jiti@2.4.2))(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) '@tanstack/react-query': specifier: 5.66.0 version: 5.66.0(react@19.0.0) @@ -239,7 +237,7 @@ importers: version: 19.0.3(@types/react@19.0.8) esbuild: specifier: ^0.25.0 - version: 0.25.0 + version: 0.25.2 e2e/react-router/basic-file-based: dependencies: @@ -940,9 +938,9 @@ importers: '@tanstack/react-router-devtools': specifier: workspace:^ version: link:../../../packages/react-router-devtools - '@tanstack/start': - specifier: workspace:^ - version: link:../../../packages/start + '@tanstack/react-start': + specifier: workspace:* + version: link:../../../packages/react-start react: specifier: ^19.0.0 version: 19.0.0 @@ -955,9 +953,6 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -1028,9 +1023,9 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) devDependencies: '@playwright/test': specifier: ^1.52.0 @@ -1098,9 +1093,9 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) devDependencies: '@playwright/test': specifier: ^1.52.0 @@ -1162,9 +1157,9 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) devDependencies: '@types/react': specifier: ^19.0.8 @@ -1205,9 +1200,9 @@ importers: react-dom: specifier: ^19.0.0 version: 19.0.0(react@19.0.0) - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) devDependencies: '@tanstack/router-e2e-utils': specifier: workspace:^ @@ -1251,9 +1246,9 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) devDependencies: '@playwright/test': specifier: ^1.52.0 @@ -1315,9 +1310,9 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -1385,9 +1380,9 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -1455,9 +1450,6 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -1492,6 +1484,9 @@ importers: typescript: specifier: ^5.7.2 version: 5.8.2 + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-tsconfig-paths: specifier: ^5.1.4 version: 5.1.4(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) @@ -1565,10 +1560,10 @@ importers: version: link:../../e2e-utils esbuild: specifier: ^0.25.0 - version: 0.25.0 + version: 0.25.2 esbuild-plugin-solid: specifier: ^0.6.0 - version: 0.6.0(esbuild@0.25.0)(solid-js@1.9.5) + version: 0.6.0(esbuild@0.25.2)(solid-js@1.9.5) e2e/solid-router/basic-file-based: dependencies: @@ -1703,10 +1698,10 @@ importers: dependencies: '@tanstack/solid-query': specifier: ^5.71.9 - version: 5.71.9(solid-js@1.9.5) + version: 5.72.2(solid-js@1.9.5) '@tanstack/solid-query-devtools': specifier: ^5.71.9 - version: 5.71.9(@tanstack/solid-query@5.71.9(solid-js@1.9.5))(solid-js@1.9.5) + version: 5.72.2(@tanstack/solid-query@5.72.2(solid-js@1.9.5))(solid-js@1.9.5) '@tanstack/solid-router': specifier: workspace:^ version: link:../../../packages/solid-router @@ -1749,10 +1744,10 @@ importers: version: link:../../../packages/router-plugin '@tanstack/solid-query': specifier: ^5.71.9 - version: 5.71.9(solid-js@1.9.5) + version: 5.72.2(solid-js@1.9.5) '@tanstack/solid-query-devtools': specifier: ^5.71.9 - version: 5.71.9(@tanstack/solid-query@5.71.9(solid-js@1.9.5))(solid-js@1.9.5) + version: 5.72.2(@tanstack/solid-query@5.72.2(solid-js@1.9.5))(solid-js@1.9.5) '@tanstack/solid-router': specifier: workspace:^ version: link:../../../packages/solid-router @@ -2044,9 +2039,6 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -2096,9 +2088,6 @@ importers: solid-js: specifier: ^1.9.5 version: 1.9.5 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) devDependencies: '@tanstack/router-e2e-utils': specifier: workspace:^ @@ -2109,6 +2098,9 @@ importers: typescript: specifier: ^5.7.2 version: 5.8.2 + vite-tsconfig-paths: + specifier: ^5.1.4 + version: 5.1.4(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) e2e/solid-start/scroll-restoration: dependencies: @@ -2133,9 +2125,6 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -2194,9 +2183,6 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -2255,9 +2241,6 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -2763,7 +2746,7 @@ importers: version: 7.26.8 '@rollup/plugin-babel': specifier: ^6.0.4 - version: 6.0.4(@babel/core@7.26.8)(@types/babel__core@7.20.5)(rollup@4.39.0) + version: 6.0.4(@babel/core@7.26.8)(@types/babel__core@7.20.5)(rollup@4.38.0) '@types/express': specifier: ^4.17.21 version: 4.17.21 @@ -2836,7 +2819,7 @@ importers: version: 7.26.8 '@rollup/plugin-babel': specifier: ^6.0.4 - version: 6.0.4(@babel/core@7.26.8)(@types/babel__core@7.20.5)(rollup@4.39.0) + version: 6.0.4(@babel/core@7.26.8)(@types/babel__core@7.20.5)(rollup@4.38.0) '@types/express': specifier: ^4.17.21 version: 4.17.21 @@ -3291,7 +3274,7 @@ importers: dependencies: '@radix-ui/react-dialog': specifier: ^1.1.6 - version: 1.1.6(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + version: 1.1.7(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@tanstack/react-query': specifier: 5.66.0 version: 5.66.0(react@19.0.0) @@ -3454,7 +3437,7 @@ importers: version: 19.0.3(@types/react@19.0.8) esbuild: specifier: ^0.25.0 - version: 0.25.0 + version: 0.25.2 examples/react/quickstart-file-based: dependencies: @@ -3586,7 +3569,7 @@ importers: version: 5.8.2 webpack: specifier: ^5.97.1 - version: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack-cli@5.1.4) + version: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack-cli@5.1.4) webpack-cli: specifier: ^5.1.4 version: 5.1.4(webpack-dev-server@5.2.0)(webpack@5.97.1) @@ -3641,7 +3624,7 @@ importers: version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-plugin-dts: specifier: ^4.5.0 - version: 4.5.0(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + version: 4.5.0(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) examples/react/router-monorepo-react-query/packages/app: dependencies: @@ -3690,7 +3673,7 @@ importers: version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-plugin-dts: specifier: ^4.5.0 - version: 4.5.0(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + version: 4.5.0(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) examples/react/router-monorepo-react-query/packages/post-feature: dependencies: @@ -3727,7 +3710,7 @@ importers: version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-plugin-dts: specifier: ^4.5.0 - version: 4.5.0(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + version: 4.5.0(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) examples/react/router-monorepo-react-query/packages/post-query: dependencies: @@ -3798,7 +3781,7 @@ importers: version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-plugin-dts: specifier: ^4.5.0 - version: 4.5.0(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + version: 4.5.0(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) examples/react/router-monorepo-simple: dependencies: @@ -3841,7 +3824,7 @@ importers: version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-plugin-dts: specifier: ^4.5.0 - version: 4.5.0(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + version: 4.5.0(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) examples/react/router-monorepo-simple-lazy: dependencies: @@ -3884,7 +3867,7 @@ importers: version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-plugin-dts: specifier: ^4.5.0 - version: 4.5.0(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + version: 4.5.0(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) examples/react/router-monorepo-simple-lazy/packages/app: dependencies: @@ -3930,7 +3913,7 @@ importers: version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-plugin-dts: specifier: ^4.5.0 - version: 4.5.0(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + version: 4.5.0(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) examples/react/router-monorepo-simple-lazy/packages/post-feature: dependencies: @@ -3964,7 +3947,7 @@ importers: version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-plugin-dts: specifier: ^4.5.0 - version: 4.5.0(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + version: 4.5.0(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) examples/react/router-monorepo-simple-lazy/packages/router: dependencies: @@ -4007,7 +3990,7 @@ importers: version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-plugin-dts: specifier: ^4.5.0 - version: 4.5.0(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + version: 4.5.0(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) examples/react/router-monorepo-simple/packages/app: dependencies: @@ -4053,7 +4036,7 @@ importers: version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-plugin-dts: specifier: ^4.5.0 - version: 4.5.0(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + version: 4.5.0(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) examples/react/router-monorepo-simple/packages/post-feature: dependencies: @@ -4084,7 +4067,7 @@ importers: version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-plugin-dts: specifier: ^4.5.0 - version: 4.5.0(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + version: 4.5.0(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) examples/react/router-monorepo-simple/packages/router: dependencies: @@ -4127,7 +4110,7 @@ importers: version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-plugin-dts: specifier: ^4.5.0 - version: 4.5.0(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + version: 4.5.0(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) examples/react/scroll-restoration: dependencies: @@ -4259,9 +4242,6 @@ importers: react-dom: specifier: ^19.0.0 version: 19.0.0(react@19.0.0) - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -4308,9 +4288,12 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) + zod: + specifier: ^3.24.2 + version: 3.24.2 devDependencies: '@types/node': specifier: ^22.5.4 @@ -4366,9 +4349,6 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) devDependencies: '@types/node': specifier: ^22.5.4 @@ -4427,9 +4407,6 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) devDependencies: '@types/node': specifier: ^22.5.4 @@ -4482,9 +4459,6 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) devDependencies: '@types/react': specifier: ^19.0.8 @@ -4531,9 +4505,6 @@ importers: tailwind-merge: specifier: ^2.5.5 version: 2.6.0 - vinxi: - specifier: 0.5.1 - version: 0.5.1(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) devDependencies: '@types/node': specifier: ^22.5.4 @@ -4586,9 +4557,6 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) devDependencies: '@types/node': specifier: ^22.5.4 @@ -4668,9 +4636,6 @@ importers: tiny-invariant: specifier: ^1.3.3 version: 1.3.3 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -4714,9 +4679,6 @@ importers: react-dom: specifier: ^19.0.0 version: 19.0.0(react@19.0.0) - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) devDependencies: '@types/node': specifier: ^22.5.4 @@ -4760,9 +4722,6 @@ importers: valibot: specifier: ^1.0.0-beta.15 version: 1.0.0-beta.15(typescript@5.8.2) - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) devDependencies: '@types/node': specifier: ^22.5.4 @@ -4824,9 +4783,6 @@ importers: react-dom: specifier: ^19.0.0 version: 19.0.0(react@19.0.0) - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -4870,9 +4826,6 @@ importers: react-dom: specifier: ^19.0.0 version: 19.0.0(react@19.0.0) - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) devDependencies: '@types/react': specifier: ^19.0.8 @@ -4940,9 +4893,6 @@ importers: tiny-invariant: specifier: ^1.3.3 version: 1.3.3 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -4985,7 +4935,7 @@ importers: version: link:../../../packages/react-start '@workos-inc/node': specifier: ^7.45.0 - version: 7.45.0(express@4.21.2) + version: 7.46.0(express@4.21.2) iron-session: specifier: ^8.0.4 version: 8.0.4 @@ -4998,9 +4948,9 @@ importers: react-dom: specifier: ^19.0.0 version: 19.0.0(react@19.0.0) - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) devDependencies: '@types/react': specifier: ^19.0.8 @@ -5160,9 +5110,6 @@ importers: tailwindcss: specifier: ^3.4.17 version: 3.4.17 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -5224,9 +5171,6 @@ importers: tailwindcss: specifier: ^3.4.17 version: 3.4.17 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -5399,10 +5343,10 @@ importers: dependencies: '@tanstack/solid-query': specifier: ^5.71.9 - version: 5.71.9(solid-js@1.9.5) + version: 5.72.2(solid-js@1.9.5) '@tanstack/solid-query-devtools': specifier: ^5.71.9 - version: 5.71.9(@tanstack/solid-query@5.71.9(solid-js@1.9.5))(solid-js@1.9.5) + version: 5.72.2(@tanstack/solid-query@5.72.2(solid-js@1.9.5))(solid-js@1.9.5) '@tanstack/solid-router': specifier: ^1.120.3 version: link:../../../packages/solid-router @@ -5442,10 +5386,10 @@ importers: dependencies: '@tanstack/solid-query': specifier: ^5.71.9 - version: 5.71.9(solid-js@1.9.5) + version: 5.72.2(solid-js@1.9.5) '@tanstack/solid-query-devtools': specifier: ^5.71.9 - version: 5.71.9(@tanstack/solid-query@5.71.9(solid-js@1.9.5))(solid-js@1.9.5) + version: 5.72.2(@tanstack/solid-query@5.72.2(solid-js@1.9.5))(solid-js@1.9.5) '@tanstack/solid-router': specifier: ^1.120.3 version: link:../../../packages/solid-router @@ -5587,9 +5531,9 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) zod: specifier: ^3.24.2 version: 3.24.2 @@ -5636,9 +5580,6 @@ importers: tailwind-merge: specifier: ^2.6.0 version: 2.6.0 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) vite: specifier: 6.1.4 version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) @@ -5847,30 +5788,18 @@ importers: '@tanstack/react-start-client': specifier: workspace:* version: link:../react-start-client - '@tanstack/react-start-config': + '@tanstack/react-start-plugin': specifier: workspace:* - version: link:../react-start-config - '@tanstack/react-start-router-manifest': - specifier: workspace:* - version: link:../react-start-router-manifest + version: link:../react-start-plugin '@tanstack/react-start-server': specifier: workspace:* version: link:../react-start-server - '@tanstack/start-api-routes': - specifier: workspace:* - version: link:../start-api-routes '@tanstack/start-server-functions-client': specifier: workspace:* version: link:../start-server-functions-client - '@tanstack/start-server-functions-handler': - specifier: workspace:* - version: link:../start-server-functions-handler '@tanstack/start-server-functions-server': specifier: workspace:* version: link:../start-server-functions-server - '@tanstack/start-server-functions-ssr': - specifier: workspace:* - version: link:../start-server-functions-ssr react: specifier: ^19.0.0 version: 19.0.0 @@ -5883,7 +5812,7 @@ importers: devDependencies: esbuild: specifier: ^0.25.0 - version: 0.25.0 + version: 0.25.2 packages/react-start-client: dependencies: @@ -5914,9 +5843,6 @@ importers: tiny-warning: specifier: ^1.0.3 version: 1.0.3 - vinxi: - specifier: ^0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) devDependencies: '@testing-library/react': specifier: ^16.2.0 @@ -5928,47 +5854,23 @@ importers: specifier: ^4.3.4 version: 4.3.4(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) - packages/react-start-config: + packages/react-start-plugin: dependencies: - '@tanstack/react-start-plugin': - specifier: workspace:* - version: link:../react-start-plugin - '@tanstack/router-core': - specifier: workspace:* - version: link:../router-core - '@tanstack/router-generator': - specifier: workspace:* - version: link:../router-generator '@tanstack/router-plugin': specifier: workspace:* version: link:../router-plugin + '@tanstack/router-utils': + specifier: workspace:* + version: link:../router-utils '@tanstack/server-functions-plugin': specifier: workspace:* version: link:../server-functions-plugin - '@tanstack/start-server-functions-handler': + '@tanstack/start-plugin-core': specifier: workspace:* - version: link:../start-server-functions-handler + version: link:../start-plugin-core '@vitejs/plugin-react': specifier: ^4.3.4 version: 4.3.4(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) - import-meta-resolve: - specifier: ^4.1.0 - version: 4.1.0 - nitropack: - specifier: ^2.10.4 - version: 2.10.4(typescript@5.8.2) - ofetch: - specifier: ^1.4.1 - version: 1.4.1 - react: - specifier: ^19.0.0 - version: 19.0.0 - react-dom: - specifier: ^19.0.0 - version: 19.0.0(react@19.0.0) - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) vite: specifier: 6.1.4 version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) @@ -5976,71 +5878,6 @@ importers: specifier: ^3.24.2 version: 3.24.2 - packages/react-start-plugin: - dependencies: - '@babel/code-frame': - specifier: 7.26.2 - version: 7.26.2 - '@babel/core': - specifier: ^7.26.8 - version: 7.26.8 - '@babel/plugin-syntax-jsx': - specifier: ^7.25.9 - version: 7.25.9(@babel/core@7.26.8) - '@babel/plugin-syntax-typescript': - specifier: ^7.25.9 - version: 7.25.9(@babel/core@7.26.8) - '@babel/template': - specifier: ^7.26.8 - version: 7.26.8 - '@babel/traverse': - specifier: ^7.26.8 - version: 7.26.8 - '@babel/types': - specifier: ^7.26.8 - version: 7.26.8 - '@tanstack/router-utils': - specifier: workspace:* - version: link:../router-utils - babel-dead-code-elimination: - specifier: ^1.0.10 - version: 1.0.10 - tiny-invariant: - specifier: ^1.3.3 - version: 1.3.3 - vite: - specifier: 6.1.4 - version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) - devDependencies: - '@types/babel__code-frame': - specifier: ^7.0.6 - version: 7.0.6 - '@types/babel__core': - specifier: ^7.20.5 - version: 7.20.5 - '@types/babel__template': - specifier: ^7.4.4 - version: 7.4.4 - '@types/babel__traverse': - specifier: ^7.20.6 - version: 7.20.6 - - packages/react-start-router-manifest: - dependencies: - '@tanstack/router-core': - specifier: workspace:* - version: link:../router-core - tiny-invariant: - specifier: ^1.3.3 - version: 1.3.3 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) - devDependencies: - typescript: - specifier: ^5.7.2 - version: 5.8.2 - packages/react-start-server: dependencies: '@tanstack/history': @@ -6067,6 +5904,9 @@ importers: jsesc: specifier: ^3.1.0 version: 3.1.0 + tiny-invariant: + specifier: ^1.3.3 + version: 1.3.3 tiny-warning: specifier: ^1.0.3 version: 1.0.3 @@ -6082,7 +5922,7 @@ importers: version: 4.3.4(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) esbuild: specifier: ^0.25.0 - version: 0.25.0 + version: 0.25.2 react: specifier: ^19.0.0 version: 19.0.0 @@ -6247,7 +6087,7 @@ importers: version: 3.6.0 unplugin: specifier: ^2.1.2 - version: 2.1.2 + version: 2.2.2 vite: specifier: 6.1.4 version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) @@ -6256,7 +6096,7 @@ importers: version: 2.11.6(@testing-library/jest-dom@6.6.3)(solid-js@1.9.5)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) webpack: specifier: '>=5.92.0' - version: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0) + version: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2) zod: specifier: ^3.24.2 version: 3.24.2 @@ -6417,30 +6257,18 @@ importers: '@tanstack/solid-start-client': specifier: workspace:* version: link:../solid-start-client - '@tanstack/solid-start-config': + '@tanstack/solid-start-plugin': specifier: workspace:* - version: link:../solid-start-config - '@tanstack/solid-start-router-manifest': - specifier: workspace:* - version: link:../solid-start-router-manifest + version: link:../solid-start-plugin '@tanstack/solid-start-server': specifier: workspace:* version: link:../solid-start-server - '@tanstack/start-api-routes': - specifier: workspace:* - version: link:../start-api-routes '@tanstack/start-server-functions-client': specifier: workspace:* version: link:../start-server-functions-client - '@tanstack/start-server-functions-handler': - specifier: workspace:* - version: link:../start-server-functions-handler '@tanstack/start-server-functions-server': specifier: workspace:* version: link:../start-server-functions-server - '@tanstack/start-server-functions-ssr': - specifier: workspace:* - version: link:../start-server-functions-ssr solid-js: specifier: '>=1.0.0' version: 1.9.5 @@ -6450,7 +6278,7 @@ importers: devDependencies: esbuild: specifier: ^0.25.0 - version: 0.25.0 + version: 0.25.2 packages/solid-start-client: dependencies: @@ -6478,9 +6306,6 @@ importers: tiny-warning: specifier: ^1.0.3 version: 1.0.3 - vinxi: - specifier: ^0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) devDependencies: '@solidjs/testing-library': specifier: ^0.8.10 @@ -6495,116 +6320,30 @@ importers: specifier: ^2.11.2 version: 2.11.6(@testing-library/jest-dom@6.6.3)(solid-js@1.9.5)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) - packages/solid-start-config: + packages/solid-start-plugin: dependencies: - '@tanstack/router-core': - specifier: workspace:* - version: link:../router-core - '@tanstack/router-generator': - specifier: workspace:* - version: link:../router-generator '@tanstack/router-plugin': specifier: workspace:* version: link:../router-plugin + '@tanstack/router-utils': + specifier: workspace:* + version: link:../router-utils '@tanstack/server-functions-plugin': specifier: workspace:* version: link:../server-functions-plugin - '@tanstack/solid-start-plugin': + '@tanstack/start-plugin-core': specifier: workspace:* - version: link:../solid-start-plugin - '@tanstack/start-server-functions-handler': - specifier: workspace:* - version: link:../start-server-functions-handler - import-meta-resolve: - specifier: ^4.1.0 - version: 4.1.0 - nitropack: - specifier: ^2.10.4 - version: 2.10.4(typescript@5.8.2) - ofetch: - specifier: ^1.4.1 - version: 1.4.1 - solid-js: - specifier: '>=1.0.0' - version: 1.9.5 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) + version: link:../start-plugin-core vite: specifier: 6.1.4 version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) vite-plugin-solid: - specifier: ^2.11.2 + specifier: ^2.11.6 version: 2.11.6(@testing-library/jest-dom@6.6.3)(solid-js@1.9.5)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) zod: specifier: ^3.24.2 version: 3.24.2 - packages/solid-start-plugin: - dependencies: - '@babel/code-frame': - specifier: 7.26.2 - version: 7.26.2 - '@babel/core': - specifier: ^7.26.8 - version: 7.26.8 - '@babel/plugin-syntax-jsx': - specifier: ^7.25.9 - version: 7.25.9(@babel/core@7.26.8) - '@babel/plugin-syntax-typescript': - specifier: ^7.25.9 - version: 7.25.9(@babel/core@7.26.8) - '@babel/template': - specifier: ^7.26.8 - version: 7.26.8 - '@babel/traverse': - specifier: ^7.26.8 - version: 7.26.8 - '@babel/types': - specifier: ^7.26.8 - version: 7.26.8 - '@tanstack/router-utils': - specifier: workspace:* - version: link:../router-utils - babel-dead-code-elimination: - specifier: ^1.0.9 - version: 1.0.10 - tiny-invariant: - specifier: ^1.3.3 - version: 1.3.3 - vite: - specifier: 6.1.4 - version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) - devDependencies: - '@types/babel__code-frame': - specifier: ^7.0.6 - version: 7.0.6 - '@types/babel__core': - specifier: ^7.20.5 - version: 7.20.5 - '@types/babel__template': - specifier: ^7.4.4 - version: 7.4.4 - '@types/babel__traverse': - specifier: ^7.20.6 - version: 7.20.6 - - packages/solid-start-router-manifest: - dependencies: - '@tanstack/router-core': - specifier: workspace:* - version: link:../router-core - tiny-invariant: - specifier: ^1.3.3 - version: 1.3.3 - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) - devDependencies: - typescript: - specifier: ^5.7.2 - version: 5.8.2 - packages/solid-start-server: dependencies: '@solidjs/meta': @@ -6646,7 +6385,7 @@ importers: version: 3.0.3 esbuild: specifier: ^0.25.0 - version: 0.25.0 + version: 0.25.2 solid-js: specifier: ^1.9.5 version: 1.9.5 @@ -6657,52 +6396,6 @@ importers: specifier: ^2.11.2 version: 2.11.6(@testing-library/jest-dom@6.6.3)(solid-js@1.9.5)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) - packages/start: - dependencies: - '@tanstack/react-start-client': - specifier: workspace:* - version: link:../react-start-client - '@tanstack/react-start-router-manifest': - specifier: workspace:* - version: link:../react-start-router-manifest - '@tanstack/react-start-server': - specifier: workspace:* - version: link:../react-start-server - '@tanstack/start-api-routes': - specifier: workspace:* - version: link:../start-api-routes - '@tanstack/start-config': - specifier: workspace:^ - version: link:../start-config - '@tanstack/start-server-functions-client': - specifier: workspace:* - version: link:../start-server-functions-client - '@tanstack/start-server-functions-handler': - specifier: workspace:* - version: link:../start-server-functions-handler - '@tanstack/start-server-functions-server': - specifier: workspace:* - version: link:../start-server-functions-server - '@tanstack/start-server-functions-ssr': - specifier: workspace:* - version: link:../start-server-functions-ssr - - packages/start-api-routes: - dependencies: - '@tanstack/router-core': - specifier: workspace:* - version: link:../router-core - '@tanstack/start-server-core': - specifier: workspace:* - version: link:../start-server-core - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) - devDependencies: - typescript: - specifier: ^5.7.2 - version: 5.8.2 - packages/start-client-core: dependencies: '@tanstack/router-core': @@ -6718,50 +6411,56 @@ importers: specifier: ^1.0.3 version: 1.0.3 - packages/start-config: + packages/start-plugin-core: dependencies: - '@tanstack/react-router': + '@babel/code-frame': + specifier: 7.26.2 + version: 7.26.2 + '@babel/core': + specifier: ^7.26.8 + version: 7.26.8 + '@babel/types': + specifier: ^7.26.8 + version: 7.26.8 + '@tanstack/router-core': specifier: workspace:* - version: link:../react-router - '@tanstack/react-start-plugin': - specifier: workspace:* - version: link:../react-start-plugin + version: link:../router-core '@tanstack/router-generator': specifier: workspace:* version: link:../router-generator - '@tanstack/router-plugin': + '@tanstack/router-utils': specifier: workspace:* - version: link:../router-plugin - '@tanstack/server-functions-plugin': - specifier: workspace:* - version: link:../server-functions-plugin - '@tanstack/start-server-functions-handler': - specifier: workspace:* - version: link:../start-server-functions-handler - '@vitejs/plugin-react': - specifier: ^4.3.4 - version: 4.3.4(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) - import-meta-resolve: - specifier: ^4.1.0 - version: 4.1.0 + version: link:../router-utils + '@types/babel__code-frame': + specifier: ^7.0.6 + version: 7.0.6 + '@types/babel__core': + specifier: ^7.20.5 + version: 7.20.5 + babel-dead-code-elimination: + specifier: ^1.0.9 + version: 1.0.10 + cheerio: + specifier: ^1.0.0 + version: 1.0.0 + h3: + specifier: 1.13.0 + version: 1.13.0 nitropack: - specifier: ^2.10.4 - version: 2.10.4(typescript@5.8.2) - ofetch: - specifier: ^1.4.1 - version: 1.4.1 - react: - specifier: ^19.0.0 - version: 19.0.0 - react-dom: - specifier: ^19.0.0 - version: 19.0.0(react@19.0.0) - vinxi: - specifier: 0.5.3 - version: 0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0) + specifier: ^2.11.8 + version: 2.11.8 + pathe: + specifier: ^2.0.3 + version: 2.0.3 + ufo: + specifier: ^1.5.4 + version: 1.5.4 vite: specifier: 6.1.4 version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) + xmlbuilder2: + specifier: ^3.1.1 + version: 3.1.1 zod: specifier: ^3.24.2 version: 3.24.2 @@ -6786,22 +6485,31 @@ importers: jsesc: specifier: ^3.1.0 version: 3.1.0 + tiny-invariant: + specifier: ^1.3.3 + version: 1.3.3 tiny-warning: specifier: ^1.0.3 version: 1.0.3 unctx: specifier: ^2.4.1 version: 2.4.1 + undici: + specifier: ^7.8.0 + version: 7.8.0 devDependencies: '@types/jsesc': specifier: ^3.0.3 version: 3.0.3 esbuild: specifier: ^0.25.0 - version: 0.25.0 + version: 0.25.2 typescript: specifier: ^5.7.2 version: 5.8.2 + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) packages/start-server-functions-client: dependencies: @@ -6828,25 +6536,9 @@ importers: typescript: specifier: ^5.7.2 version: 5.8.2 - - packages/start-server-functions-handler: - dependencies: - '@tanstack/router-core': - specifier: workspace:* - version: link:../router-core - '@tanstack/start-client-core': - specifier: workspace:* - version: link:../start-client-core - '@tanstack/start-server-core': - specifier: workspace:* - version: link:../start-server-core - tiny-invariant: - specifier: ^1.3.3 - version: 1.3.3 - devDependencies: - typescript: - specifier: ^5.7.2 - version: 5.8.2 + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) packages/start-server-functions-server: dependencies: @@ -6856,28 +6548,9 @@ importers: tiny-invariant: specifier: ^1.3.3 version: 1.3.3 - devDependencies: - typescript: - specifier: ^5.7.2 - version: 5.8.2 - - packages/start-server-functions-ssr: - dependencies: - '@tanstack/server-functions-plugin': - specifier: workspace:* - version: link:../server-functions-plugin - '@tanstack/start-client-core': - specifier: workspace:* - version: link:../start-client-core - '@tanstack/start-server-core': - specifier: workspace:* - version: link:../start-server-core - '@tanstack/start-server-functions-fetcher': - specifier: workspace:* - version: link:../start-server-functions-fetcher - tiny-invariant: - specifier: ^1.3.3 - version: 1.3.3 + vite: + specifier: 6.1.4 + version: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) devDependencies: typescript: specifier: ^5.7.2 @@ -7112,10 +6785,6 @@ packages: resolution: {integrity: sha512-AOPI3D+a8dXnja+iwsUqGRjr1BbZIe771sXdapOtYI531gSqpi92vXivKcq2asu/DFpdl1ceFAKZyRzK2PCVcQ==} engines: {node: '>=6.9.0'} - '@babel/standalone@7.26.7': - resolution: {integrity: sha512-Fvdo9Dd20GDUAREzYMIR2EFMKAJ+ccxstgQdb39XV/yvygHL4UPcqgTkiChPyltAe/b+zgq+vUPXeukEZ6aUeA==} - engines: {node: '>=6.9.0'} - '@babel/template@7.26.8': resolution: {integrity: sha512-iNKaX3ZebKIsCvJ+0jd6embf+Aulaa3vNBqZ41kM7iTWjx5qzWKXGHiJUW3+nTpQ18SG11hdF8OAzKrpXkb96Q==} engines: {node: '>=6.9.0'} @@ -7173,9 +6842,9 @@ packages: resolution: {integrity: sha512-b4LR3Xsegqe0S6ZkaSJ1skO5a36EIiYRCFBzrJIbJX58vh25FFbOs4VHcK71uCLGJ1Jm1bViPi8QPGYoqYAUuw==} engines: {node: '>=18.17.0'} - '@cloudflare/kv-asset-handler@0.3.4': - resolution: {integrity: sha512-YLPHc8yASwjNkmcDMQMY35yiWjoKAKnhUbPRszBRS0YgH+IXtsMp61j+yTcnCE3oO2DgP0U3iejLC8FTtKDC8Q==} - engines: {node: '>=16.13'} + '@cloudflare/kv-asset-handler@0.4.0': + resolution: {integrity: sha512-+tv3z+SPp+gqTIcImN9o0hqE9xyfQjI1XD9pL6NuKjua9B1y7mNYv0S9cP+QEbA4ppVgGZEmKOvHX5G5Ei1CVA==} + engines: {node: '>=18.0.0'} '@colors/colors@1.5.0': resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} @@ -7223,12 +6892,6 @@ packages: resolution: {integrity: sha512-UJnjoFsmxfKUdNYdWgOB0mWUypuLvAfQPH1+pyvRJs6euowbFkFC6P13w1l8mJyi3vxYMxc9kld5jZEGRQs6bw==} engines: {node: '>=18'} - '@deno/shim-deno-test@0.5.0': - resolution: {integrity: sha512-4nMhecpGlPi0cSzT67L+Tm+GOJqvuk8gqHBziqcUQOarnuIax1z96/gJHCSIz2Z0zhxE6Rzwb3IZXPtFh51j+w==} - - '@deno/shim-deno@0.19.2': - resolution: {integrity: sha512-q3VTHl44ad8T2Tw2SpeAvghdGOjlnLPDNO2cpOxwMrBE/PVas6geWpbpIgrM+czOCH0yejp0yi8OaTuB+NU40Q==} - '@discoveryjs/json-ext@0.5.7': resolution: {integrity: sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==} engines: {node: '>=10.0.0'} @@ -7296,12 +6959,6 @@ packages: '@emotion/weak-memoize@0.4.0': resolution: {integrity: sha512-snKqtPW01tN0ui7yu9rGv69aJXr/a/Ywvl11sUjNtEcRc+ng/mQriFL0wLXMef74iHa/EkftbDzU9F8iFbH+zg==} - '@esbuild/aix-ppc64@0.20.2': - resolution: {integrity: sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [aix] - '@esbuild/aix-ppc64@0.23.0': resolution: {integrity: sha512-3sG8Zwa5fMcA9bgqB8AfWPQ+HFke6uD3h1s3RIwUNK8EG7a4buxvuFTs3j1IMs2NXAk9F30C/FF4vxRgQCcmoQ==} engines: {node: '>=18'} @@ -7320,18 +6977,12 @@ packages: cpu: [ppc64] os: [aix] - '@esbuild/aix-ppc64@0.25.0': - resolution: {integrity: sha512-O7vun9Sf8DFjH2UtqK8Ku3LkquL9SZL8OLY1T5NZkA34+wG3OQF7cl4Ql8vdNzM6fzBbYfLaiRLIOZ+2FOCgBQ==} + '@esbuild/aix-ppc64@0.25.2': + resolution: {integrity: sha512-wCIboOL2yXZym2cgm6mlA742s9QeJ8DjGVaL39dLN4rRwrOgOyYSnOaFPhKZGLb2ngj4EyfAFjsNJwPXZvseag==} engines: {node: '>=18'} cpu: [ppc64] os: [aix] - '@esbuild/android-arm64@0.20.2': - resolution: {integrity: sha512-mRzjLacRtl/tWU0SvD8lUEwb61yP9cqQo6noDZP/O8VkwafSYwZ4yWy24kan8jE/IMERpYncRt2dw438LP3Xmg==} - engines: {node: '>=12'} - cpu: [arm64] - os: [android] - '@esbuild/android-arm64@0.23.0': resolution: {integrity: sha512-EuHFUYkAVfU4qBdyivULuu03FhJO4IJN9PGuABGrFy4vUuzk91P2d+npxHcFdpUnfYKy0PuV+n6bKIpHOB3prQ==} engines: {node: '>=18'} @@ -7350,18 +7001,12 @@ packages: cpu: [arm64] os: [android] - '@esbuild/android-arm64@0.25.0': - resolution: {integrity: sha512-grvv8WncGjDSyUBjN9yHXNt+cq0snxXbDxy5pJtzMKGmmpPxeAmAhWxXI+01lU5rwZomDgD3kJwulEnhTRUd6g==} + '@esbuild/android-arm64@0.25.2': + resolution: {integrity: sha512-5ZAX5xOmTligeBaeNEPnPaeEuah53Id2tX4c2CVP3JaROTH+j4fnfHCkr1PjXMd78hMst+TlkfKcW/DlTq0i4w==} engines: {node: '>=18'} cpu: [arm64] os: [android] - '@esbuild/android-arm@0.20.2': - resolution: {integrity: sha512-t98Ra6pw2VaDhqNWO2Oph2LXbz/EJcnLmKLGBJwEwXX/JAN83Fym1rU8l0JUWK6HkIbWONCSSatf4sf2NBRx/w==} - engines: {node: '>=12'} - cpu: [arm] - os: [android] - '@esbuild/android-arm@0.23.0': resolution: {integrity: sha512-+KuOHTKKyIKgEEqKbGTK8W7mPp+hKinbMBeEnNzjJGyFcWsfrXjSTNluJHCY1RqhxFurdD8uNXQDei7qDlR6+g==} engines: {node: '>=18'} @@ -7380,18 +7025,12 @@ packages: cpu: [arm] os: [android] - '@esbuild/android-arm@0.25.0': - resolution: {integrity: sha512-PTyWCYYiU0+1eJKmw21lWtC+d08JDZPQ5g+kFyxP0V+es6VPPSUhM6zk8iImp2jbV6GwjX4pap0JFbUQN65X1g==} + '@esbuild/android-arm@0.25.2': + resolution: {integrity: sha512-NQhH7jFstVY5x8CKbcfa166GoV0EFkaPkCKBQkdPJFvo5u+nGXLEH/ooniLb3QI8Fk58YAx7nsPLozUWfCBOJA==} engines: {node: '>=18'} cpu: [arm] os: [android] - '@esbuild/android-x64@0.20.2': - resolution: {integrity: sha512-btzExgV+/lMGDDa194CcUQm53ncxzeBrWJcncOBxuC6ndBkKxnHdFJn86mCIgTELsooUmwUm9FkhSp5HYu00Rg==} - engines: {node: '>=12'} - cpu: [x64] - os: [android] - '@esbuild/android-x64@0.23.0': resolution: {integrity: sha512-WRrmKidLoKDl56LsbBMhzTTBxrsVwTKdNbKDalbEZr0tcsBgCLbEtoNthOW6PX942YiYq8HzEnb4yWQMLQuipQ==} engines: {node: '>=18'} @@ -7410,18 +7049,12 @@ packages: cpu: [x64] os: [android] - '@esbuild/android-x64@0.25.0': - resolution: {integrity: sha512-m/ix7SfKG5buCnxasr52+LI78SQ+wgdENi9CqyCXwjVR2X4Jkz+BpC3le3AoBPYTC9NHklwngVXvbJ9/Akhrfg==} + '@esbuild/android-x64@0.25.2': + resolution: {integrity: sha512-Ffcx+nnma8Sge4jzddPHCZVRvIfQ0kMsUsCMcJRHkGJ1cDmhe4SsrYIjLUKn1xpHZybmOqCWwB0zQvsjdEHtkg==} engines: {node: '>=18'} cpu: [x64] os: [android] - '@esbuild/darwin-arm64@0.20.2': - resolution: {integrity: sha512-4J6IRT+10J3aJH3l1yzEg9y3wkTDgDk7TSDFX+wKFiWjqWp/iCfLIYzGyasx9l0SAFPT1HwSCR+0w/h1ES/MjA==} - engines: {node: '>=12'} - cpu: [arm64] - os: [darwin] - '@esbuild/darwin-arm64@0.23.0': resolution: {integrity: sha512-YLntie/IdS31H54Ogdn+v50NuoWF5BDkEUFpiOChVa9UnKpftgwzZRrI4J132ETIi+D8n6xh9IviFV3eXdxfow==} engines: {node: '>=18'} @@ -7440,18 +7073,12 @@ packages: cpu: [arm64] os: [darwin] - '@esbuild/darwin-arm64@0.25.0': - resolution: {integrity: sha512-mVwdUb5SRkPayVadIOI78K7aAnPamoeFR2bT5nszFUZ9P8UpK4ratOdYbZZXYSqPKMHfS1wdHCJk1P1EZpRdvw==} + '@esbuild/darwin-arm64@0.25.2': + resolution: {integrity: sha512-MpM6LUVTXAzOvN4KbjzU/q5smzryuoNjlriAIx+06RpecwCkL9JpenNzpKd2YMzLJFOdPqBpuub6eVRP5IgiSA==} engines: {node: '>=18'} cpu: [arm64] os: [darwin] - '@esbuild/darwin-x64@0.20.2': - resolution: {integrity: sha512-tBcXp9KNphnNH0dfhv8KYkZhjc+H3XBkF5DKtswJblV7KlT9EI2+jeA8DgBjp908WEuYll6pF+UStUCfEpdysA==} - engines: {node: '>=12'} - cpu: [x64] - os: [darwin] - '@esbuild/darwin-x64@0.23.0': resolution: {integrity: sha512-IMQ6eme4AfznElesHUPDZ+teuGwoRmVuuixu7sv92ZkdQcPbsNHzutd+rAfaBKo8YK3IrBEi9SLLKWJdEvJniQ==} engines: {node: '>=18'} @@ -7470,18 +7097,12 @@ packages: cpu: [x64] os: [darwin] - '@esbuild/darwin-x64@0.25.0': - resolution: {integrity: sha512-DgDaYsPWFTS4S3nWpFcMn/33ZZwAAeAFKNHNa1QN0rI4pUjgqf0f7ONmXf6d22tqTY+H9FNdgeaAa+YIFUn2Rg==} + '@esbuild/darwin-x64@0.25.2': + resolution: {integrity: sha512-5eRPrTX7wFyuWe8FqEFPG2cU0+butQQVNcT4sVipqjLYQjjh8a8+vUTfgBKM88ObB85ahsnTwF7PSIt6PG+QkA==} engines: {node: '>=18'} cpu: [x64] os: [darwin] - '@esbuild/freebsd-arm64@0.20.2': - resolution: {integrity: sha512-d3qI41G4SuLiCGCFGUrKsSeTXyWG6yem1KcGZVS+3FYlYhtNoNgYrWcvkOoaqMhwXSMrZRl69ArHsGJ9mYdbbw==} - engines: {node: '>=12'} - cpu: [arm64] - os: [freebsd] - '@esbuild/freebsd-arm64@0.23.0': resolution: {integrity: sha512-0muYWCng5vqaxobq6LB3YNtevDFSAZGlgtLoAc81PjUfiFz36n4KMpwhtAd4he8ToSI3TGyuhyx5xmiWNYZFyw==} engines: {node: '>=18'} @@ -7500,18 +7121,12 @@ packages: cpu: [arm64] os: [freebsd] - '@esbuild/freebsd-arm64@0.25.0': - resolution: {integrity: sha512-VN4ocxy6dxefN1MepBx/iD1dH5K8qNtNe227I0mnTRjry8tj5MRk4zprLEdG8WPyAPb93/e4pSgi1SoHdgOa4w==} + '@esbuild/freebsd-arm64@0.25.2': + resolution: {integrity: sha512-mLwm4vXKiQ2UTSX4+ImyiPdiHjiZhIaE9QvC7sw0tZ6HoNMjYAqQpGyui5VRIi5sGd+uWq940gdCbY3VLvsO1w==} engines: {node: '>=18'} cpu: [arm64] os: [freebsd] - '@esbuild/freebsd-x64@0.20.2': - resolution: {integrity: sha512-d+DipyvHRuqEeM5zDivKV1KuXn9WeRX6vqSqIDgwIfPQtwMP4jaDsQsDncjTDDsExT4lR/91OLjRo8bmC1e+Cw==} - engines: {node: '>=12'} - cpu: [x64] - os: [freebsd] - '@esbuild/freebsd-x64@0.23.0': resolution: {integrity: sha512-XKDVu8IsD0/q3foBzsXGt/KjD/yTKBCIwOHE1XwiXmrRwrX6Hbnd5Eqn/WvDekddK21tfszBSrE/WMaZh+1buQ==} engines: {node: '>=18'} @@ -7530,18 +7145,12 @@ packages: cpu: [x64] os: [freebsd] - '@esbuild/freebsd-x64@0.25.0': - resolution: {integrity: sha512-mrSgt7lCh07FY+hDD1TxiTyIHyttn6vnjesnPoVDNmDfOmggTLXRv8Id5fNZey1gl/V2dyVK1VXXqVsQIiAk+A==} + '@esbuild/freebsd-x64@0.25.2': + resolution: {integrity: sha512-6qyyn6TjayJSwGpm8J9QYYGQcRgc90nmfdUb0O7pp1s4lTY+9D0H9O02v5JqGApUyiHOtkz6+1hZNvNtEhbwRQ==} engines: {node: '>=18'} cpu: [x64] os: [freebsd] - '@esbuild/linux-arm64@0.20.2': - resolution: {integrity: sha512-9pb6rBjGvTFNira2FLIWqDk/uaf42sSyLE8j1rnUpuzsODBq7FvpwHYZxQ/It/8b+QOS1RYfqgGFNLRI+qlq2A==} - engines: {node: '>=12'} - cpu: [arm64] - os: [linux] - '@esbuild/linux-arm64@0.23.0': resolution: {integrity: sha512-j1t5iG8jE7BhonbsEg5d9qOYcVZv/Rv6tghaXM/Ug9xahM0nX/H2gfu6X6z11QRTMT6+aywOMA8TDkhPo8aCGw==} engines: {node: '>=18'} @@ -7560,18 +7169,12 @@ packages: cpu: [arm64] os: [linux] - '@esbuild/linux-arm64@0.25.0': - resolution: {integrity: sha512-9QAQjTWNDM/Vk2bgBl17yWuZxZNQIF0OUUuPZRKoDtqF2k4EtYbpyiG5/Dk7nqeK6kIJWPYldkOcBqjXjrUlmg==} + '@esbuild/linux-arm64@0.25.2': + resolution: {integrity: sha512-gq/sjLsOyMT19I8obBISvhoYiZIAaGF8JpeXu1u8yPv8BE5HlWYobmlsfijFIZ9hIVGYkbdFhEqC0NvM4kNO0g==} engines: {node: '>=18'} cpu: [arm64] os: [linux] - '@esbuild/linux-arm@0.20.2': - resolution: {integrity: sha512-VhLPeR8HTMPccbuWWcEUD1Az68TqaTYyj6nfE4QByZIQEQVWBB8vup8PpR7y1QHL3CpcF6xd5WVBU/+SBEvGTg==} - engines: {node: '>=12'} - cpu: [arm] - os: [linux] - '@esbuild/linux-arm@0.23.0': resolution: {integrity: sha512-SEELSTEtOFu5LPykzA395Mc+54RMg1EUgXP+iw2SJ72+ooMwVsgfuwXo5Fn0wXNgWZsTVHwY2cg4Vi/bOD88qw==} engines: {node: '>=18'} @@ -7590,18 +7193,12 @@ packages: cpu: [arm] os: [linux] - '@esbuild/linux-arm@0.25.0': - resolution: {integrity: sha512-vkB3IYj2IDo3g9xX7HqhPYxVkNQe8qTK55fraQyTzTX/fxaDtXiEnavv9geOsonh2Fd2RMB+i5cbhu2zMNWJwg==} + '@esbuild/linux-arm@0.25.2': + resolution: {integrity: sha512-UHBRgJcmjJv5oeQF8EpTRZs/1knq6loLxTsjc3nxO9eXAPDLcWW55flrMVc97qFPbmZP31ta1AZVUKQzKTzb0g==} engines: {node: '>=18'} cpu: [arm] os: [linux] - '@esbuild/linux-ia32@0.20.2': - resolution: {integrity: sha512-o10utieEkNPFDZFQm9CoP7Tvb33UutoJqg3qKf1PWVeeJhJw0Q347PxMvBgVVFgouYLGIhFYG0UGdBumROyiig==} - engines: {node: '>=12'} - cpu: [ia32] - os: [linux] - '@esbuild/linux-ia32@0.23.0': resolution: {integrity: sha512-P7O5Tkh2NbgIm2R6x1zGJJsnacDzTFcRWZyTTMgFdVit6E98LTxO+v8LCCLWRvPrjdzXHx9FEOA8oAZPyApWUA==} engines: {node: '>=18'} @@ -7620,18 +7217,12 @@ packages: cpu: [ia32] os: [linux] - '@esbuild/linux-ia32@0.25.0': - resolution: {integrity: sha512-43ET5bHbphBegyeqLb7I1eYn2P/JYGNmzzdidq/w0T8E2SsYL1U6un2NFROFRg1JZLTzdCoRomg8Rvf9M6W6Gg==} + '@esbuild/linux-ia32@0.25.2': + resolution: {integrity: sha512-bBYCv9obgW2cBP+2ZWfjYTU+f5cxRoGGQ5SeDbYdFCAZpYWrfjjfYwvUpP8MlKbP0nwZ5gyOU/0aUzZ5HWPuvQ==} engines: {node: '>=18'} cpu: [ia32] os: [linux] - '@esbuild/linux-loong64@0.20.2': - resolution: {integrity: sha512-PR7sp6R/UC4CFVomVINKJ80pMFlfDfMQMYynX7t1tNTeivQ6XdX5r2XovMmha/VjR1YN/HgHWsVcTRIMkymrgQ==} - engines: {node: '>=12'} - cpu: [loong64] - os: [linux] - '@esbuild/linux-loong64@0.23.0': resolution: {integrity: sha512-InQwepswq6urikQiIC/kkx412fqUZudBO4SYKu0N+tGhXRWUqAx+Q+341tFV6QdBifpjYgUndV1hhMq3WeJi7A==} engines: {node: '>=18'} @@ -7650,18 +7241,12 @@ packages: cpu: [loong64] os: [linux] - '@esbuild/linux-loong64@0.25.0': - resolution: {integrity: sha512-fC95c/xyNFueMhClxJmeRIj2yrSMdDfmqJnyOY4ZqsALkDrrKJfIg5NTMSzVBr5YW1jf+l7/cndBfP3MSDpoHw==} + '@esbuild/linux-loong64@0.25.2': + resolution: {integrity: sha512-SHNGiKtvnU2dBlM5D8CXRFdd+6etgZ9dXfaPCeJtz+37PIUlixvlIhI23L5khKXs3DIzAn9V8v+qb1TRKrgT5w==} engines: {node: '>=18'} cpu: [loong64] os: [linux] - '@esbuild/linux-mips64el@0.20.2': - resolution: {integrity: sha512-4BlTqeutE/KnOiTG5Y6Sb/Hw6hsBOZapOVF6njAESHInhlQAghVVZL1ZpIctBOoTFbQyGW+LsVYZ8lSSB3wkjA==} - engines: {node: '>=12'} - cpu: [mips64el] - os: [linux] - '@esbuild/linux-mips64el@0.23.0': resolution: {integrity: sha512-J9rflLtqdYrxHv2FqXE2i1ELgNjT+JFURt/uDMoPQLcjWQA5wDKgQA4t/dTqGa88ZVECKaD0TctwsUfHbVoi4w==} engines: {node: '>=18'} @@ -7680,18 +7265,12 @@ packages: cpu: [mips64el] os: [linux] - '@esbuild/linux-mips64el@0.25.0': - resolution: {integrity: sha512-nkAMFju7KDW73T1DdH7glcyIptm95a7Le8irTQNO/qtkoyypZAnjchQgooFUDQhNAy4iu08N79W4T4pMBwhPwQ==} + '@esbuild/linux-mips64el@0.25.2': + resolution: {integrity: sha512-hDDRlzE6rPeoj+5fsADqdUZl1OzqDYow4TB4Y/3PlKBD0ph1e6uPHzIQcv2Z65u2K0kpeByIyAjCmjn1hJgG0Q==} engines: {node: '>=18'} cpu: [mips64el] os: [linux] - '@esbuild/linux-ppc64@0.20.2': - resolution: {integrity: sha512-rD3KsaDprDcfajSKdn25ooz5J5/fWBylaaXkuotBDGnMnDP1Uv5DLAN/45qfnf3JDYyJv/ytGHQaziHUdyzaAg==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [linux] - '@esbuild/linux-ppc64@0.23.0': resolution: {integrity: sha512-cShCXtEOVc5GxU0fM+dsFD10qZ5UpcQ8AM22bYj0u/yaAykWnqXJDpd77ublcX6vdDsWLuweeuSNZk4yUxZwtw==} engines: {node: '>=18'} @@ -7710,18 +7289,12 @@ packages: cpu: [ppc64] os: [linux] - '@esbuild/linux-ppc64@0.25.0': - resolution: {integrity: sha512-NhyOejdhRGS8Iwv+KKR2zTq2PpysF9XqY+Zk77vQHqNbo/PwZCzB5/h7VGuREZm1fixhs4Q/qWRSi5zmAiO4Fw==} + '@esbuild/linux-ppc64@0.25.2': + resolution: {integrity: sha512-tsHu2RRSWzipmUi9UBDEzc0nLc4HtpZEI5Ba+Omms5456x5WaNuiG3u7xh5AO6sipnJ9r4cRWQB2tUjPyIkc6g==} engines: {node: '>=18'} cpu: [ppc64] os: [linux] - '@esbuild/linux-riscv64@0.20.2': - resolution: {integrity: sha512-snwmBKacKmwTMmhLlz/3aH1Q9T8v45bKYGE3j26TsaOVtjIag4wLfWSiZykXzXuE1kbCE+zJRmwp+ZbIHinnVg==} - engines: {node: '>=12'} - cpu: [riscv64] - os: [linux] - '@esbuild/linux-riscv64@0.23.0': resolution: {integrity: sha512-HEtaN7Y5UB4tZPeQmgz/UhzoEyYftbMXrBCUjINGjh3uil+rB/QzzpMshz3cNUxqXN7Vr93zzVtpIDL99t9aRw==} engines: {node: '>=18'} @@ -7740,18 +7313,12 @@ packages: cpu: [riscv64] os: [linux] - '@esbuild/linux-riscv64@0.25.0': - resolution: {integrity: sha512-5S/rbP5OY+GHLC5qXp1y/Mx//e92L1YDqkiBbO9TQOvuFXM+iDqUNG5XopAnXoRH3FjIUDkeGcY1cgNvnXp/kA==} + '@esbuild/linux-riscv64@0.25.2': + resolution: {integrity: sha512-k4LtpgV7NJQOml/10uPU0s4SAXGnowi5qBSjaLWMojNCUICNu7TshqHLAEbkBdAszL5TabfvQ48kK84hyFzjnw==} engines: {node: '>=18'} cpu: [riscv64] os: [linux] - '@esbuild/linux-s390x@0.20.2': - resolution: {integrity: sha512-wcWISOobRWNm3cezm5HOZcYz1sKoHLd8VL1dl309DiixxVFoFe/o8HnwuIwn6sXre88Nwj+VwZUvJf4AFxkyrQ==} - engines: {node: '>=12'} - cpu: [s390x] - os: [linux] - '@esbuild/linux-s390x@0.23.0': resolution: {integrity: sha512-WDi3+NVAuyjg/Wxi+o5KPqRbZY0QhI9TjrEEm+8dmpY9Xir8+HE/HNx2JoLckhKbFopW0RdO2D72w8trZOV+Wg==} engines: {node: '>=18'} @@ -7770,18 +7337,12 @@ packages: cpu: [s390x] os: [linux] - '@esbuild/linux-s390x@0.25.0': - resolution: {integrity: sha512-XM2BFsEBz0Fw37V0zU4CXfcfuACMrppsMFKdYY2WuTS3yi8O1nFOhil/xhKTmE1nPmVyvQJjJivgDT+xh8pXJA==} + '@esbuild/linux-s390x@0.25.2': + resolution: {integrity: sha512-GRa4IshOdvKY7M/rDpRR3gkiTNp34M0eLTaC1a08gNrh4u488aPhuZOCpkF6+2wl3zAN7L7XIpOFBhnaE3/Q8Q==} engines: {node: '>=18'} cpu: [s390x] os: [linux] - '@esbuild/linux-x64@0.20.2': - resolution: {integrity: sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==} - engines: {node: '>=12'} - cpu: [x64] - os: [linux] - '@esbuild/linux-x64@0.23.0': resolution: {integrity: sha512-a3pMQhUEJkITgAw6e0bWA+F+vFtCciMjW/LPtoj99MhVt+Mfb6bbL9hu2wmTZgNd994qTAEw+U/r6k3qHWWaOQ==} engines: {node: '>=18'} @@ -7800,8 +7361,8 @@ packages: cpu: [x64] os: [linux] - '@esbuild/linux-x64@0.25.0': - resolution: {integrity: sha512-9yl91rHw/cpwMCNytUDxwj2XjFpxML0y9HAOH9pNVQDpQrBxHy01Dx+vaMu0N1CKa/RzBD2hB4u//nfc+Sd3Cw==} + '@esbuild/linux-x64@0.25.2': + resolution: {integrity: sha512-QInHERlqpTTZ4FRB0fROQWXcYRD64lAoiegezDunLpalZMjcUcld3YzZmVJ2H/Cp0wJRZ8Xtjtj0cEHhYc/uUg==} engines: {node: '>=18'} cpu: [x64] os: [linux] @@ -7812,18 +7373,12 @@ packages: cpu: [arm64] os: [netbsd] - '@esbuild/netbsd-arm64@0.25.0': - resolution: {integrity: sha512-RuG4PSMPFfrkH6UwCAqBzauBWTygTvb1nxWasEJooGSJ/NwRw7b2HOwyRTQIU97Hq37l3npXoZGYMy3b3xYvPw==} + '@esbuild/netbsd-arm64@0.25.2': + resolution: {integrity: sha512-talAIBoY5M8vHc6EeI2WW9d/CkiO9MQJ0IOWX8hrLhxGbro/vBXJvaQXefW2cP0z0nQVTdQ/eNyGFV1GSKrxfw==} engines: {node: '>=18'} cpu: [arm64] os: [netbsd] - '@esbuild/netbsd-x64@0.20.2': - resolution: {integrity: sha512-K8/DhBxcVQkzYc43yJXDSyjlFeHQJBiowJ0uVL6Tor3jGQfSGHNNJcWxNbOI8v5k82prYqzPuwkzHt3J1T1iZQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [netbsd] - '@esbuild/netbsd-x64@0.23.0': resolution: {integrity: sha512-cRK+YDem7lFTs2Q5nEv/HHc4LnrfBCbH5+JHu6wm2eP+d8OZNoSMYgPZJq78vqQ9g+9+nMuIsAO7skzphRXHyw==} engines: {node: '>=18'} @@ -7842,8 +7397,8 @@ packages: cpu: [x64] os: [netbsd] - '@esbuild/netbsd-x64@0.25.0': - resolution: {integrity: sha512-jl+qisSB5jk01N5f7sPCsBENCOlPiS/xptD5yxOx2oqQfyourJwIKLRA2yqWdifj3owQZCL2sn6o08dBzZGQzA==} + '@esbuild/netbsd-x64@0.25.2': + resolution: {integrity: sha512-voZT9Z+tpOxrvfKFyfDYPc4DO4rk06qamv1a/fkuzHpiVBMOhpjK+vBmWM8J1eiB3OLSMFYNaOaBNLXGChf5tg==} engines: {node: '>=18'} cpu: [x64] os: [netbsd] @@ -7866,18 +7421,12 @@ packages: cpu: [arm64] os: [openbsd] - '@esbuild/openbsd-arm64@0.25.0': - resolution: {integrity: sha512-21sUNbq2r84YE+SJDfaQRvdgznTD8Xc0oc3p3iW/a1EVWeNj/SdUCbm5U0itZPQYRuRTW20fPMWMpcrciH2EJw==} + '@esbuild/openbsd-arm64@0.25.2': + resolution: {integrity: sha512-dcXYOC6NXOqcykeDlwId9kB6OkPUxOEqU+rkrYVqJbK2hagWOMrsTGsMr8+rW02M+d5Op5NNlgMmjzecaRf7Tg==} engines: {node: '>=18'} cpu: [arm64] os: [openbsd] - '@esbuild/openbsd-x64@0.20.2': - resolution: {integrity: sha512-eMpKlV0SThJmmJgiVyN9jTPJ2VBPquf6Kt/nAoo6DgHAoN57K15ZghiHaMvqjCye/uU4X5u3YSMgVBI1h3vKrQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [openbsd] - '@esbuild/openbsd-x64@0.23.0': resolution: {integrity: sha512-6p3nHpby0DM/v15IFKMjAaayFhqnXV52aEmv1whZHX56pdkK+MEaLoQWj+H42ssFarP1PcomVhbsR4pkz09qBg==} engines: {node: '>=18'} @@ -7896,18 +7445,12 @@ packages: cpu: [x64] os: [openbsd] - '@esbuild/openbsd-x64@0.25.0': - resolution: {integrity: sha512-2gwwriSMPcCFRlPlKx3zLQhfN/2WjJ2NSlg5TKLQOJdV0mSxIcYNTMhk3H3ulL/cak+Xj0lY1Ym9ysDV1igceg==} + '@esbuild/openbsd-x64@0.25.2': + resolution: {integrity: sha512-t/TkWwahkH0Tsgoq1Ju7QfgGhArkGLkF1uYz8nQS/PPFlXbP5YgRpqQR3ARRiC2iXoLTWFxc6DJMSK10dVXluw==} engines: {node: '>=18'} cpu: [x64] os: [openbsd] - '@esbuild/sunos-x64@0.20.2': - resolution: {integrity: sha512-2UyFtRC6cXLyejf/YEld4Hajo7UHILetzE1vsRcGL3earZEW77JxrFjH4Ez2qaTiEfMgAXxfAZCm1fvM/G/o8w==} - engines: {node: '>=12'} - cpu: [x64] - os: [sunos] - '@esbuild/sunos-x64@0.23.0': resolution: {integrity: sha512-BFelBGfrBwk6LVrmFzCq1u1dZbG4zy/Kp93w2+y83Q5UGYF1d8sCzeLI9NXjKyujjBBniQa8R8PzLFAUrSM9OA==} engines: {node: '>=18'} @@ -7926,18 +7469,12 @@ packages: cpu: [x64] os: [sunos] - '@esbuild/sunos-x64@0.25.0': - resolution: {integrity: sha512-bxI7ThgLzPrPz484/S9jLlvUAHYMzy6I0XiU1ZMeAEOBcS0VePBFxh1JjTQt3Xiat5b6Oh4x7UC7IwKQKIJRIg==} + '@esbuild/sunos-x64@0.25.2': + resolution: {integrity: sha512-cfZH1co2+imVdWCjd+D1gf9NjkchVhhdpgb1q5y6Hcv9TP6Zi9ZG/beI3ig8TvwT9lH9dlxLq5MQBBgwuj4xvA==} engines: {node: '>=18'} cpu: [x64] os: [sunos] - '@esbuild/win32-arm64@0.20.2': - resolution: {integrity: sha512-GRibxoawM9ZCnDxnP3usoUDO9vUkpAxIIZ6GQI+IlVmr5kP3zUq+l17xELTHMWTWzjxa2guPNyrpq1GWmPvcGQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [win32] - '@esbuild/win32-arm64@0.23.0': resolution: {integrity: sha512-lY6AC8p4Cnb7xYHuIxQ6iYPe6MfO2CC43XXKo9nBXDb35krYt7KGhQnOkRGar5psxYkircpCqfbNDB4uJbS2jQ==} engines: {node: '>=18'} @@ -7956,18 +7493,12 @@ packages: cpu: [arm64] os: [win32] - '@esbuild/win32-arm64@0.25.0': - resolution: {integrity: sha512-ZUAc2YK6JW89xTbXvftxdnYy3m4iHIkDtK3CLce8wg8M2L+YZhIvO1DKpxrd0Yr59AeNNkTiic9YLf6FTtXWMw==} + '@esbuild/win32-arm64@0.25.2': + resolution: {integrity: sha512-7Loyjh+D/Nx/sOTzV8vfbB3GJuHdOQyrOryFdZvPHLf42Tk9ivBU5Aedi7iyX+x6rbn2Mh68T4qq1SDqJBQO5Q==} engines: {node: '>=18'} cpu: [arm64] os: [win32] - '@esbuild/win32-ia32@0.20.2': - resolution: {integrity: sha512-HfLOfn9YWmkSKRQqovpnITazdtquEW8/SoHW7pWpuEeguaZI4QnCRW6b+oZTztdBnZOS2hqJ6im/D5cPzBTTlQ==} - engines: {node: '>=12'} - cpu: [ia32] - os: [win32] - '@esbuild/win32-ia32@0.23.0': resolution: {integrity: sha512-7L1bHlOTcO4ByvI7OXVI5pNN6HSu6pUQq9yodga8izeuB1KcT2UkHaH6118QJwopExPn0rMHIseCTx1CRo/uNA==} engines: {node: '>=18'} @@ -7986,18 +7517,12 @@ packages: cpu: [ia32] os: [win32] - '@esbuild/win32-ia32@0.25.0': - resolution: {integrity: sha512-eSNxISBu8XweVEWG31/JzjkIGbGIJN/TrRoiSVZwZ6pkC6VX4Im/WV2cz559/TXLcYbcrDN8JtKgd9DJVIo8GA==} + '@esbuild/win32-ia32@0.25.2': + resolution: {integrity: sha512-WRJgsz9un0nqZJ4MfhabxaD9Ft8KioqU3JMinOTvobbX6MOSUigSBlogP8QB3uxpJDsFS6yN+3FDBdqE5lg9kg==} engines: {node: '>=18'} cpu: [ia32] os: [win32] - '@esbuild/win32-x64@0.20.2': - resolution: {integrity: sha512-N49X4lJX27+l9jbLKSqZ6bKNjzQvHaT8IIFUy+YIqmXQdjYCToGWwOItDrfby14c78aDd5NHQl29xingXfCdLQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [win32] - '@esbuild/win32-x64@0.23.0': resolution: {integrity: sha512-Arm+WgUFLUATuoxCJcahGuk6Yj9Pzxd6l11Zb/2aAuv5kWWvvfhLFo2fni4uSK5vzlUdCGZ/BdV5tH8klj8p8g==} engines: {node: '>=18'} @@ -8016,8 +7541,8 @@ packages: cpu: [x64] os: [win32] - '@esbuild/win32-x64@0.25.0': - resolution: {integrity: sha512-ZENoHJBxA20C2zFzh6AI4fT6RraMzjYw4xKWemRTRmRVtN9c5DcH9r/f2ihEkMjOW5eGgrwCslG/+Y/3bL+DHQ==} + '@esbuild/win32-x64@0.25.2': + resolution: {integrity: sha512-kM3HKb16VIXZyIeVrM1ygYmZBKybX8N4p754bw390wGO3Tf2j4L2/WYL+4suWujpgf6GBYs3jv7TyUivdd05JA==} engines: {node: '>=18'} cpu: [x64] os: [win32] @@ -8567,16 +8092,12 @@ packages: '@napi-rs/wasm-runtime@0.2.4': resolution: {integrity: sha512-9zESzOO5aDByvhIAsOy9TbpZ0Ur2AJbUI7UT73kcUTS2mxAMHOBaa1st/jAymNoCtvrit99kkzT1FZuXVcgfIQ==} - '@netlify/functions@2.8.2': - resolution: {integrity: sha512-DeoAQh8LuNPvBE4qsKlezjKj0PyXDryOFJfJKo3Z1qZLKzQ21sT314KQKPVjfvw6knqijj+IO+0kHXy/TJiqNA==} - engines: {node: '>=14.0.0'} + '@netlify/functions@3.0.4': + resolution: {integrity: sha512-Ox8+ABI+nsLK+c4/oC5dpquXuEIjzfTlJrdQKgQijCsDQoje7inXFAtKDLvvaGvuvE+PVpMLwQcIUL6P9Ob1hQ==} + engines: {node: '>=18.0.0'} - '@netlify/node-cookies@0.1.0': - resolution: {integrity: sha512-OAs1xG+FfLX0LoRASpqzVntVV/RpYkgpI0VrUnw2u0Q1qiZUzcPffxRK8HF3gc4GjuhG5ahOEMJ9bswBiZPq0g==} - engines: {node: ^14.16.0 || >=16.0.0} - - '@netlify/serverless-functions-api@1.26.1': - resolution: {integrity: sha512-q3L9i3HoNfz0SGpTIS4zTcKBbRkxzCRpd169eyiTuk3IwcPC3/85mzLHranlKo2b+HYT0gu37YxGB45aD8A3Tw==} + '@netlify/serverless-functions-api@1.36.0': + resolution: {integrity: sha512-z6okREyK8in0486a22Oro0k+YsuyEjDXJt46FpgeOgXqKJ9ElM8QPll0iuLBkpbH33ENiNbIPLd1cuClRQnhiw==} engines: {node: '>=18.0.0'} '@nodelib/fs.scandir@2.1.5': @@ -8654,6 +8175,22 @@ packages: cpu: [x64] os: [win32] + '@oozcitak/dom@1.15.10': + resolution: {integrity: sha512-0JT29/LaxVgRcGKvHmSrUTEvZ8BXvZhGl2LASRUgHqDTC1M5g1pLmVv56IYNyt3bG2CUjDkc67wnyZC14pbQrQ==} + engines: {node: '>=8.0'} + + '@oozcitak/infra@1.0.8': + resolution: {integrity: sha512-JRAUc9VR6IGHOL7OGF+yrvs0LO8SlqGnPAMqyzOuFZPSZSXI7Xf2O9+awQPSMXgIWGtgUf/dA6Hs6X6ySEaWTg==} + engines: {node: '>=6.0'} + + '@oozcitak/url@1.0.4': + resolution: {integrity: sha512-kDcD8y+y3FCSOvnBI6HJgl00viO/nGbQoCINmQ0h98OhnGITrWR3bOGfwYCthgcrV8AnTJz8MzslTQbC3SOAmw==} + engines: {node: '>=8.0'} + + '@oozcitak/util@8.3.8': + resolution: {integrity: sha512-T8TbSnGsxo6TDBJx/Sgv/BlVJL3tshxZP7Aq5R1mSnM5OcHY2dQaxLMu2+E8u3gN0MLOzdjurqN4ZRVuzQycOQ==} + engines: {node: '>=8.0'} + '@open-draft/deferred-promise@2.2.0': resolution: {integrity: sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==} @@ -8723,12 +8260,6 @@ packages: cpu: [x64] os: [linux] - '@parcel/watcher-wasm@2.3.0': - resolution: {integrity: sha512-ejBAX8H0ZGsD8lSICDNyMbSEtPMWgDL0WFCt/0z7hyf5v8Imz4rAM8xY379mBsECkq/Wdqa5WEDLqtjZ+6NxfA==} - engines: {node: '>= 10.0.0'} - bundledDependencies: - - napi-wasm - '@parcel/watcher-wasm@2.5.1': resolution: {integrity: sha512-RJxlQQLkaMMIuWRozy+z2vEqbaQlCuaCgVZIUCzQLYggY22LZbP5Y1+ia+FD724Ids9e+XIyOLXLrLgQSHIthw==} engines: {node: '>= 10.0.0'} @@ -8783,6 +8314,17 @@ packages: '@popperjs/core@2.11.8': resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==} + '@poppinss/colors@4.1.4': + resolution: {integrity: sha512-FA+nTU8p6OcSH4tLDY5JilGYr1bVWHpNmcLr7xmMEdbWmKHa+3QZ+DqefrXKmdjO/brHTnQZo20lLSjaO7ydog==} + engines: {node: '>=18.16.0'} + + '@poppinss/dumper@0.6.3': + resolution: {integrity: sha512-iombbn8ckOixMtuV1p3f8jN6vqhXefNjJttoPaJDMeIk/yIGhkkL3OrHkEjE9SRsgoAx1vBUU2GtgggjvA5hCA==} + + '@poppinss/exception@1.2.1': + resolution: {integrity: sha512-aQypoot0HPSJa6gDPEPTntc1GT6QINrSbgRlRhadGW2WaYqUK3tK4Bw9SBMZXhmxd3GeAlZjVcODHgiu+THY7A==} + engines: {node: '>=18'} + '@prisma/client@5.22.0': resolution: {integrity: sha512-M0SVXfyHnQREBKxCgyo7sffrKttwE6R8PMq330MIUF0pTwjUhLbW84pFDlf06B27XyCR++VtjugEnIHdr07SVA==} engines: {node: '>=16.13'} @@ -8847,9 +8389,6 @@ packages: '@radix-ui/number@1.1.1': resolution: {integrity: sha512-MkKCwxlXTgz6CFoJx3pCwn07GKp36+aZyu/u2Ln2VrA5DcdyCZkASEDBTd8x5whTQQL5CiYf4prXKLcgQdv29g==} - '@radix-ui/primitive@1.1.1': - resolution: {integrity: sha512-SJ31y+Q/zAyShtXJc8x83i9TYdbAfHZ++tUZnvjJJqFjzsdUnKsxPL6IEtBlxKkU7yzer//GQtZSV4GbldL3YA==} - '@radix-ui/primitive@1.1.2': resolution: {integrity: sha512-XnbHrrprsNqZKQhStrSwgRUQzoCI1glLzdw79xiZPoofhGICeZRSQ3dIxAKH1gb3OHfNf4d6f+vAv3kil2eggA==} @@ -8970,15 +8509,6 @@ packages: '@types/react-dom': optional: true - '@radix-ui/react-compose-refs@1.1.1': - resolution: {integrity: sha512-Y9VzoRDSJtgFMUCoiZBDVo084VQ5hfpXxVE+NgkdNsjiDBByiImMZKKhxMwCbdHvhlENG6a833CbFkOQvTricw==} - peerDependencies: - '@types/react': ^19.0.8 - react: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@radix-ui/react-compose-refs@1.1.2': resolution: {integrity: sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg==} peerDependencies: @@ -9001,15 +8531,6 @@ packages: '@types/react-dom': optional: true - '@radix-ui/react-context@1.1.1': - resolution: {integrity: sha512-UASk9zi+crv9WteK/NU4PLvOoL3OuE6BWVKNF6hPRBtYBDXQ2u5iu3O59zUlJiTVvkyuycnqrztsHVJwcK9K+Q==} - peerDependencies: - '@types/react': ^19.0.8 - react: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@radix-ui/react-context@1.1.2': resolution: {integrity: sha512-jCi/QKUM2r1Ju5a3J64TH2A5SpKAgh0LpknyqdQ4m6DCV0xJ2HG1xARRwNGPQfi1SLdLWZ1OJz6F4OMBBNiGJA==} peerDependencies: @@ -9019,19 +8540,6 @@ packages: '@types/react': optional: true - '@radix-ui/react-dialog@1.1.6': - resolution: {integrity: sha512-/IVhJV5AceX620DUJ4uYVMymzsipdKBzo3edo+omeskCKGm9FRHM0ebIdbPnlQVJqyuHbuBltQUOG2mOTq2IYw==} - peerDependencies: - '@types/react': ^19.0.8 - '@types/react-dom': ^19.0.3 - react: ^19.0.0 - react-dom: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@types/react-dom': - optional: true - '@radix-ui/react-dialog@1.1.7': resolution: {integrity: sha512-EIdma8C0C/I6kL6sO02avaCRqi3fmWJpxH6mqbVScorW6nNktzKJT/le7VPho3o/7wCsyRg3z0+Q+Obr0Gy/VQ==} peerDependencies: @@ -9054,19 +8562,6 @@ packages: '@types/react': optional: true - '@radix-ui/react-dismissable-layer@1.1.5': - resolution: {integrity: sha512-E4TywXY6UsXNRhFrECa5HAvE5/4BFcGyfTyK36gP+pAW1ed7UTK4vKwdr53gAJYwqbfCWC6ATvJa3J3R/9+Qrg==} - peerDependencies: - '@types/react': ^19.0.8 - '@types/react-dom': ^19.0.3 - react: ^19.0.0 - react-dom: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@types/react-dom': - optional: true - '@radix-ui/react-dismissable-layer@1.1.6': resolution: {integrity: sha512-7gpgMT2gyKym9Jz2ZhlRXSg2y6cNQIK8d/cqBZ0RBCaps8pFryCWXiUKI+uHGFrhMrbGUP7U6PWgiXzIxoyF3Q==} peerDependencies: @@ -9093,15 +8588,6 @@ packages: '@types/react-dom': optional: true - '@radix-ui/react-focus-guards@1.1.1': - resolution: {integrity: sha512-pSIwfrT1a6sIoDASCSpFwOasEwKTZWDw/iBdtnqKO7v6FeOzYJ7U53cPzYFVR3geGGXgVHaH+CdngrrAzqUGxg==} - peerDependencies: - '@types/react': ^19.0.8 - react: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@radix-ui/react-focus-guards@1.1.2': resolution: {integrity: sha512-fyjAACV62oPV925xFCrH8DR5xWhg9KYtJT4s3u54jxp+L/hbpTY2kIeEFFbFe+a/HCE94zGQMZLIpVTPVZDhaA==} peerDependencies: @@ -9111,19 +8597,6 @@ packages: '@types/react': optional: true - '@radix-ui/react-focus-scope@1.1.2': - resolution: {integrity: sha512-zxwE80FCU7lcXUGWkdt6XpTTCKPitG1XKOwViTxHVKIJhZl9MvIl2dVHeZENCWD9+EdWv05wlaEkRXUykU27RA==} - peerDependencies: - '@types/react': ^19.0.8 - '@types/react-dom': ^19.0.3 - react: ^19.0.0 - react-dom: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@types/react-dom': - optional: true - '@radix-ui/react-focus-scope@1.1.3': resolution: {integrity: sha512-4XaDlq0bPt7oJwR+0k0clCiCO/7lO7NKZTAaJBYxDNQT/vj4ig0/UvctrRscZaFREpRvUTkpKR96ov1e6jptQg==} peerDependencies: @@ -9163,15 +8636,6 @@ packages: '@types/react-dom': optional: true - '@radix-ui/react-id@1.1.0': - resolution: {integrity: sha512-EJUrI8yYh7WOjNOqpoJaf1jlFIH2LvtgAl+YcFqNCa+4hj64ZXmPkAKOFs/ukjz3byN6bdb/AVUqHkI8/uWWMA==} - peerDependencies: - '@types/react': ^19.0.8 - react: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@radix-ui/react-id@1.1.1': resolution: {integrity: sha512-kGkGegYIdQsOb4XjsfM97rXsiHaBwco+hFI66oO4s9LU+PLAC5oJ7khdOVFxkhsmlbpUqDAvXw11CluXP+jkHg==} peerDependencies: @@ -9259,19 +8723,6 @@ packages: '@types/react-dom': optional: true - '@radix-ui/react-portal@1.1.4': - resolution: {integrity: sha512-sn2O9k1rPFYVyKd5LAJfo96JlSGVFpa1fS6UuBJfrZadudiw5tAmru+n1x7aMRQ84qDM71Zh1+SzK5QwU0tJfA==} - peerDependencies: - '@types/react': ^19.0.8 - '@types/react-dom': ^19.0.3 - react: ^19.0.0 - react-dom: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@types/react-dom': - optional: true - '@radix-ui/react-portal@1.1.5': resolution: {integrity: sha512-ps/67ZqsFm+Mb6lSPJpfhRLrVL2i2fntgCmGMqqth4eaGUf+knAuuRtWVJrNjUhExgmdRqftSgzpf0DF0n6yXA==} peerDependencies: @@ -9285,19 +8736,6 @@ packages: '@types/react-dom': optional: true - '@radix-ui/react-presence@1.1.2': - resolution: {integrity: sha512-18TFr80t5EVgL9x1SwF/YGtfG+l0BS0PRAlCWBDoBEiDQjeKgnNZRVJp/oVBl24sr3Gbfwc/Qpj4OcWTQMsAEg==} - peerDependencies: - '@types/react': ^19.0.8 - '@types/react-dom': ^19.0.3 - react: ^19.0.0 - react-dom: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@types/react-dom': - optional: true - '@radix-ui/react-presence@1.1.3': resolution: {integrity: sha512-IrVLIhskYhH3nLvtcBLQFZr61tBG7wx7O3kEmdzcYwRGAEBmBicGGL7ATzNgruYJ3xBTbuzEEq9OXJM3PAX3tA==} peerDependencies: @@ -9311,19 +8749,6 @@ packages: '@types/react-dom': optional: true - '@radix-ui/react-primitive@2.0.2': - resolution: {integrity: sha512-Ec/0d38EIuvDF+GZjcMU/Ze6MxntVJYO/fRlCPhCaVUyPY9WTalHJw54tp9sXeJo3tlShWpy41vQRgLRGOuz+w==} - peerDependencies: - '@types/react': ^19.0.8 - '@types/react-dom': ^19.0.3 - react: ^19.0.0 - react-dom: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@types/react-dom': - optional: true - '@radix-ui/react-primitive@2.0.3': resolution: {integrity: sha512-Pf/t/GkndH7CQ8wE2hbkXA+WyZ83fhQQn5DDmwDiDo6AwN/fhaH8oqZ0jRjMrO2iaMhDi6P1HRx6AZwyMinY1g==} peerDependencies: @@ -9428,15 +8853,6 @@ packages: '@types/react-dom': optional: true - '@radix-ui/react-slot@1.1.2': - resolution: {integrity: sha512-YAKxaiGsSQJ38VzKH86/BPRC4rh+b1Jpa+JneA5LRE7skmLPNAyeG8kPJj/oo4STLvlrs8vkf/iYyc3A5stYCQ==} - peerDependencies: - '@types/react': ^19.0.8 - react: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@radix-ui/react-slot@1.2.0': resolution: {integrity: sha512-ujc+V6r0HNDviYqIK3rW4ffgYiZ8g5DEHrGJVk4x7kTlLXRDILnKX9vAUYeIsLOoDpDJ0ujpqMkjH4w2ofuo6w==} peerDependencies: @@ -9537,15 +8953,6 @@ packages: '@types/react-dom': optional: true - '@radix-ui/react-use-callback-ref@1.1.0': - resolution: {integrity: sha512-CasTfvsy+frcFkbXtSJ2Zu9JHpN8TYKxkgJGWbjiZhFivxaeW7rMeZt7QELGVLaYVfFMsKHjb7Ak0nMEe+2Vfw==} - peerDependencies: - '@types/react': ^19.0.8 - react: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@radix-ui/react-use-callback-ref@1.1.1': resolution: {integrity: sha512-FkBMwD+qbGQeMu1cOHnuGB6x4yzPjho8ap5WtbEJ26umhgqVXbhekKUQO+hZEL1vU92a3wHwdp0HAcqAUF5iDg==} peerDependencies: @@ -9555,15 +8962,6 @@ packages: '@types/react': optional: true - '@radix-ui/react-use-controllable-state@1.1.0': - resolution: {integrity: sha512-MtfMVJiSr2NjzS0Aa90NPTnvTSg6C/JLCV7ma0W6+OMV78vd8OyRpID+Ng9LxzsPbLeuBnWBA1Nq30AtBIDChw==} - peerDependencies: - '@types/react': ^19.0.8 - react: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@radix-ui/react-use-controllable-state@1.1.1': resolution: {integrity: sha512-YnEXIy8/ga01Y1PN0VfaNH//MhA91JlEGVBDxDzROqwrAtG5Yr2QGEPz8A/rJA3C7ZAHryOYGaUv8fLSW2H/mg==} peerDependencies: @@ -9573,15 +8971,6 @@ packages: '@types/react': optional: true - '@radix-ui/react-use-escape-keydown@1.1.0': - resolution: {integrity: sha512-L7vwWlR1kTTQ3oh7g1O0CBF3YCyyTj8NmhLR+phShpyA50HCfBFKVJTpshm9PzLiKmehsrQzTYTpX9HvmC9rhw==} - peerDependencies: - '@types/react': ^19.0.8 - react: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@radix-ui/react-use-escape-keydown@1.1.1': resolution: {integrity: sha512-Il0+boE7w/XebUHyBjroE+DbByORGR9KKmITzbR7MyQ4akpORYP/ZmbhAr0DG7RmmBqoOnZdy2QlvajJ2QA59g==} peerDependencies: @@ -9591,15 +8980,6 @@ packages: '@types/react': optional: true - '@radix-ui/react-use-layout-effect@1.1.0': - resolution: {integrity: sha512-+FPE0rOdziWSrH9athwI1R0HDVbWlEhd+FR+aSDk4uWGmSJ9Z54sdZVDQPZAinJhJXwfT+qnj969mCsT2gfm5w==} - peerDependencies: - '@types/react': ^19.0.8 - react: ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@radix-ui/react-use-layout-effect@1.1.1': resolution: {integrity: sha512-RbJRS4UWQFkzHTTwVymMTUv8EqYhOp8dOOviLj2ugtTiXRaRQS7GLGxZTLL1jWhMeoSCf5zmcZkqTl9IiYfXcQ==} peerDependencies: @@ -9665,16 +9045,6 @@ packages: '@types/react-dom': optional: true - '@redocly/ajv@8.11.2': - resolution: {integrity: sha512-io1JpnwtIcvojV7QKDUSIuMN/ikdOUd1ReEnUnMKGfDVridQZ31J0MmIuqwuRjWDZfmvr+Q0MqCcfHM2gTivOg==} - - '@redocly/config@0.20.3': - resolution: {integrity: sha512-Nyyv1Bj7GgYwj/l46O0nkH1GTKWbO3Ixe7KFcn021aZipkZd+z8Vlu1BwkhqtVgivcKaClaExtWU/lDHkjBzag==} - - '@redocly/openapi-core@1.28.0': - resolution: {integrity: sha512-jnUsOFnz8w71l14Ww34Iswlj0AI4e/R0C5+K2W4v4GaY/sUkpH/145gHLJYlG4XV0neET4lNIptd4I8+yLyEHQ==} - engines: {node: '>=18.17.0', npm: '>=10.8.2'} - '@rollup/plugin-alias@5.1.1': resolution: {integrity: sha512-PR9zDb+rOzkRb2VD+EuKB7UC41vU5DIwZ5qqCpk0KJudcWAyi8rvYOhS7+L5aZCspw1stTViLgN5v6FF1p5cgQ==} engines: {node: '>=14.0.0'} @@ -9697,8 +9067,8 @@ packages: rollup: optional: true - '@rollup/plugin-commonjs@28.0.2': - resolution: {integrity: sha512-BEFI2EDqzl+vA1rl97IDRZ61AIwGH093d9nz8+dThxJNH8oSoB7MjWvPCX3dkaK1/RCJ/1v/R1XB15FuSs0fQw==} + '@rollup/plugin-commonjs@28.0.3': + resolution: {integrity: sha512-pyltgilam1QPdn+Zd9gaCfOLcnjMEJ9gV+bTw6/r73INdvzf1ah9zLIJBm+kW7R6IUFIQ1YO+VqZtYxZNWFPEQ==} engines: {node: '>=16.0.0 || 14 >= 14.17'} peerDependencies: rollup: ^2.68.0||^3.0.0||^4.0.0 @@ -9724,8 +9094,8 @@ packages: rollup: optional: true - '@rollup/plugin-node-resolve@15.3.1': - resolution: {integrity: sha512-tgg6b91pAybXHJQMAAwW9VuWBO6Thi+q7BCNARLwSqlmsHz0XYURtGvh/AuwSADXSI4h/2uHbs7s4FzlZDGSGA==} + '@rollup/plugin-node-resolve@16.0.1': + resolution: {integrity: sha512-tk5YCxJWIG81umIvNkSod2qK5KyQW19qcBF/B78n1bjtOON6gzKoVeSzAE8yHCZEDmqkHKkxplExA8KzdJLJpA==} engines: {node: '>=14.0.0'} peerDependencies: rollup: ^2.78.0||^3.0.0||^4.0.0 @@ -9760,103 +9130,103 @@ packages: rollup: optional: true - '@rollup/rollup-android-arm-eabi@4.39.0': - resolution: {integrity: sha512-lGVys55Qb00Wvh8DMAocp5kIcaNzEFTmGhfFd88LfaogYTRKrdxgtlO5H6S49v2Nd8R2C6wLOal0qv6/kCkOwA==} + '@rollup/rollup-android-arm-eabi@4.38.0': + resolution: {integrity: sha512-ldomqc4/jDZu/xpYU+aRxo3V4mGCV9HeTgUBANI3oIQMOL+SsxB+S2lxMpkFp5UamSS3XuTMQVbsS24R4J4Qjg==} cpu: [arm] os: [android] - '@rollup/rollup-android-arm64@4.39.0': - resolution: {integrity: sha512-It9+M1zE31KWfqh/0cJLrrsCPiF72PoJjIChLX+rEcujVRCb4NLQ5QzFkzIZW8Kn8FTbvGQBY5TkKBau3S8cCQ==} + '@rollup/rollup-android-arm64@4.38.0': + resolution: {integrity: sha512-VUsgcy4GhhT7rokwzYQP+aV9XnSLkkhlEJ0St8pbasuWO/vwphhZQxYEKUP3ayeCYLhk6gEtacRpYP/cj3GjyQ==} cpu: [arm64] os: [android] - '@rollup/rollup-darwin-arm64@4.39.0': - resolution: {integrity: sha512-lXQnhpFDOKDXiGxsU9/l8UEGGM65comrQuZ+lDcGUx+9YQ9dKpF3rSEGepyeR5AHZ0b5RgiligsBhWZfSSQh8Q==} + '@rollup/rollup-darwin-arm64@4.38.0': + resolution: {integrity: sha512-buA17AYXlW9Rn091sWMq1xGUvWQFOH4N1rqUxGJtEQzhChxWjldGCCup7r/wUnaI6Au8sKXpoh0xg58a7cgcpg==} cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-x64@4.39.0': - resolution: {integrity: sha512-mKXpNZLvtEbgu6WCkNij7CGycdw9cJi2k9v0noMb++Vab12GZjFgUXD69ilAbBh034Zwn95c2PNSz9xM7KYEAQ==} + '@rollup/rollup-darwin-x64@4.38.0': + resolution: {integrity: sha512-Mgcmc78AjunP1SKXl624vVBOF2bzwNWFPMP4fpOu05vS0amnLcX8gHIge7q/lDAHy3T2HeR0TqrriZDQS2Woeg==} cpu: [x64] os: [darwin] - '@rollup/rollup-freebsd-arm64@4.39.0': - resolution: {integrity: sha512-jivRRlh2Lod/KvDZx2zUR+I4iBfHcu2V/BA2vasUtdtTN2Uk3jfcZczLa81ESHZHPHy4ih3T/W5rPFZ/hX7RtQ==} + '@rollup/rollup-freebsd-arm64@4.38.0': + resolution: {integrity: sha512-zzJACgjLbQTsscxWqvrEQAEh28hqhebpRz5q/uUd1T7VTwUNZ4VIXQt5hE7ncs0GrF+s7d3S4on4TiXUY8KoQA==} cpu: [arm64] os: [freebsd] - '@rollup/rollup-freebsd-x64@4.39.0': - resolution: {integrity: sha512-8RXIWvYIRK9nO+bhVz8DwLBepcptw633gv/QT4015CpJ0Ht8punmoHU/DuEd3iw9Hr8UwUV+t+VNNuZIWYeY7Q==} + '@rollup/rollup-freebsd-x64@4.38.0': + resolution: {integrity: sha512-hCY/KAeYMCyDpEE4pTETam0XZS4/5GXzlLgpi5f0IaPExw9kuB+PDTOTLuPtM10TlRG0U9OSmXJ+Wq9J39LvAg==} cpu: [x64] os: [freebsd] - '@rollup/rollup-linux-arm-gnueabihf@4.39.0': - resolution: {integrity: sha512-mz5POx5Zu58f2xAG5RaRRhp3IZDK7zXGk5sdEDj4o96HeaXhlUwmLFzNlc4hCQi5sGdR12VDgEUqVSHer0lI9g==} + '@rollup/rollup-linux-arm-gnueabihf@4.38.0': + resolution: {integrity: sha512-mimPH43mHl4JdOTD7bUMFhBdrg6f9HzMTOEnzRmXbOZqjijCw8LA5z8uL6LCjxSa67H2xiLFvvO67PT05PRKGg==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm-musleabihf@4.39.0': - resolution: {integrity: sha512-+YDwhM6gUAyakl0CD+bMFpdmwIoRDzZYaTWV3SDRBGkMU/VpIBYXXEvkEcTagw/7VVkL2vA29zU4UVy1mP0/Yw==} + '@rollup/rollup-linux-arm-musleabihf@4.38.0': + resolution: {integrity: sha512-tPiJtiOoNuIH8XGG8sWoMMkAMm98PUwlriOFCCbZGc9WCax+GLeVRhmaxjJtz6WxrPKACgrwoZ5ia/uapq3ZVg==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm64-gnu@4.39.0': - resolution: {integrity: sha512-EKf7iF7aK36eEChvlgxGnk7pdJfzfQbNvGV/+l98iiMwU23MwvmV0Ty3pJ0p5WQfm3JRHOytSIqD9LB7Bq7xdQ==} + '@rollup/rollup-linux-arm64-gnu@4.38.0': + resolution: {integrity: sha512-wZco59rIVuB0tjQS0CSHTTUcEde+pXQWugZVxWaQFdQQ1VYub/sTrNdY76D1MKdN2NB48JDuGABP6o6fqos8mA==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-arm64-musl@4.39.0': - resolution: {integrity: sha512-vYanR6MtqC7Z2SNr8gzVnzUul09Wi1kZqJaek3KcIlI/wq5Xtq4ZPIZ0Mr/st/sv/NnaPwy/D4yXg5x0B3aUUA==} + '@rollup/rollup-linux-arm64-musl@4.38.0': + resolution: {integrity: sha512-fQgqwKmW0REM4LomQ+87PP8w8xvU9LZfeLBKybeli+0yHT7VKILINzFEuggvnV9M3x1Ed4gUBmGUzCo/ikmFbQ==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-loongarch64-gnu@4.39.0': - resolution: {integrity: sha512-NMRUT40+h0FBa5fb+cpxtZoGAggRem16ocVKIv5gDB5uLDgBIwrIsXlGqYbLwW8YyO3WVTk1FkFDjMETYlDqiw==} + '@rollup/rollup-linux-loongarch64-gnu@4.38.0': + resolution: {integrity: sha512-hz5oqQLXTB3SbXpfkKHKXLdIp02/w3M+ajp8p4yWOWwQRtHWiEOCKtc9U+YXahrwdk+3qHdFMDWR5k+4dIlddg==} cpu: [loong64] os: [linux] - '@rollup/rollup-linux-powerpc64le-gnu@4.39.0': - resolution: {integrity: sha512-0pCNnmxgduJ3YRt+D+kJ6Ai/r+TaePu9ZLENl+ZDV/CdVczXl95CbIiwwswu4L+K7uOIGf6tMo2vm8uadRaICQ==} + '@rollup/rollup-linux-powerpc64le-gnu@4.38.0': + resolution: {integrity: sha512-NXqygK/dTSibQ+0pzxsL3r4Xl8oPqVoWbZV9niqOnIHV/J92fe65pOir0xjkUZDRSPyFRvu+4YOpJF9BZHQImw==} cpu: [ppc64] os: [linux] - '@rollup/rollup-linux-riscv64-gnu@4.39.0': - resolution: {integrity: sha512-t7j5Zhr7S4bBtksT73bO6c3Qa2AV/HqiGlj9+KB3gNF5upcVkx+HLgxTm8DK4OkzsOYqbdqbLKwvGMhylJCPhQ==} + '@rollup/rollup-linux-riscv64-gnu@4.38.0': + resolution: {integrity: sha512-GEAIabR1uFyvf/jW/5jfu8gjM06/4kZ1W+j1nWTSSB3w6moZEBm7iBtzwQ3a1Pxos2F7Gz+58aVEnZHU295QTg==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-riscv64-musl@4.39.0': - resolution: {integrity: sha512-m6cwI86IvQ7M93MQ2RF5SP8tUjD39Y7rjb1qjHgYh28uAPVU8+k/xYWvxRO3/tBN2pZkSMa5RjnPuUIbrwVxeA==} + '@rollup/rollup-linux-riscv64-musl@4.38.0': + resolution: {integrity: sha512-9EYTX+Gus2EGPbfs+fh7l95wVADtSQyYw4DfSBcYdUEAmP2lqSZY0Y17yX/3m5VKGGJ4UmIH5LHLkMJft3bYoA==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-s390x-gnu@4.39.0': - resolution: {integrity: sha512-iRDJd2ebMunnk2rsSBYlsptCyuINvxUfGwOUldjv5M4tpa93K8tFMeYGpNk2+Nxl+OBJnBzy2/JCscGeO507kA==} + '@rollup/rollup-linux-s390x-gnu@4.38.0': + resolution: {integrity: sha512-Mpp6+Z5VhB9VDk7RwZXoG2qMdERm3Jw07RNlXHE0bOnEeX+l7Fy4bg+NxfyN15ruuY3/7Vrbpm75J9QHFqj5+Q==} cpu: [s390x] os: [linux] - '@rollup/rollup-linux-x64-gnu@4.39.0': - resolution: {integrity: sha512-t9jqYw27R6Lx0XKfEFe5vUeEJ5pF3SGIM6gTfONSMb7DuG6z6wfj2yjcoZxHg129veTqU7+wOhY6GX8wmf90dA==} + '@rollup/rollup-linux-x64-gnu@4.38.0': + resolution: {integrity: sha512-vPvNgFlZRAgO7rwncMeE0+8c4Hmc+qixnp00/Uv3ht2x7KYrJ6ERVd3/R0nUtlE6/hu7/HiiNHJ/rP6knRFt1w==} cpu: [x64] os: [linux] - '@rollup/rollup-linux-x64-musl@4.39.0': - resolution: {integrity: sha512-ThFdkrFDP55AIsIZDKSBWEt/JcWlCzydbZHinZ0F/r1h83qbGeenCt/G/wG2O0reuENDD2tawfAj2s8VK7Bugg==} + '@rollup/rollup-linux-x64-musl@4.38.0': + resolution: {integrity: sha512-q5Zv+goWvQUGCaL7fU8NuTw8aydIL/C9abAVGCzRReuj5h30TPx4LumBtAidrVOtXnlB+RZkBtExMsfqkMfb8g==} cpu: [x64] os: [linux] - '@rollup/rollup-win32-arm64-msvc@4.39.0': - resolution: {integrity: sha512-jDrLm6yUtbOg2TYB3sBF3acUnAwsIksEYjLeHL+TJv9jg+TmTwdyjnDex27jqEMakNKf3RwwPahDIt7QXCSqRQ==} + '@rollup/rollup-win32-arm64-msvc@4.38.0': + resolution: {integrity: sha512-u/Jbm1BU89Vftqyqbmxdq14nBaQjQX1HhmsdBWqSdGClNaKwhjsg5TpW+5Ibs1mb8Es9wJiMdl86BcmtUVXNZg==} cpu: [arm64] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.39.0': - resolution: {integrity: sha512-6w9uMuza+LbLCVoNKL5FSLE7yvYkq9laSd09bwS0tMjkwXrmib/4KmoJcrKhLWHvw19mwU+33ndC69T7weNNjQ==} + '@rollup/rollup-win32-ia32-msvc@4.38.0': + resolution: {integrity: sha512-mqu4PzTrlpNHHbu5qleGvXJoGgHpChBlrBx/mEhTPpnAL1ZAYFlvHD7rLK839LLKQzqEQMFJfGrrOHItN4ZQqA==} cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.39.0': - resolution: {integrity: sha512-yAkUOkIKZlK5dl7u6dg897doBgLXmUHhIINM2c+sND3DZwnrdQkkSiDh7N75Ll4mM4dxSkYfXqU9fW3lLkMFug==} + '@rollup/rollup-win32-x64-msvc@4.38.0': + resolution: {integrity: sha512-jjqy3uWlecfB98Psxb5cD6Fny9Fupv9LrDSPTQZUROqjvZmcCqNu4UMl7qqhlUUGpwiAkotj6GYu4SZdcr/nLw==} cpu: [x64] os: [win32] @@ -10117,6 +9487,10 @@ packages: resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==} engines: {node: '>=10'} + '@sindresorhus/is@7.0.1': + resolution: {integrity: sha512-QWLl2P+rsCJeofkDNIT3WFmb6NrRud1SUYW8dIhXK/46XFV8Q/g7Bsvib0Askb0reRLe+WYPeeE+l5cH7SlkuQ==} + engines: {node: '>=18'} + '@sindresorhus/merge-streams@2.3.0': resolution: {integrity: sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==} engines: {node: '>=18'} @@ -10221,6 +9595,9 @@ packages: '@solidjs/router': optional: true + '@speed-highlight/core@1.2.7': + resolution: {integrity: sha512-0dxmVj4gxg3Jg879kvFS/msl4s9F3T9UXC1InxgOf7t5NvcPD97u/WTA5vL/IxWHMn7qSxBozqrnnE2wvl1m8g==} + '@stylistic/eslint-plugin-js@2.13.0': resolution: {integrity: sha512-GPPDK4+fcbsQD58a3abbng2Dx+jBoxM5cnYjBM4T24WFZRZdlNSKvR19TxP8CPevzMOodQ9QVzNeqWvMXzfJRA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -10418,14 +9795,14 @@ packages: '@tanstack/query-core@5.66.0': resolution: {integrity: sha512-J+JeBtthiKxrpzUu7rfIPDzhscXF2p5zE/hVdrqkACBP8Yu0M96mwJ5m/8cPPYQE9aRNvXztXHlNwIh4FEeMZw==} - '@tanstack/query-core@5.71.5': - resolution: {integrity: sha512-XOQ5SyjCdwhxyLksGKWSL5poqyEXYPDnsrZAzJm2LgrMm4Yh6VOrfC+IFosXreDw9HNqC11YAMY3HlfHjNzuaA==} + '@tanstack/query-core@5.72.2': + resolution: {integrity: sha512-fxl9/0yk3mD/FwTmVEf1/H6N5B975H0luT+icKyX566w6uJG0x6o+Yl+I38wJRCaogiMkstByt+seXfDbWDAcA==} '@tanstack/query-devtools@5.67.2': resolution: {integrity: sha512-O4QXFFd7xqp6EX7sdvc9tsVO8nm4lpWBqwpgjpVLW5g7IeOY6VnS/xvs/YzbRhBVkKTMaJMOUGU7NhSX+YGoNg==} - '@tanstack/query-devtools@5.71.5': - resolution: {integrity: sha512-Fq1JeAp+I52Md/KnyeFxzG7G0RpdHgeOfDNhSPkZQs/JqqXuAfpUf+wFHDz+vP0GZbSnla2JmcLSQebOkIb1yA==} + '@tanstack/query-devtools@5.72.2': + resolution: {integrity: sha512-mMKnGb+iOhVBcj6jaerCFRpg8pACStdG8hmUBHPtToeZzs4ctjBUL1FajqpVn2WaMxnq8Wya+P3Q5tPFNM9jQw==} '@tanstack/react-query-devtools@5.67.2': resolution: {integrity: sha512-cmj2DxBc+/9btQ66n5xI8wTtAma2BLVa403K7zIYiguzJ/kV201jnGensYqJeu1Rd8uRMLLRM74jLVMLDWNRJA==} @@ -10450,14 +9827,14 @@ packages: react: ^19.0.0 react-dom: ^19.0.0 - '@tanstack/solid-query-devtools@5.71.9': - resolution: {integrity: sha512-i2U8UcJM7TnciR7QBWFynAaEub+uhzYcS9L80pAu0J3nETTojjZl3Hl1UUMUYiA7jCFPU9bWQWHjJouUvzGU1w==} + '@tanstack/solid-query-devtools@5.72.2': + resolution: {integrity: sha512-duYFN6EMsV0iwz1vV60GvxsQy3PXycgHhrucaik2yvJlRKrEYuHTYGqpRTy+P3JrFZkEzVLjevMnbzR4IIt5vw==} peerDependencies: - '@tanstack/solid-query': ^5.71.9 + '@tanstack/solid-query': ^5.72.2 solid-js: ^1.6.0 - '@tanstack/solid-query@5.71.9': - resolution: {integrity: sha512-ue9xAX2okLGdXxSWcnYfOedL/QgOx9eNKEJdoM9D3RF5xxxn3p+dXp7+Buzqu2OmfwRnAjHkWRASgS/9NlDMLg==} + '@tanstack/solid-query@5.72.2': + resolution: {integrity: sha512-ty4J5q+DIPEs7xB01TqkTfx0wYkcccJaofb378Nq/HfWoQ/0300A8TM7CU7YotJUmVWA3qwBHnJLChXlNzX4ow==} peerDependencies: solid-js: ^1.6.0 @@ -10560,9 +9937,6 @@ packages: '@types/bonjour@3.5.13': resolution: {integrity: sha512-z9fJ5Im06zvUL548KvYNecEVlA7cVDkGUi6kZusb04mpyEFKCIZJvloCcmpmLaIahDpOQGHaHmG6imtPMmPXGQ==} - '@types/braces@3.0.5': - resolution: {integrity: sha512-SQFof9H+LXeWNz8wDe7oN5zu7ket0qwMu5vZubW4GCJ8Kkeh6nBWUz87+KTz/G3Kqsrp0j/W253XJb3KMEeg3w==} - '@types/connect-history-api-fallback@1.5.4': resolution: {integrity: sha512-n6Cr2xS1h4uAulPRdlw6Jl6s1oG8KrVilPN2yUITEs+K48EzMJJ3W1xy8K5eWuFvjp3R74AOIGSmp2UfBJ8HFw==} @@ -10644,9 +10018,6 @@ packages: '@types/koa@2.15.0': resolution: {integrity: sha512-7QFsywoE5URbuVnG3loe03QXuGajrnotr3gQkXcEBShORai23MePfFYdhz90FEtBBpkyIYQbVD+evKtloCgX3g==} - '@types/micromatch@4.0.9': - resolution: {integrity: sha512-7V+8ncr22h4UoYRLnLXSpTxjQrNUXtWHGeMPRJt1nULXI57G9bIcpyrHlmrQ7QK24EyyuXvYcSSWAM8GA9nqCg==} - '@types/mime@1.3.5': resolution: {integrity: sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==} @@ -10808,13 +10179,9 @@ packages: resolution: {integrity: sha512-oWWhcWDLwDfu++BGTZcmXWqpwtkwb5o7fxUIGksMQQDSdPW9prsSnfIOZMlsj4vBOSrcnjIUZMiIjODgGosFhQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@vercel/nft@0.27.10': - resolution: {integrity: sha512-zbaF9Wp/NsZtKLE4uVmL3FyfFwlpDyuymQM1kPbeT0mVOHKDQQNjnnfslB3REg3oZprmNFJuh3pkHBk2qAaizg==} - engines: {node: '>=16'} - hasBin: true - - '@vinxi/listhen@1.5.6': - resolution: {integrity: sha512-WSN1z931BtasZJlgPp704zJFnQFRg7yzSjkm3MzAWQYe4uXFXlFr1hc5Ac2zae5/HDOz5x1/zDM5Cb54vTCnWw==} + '@vercel/nft@0.29.2': + resolution: {integrity: sha512-A/Si4mrTkQqJ6EXJKv5EYCDQ3NL6nJXxG8VGXePsaiQigsomHYQC9xSpX8qGk7AEZk4b1ssbYIqJ0ISQQ7bfcA==} + engines: {node: '>=18'} hasBin: true '@vitejs/plugin-react@4.3.4': @@ -10979,8 +10346,8 @@ packages: webpack-dev-server: optional: true - '@workos-inc/node@7.45.0': - resolution: {integrity: sha512-8wx2YuhkmTc3bKc1Py/Gv8X44QovIDQVLfDL8qNMRybCLD5Cu7R6AnWP/ZI5VHwSgeird0g+Cuukqk3ZG8ycMg==} + '@workos-inc/node@7.46.0': + resolution: {integrity: sha512-r/j+l/nlHkOqgIt0U70shZMKIQwLYFFU9aYmFW53l16+FwG+61SfldaK3ckjb3gscoGxWq+t7RlxcEe7Tz5eRA==} engines: {node: '>=16'} '@xtuc/ieee754@1.2.0': @@ -11026,8 +10393,8 @@ packages: peerDependencies: acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 - acorn@8.14.0: - resolution: {integrity: sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==} + acorn@8.14.1: + resolution: {integrity: sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==} engines: {node: '>=0.4.0'} hasBin: true @@ -11088,9 +10455,6 @@ packages: alien-signals@0.4.14: resolution: {integrity: sha512-itUAVzhczTmP2U5yX67xVpsbbOiquusbWVyA9N+sy6+r6YVbFkahXvNCeEPWEOMhwDYwbVbGHFkVL03N9I5g+Q==} - ansi-align@3.0.1: - resolution: {integrity: sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==} - ansi-colors@4.1.3: resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} engines: {node: '>=6'} @@ -11266,10 +10630,6 @@ packages: boolbase@1.0.0: resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} - boxen@7.1.1: - resolution: {integrity: sha512-2hCgjEmP8YLWQ130n2FerGv7rYpfBmnmp9Uy2Le1vge6X3gZIfSmEzP5QTDElFxcvVcXlEn8Aq6MU/PZygIOog==} - engines: {node: '>=14.16'} - brace-expansion@1.1.11: resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} @@ -11306,8 +10666,8 @@ packages: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} engines: {node: '>= 0.8'} - c12@2.0.1: - resolution: {integrity: sha512-Z4JgsKXHG37C6PYUtIxCfLJZvo6FyhHJoClwwb9ftUkLpPSkuYqn6Tr+vnaN8hymm0kIbcg6Ey3kv/Q71k5w/A==} + c12@3.0.2: + resolution: {integrity: sha512-6Tzk1/TNeI3WBPpK0j/Ss4+gPj3PUJYbWl/MWDJBThFvwNGNkXtd7Cz8BJtD4aRwoGHtzQD0SnxamgUiBH0/Nw==} peerDependencies: magicast: ^0.3.5 peerDependenciesMeta: @@ -11337,10 +10697,6 @@ packages: resolution: {integrity: sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==} engines: {node: '>= 6'} - camelcase@7.0.1: - resolution: {integrity: sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw==} - engines: {node: '>=14.16'} - caniuse-lite@1.0.30001696: resolution: {integrity: sha512-pDCPkvzfa39ehJtJ+OwGT/2yvT2SbjfHhiIW2LWOAcMQ7BzwxT/XuyUp4OTOd0XFWA6BKw0JalnBHgSi5DGJBQ==} @@ -11360,9 +10716,6 @@ packages: resolution: {integrity: sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} - change-case@5.4.4: - resolution: {integrity: sha512-HRQyTk2/YPEkt9TnUPbOpr64Uw3KOicFWPVBb+xiHvd6eBx/qPr9xqfBFDT8P2vWsvvz4jbEkfDe71W3VyNu2w==} - char-regex@1.0.2: resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==} engines: {node: '>=10'} @@ -11371,6 +10724,13 @@ packages: resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} engines: {node: '>= 16'} + cheerio-select@2.1.0: + resolution: {integrity: sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==} + + cheerio@1.0.0: + resolution: {integrity: sha512-quS9HgjQpdaXOvsZz82Oz7uxtXiy6UIsIQcpBj7HRw2M63Skasm9qlDocAM7jNuaxdhpPU7c4kJN+gA5MCu4ww==} + engines: {node: '>=18.17'} + chokidar@3.6.0: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} @@ -11379,10 +10739,6 @@ packages: resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==} engines: {node: '>= 14.16.0'} - chownr@2.0.0: - resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} - engines: {node: '>=10'} - chownr@3.0.0: resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==} engines: {node: '>=18'} @@ -11404,10 +10760,6 @@ packages: resolution: {integrity: sha512-D5J+kHaVb/wKSFcyyV75uCn8fiY4sV38XJoe4CUyGQ+mOU/fMVYUdH1hJC+CJQ5uY3EnW27SbJYS4X8BiLrAFg==} engines: {node: '>= 10.0'} - cli-boxes@3.0.0: - resolution: {integrity: sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==} - engines: {node: '>=10'} - cli-cursor@3.1.0: resolution: {integrity: sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==} engines: {node: '>=8'} @@ -11463,9 +10815,6 @@ packages: color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - colorette@1.4.0: - resolution: {integrity: sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==} - colorette@2.0.20: resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} @@ -11533,12 +10882,15 @@ packages: confbox@0.1.8: resolution: {integrity: sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==} + confbox@0.2.1: + resolution: {integrity: sha512-hkT3yDPFbs95mNCy1+7qNKC6Pro+/ibzYxtM2iqEigpf0sVw+bg4Zh9/snjsBcf990vfIsg5+1U7VyiyBb3etg==} + connect-history-api-fallback@2.0.0: resolution: {integrity: sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA==} engines: {node: '>=0.8'} - consola@3.4.0: - resolution: {integrity: sha512-EiPU8G6dQG0GFHNR8ljnZFki/8a+cQwEQ+7wpxdChl02Q8HXlwEZWD5lqAF8vC2sEC3Tehr8hy7vErz88LHyUA==} + consola@3.4.2: + resolution: {integrity: sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==} engines: {node: ^14.18.0 || >=16.10.0} content-disposition@0.5.4: @@ -11586,6 +10938,9 @@ packages: cookie-es@1.2.2: resolution: {integrity: sha512-+W7VmiVINB+ywl1HGXJXmrqkOhpKrIiVZV6tQuV54ZyQC7MMuBt81Vc336GMLoHBq5hV/F9eXgt5Mnx0Rha5Fg==} + cookie-es@2.0.0: + resolution: {integrity: sha512-RAj4E421UYRgqokKUmotqAwuplYw15qtdXfY+hGzgCJ/MBjCVZcSoHK/kH9kocfjRjcDME7IiDWR/1WX1TM2Pg==} + cookie-signature@1.0.6: resolution: {integrity: sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==} @@ -11636,12 +10991,15 @@ packages: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} - crossws@0.3.3: - resolution: {integrity: sha512-/71DJT3xJlqSnBr83uGJesmVHSzZEvgxHt/fIKxBAAngqMHmnBWQNxCphVxxJ2XL3xleu5+hJD6IQ3TglBedcw==} + crossws@0.3.4: + resolution: {integrity: sha512-uj0O1ETYX1Bh6uSgktfPvwDiPYGQ3aI4qVsaC/LWpkIzGj1nUYm5FK3K+t11oOlpN01lGbprFCH4wBlKdJjVgw==} css-select@4.3.0: resolution: {integrity: sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==} + css-select@5.1.0: + resolution: {integrity: sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==} + css-what@6.1.0: resolution: {integrity: sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==} engines: {node: '>= 6'} @@ -11673,11 +11031,8 @@ packages: resolution: {integrity: sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==} engines: {node: '>=0.11'} - dax-sh@0.39.2: - resolution: {integrity: sha512-gpuGEkBQM+5y6p4cWaw9+ePy5TNon+fdwFVtTI8leU3UhwhsBfPewRxMXGuQNC+M2b/MDGMlfgpqynkcd0C3FQ==} - - db0@0.2.3: - resolution: {integrity: sha512-PunuHESDNefmwVy1LDpY663uWwKt2ogLGoB6NOz2sflGREWqDreMwDgF8gfkXxgNXW+dqviyiJGm924H1BaGiw==} + db0@0.3.1: + resolution: {integrity: sha512-3RogPLE2LLq6t4YiFCREyl572aBjkfMvfwPyN51df00TbPbryL3XqBYuJ/j6mgPssPK8AKfYdLxizaO5UG10sA==} peerDependencies: '@electric-sql/pglite': '*' '@libsql/client': '*' @@ -11854,6 +11209,9 @@ packages: dom-serializer@1.4.1: resolution: {integrity: sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==} + dom-serializer@2.0.0: + resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==} + domelementtype@2.3.0: resolution: {integrity: sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==} @@ -11861,9 +11219,16 @@ packages: resolution: {integrity: sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==} engines: {node: '>= 4'} + domhandler@5.0.3: + resolution: {integrity: sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==} + engines: {node: '>= 4'} + domutils@2.8.0: resolution: {integrity: sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==} + domutils@3.2.2: + resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==} + dot-case@3.0.4: resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==} @@ -11916,6 +11281,9 @@ packages: resolution: {integrity: sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==} engines: {node: '>= 0.8'} + encoding-sniffer@0.2.0: + resolution: {integrity: sha512-ju7Wq1kg04I3HtiYIOrUrdfdDvkyO9s5XM8QAj/bN61Yo/Vb4vgJxy5vi4Yxk01gWHbrofpPtpxM8bKger9jhg==} + end-of-stream@1.4.4: resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==} @@ -11934,6 +11302,10 @@ packages: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} + entities@6.0.0: + resolution: {integrity: sha512-aKstq2TDOndCn4diEyp9Uq/Flu2i1GlLkc6XIDQSDMuaFE3OPW5OphLCyQ5SpSJZTb4reN+kTcYru5yIfXoRPw==} + engines: {node: '>=0.12'} + envinfo@7.14.0: resolution: {integrity: sha512-CO40UI41xDQzhLB1hWyqUKgFhs250pNcGbyGKe1l/e4FSaI/+YE4IMG76GDt0In67WLPACIITC+sOi08x4wIvg==} engines: {node: '>=4'} @@ -11946,6 +11318,9 @@ packages: error-ex@1.3.2: resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} + error-stack-parser-es@1.0.5: + resolution: {integrity: sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==} + error-stack-parser@2.1.4: resolution: {integrity: sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==} @@ -11975,11 +11350,6 @@ packages: peerDependencies: esbuild: '>=0.12 <1' - esbuild@0.20.2: - resolution: {integrity: sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==} - engines: {node: '>=12'} - hasBin: true - esbuild@0.23.0: resolution: {integrity: sha512-1lvV17H2bMYda/WaFb2jLPeHU3zml2k4/yagNMG8Q/YtfMjCwEUZa2eXXMgZTVSL5q1n4H7sQ0X6CdJDqqeCFA==} engines: {node: '>=18'} @@ -11995,8 +11365,8 @@ packages: engines: {node: '>=18'} hasBin: true - esbuild@0.25.0: - resolution: {integrity: sha512-BXq5mqc8ltbaN34cDqWuYKyNhX8D/Z0J1xdtdQ8UcIIIyJyz+ZMKUt58tF3SrZ85jcfN/PZYhjR5uDQAYNVbuw==} + esbuild@0.25.2: + resolution: {integrity: sha512-16854zccKPnC+toMywC+uKNeYSv+/eXkevRAfwRD/G9Cleq66m8XFIrigkbvauLLlCfDL45Q2cWegSg53gGBnQ==} engines: {node: '>=18'} hasBin: true @@ -12231,6 +11601,9 @@ packages: resolution: {integrity: sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==} engines: {node: '>= 0.10.0'} + exsolve@1.0.4: + resolution: {integrity: sha512-xsZH6PXaER4XoV+NiT7JHp1bJodJVT+cxeSH1G0f0tlT0lJqYuHUP3bUx2HtfTDvOagMINYp8rsqusxud3RXhw==} + extend@3.0.2: resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} @@ -12403,10 +11776,6 @@ packages: resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==} engines: {node: '>=6 <7 || >=8'} - fs-minipass@2.1.0: - resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} - engines: {node: '>= 8'} - fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} @@ -12457,8 +11826,8 @@ packages: get-tsconfig@4.10.0: resolution: {integrity: sha512-kGzZ3LWWQcGIAmg6iWvXn0ei6WDtV26wzHRMwDSzmAbcXrTEXxHy6IehI6/4eT6VRKyMP1eF1VqwrVUmE/LR7A==} - giget@1.2.4: - resolution: {integrity: sha512-Wv+daGyispVoA31TrWAVR+aAdP7roubTPEM/8JzRnqXhLbdJH0T9eQyXVFF8fjk3WKTsctII6QcyxILYgNp2DA==} + giget@2.0.0: + resolution: {integrity: sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA==} hasBin: true glob-parent@5.1.2: @@ -12481,10 +11850,6 @@ packages: engines: {node: 20 || >=22} hasBin: true - glob@7.2.3: - resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} - deprecated: Glob versions prior to v9 are no longer supported - glob@9.3.5: resolution: {integrity: sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==} engines: {node: '>=16 || 14 >=14.17'} @@ -12509,8 +11874,8 @@ packages: resolution: {integrity: sha512-OkToC372DtlQeje9/zHIo5CT8lRP/FUgEOKBEhU4e0abL7J7CD24fD9ohiLN5hagG/kWCYj4K5oaxxtj2Z0Dig==} engines: {node: '>=18'} - globby@14.0.2: - resolution: {integrity: sha512-s3Fq41ZVh7vbbe2PN3nrW7yC7U7MFVc5c98/iTl9c2GawNMKx/J648KQRW6WKkuU8GIbbh2IXfIRQjOZnXcTnw==} + globby@14.1.0: + resolution: {integrity: sha512-0Ia46fDOaT7k4og1PDW4YbodWWr3scS2vAr2lTbsplOt2WkKp0vQbkI9wKis/T5LV/dqPjO3bpS/z6GTJB82LA==} engines: {node: '>=18'} globrex@0.1.2: @@ -12542,6 +11907,9 @@ packages: h3@1.13.0: resolution: {integrity: sha512-vFEAu/yf8UMUcB4s43OaDaigcqpQd14yanmOsn+NcRX3/guSKncyE2rOYhq8RIchgJrPSs/QiIddnTTR1ddiAg==} + h3@1.15.1: + resolution: {integrity: sha512-+ORaOBttdUm1E2Uu/obAyCguiI7MbBvsLTndc3gyK3zU+SYLoZXlyCP9Xgy0gikkGufFLTZXCXD6+4BsufnmHA==} + handle-thing@2.0.1: resolution: {integrity: sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==} @@ -12614,6 +11982,9 @@ packages: htmlparser2@6.1.0: resolution: {integrity: sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==} + htmlparser2@9.1.0: + resolution: {integrity: sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==} + http-deceiver@1.2.7: resolution: {integrity: sha512-LmpOGxTfbpgtGVxJrj5k7asXHCgNZp5nLfp+hWc8QQRqtb7fUy6kRY3BO1h9ddF6yIPYUARgxGOwB42DnxIaNw==} @@ -12686,6 +12057,10 @@ packages: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} + ignore@7.0.3: + resolution: {integrity: sha512-bAH5jbK/F3T3Jls4I0SO1hmPR0dKU0a7+SY6n1yzRtG54FLO8d6w/nxLFX2Nb7dBu6cCWXPaAME6cYqFUMmuCA==} + engines: {node: '>= 4'} + immer@10.1.1: resolution: {integrity: sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==} @@ -12702,9 +12077,6 @@ packages: engines: {node: '>=8'} hasBin: true - import-meta-resolve@4.1.0: - resolution: {integrity: sha512-I6fiaX09Xivtk+THaMfAwnA3MVA5Big1WHF1Dfx9hFuvNIWpXnorlkzhcQf6ehrqQiiZECRt1poOAkPmer3ruw==} - imurmurhash@0.1.4: resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} engines: {node: '>=0.8.19'} @@ -12713,14 +12085,6 @@ packages: resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==} engines: {node: '>=8'} - index-to-position@0.1.2: - resolution: {integrity: sha512-MWDKS3AS1bGCHLBA2VLImJz42f7bJh8wQsTGCzI3j519/CASStoDONUBVz2I/VID0MpiX3SGSnbOD2xUalbE5g==} - engines: {node: '>=18'} - - inflight@1.0.6: - resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} - deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. - inherits@2.0.3: resolution: {integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==} @@ -12737,8 +12101,8 @@ packages: resolution: {integrity: sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==} engines: {node: '>=10.13.0'} - ioredis@5.4.2: - resolution: {integrity: sha512-0SZXGNGZ+WzISQ67QDyZ2x0+wVxjjUndtD8oSeik/4ajifeiRufed8fCb8QW8VMyi4MXcS+UO1k/0NGhvq1PAg==} + ioredis@5.6.0: + resolution: {integrity: sha512-tBZlIIWbndeWBWCXWZiqtOF/yxf6yZX3tAlTJ7nfo5jhd6dctNxF7QnYlZLZ1a0o0pDoen7CgZqO+zjNaFbJAg==} engines: {node: '>=12.22.0'} ipaddr.js@1.9.1: @@ -12919,10 +12283,6 @@ packages: isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - isexe@3.1.1: - resolution: {integrity: sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==} - engines: {node: '>=16'} - isobject@3.0.1: resolution: {integrity: sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==} engines: {node: '>=0.10.0'} @@ -12971,10 +12331,6 @@ packages: resolution: {integrity: sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==} engines: {node: '>=14'} - js-levenshtein@1.1.6: - resolution: {integrity: sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g==} - engines: {node: '>=0.10.0'} - js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -13049,6 +12405,10 @@ packages: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} + kleur@4.1.5: + resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} + engines: {node: '>=6'} + klona@2.0.6: resolution: {integrity: sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA==} engines: {node: '>= 8'} @@ -13174,8 +12534,8 @@ packages: resolution: {integrity: sha512-9rrA30MRRP3gBD3HTGnC6cDFpaE1kVDWxWgqWJUN0RvDNAo+Nz/9GxB+nHOH0ifbVFy0hSA1V6vFDvnx54lTEQ==} engines: {node: '>=14'} - local-pkg@1.0.0: - resolution: {integrity: sha512-bbgPw/wmroJsil/GgL4qjDzs5YLTBMQ99weRsok1XCDccQeehbHA/I1oRvk2NPtr7KGZgT/Y5tPRnAtMqeG2Kg==} + local-pkg@1.1.1: + resolution: {integrity: sha512-WunYko2W1NcdfAFpuLUoucsgULmgDBRkdxHxWQ7mK0cQqwPiy8E1enjuRBrhLtZkB5iScJ1XIPdhVEFK8aOLSg==} engines: {node: '>=14'} locate-path@5.0.0: @@ -13384,35 +12744,18 @@ packages: minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} - minipass@3.3.6: - resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==} - engines: {node: '>=8'} - minipass@4.2.8: resolution: {integrity: sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==} engines: {node: '>=8'} - minipass@5.0.0: - resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==} - engines: {node: '>=8'} - minipass@7.1.2: resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==} engines: {node: '>=16 || 14 >=14.17'} - minizlib@2.1.2: - resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} - engines: {node: '>= 8'} - minizlib@3.0.1: resolution: {integrity: sha512-umcy022ILvb5/3Djuu8LWeqUa8D68JaBzlttKeMWen48SjabqS3iY5w/vzeMzMUNhLDifyhbOwKDSznB1vvrwg==} engines: {node: '>= 18'} - mkdirp@1.0.4: - resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} - engines: {node: '>=10'} - hasBin: true - mkdirp@3.0.1: resolution: {integrity: sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==} engines: {node: '>=10'} @@ -13484,8 +12827,8 @@ packages: neo-async@2.6.2: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} - nitropack@2.10.4: - resolution: {integrity: sha512-sJiG/MIQlZCVSw2cQrFG1H6mLeSqHlYfFerRjLKz69vUfdu0EL2l0WdOxlQbzJr3mMv/l4cOlCCLzVRzjzzF/g==} + nitropack@2.11.8: + resolution: {integrity: sha512-ummTu4R8Lhd1nO3nWrW7eeiHA2ey3ntbWFKkYakm4rcbvT6meWp+oykyrYBNFQKhobQl9CydmUWlCyztYXFPJw==} engines: {node: ^16.11.0 || >=17.0.0} hasBin: true peerDependencies: @@ -13503,6 +12846,7 @@ packages: node-domexception@1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} + deprecated: Use your platform's native DOMException instead node-emoji@2.2.0: resolution: {integrity: sha512-Z3lTE9pLaJF47NyMhd4ww1yFTAP8YhYI8SleJiHzM46Fgpm5cnNzSl9XfzFNqbaz+VlJrIj3fXQ4DeN1Rjm6cw==} @@ -13535,6 +12879,9 @@ packages: node-machine-id@1.1.12: resolution: {integrity: sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==} + node-mock-http@1.0.0: + resolution: {integrity: sha512-0uGYQ1WQL1M5kKvGRXWQ3uZCHtLTO8hln3oBjIusM75WoesZ909uQJs/Hb946i2SS+Gsrhkaa6iAO17jRIv6DQ==} + node-releases@2.0.19: resolution: {integrity: sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==} @@ -13577,8 +12924,8 @@ packages: '@swc/core': optional: true - nypm@0.5.2: - resolution: {integrity: sha512-AHzvnyUJYSrrphPhRWWZNcoZfArGNp3Vrc4pm/ZurO74tYNTgAPrEyBQEKy+qioqmWlPXwvMZCG2wOaHlPG0Pw==} + nypm@0.6.0: + resolution: {integrity: sha512-mn8wBFV9G9+UFHIrq+pZ2r2zL4aPau/by3kJb3cM7+5tQHMt6HGQB8FDIeKFYp8o0D2pnH6nVsO88N4AmUxIWg==} engines: {node: ^14.16.0 || >=16.10.0} hasBin: true @@ -13611,6 +12958,9 @@ packages: ohash@1.1.4: resolution: {integrity: sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g==} + ohash@2.0.11: + resolution: {integrity: sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==} + on-finished@2.4.1: resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==} engines: {node: '>= 0.8'} @@ -13638,12 +12988,6 @@ packages: resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} engines: {node: '>=12'} - openapi-typescript@7.6.0: - resolution: {integrity: sha512-p/xxKcWFR7aZDOAdnqYBQ1NdNyWdine+gHKHKvjxGXmlq8JT1G9+SkY8I5csKaktLHMbDDH6ZDeWQpydwBHa+Q==} - hasBin: true - peerDependencies: - typescript: ^5.x - optionator@0.9.4: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} @@ -13700,10 +13044,6 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} - parse-json@8.1.0: - resolution: {integrity: sha512-rum1bPifK5SSar35Z6EKZuYPJx85pkNaFrxBK3mwdfSJ1/WKbYrjoW/zTPSjRRamfmVX1ACBIdFAO0VRErW/EA==} - engines: {node: '>=18'} - parse-passwd@1.0.0: resolution: {integrity: sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==} engines: {node: '>=0.10.0'} @@ -13711,6 +13051,12 @@ packages: parse5-htmlparser2-tree-adapter@6.0.1: resolution: {integrity: sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==} + parse5-htmlparser2-tree-adapter@7.1.0: + resolution: {integrity: sha512-ruw5xyKs6lrpo9x9rCZqZZnIUntICjQAd0Wsmp396Ul9lN/h+ifgVV1x1gZHi8euej6wTfpqX8j+BFQxF0NS/g==} + + parse5-parser-stream@7.1.2: + resolution: {integrity: sha512-JyeQc9iwFLn5TbvvqACIF/VXG6abODeB3Fwmv/TGdLk2LfbWkaySGY72at4+Ty7EkPZj854u4CrICqNk2qIbow==} + parse5@5.1.1: resolution: {integrity: sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==} @@ -13720,6 +13066,9 @@ packages: parse5@7.2.1: resolution: {integrity: sha512-BuBYQYlv1ckiPdQi/ohiivi9Sagc9JG+Ozs0r7b/0iK3sKmrb0b9FdWdBbOdx6hBCM/F9Ir82ofnBhtZOjCRPQ==} + parse5@7.3.0: + resolution: {integrity: sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==} + parseurl@1.3.3: resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==} engines: {node: '>= 0.8'} @@ -13734,10 +13083,6 @@ packages: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} - path-is-absolute@1.0.1: - resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} - engines: {node: '>=0.10.0'} - path-key@3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} @@ -13775,9 +13120,9 @@ packages: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} - path-type@5.0.0: - resolution: {integrity: sha512-5HviZNaZcfqP95rwpv+1HDgUamezbqdSYTyzjTvwtJSnIH+3vnbmWsItli8OFEndS984VT55M3jduxZbX351gg==} - engines: {node: '>=12'} + path-type@6.0.0: + resolution: {integrity: sha512-Vj7sf++t5pBD637NSfkxpHSMfWaeig5+DKWLhcqIYx6mWQz5hdJTGDVMQiJcw1ZYkhs7AazKDGpRVji1LJCZUQ==} + engines: {node: '>=18'} pathe@1.1.2: resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} @@ -13818,6 +13163,9 @@ packages: pkg-types@1.3.1: resolution: {integrity: sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==} + pkg-types@2.1.0: + resolution: {integrity: sha512-wmJwA+8ihJixSoHKxZJRBQG1oY8Yr9pGLzRmSsNms0iNWyHHAlZCa7mmKiFR10YPZuz/2k169JiS/inOjBCZ2A==} + playwright-core@1.52.0: resolution: {integrity: sha512-l2osTgLXSMeuLZOML9qYODUQoPPnUsKsb5/P6LJ2e6uPKXUdPK5WYhN4z03G+YNbWmGDY4YENauNu4ZKczreHg==} engines: {node: '>=18'} @@ -13959,6 +13307,9 @@ packages: resolution: {integrity: sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==} engines: {node: '>=0.6'} + quansync@0.2.10: + resolution: {integrity: sha512-t41VRkMYbkHyCYmOvx/6URnN80H7k4X0lLdBMGsz+maAwrJQYB1djpV6vHrQIBE0WBSGqhtEHrK9U3DWWH8v7A==} + querystringify@2.2.0: resolution: {integrity: sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==} @@ -14202,8 +13553,8 @@ packages: rollup: optional: true - rollup@4.39.0: - resolution: {integrity: sha512-thI8kNc02yNvnmJp8dr3fNWJ9tCONDhp6TV35X6HkKGGs9E6q7YWCHbe5vKiTa7TAiNcFEmXKj3X/pG2b3ci0g==} + rollup@4.38.0: + resolution: {integrity: sha512-5SsIRtJy9bf1ErAOiFMFzl64Ex9X5V7bnJ+WlFMb+zmP459OSWCEG7b0ERZ+PEU7xPt4OG3RHbrp1LJlXxYTrw==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true @@ -14270,8 +13621,8 @@ packages: engines: {node: '>=10'} hasBin: true - semver@7.7.0: - resolution: {integrity: sha512-DrfFnPzblFmNrIZzg5RzHegbiRWg7KMR7btwi2yjHwx06zsUbO5g613sVwEV7FTwmzJu+Io0lJe2GJ3LxqpvBQ==} + semver@7.7.1: + resolution: {integrity: sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==} engines: {node: '>=10'} hasBin: true @@ -14447,8 +13798,8 @@ packages: resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==} engines: {node: '>= 0.8'} - std-env@3.8.0: - resolution: {integrity: sha512-Bc3YwwCB+OzldMxOXJIIvC6cPRWr/LxOp48CdQTOkPyk/t4JWWJbrilwBd7RJzKV8QW7tJkcgAmeuLLJugl5/w==} + std-env@3.8.1: + resolution: {integrity: sha512-vj5lIj3Mwf9D79hBkltk5qmkFI+biIKWS2IBxEyEU3AX1tUf7AoL8nSazCOiiqQsGKIq01SClsKEzweu34uwvA==} streamx@2.22.0: resolution: {integrity: sha512-sLh1evHOzBy/iWRiR6d1zRcLao4gGZr3C1kzNz4fopCOKJb6xD9ub8Mpi9Mr1R6id5o43S+d93fI48UC5uM9aw==} @@ -14501,8 +13852,8 @@ packages: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} - strip-literal@2.1.1: - resolution: {integrity: sha512-631UJ6O00eNGfMiWG78ck80dfBab8X6IVFB51jZK5Icd7XAs60Z5y7QdSd/wGIklnWvRbUNloVzhOKKmutxQ6Q==} + strip-literal@3.0.0: + resolution: {integrity: sha512-TcccoMhJOM3OebGhSBEmp3UZ2SfDMZUEBdRA/9ynfLi8yYajyWX3JiXArcJt4Umh4vISpspkQIY8ZZoCqjbviA==} style-to-object@1.0.8: resolution: {integrity: sha512-xT47I/Eo0rwJmaXC4oilDGDWLohVhR6o/xAQcPQN8q6QBuZVL8qMYL85kLmST5cPjAorwvqIA4qXTRQoYHaL6g==} @@ -14519,6 +13870,10 @@ packages: resolution: {integrity: sha512-5JRxVqC8I8NuOUjzBbvVJAKNM8qoVuH0O77h4WInc/qC2q5IreqKxYwgkga3PfA22OayK2ikceb/B26dztPl+Q==} engines: {node: '>=16'} + supports-color@10.0.0: + resolution: {integrity: sha512-HRVVSbCCMbj7/kdWF9Q+bbckjBHLtHMEoJWlkmYzzdwhYMkjkOwubLM6t7NbWKjgKamGDrWL1++KrjUO1t9oAQ==} + engines: {node: '>=18'} + supports-color@7.2.0: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} engines: {node: '>=8'} @@ -14527,10 +13882,6 @@ packages: resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} engines: {node: '>=10'} - supports-color@9.4.0: - resolution: {integrity: sha512-VL+lNrEoIXww1coLPOmiEmK/0sGigko5COxI09KzHc2VJXJsQ37UaQ+8quuxjDeA7+KnLGTWRyOXSLLR2Wb4jw==} - engines: {node: '>=12'} - supports-hyperlinks@3.1.0: resolution: {integrity: sha512-2rn0BZ+/f7puLOHZm1HOJfwBggfaHXUpPUSSG/SWM4TWp5KCfmNYwnC3hruy2rZlMnmWZ+QAGpZfchu3f3695A==} engines: {node: '>=14.18'} @@ -14579,10 +13930,6 @@ packages: tar-stream@3.1.7: resolution: {integrity: sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==} - tar@6.2.1: - resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} - engines: {node: '>=10'} - tar@7.4.3: resolution: {integrity: sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==} engines: {node: '>=18'} @@ -14757,10 +14104,6 @@ packages: resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} engines: {node: '>=10'} - type-fest@2.19.0: - resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==} - engines: {node: '>=12.20'} - type-fest@4.33.0: resolution: {integrity: sha512-s6zVrxuyKbbAsSAD5ZPTB77q4YIdRctkTbJ2/Dqlinwz+8ooH2gd+YA7VA6Pa93KML9GockVvoxjZ2vHP+mu8g==} engines: {node: '>=16'} @@ -14845,6 +14188,9 @@ packages: ufo@1.5.4: resolution: {integrity: sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==} + ultrahtml@1.5.3: + resolution: {integrity: sha512-GykOvZwgDWZlTQMtp5jrD4BVL+gNn2NVlVafjcFUJ7taY20tqYdwdoWBFy6GBJsNTZe1GkGPkSl5knQAjtgceg==} + unc-path-regex@0.1.2: resolution: {integrity: sha512-eXL4nmJT7oCpkZsHZUOJo8hcX3GbsiDOa0Qu9F646fi8dT3XuSVopVqAcEiVzSKKH7UoDti23wNX3qGFxcW5Qg==} engines: {node: '>=0.10.0'} @@ -14855,25 +14201,34 @@ packages: unctx@2.4.1: resolution: {integrity: sha512-AbaYw0Nm4mK4qjhns67C+kgxR2YWiwlDBPzxrN8h8C6VtAdCgditAY5Dezu3IJy4XVqAnbrXt9oQJvsn3fyozg==} - undici-types@5.28.4: - resolution: {integrity: sha512-3OeMF5Lyowe8VW0skf5qaIE7Or3yS9LS7fvMUI0gg4YxpIBVg0L8BxCmROw2CcYhSkpR68Epz7CGc8MPj94Uww==} - undici-types@6.20.0: resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==} + undici@6.21.2: + resolution: {integrity: sha512-uROZWze0R0itiAKVPsYhFov9LxrPMHLMEQFszeI2gCN6bnIIZ8twzBCJcN2LJrBBLfrP0t1FW0g+JmKVl8Vk1g==} + engines: {node: '>=18.17'} + + undici@7.8.0: + resolution: {integrity: sha512-vFv1GA99b7eKO1HG/4RPu2Is3FBTWBrmzqzO0mz+rLxN3yXkE4mqRcb8g8fHxzX4blEysrNZLqg5RbJLqX5buA==} + engines: {node: '>=20.18.1'} + unenv@1.10.0: resolution: {integrity: sha512-wY5bskBQFL9n3Eca5XnhH6KbUo/tfvkwm9OpcdCvLaeA7piBNbavbOKJySEwQ1V0RH6HvNlSAFRTpvTqgKRQXQ==} + unenv@2.0.0-rc.15: + resolution: {integrity: sha512-J/rEIZU8w6FOfLNz/hNKsnY+fFHWnu9MH4yRbSZF3xbbGHovcetXPs7sD+9p8L6CeNC//I9bhRYAOsBt2u7/OA==} + unicode-emoji-modifier-base@1.0.0: resolution: {integrity: sha512-yLSH4py7oFH3oG/9K+XWrz1pSi3dfUrWEnInbxMfArOfc1+33BlGPQtLsOYwvdMy11AwUBetYuaRxSPqgkq+8g==} engines: {node: '>=4'} - unicorn-magic@0.1.0: - resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==} + unicorn-magic@0.3.0: + resolution: {integrity: sha512-+QBBXBCvifc56fsbuxZQ6Sic3wqqc3WWaqxs58gvJrcOuN83HGTCwz3oS5phzU9LthRNE9VrJCFCLUgHeeFnfA==} engines: {node: '>=18'} - unimport@3.14.6: - resolution: {integrity: sha512-CYvbDaTT04Rh8bmD8jz3WPmHYZRG/NnvYVzwD6V1YAlvvKROlAeNDUBhkBGzNav2RKaeuXvlWYaa1V4Lfi/O0g==} + unimport@4.1.3: + resolution: {integrity: sha512-H+IVJ7rAkE3b+oC8rSJ2FsPaVsweeMC8eKZc+C6Mz7+hxDF45AnrY/tVCNRBvzMwWNcJEV67WdAVcal27iMjOw==} + engines: {node: '>=18.12.0'} universalify@0.1.2: resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} @@ -14891,6 +14246,10 @@ packages: resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} engines: {node: '>= 0.8'} + unplugin-utils@0.2.4: + resolution: {integrity: sha512-8U/MtpkPkkk3Atewj1+RcKIjb5WBimZ/WSLhhR3w6SsIj8XJuKTacSP8g+2JhfSGw0Cb125Y+2zA/IzJZDVbhA==} + engines: {node: '>=18.12.0'} + unplugin@1.0.1: resolution: {integrity: sha512-aqrHaVBWW1JVKBHmGo33T5TxeL0qWzfvjWokObHA9bYmN7eNDkwOxmLjhioHl9878qDFMAaT51XNroRyuz7WxA==} @@ -14898,31 +14257,31 @@ packages: resolution: {integrity: sha512-4/u/j4FrCKdi17jaxuJA0jClGxB1AvU2hw/IuayPc4ay1XGaJs/rbb4v5WKwAjNifjmXK9PIFyuPiaK8azyR9w==} engines: {node: '>=14.0.0'} - unplugin@2.1.2: - resolution: {integrity: sha512-Q3LU0e4zxKfRko1wMV2HmP8lB9KWislY7hxXpxd+lGx0PRInE4vhMBVEZwpdVYHvtqzhSrzuIfErsob6bQfCzw==} + unplugin@2.2.2: + resolution: {integrity: sha512-Qp+iiD+qCRnUek+nDoYvtWX7tfnYyXsrOnJ452FRTgOyKmTM7TUJ3l+PLPJOOWPTUyKISKp4isC5JJPSXUjGgw==} engines: {node: '>=18.12.0'} - unstorage@1.14.4: - resolution: {integrity: sha512-1SYeamwuYeQJtJ/USE1x4l17LkmQBzg7deBJ+U9qOBoHo15d1cDxG4jM31zKRgF7pG0kirZy4wVMX6WL6Zoscg==} + unstorage@1.15.0: + resolution: {integrity: sha512-m40eHdGY/gA6xAPqo8eaxqXgBuzQTlAKfmB1iF7oCKXE1HfwHwzDJBywK+qQGn52dta+bPlZluPF7++yR3p/bg==} peerDependencies: '@azure/app-configuration': ^1.8.0 '@azure/cosmos': ^4.2.0 '@azure/data-tables': ^13.3.0 - '@azure/identity': ^4.5.0 + '@azure/identity': ^4.6.0 '@azure/keyvault-secrets': ^4.9.0 '@azure/storage-blob': ^12.26.0 '@capacitor/preferences': ^6.0.3 - '@deno/kv': '>=0.8.4' + '@deno/kv': '>=0.9.0' '@netlify/blobs': ^6.5.0 || ^7.0.0 || ^8.1.0 '@planetscale/database': ^1.19.0 '@upstash/redis': ^1.34.3 - '@vercel/blob': '>=0.27.0' + '@vercel/blob': '>=0.27.1' '@vercel/kv': ^1.0.1 aws4fetch: ^1.0.20 db0: '>=0.2.1' idb-keyval: ^6.2.1 ioredis: ^5.4.2 - uploadthing: ^7.4.1 + uploadthing: ^7.4.4 peerDependenciesMeta: '@azure/app-configuration': optional: true @@ -14965,8 +14324,8 @@ packages: resolution: {integrity: sha512-4luGP9LMYszMRZwsvyUd9MrxgEGZdZuZgpVQHEEX0lCYFESasVRvZd0EYpCkOIbJKHMuv0LskpXc/8Un+MJzEQ==} hasBin: true - untyped@1.5.2: - resolution: {integrity: sha512-eL/8PlhLcMmlMDtNPKhyyz9kEBDS3Uk4yMu/ewlkT2WFbtzScjHWPJLdQLmaGPUKjXzwe9MumOtOgc4Fro96Kg==} + untyped@2.0.0: + resolution: {integrity: sha512-nwNCjxJTjNuLCgFr42fEak5OcLuB3ecca+9ksPFNvtfYSLpjf+iJqSIaSnIile6ZPbKYxI5k2AfXqeopGudK/g==} hasBin: true unwasm@0.3.9: @@ -14985,18 +14344,12 @@ packages: uqr@0.1.2: resolution: {integrity: sha512-MJu7ypHq6QasgF5YRTjqscSzQp/W11zoUk6kvmlH+fmWEs63Y0Eib13hYFwAzagRJcVY8WVnlV+eBDUGMJ5IbA==} - uri-js-replace@1.0.1: - resolution: {integrity: sha512-W+C9NWNLFOoBI2QWDp4UT9pv65r2w5Cx+3sTYFvtMdDBxkKt1syCqsUdSFAChbEe1uK5TfS04wt/nGwmaeIQ0g==} - uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} url-parse@1.5.10: resolution: {integrity: sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==} - urlpattern-polyfill@8.0.2: - resolution: {integrity: sha512-Qp95D4TPJl1kC9SKigDcqgyM2VDVO4RiJc2d4qe5GrYm+zbIQCWWKAFaJNQ4BhdFeDGwBmAxqJBwWSJDb9T3BQ==} - use-callback-ref@1.3.3: resolution: {integrity: sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg==} engines: {node: '>=10'} @@ -15059,14 +14412,6 @@ packages: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} - vinxi@0.5.1: - resolution: {integrity: sha512-jvl2hJ0fyWwfDVQdDDHCJiVxqU4k0A6kFAnljS0kIjrGfhdTvKEWIoj0bcJgMyrKhxNMoZZGmHZsstQgjDIL3g==} - hasBin: true - - vinxi@0.5.3: - resolution: {integrity: sha512-4sL2SMrRzdzClapP44oXdGjCE1oq7/DagsbjY5A09EibmoIO4LP8ScRVdh03lfXxKRk7nCWK7n7dqKvm+fp/9w==} - hasBin: true - vite-node@3.0.6: resolution: {integrity: sha512-s51RzrTkXKJrhNbUzQRsarjmAae7VmMPAsRT7lppVpIg6mK3zGthP9Hgz0YQQKuNcF+Ii7DfYk3Fxz40jRmePw==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} @@ -15331,20 +14676,11 @@ packages: engines: {node: '>= 8'} hasBin: true - which@4.0.0: - resolution: {integrity: sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==} - engines: {node: ^16.13.0 || >=18.0.0} - hasBin: true - why-is-node-running@2.3.0: resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} engines: {node: '>=8'} hasBin: true - widest-line@4.0.1: - resolution: {integrity: sha512-o0cyEG0e8GPzT4iGHphIOh0cJOV8fivsXxddQasHPHfoZf1ZexrfeA21w2NaEN1RHE+fXlfISmOE8R9N3u3Qig==} - engines: {node: '>=12'} - wildcard@2.0.1: resolution: {integrity: sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==} @@ -15383,6 +14719,10 @@ packages: resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==} engines: {node: '>=18'} + xmlbuilder2@3.1.1: + resolution: {integrity: sha512-WCSfbfZnQDdLQLiMdGUQpMxxckeQ4oZNMNhLVkcekTu7xhD4tuUDyAPoY8CwXvBYE6LwBHd6QW2WZXlOWr1vCw==} + engines: {node: '>=12.0'} + xmlchars@2.2.0: resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==} @@ -15400,9 +14740,6 @@ packages: resolution: {integrity: sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==} engines: {node: '>=18'} - yaml-ast-parser@0.0.43: - resolution: {integrity: sha512-2PTINUwsRqSd+s8XxKaJWQlUuEMHJQyEuh2edBbW8KNJz0SJPwUSD2zRWqezFEdN7IzAgeuYHFUCF7o8zRdZ0A==} - yaml@1.10.2: resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==} engines: {node: '>= 6'} @@ -15436,6 +14773,14 @@ packages: resolution: {integrity: sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA==} engines: {node: '>=18'} + youch-core@0.3.2: + resolution: {integrity: sha512-fusrlIMLeRvTFYLUjJ9KzlGC3N+6MOPJ68HNj/yJv2nz7zq8t4HEviLms2gkdRPUS7F5rZ5n+pYx9r88m6IE1g==} + engines: {node: '>=18'} + + youch@4.1.0-beta.7: + resolution: {integrity: sha512-HUn0M24AUTMvjdkoMtH8fJz2FEd+k1xvtR9EoTrDUoVUi6o7xl5X+pST/vjk4T3GEQo2mJ9FlAvhWBm8dIdD4g==} + engines: {node: '>=18'} + zip-stream@6.0.1: resolution: {integrity: sha512-zK7YHHz4ZXpW89AHXUPbQVGKI7uvkd3hzusTdotCg1UxyaVtg0zFJSTfW/Dq5f7OBBVnq6cZIaC8Ti4hb6dtCA==} engines: {node: '>= 14'} @@ -15464,7 +14809,7 @@ snapshots: commander: 10.0.1 marked: 9.1.6 marked-terminal: 7.3.0(marked@9.1.6) - semver: 7.7.0 + semver: 7.7.1 '@arethetypeswrong/core@0.17.3': dependencies: @@ -15472,7 +14817,7 @@ snapshots: cjs-module-lexer: 1.4.3 fflate: 0.8.2 lru-cache: 10.4.3 - semver: 7.7.0 + semver: 7.7.1 typescript: 5.6.1-rc validate-npm-package-name: 5.0.1 @@ -15512,7 +14857,7 @@ snapshots: '@babel/types': 7.26.8 '@types/gensync': 1.0.4 convert-source-map: 2.0.0 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -15692,8 +15037,6 @@ snapshots: dependencies: regenerator-runtime: 0.14.1 - '@babel/standalone@7.26.7': {} - '@babel/template@7.26.8': dependencies: '@babel/code-frame': 7.26.2 @@ -15707,7 +15050,7 @@ snapshots: '@babel/parser': 7.26.8 '@babel/template': 7.26.8 '@babel/types': 7.26.8 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -15755,7 +15098,7 @@ snapshots: dequal: 2.0.3 glob-to-regexp: 0.4.1 js-cookie: 3.0.5 - std-env: 3.8.0 + std-env: 3.8.1 swr: 2.3.0(react@19.0.0) optionalDependencies: react: 19.0.0 @@ -15777,7 +15120,7 @@ snapshots: dependencies: csstype: 3.1.3 - '@cloudflare/kv-asset-handler@0.3.4': + '@cloudflare/kv-asset-handler@0.4.0': dependencies: mime: 3.0.0 @@ -15820,13 +15163,6 @@ snapshots: '@csstools/css-tokenizer@3.0.3': {} - '@deno/shim-deno-test@0.5.0': {} - - '@deno/shim-deno@0.19.2': - dependencies: - '@deno/shim-deno-test': 0.5.0 - which: 4.0.0 - '@discoveryjs/json-ext@0.5.7': {} '@emnapi/core@1.3.1': @@ -15925,9 +15261,6 @@ snapshots: '@emotion/weak-memoize@0.4.0': {} - '@esbuild/aix-ppc64@0.20.2': - optional: true - '@esbuild/aix-ppc64@0.23.0': optional: true @@ -15937,10 +15270,7 @@ snapshots: '@esbuild/aix-ppc64@0.24.2': optional: true - '@esbuild/aix-ppc64@0.25.0': - optional: true - - '@esbuild/android-arm64@0.20.2': + '@esbuild/aix-ppc64@0.25.2': optional: true '@esbuild/android-arm64@0.23.0': @@ -15952,10 +15282,7 @@ snapshots: '@esbuild/android-arm64@0.24.2': optional: true - '@esbuild/android-arm64@0.25.0': - optional: true - - '@esbuild/android-arm@0.20.2': + '@esbuild/android-arm64@0.25.2': optional: true '@esbuild/android-arm@0.23.0': @@ -15967,10 +15294,7 @@ snapshots: '@esbuild/android-arm@0.24.2': optional: true - '@esbuild/android-arm@0.25.0': - optional: true - - '@esbuild/android-x64@0.20.2': + '@esbuild/android-arm@0.25.2': optional: true '@esbuild/android-x64@0.23.0': @@ -15982,10 +15306,7 @@ snapshots: '@esbuild/android-x64@0.24.2': optional: true - '@esbuild/android-x64@0.25.0': - optional: true - - '@esbuild/darwin-arm64@0.20.2': + '@esbuild/android-x64@0.25.2': optional: true '@esbuild/darwin-arm64@0.23.0': @@ -15997,10 +15318,7 @@ snapshots: '@esbuild/darwin-arm64@0.24.2': optional: true - '@esbuild/darwin-arm64@0.25.0': - optional: true - - '@esbuild/darwin-x64@0.20.2': + '@esbuild/darwin-arm64@0.25.2': optional: true '@esbuild/darwin-x64@0.23.0': @@ -16012,10 +15330,7 @@ snapshots: '@esbuild/darwin-x64@0.24.2': optional: true - '@esbuild/darwin-x64@0.25.0': - optional: true - - '@esbuild/freebsd-arm64@0.20.2': + '@esbuild/darwin-x64@0.25.2': optional: true '@esbuild/freebsd-arm64@0.23.0': @@ -16027,10 +15342,7 @@ snapshots: '@esbuild/freebsd-arm64@0.24.2': optional: true - '@esbuild/freebsd-arm64@0.25.0': - optional: true - - '@esbuild/freebsd-x64@0.20.2': + '@esbuild/freebsd-arm64@0.25.2': optional: true '@esbuild/freebsd-x64@0.23.0': @@ -16042,10 +15354,7 @@ snapshots: '@esbuild/freebsd-x64@0.24.2': optional: true - '@esbuild/freebsd-x64@0.25.0': - optional: true - - '@esbuild/linux-arm64@0.20.2': + '@esbuild/freebsd-x64@0.25.2': optional: true '@esbuild/linux-arm64@0.23.0': @@ -16057,10 +15366,7 @@ snapshots: '@esbuild/linux-arm64@0.24.2': optional: true - '@esbuild/linux-arm64@0.25.0': - optional: true - - '@esbuild/linux-arm@0.20.2': + '@esbuild/linux-arm64@0.25.2': optional: true '@esbuild/linux-arm@0.23.0': @@ -16072,10 +15378,7 @@ snapshots: '@esbuild/linux-arm@0.24.2': optional: true - '@esbuild/linux-arm@0.25.0': - optional: true - - '@esbuild/linux-ia32@0.20.2': + '@esbuild/linux-arm@0.25.2': optional: true '@esbuild/linux-ia32@0.23.0': @@ -16087,10 +15390,7 @@ snapshots: '@esbuild/linux-ia32@0.24.2': optional: true - '@esbuild/linux-ia32@0.25.0': - optional: true - - '@esbuild/linux-loong64@0.20.2': + '@esbuild/linux-ia32@0.25.2': optional: true '@esbuild/linux-loong64@0.23.0': @@ -16102,10 +15402,7 @@ snapshots: '@esbuild/linux-loong64@0.24.2': optional: true - '@esbuild/linux-loong64@0.25.0': - optional: true - - '@esbuild/linux-mips64el@0.20.2': + '@esbuild/linux-loong64@0.25.2': optional: true '@esbuild/linux-mips64el@0.23.0': @@ -16117,10 +15414,7 @@ snapshots: '@esbuild/linux-mips64el@0.24.2': optional: true - '@esbuild/linux-mips64el@0.25.0': - optional: true - - '@esbuild/linux-ppc64@0.20.2': + '@esbuild/linux-mips64el@0.25.2': optional: true '@esbuild/linux-ppc64@0.23.0': @@ -16132,10 +15426,7 @@ snapshots: '@esbuild/linux-ppc64@0.24.2': optional: true - '@esbuild/linux-ppc64@0.25.0': - optional: true - - '@esbuild/linux-riscv64@0.20.2': + '@esbuild/linux-ppc64@0.25.2': optional: true '@esbuild/linux-riscv64@0.23.0': @@ -16147,10 +15438,7 @@ snapshots: '@esbuild/linux-riscv64@0.24.2': optional: true - '@esbuild/linux-riscv64@0.25.0': - optional: true - - '@esbuild/linux-s390x@0.20.2': + '@esbuild/linux-riscv64@0.25.2': optional: true '@esbuild/linux-s390x@0.23.0': @@ -16162,10 +15450,7 @@ snapshots: '@esbuild/linux-s390x@0.24.2': optional: true - '@esbuild/linux-s390x@0.25.0': - optional: true - - '@esbuild/linux-x64@0.20.2': + '@esbuild/linux-s390x@0.25.2': optional: true '@esbuild/linux-x64@0.23.0': @@ -16177,16 +15462,13 @@ snapshots: '@esbuild/linux-x64@0.24.2': optional: true - '@esbuild/linux-x64@0.25.0': + '@esbuild/linux-x64@0.25.2': optional: true '@esbuild/netbsd-arm64@0.24.2': optional: true - '@esbuild/netbsd-arm64@0.25.0': - optional: true - - '@esbuild/netbsd-x64@0.20.2': + '@esbuild/netbsd-arm64@0.25.2': optional: true '@esbuild/netbsd-x64@0.23.0': @@ -16198,7 +15480,7 @@ snapshots: '@esbuild/netbsd-x64@0.24.2': optional: true - '@esbuild/netbsd-x64@0.25.0': + '@esbuild/netbsd-x64@0.25.2': optional: true '@esbuild/openbsd-arm64@0.23.0': @@ -16210,10 +15492,7 @@ snapshots: '@esbuild/openbsd-arm64@0.24.2': optional: true - '@esbuild/openbsd-arm64@0.25.0': - optional: true - - '@esbuild/openbsd-x64@0.20.2': + '@esbuild/openbsd-arm64@0.25.2': optional: true '@esbuild/openbsd-x64@0.23.0': @@ -16225,10 +15504,7 @@ snapshots: '@esbuild/openbsd-x64@0.24.2': optional: true - '@esbuild/openbsd-x64@0.25.0': - optional: true - - '@esbuild/sunos-x64@0.20.2': + '@esbuild/openbsd-x64@0.25.2': optional: true '@esbuild/sunos-x64@0.23.0': @@ -16240,10 +15516,7 @@ snapshots: '@esbuild/sunos-x64@0.24.2': optional: true - '@esbuild/sunos-x64@0.25.0': - optional: true - - '@esbuild/win32-arm64@0.20.2': + '@esbuild/sunos-x64@0.25.2': optional: true '@esbuild/win32-arm64@0.23.0': @@ -16255,10 +15528,7 @@ snapshots: '@esbuild/win32-arm64@0.24.2': optional: true - '@esbuild/win32-arm64@0.25.0': - optional: true - - '@esbuild/win32-ia32@0.20.2': + '@esbuild/win32-arm64@0.25.2': optional: true '@esbuild/win32-ia32@0.23.0': @@ -16270,10 +15540,7 @@ snapshots: '@esbuild/win32-ia32@0.24.2': optional: true - '@esbuild/win32-ia32@0.25.0': - optional: true - - '@esbuild/win32-x64@0.20.2': + '@esbuild/win32-ia32@0.25.2': optional: true '@esbuild/win32-x64@0.23.0': @@ -16285,7 +15552,7 @@ snapshots: '@esbuild/win32-x64@0.24.2': optional: true - '@esbuild/win32-x64@0.25.0': + '@esbuild/win32-x64@0.25.2': optional: true '@eslint-community/eslint-utils@4.4.1(eslint@9.22.0(jiti@2.4.2))': @@ -16391,7 +15658,7 @@ snapshots: '@eslint/config-array@0.19.2': dependencies: '@eslint/object-schema': 2.1.6 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -16405,7 +15672,7 @@ snapshots: '@eslint/eslintrc@3.3.0': dependencies: ajv: 6.12.6 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 espree: 10.3.0 globals: 14.0.0 ignore: 5.3.2 @@ -16877,7 +16144,7 @@ snapshots: '@kwsites/file-exists@1.1.1': dependencies: - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 transitivePeerDependencies: - supports-color @@ -16887,12 +16154,12 @@ snapshots: '@mapbox/node-pre-gyp@2.0.0': dependencies: - consola: 3.4.0 + consola: 3.4.2 detect-libc: 2.0.3 - https-proxy-agent: 7.0.6(supports-color@9.4.0) + https-proxy-agent: 7.0.6 node-fetch: 2.7.0 nopt: 8.1.0 - semver: 7.7.0 + semver: 7.7.1 tar: 7.4.3 transitivePeerDependencies: - encoding @@ -17072,16 +16339,11 @@ snapshots: '@emnapi/runtime': 1.3.1 '@tybys/wasm-util': 0.9.0 - '@netlify/functions@2.8.2': + '@netlify/functions@3.0.4': dependencies: - '@netlify/serverless-functions-api': 1.26.1 + '@netlify/serverless-functions-api': 1.36.0 - '@netlify/node-cookies@0.1.0': {} - - '@netlify/serverless-functions-api@1.26.1': - dependencies: - '@netlify/node-cookies': 0.1.0 - urlpattern-polyfill: 8.0.2 + '@netlify/serverless-functions-api@1.36.0': {} '@nodelib/fs.scandir@2.1.5': dependencies: @@ -17127,6 +16389,23 @@ snapshots: '@nx/nx-win32-x64-msvc@20.8.1': optional: true + '@oozcitak/dom@1.15.10': + dependencies: + '@oozcitak/infra': 1.0.8 + '@oozcitak/url': 1.0.4 + '@oozcitak/util': 8.3.8 + + '@oozcitak/infra@1.0.8': + dependencies: + '@oozcitak/util': 8.3.8 + + '@oozcitak/url@1.0.4': + dependencies: + '@oozcitak/infra': 1.0.8 + '@oozcitak/util': 8.3.8 + + '@oozcitak/util@8.3.8': {} + '@open-draft/deferred-promise@2.2.0': {} '@open-draft/logger@0.3.0': @@ -17166,11 +16445,6 @@ snapshots: '@parcel/watcher-linux-x64-musl@2.5.1': optional: true - '@parcel/watcher-wasm@2.3.0': - dependencies: - is-glob: 4.0.3 - micromatch: 4.0.8 - '@parcel/watcher-wasm@2.5.1': dependencies: is-glob: 4.0.3 @@ -17235,6 +16509,18 @@ snapshots: '@popperjs/core@2.11.8': {} + '@poppinss/colors@4.1.4': + dependencies: + kleur: 4.1.5 + + '@poppinss/dumper@0.6.3': + dependencies: + '@poppinss/colors': 4.1.4 + '@sindresorhus/is': 7.0.1 + supports-color: 10.0.0 + + '@poppinss/exception@1.2.1': {} + '@prisma/client@5.22.0(prisma@5.22.0)': optionalDependencies: prisma: 5.22.0 @@ -17289,8 +16575,6 @@ snapshots: '@radix-ui/number@1.1.1': {} - '@radix-ui/primitive@1.1.1': {} - '@radix-ui/primitive@1.1.2': {} '@radix-ui/react-accessible-icon@1.1.3(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': @@ -17407,12 +16691,6 @@ snapshots: '@types/react': 19.0.8 '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-compose-refs@1.1.1(@types/react@19.0.8)(react@19.0.0)': - dependencies: - react: 19.0.0 - optionalDependencies: - '@types/react': 19.0.8 - '@radix-ui/react-compose-refs@1.1.2(@types/react@19.0.8)(react@19.0.0)': dependencies: react: 19.0.0 @@ -17433,40 +16711,12 @@ snapshots: '@types/react': 19.0.8 '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-context@1.1.1(@types/react@19.0.8)(react@19.0.0)': - dependencies: - react: 19.0.0 - optionalDependencies: - '@types/react': 19.0.8 - '@radix-ui/react-context@1.1.2(@types/react@19.0.8)(react@19.0.0)': dependencies: react: 19.0.0 optionalDependencies: '@types/react': 19.0.8 - '@radix-ui/react-dialog@1.1.6(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': - dependencies: - '@radix-ui/primitive': 1.1.1 - '@radix-ui/react-compose-refs': 1.1.1(@types/react@19.0.8)(react@19.0.0) - '@radix-ui/react-context': 1.1.1(@types/react@19.0.8)(react@19.0.0) - '@radix-ui/react-dismissable-layer': 1.1.5(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) - '@radix-ui/react-focus-guards': 1.1.1(@types/react@19.0.8)(react@19.0.0) - '@radix-ui/react-focus-scope': 1.1.2(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) - '@radix-ui/react-id': 1.1.0(@types/react@19.0.8)(react@19.0.0) - '@radix-ui/react-portal': 1.1.4(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) - '@radix-ui/react-presence': 1.1.2(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) - '@radix-ui/react-primitive': 2.0.2(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) - '@radix-ui/react-slot': 1.1.2(@types/react@19.0.8)(react@19.0.0) - '@radix-ui/react-use-controllable-state': 1.1.0(@types/react@19.0.8)(react@19.0.0) - aria-hidden: 1.2.4 - react: 19.0.0 - react-dom: 19.0.0(react@19.0.0) - react-remove-scroll: 2.6.3(@types/react@19.0.8)(react@19.0.0) - optionalDependencies: - '@types/react': 19.0.8 - '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-dialog@1.1.7(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': dependencies: '@radix-ui/primitive': 1.1.2 @@ -17495,19 +16745,6 @@ snapshots: optionalDependencies: '@types/react': 19.0.8 - '@radix-ui/react-dismissable-layer@1.1.5(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': - dependencies: - '@radix-ui/primitive': 1.1.1 - '@radix-ui/react-compose-refs': 1.1.1(@types/react@19.0.8)(react@19.0.0) - '@radix-ui/react-primitive': 2.0.2(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) - '@radix-ui/react-use-callback-ref': 1.1.0(@types/react@19.0.8)(react@19.0.0) - '@radix-ui/react-use-escape-keydown': 1.1.0(@types/react@19.0.8)(react@19.0.0) - react: 19.0.0 - react-dom: 19.0.0(react@19.0.0) - optionalDependencies: - '@types/react': 19.0.8 - '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-dismissable-layer@1.1.6(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': dependencies: '@radix-ui/primitive': 1.1.2 @@ -17536,29 +16773,12 @@ snapshots: '@types/react': 19.0.8 '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-focus-guards@1.1.1(@types/react@19.0.8)(react@19.0.0)': - dependencies: - react: 19.0.0 - optionalDependencies: - '@types/react': 19.0.8 - '@radix-ui/react-focus-guards@1.1.2(@types/react@19.0.8)(react@19.0.0)': dependencies: react: 19.0.0 optionalDependencies: '@types/react': 19.0.8 - '@radix-ui/react-focus-scope@1.1.2(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': - dependencies: - '@radix-ui/react-compose-refs': 1.1.1(@types/react@19.0.8)(react@19.0.0) - '@radix-ui/react-primitive': 2.0.2(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) - '@radix-ui/react-use-callback-ref': 1.1.0(@types/react@19.0.8)(react@19.0.0) - react: 19.0.0 - react-dom: 19.0.0(react@19.0.0) - optionalDependencies: - '@types/react': 19.0.8 - '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-focus-scope@1.1.3(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': dependencies: '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.0.8)(react@19.0.0) @@ -17601,13 +16821,6 @@ snapshots: '@types/react': 19.0.8 '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-id@1.1.0(@types/react@19.0.8)(react@19.0.0)': - dependencies: - '@radix-ui/react-use-layout-effect': 1.1.0(@types/react@19.0.8)(react@19.0.0) - react: 19.0.0 - optionalDependencies: - '@types/react': 19.0.8 - '@radix-ui/react-id@1.1.1(@types/react@19.0.8)(react@19.0.0)': dependencies: '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.0.8)(react@19.0.0) @@ -17731,16 +16944,6 @@ snapshots: '@types/react': 19.0.8 '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-portal@1.1.4(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': - dependencies: - '@radix-ui/react-primitive': 2.0.2(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) - '@radix-ui/react-use-layout-effect': 1.1.0(@types/react@19.0.8)(react@19.0.0) - react: 19.0.0 - react-dom: 19.0.0(react@19.0.0) - optionalDependencies: - '@types/react': 19.0.8 - '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-portal@1.1.5(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': dependencies: '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) @@ -17751,16 +16954,6 @@ snapshots: '@types/react': 19.0.8 '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-presence@1.1.2(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': - dependencies: - '@radix-ui/react-compose-refs': 1.1.1(@types/react@19.0.8)(react@19.0.0) - '@radix-ui/react-use-layout-effect': 1.1.0(@types/react@19.0.8)(react@19.0.0) - react: 19.0.0 - react-dom: 19.0.0(react@19.0.0) - optionalDependencies: - '@types/react': 19.0.8 - '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-presence@1.1.3(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': dependencies: '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.0.8)(react@19.0.0) @@ -17771,15 +16964,6 @@ snapshots: '@types/react': 19.0.8 '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-primitive@2.0.2(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': - dependencies: - '@radix-ui/react-slot': 1.1.2(@types/react@19.0.8)(react@19.0.0) - react: 19.0.0 - react-dom: 19.0.0(react@19.0.0) - optionalDependencies: - '@types/react': 19.0.8 - '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-primitive@2.0.3(@types/react-dom@19.0.3(@types/react@19.0.8))(@types/react@19.0.8)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': dependencies: '@radix-ui/react-slot': 1.2.0(@types/react@19.0.8)(react@19.0.0) @@ -17908,13 +17092,6 @@ snapshots: '@types/react': 19.0.8 '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-slot@1.1.2(@types/react@19.0.8)(react@19.0.0)': - dependencies: - '@radix-ui/react-compose-refs': 1.1.1(@types/react@19.0.8)(react@19.0.0) - react: 19.0.0 - optionalDependencies: - '@types/react': 19.0.8 - '@radix-ui/react-slot@1.2.0(@types/react@19.0.8)(react@19.0.0)': dependencies: '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.0.8)(react@19.0.0) @@ -18034,25 +17211,12 @@ snapshots: '@types/react': 19.0.8 '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@radix-ui/react-use-callback-ref@1.1.0(@types/react@19.0.8)(react@19.0.0)': - dependencies: - react: 19.0.0 - optionalDependencies: - '@types/react': 19.0.8 - '@radix-ui/react-use-callback-ref@1.1.1(@types/react@19.0.8)(react@19.0.0)': dependencies: react: 19.0.0 optionalDependencies: '@types/react': 19.0.8 - '@radix-ui/react-use-controllable-state@1.1.0(@types/react@19.0.8)(react@19.0.0)': - dependencies: - '@radix-ui/react-use-callback-ref': 1.1.0(@types/react@19.0.8)(react@19.0.0) - react: 19.0.0 - optionalDependencies: - '@types/react': 19.0.8 - '@radix-ui/react-use-controllable-state@1.1.1(@types/react@19.0.8)(react@19.0.0)': dependencies: '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.0.8)(react@19.0.0) @@ -18060,13 +17224,6 @@ snapshots: optionalDependencies: '@types/react': 19.0.8 - '@radix-ui/react-use-escape-keydown@1.1.0(@types/react@19.0.8)(react@19.0.0)': - dependencies: - '@radix-ui/react-use-callback-ref': 1.1.0(@types/react@19.0.8)(react@19.0.0) - react: 19.0.0 - optionalDependencies: - '@types/react': 19.0.8 - '@radix-ui/react-use-escape-keydown@1.1.1(@types/react@19.0.8)(react@19.0.0)': dependencies: '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.0.8)(react@19.0.0) @@ -18074,12 +17231,6 @@ snapshots: optionalDependencies: '@types/react': 19.0.8 - '@radix-ui/react-use-layout-effect@1.1.0(@types/react@19.0.8)(react@19.0.0)': - dependencies: - react: 19.0.0 - optionalDependencies: - '@types/react': 19.0.8 - '@radix-ui/react-use-layout-effect@1.1.1(@types/react@19.0.8)(react@19.0.0)': dependencies: react: 19.0.0 @@ -18129,47 +17280,24 @@ snapshots: '@types/react': 19.0.8 '@types/react-dom': 19.0.3(@types/react@19.0.8) - '@redocly/ajv@8.11.2': - dependencies: - fast-deep-equal: 3.1.3 - json-schema-traverse: 1.0.0 - require-from-string: 2.0.2 - uri-js-replace: 1.0.1 - - '@redocly/config@0.20.3': {} - - '@redocly/openapi-core@1.28.0(supports-color@9.4.0)': - dependencies: - '@redocly/ajv': 8.11.2 - '@redocly/config': 0.20.3 - colorette: 1.4.0 - https-proxy-agent: 7.0.6(supports-color@9.4.0) - js-levenshtein: 1.1.6 - js-yaml: 4.1.0 - minimatch: 5.1.6 - pluralize: 8.0.0 - yaml-ast-parser: 0.0.43 - transitivePeerDependencies: - - supports-color - - '@rollup/plugin-alias@5.1.1(rollup@4.39.0)': + '@rollup/plugin-alias@5.1.1(rollup@4.38.0)': optionalDependencies: - rollup: 4.39.0 + rollup: 4.38.0 - '@rollup/plugin-babel@6.0.4(@babel/core@7.26.8)(@types/babel__core@7.20.5)(rollup@4.39.0)': + '@rollup/plugin-babel@6.0.4(@babel/core@7.26.8)(@types/babel__core@7.20.5)(rollup@4.38.0)': dependencies: '@babel/core': 7.26.8 '@babel/helper-module-imports': 7.25.9 - '@rollup/pluginutils': 5.1.4(rollup@4.39.0) + '@rollup/pluginutils': 5.1.4(rollup@4.38.0) optionalDependencies: '@types/babel__core': 7.20.5 - rollup: 4.39.0 + rollup: 4.38.0 transitivePeerDependencies: - supports-color - '@rollup/plugin-commonjs@28.0.2(rollup@4.39.0)': + '@rollup/plugin-commonjs@28.0.3(rollup@4.38.0)': dependencies: - '@rollup/pluginutils': 5.1.4(rollup@4.39.0) + '@rollup/pluginutils': 5.1.4(rollup@4.38.0) commondir: 1.0.1 estree-walker: 2.0.2 fdir: 6.4.3(picomatch@4.0.2) @@ -18177,113 +17305,113 @@ snapshots: magic-string: 0.30.17 picomatch: 4.0.2 optionalDependencies: - rollup: 4.39.0 + rollup: 4.38.0 - '@rollup/plugin-inject@5.0.5(rollup@4.39.0)': + '@rollup/plugin-inject@5.0.5(rollup@4.38.0)': dependencies: - '@rollup/pluginutils': 5.1.4(rollup@4.39.0) + '@rollup/pluginutils': 5.1.4(rollup@4.38.0) estree-walker: 2.0.2 magic-string: 0.30.17 optionalDependencies: - rollup: 4.39.0 + rollup: 4.38.0 - '@rollup/plugin-json@6.1.0(rollup@4.39.0)': + '@rollup/plugin-json@6.1.0(rollup@4.38.0)': dependencies: - '@rollup/pluginutils': 5.1.4(rollup@4.39.0) + '@rollup/pluginutils': 5.1.4(rollup@4.38.0) optionalDependencies: - rollup: 4.39.0 + rollup: 4.38.0 - '@rollup/plugin-node-resolve@15.3.1(rollup@4.39.0)': + '@rollup/plugin-node-resolve@16.0.1(rollup@4.38.0)': dependencies: - '@rollup/pluginutils': 5.1.4(rollup@4.39.0) + '@rollup/pluginutils': 5.1.4(rollup@4.38.0) '@types/resolve': 1.20.2 deepmerge: 4.3.1 is-module: 1.0.0 resolve: 1.22.10 optionalDependencies: - rollup: 4.39.0 + rollup: 4.38.0 - '@rollup/plugin-replace@6.0.2(rollup@4.39.0)': + '@rollup/plugin-replace@6.0.2(rollup@4.38.0)': dependencies: - '@rollup/pluginutils': 5.1.4(rollup@4.39.0) + '@rollup/pluginutils': 5.1.4(rollup@4.38.0) magic-string: 0.30.17 optionalDependencies: - rollup: 4.39.0 + rollup: 4.38.0 - '@rollup/plugin-terser@0.4.4(rollup@4.39.0)': + '@rollup/plugin-terser@0.4.4(rollup@4.38.0)': dependencies: serialize-javascript: 6.0.2 smob: 1.5.0 terser: 5.37.0 optionalDependencies: - rollup: 4.39.0 + rollup: 4.38.0 - '@rollup/pluginutils@5.1.4(rollup@4.39.0)': + '@rollup/pluginutils@5.1.4(rollup@4.38.0)': dependencies: '@types/estree': 1.0.7 estree-walker: 2.0.2 picomatch: 4.0.2 optionalDependencies: - rollup: 4.39.0 + rollup: 4.38.0 - '@rollup/rollup-android-arm-eabi@4.39.0': + '@rollup/rollup-android-arm-eabi@4.38.0': optional: true - '@rollup/rollup-android-arm64@4.39.0': + '@rollup/rollup-android-arm64@4.38.0': optional: true - '@rollup/rollup-darwin-arm64@4.39.0': + '@rollup/rollup-darwin-arm64@4.38.0': optional: true - '@rollup/rollup-darwin-x64@4.39.0': + '@rollup/rollup-darwin-x64@4.38.0': optional: true - '@rollup/rollup-freebsd-arm64@4.39.0': + '@rollup/rollup-freebsd-arm64@4.38.0': optional: true - '@rollup/rollup-freebsd-x64@4.39.0': + '@rollup/rollup-freebsd-x64@4.38.0': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.39.0': + '@rollup/rollup-linux-arm-gnueabihf@4.38.0': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.39.0': + '@rollup/rollup-linux-arm-musleabihf@4.38.0': optional: true - '@rollup/rollup-linux-arm64-gnu@4.39.0': + '@rollup/rollup-linux-arm64-gnu@4.38.0': optional: true - '@rollup/rollup-linux-arm64-musl@4.39.0': + '@rollup/rollup-linux-arm64-musl@4.38.0': optional: true - '@rollup/rollup-linux-loongarch64-gnu@4.39.0': + '@rollup/rollup-linux-loongarch64-gnu@4.38.0': optional: true - '@rollup/rollup-linux-powerpc64le-gnu@4.39.0': + '@rollup/rollup-linux-powerpc64le-gnu@4.38.0': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.39.0': + '@rollup/rollup-linux-riscv64-gnu@4.38.0': optional: true - '@rollup/rollup-linux-riscv64-musl@4.39.0': + '@rollup/rollup-linux-riscv64-musl@4.38.0': optional: true - '@rollup/rollup-linux-s390x-gnu@4.39.0': + '@rollup/rollup-linux-s390x-gnu@4.38.0': optional: true - '@rollup/rollup-linux-x64-gnu@4.39.0': + '@rollup/rollup-linux-x64-gnu@4.38.0': optional: true - '@rollup/rollup-linux-x64-musl@4.39.0': + '@rollup/rollup-linux-x64-musl@4.38.0': optional: true - '@rollup/rollup-win32-arm64-msvc@4.39.0': + '@rollup/rollup-win32-arm64-msvc@4.38.0': optional: true - '@rollup/rollup-win32-ia32-msvc@4.39.0': + '@rollup/rollup-win32-ia32-msvc@4.38.0': optional: true - '@rollup/rollup-win32-x64-msvc@4.39.0': + '@rollup/rollup-win32-x64-msvc@4.38.0': optional: true '@rsbuild/core@1.2.4': @@ -18582,6 +17710,8 @@ snapshots: '@sindresorhus/is@4.6.0': {} + '@sindresorhus/is@7.0.1': {} + '@sindresorhus/merge-streams@2.3.0': {} '@solid-devtools/debugger@0.26.0(solid-js@1.9.5)': @@ -18708,6 +17838,8 @@ snapshots: '@testing-library/dom': 10.4.0 solid-js: 1.9.5 + '@speed-highlight/core@1.2.7': {} + '@stylistic/eslint-plugin-js@2.13.0(eslint@9.22.0(jiti@2.4.2))': dependencies: eslint: 9.22.0(jiti@2.4.2) @@ -18880,13 +18012,13 @@ snapshots: tailwindcss: 4.0.8 vite: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) - '@tanstack/config@0.16.1(@types/node@22.13.4)(esbuild@0.25.0)(eslint@9.22.0(jiti@2.4.2))(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0))': + '@tanstack/config@0.16.1(@types/node@22.13.4)(esbuild@0.25.2)(eslint@9.22.0(jiti@2.4.2))(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0))': dependencies: '@commitlint/parse': 19.5.0 '@eslint/js': 9.22.0 '@stylistic/eslint-plugin-js': 2.13.0(eslint@9.22.0(jiti@2.4.2)) commander: 13.1.0 - esbuild-register: 3.6.0(esbuild@0.25.0) + esbuild-register: 3.6.0(esbuild@0.25.2) eslint-plugin-import-x: 4.6.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.2) eslint-plugin-n: 17.15.1(eslint@9.22.0(jiti@2.4.2)) globals: 15.14.0 @@ -18894,15 +18026,15 @@ snapshots: jsonfile: 6.1.0 liftoff: 5.0.0 minimist: 1.2.8 - rollup-plugin-preserve-directives: 0.4.0(rollup@4.39.0) - semver: 7.7.0 + rollup-plugin-preserve-directives: 0.4.0(rollup@4.38.0) + semver: 7.7.1 simple-git: 3.27.0 typedoc: 0.27.6(typescript@5.8.2) typedoc-plugin-frontmatter: 1.1.2(typedoc-plugin-markdown@4.4.1(typedoc@0.27.6(typescript@5.8.2))) typedoc-plugin-markdown: 4.4.1(typedoc@0.27.6(typescript@5.8.2)) typescript-eslint: 8.22.0(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.2) v8flags: 4.0.1 - vite-plugin-dts: 4.0.3(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) + vite-plugin-dts: 4.0.3(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) vite-plugin-externalize-deps: 0.9.0(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) vite-tsconfig-paths: 5.1.4(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)) vue-eslint-parser: 9.4.3(eslint@9.22.0(jiti@2.4.2)) @@ -18917,11 +18049,11 @@ snapshots: '@tanstack/query-core@5.66.0': {} - '@tanstack/query-core@5.71.5': {} + '@tanstack/query-core@5.72.2': {} '@tanstack/query-devtools@5.67.2': {} - '@tanstack/query-devtools@5.71.5': {} + '@tanstack/query-devtools@5.72.2': {} '@tanstack/react-query-devtools@5.67.2(@tanstack/react-query@5.66.0(react@19.0.0))(react@19.0.0)': dependencies: @@ -18947,15 +18079,15 @@ snapshots: react: 19.0.0 react-dom: 19.0.0(react@19.0.0) - '@tanstack/solid-query-devtools@5.71.9(@tanstack/solid-query@5.71.9(solid-js@1.9.5))(solid-js@1.9.5)': + '@tanstack/solid-query-devtools@5.72.2(@tanstack/solid-query@5.72.2(solid-js@1.9.5))(solid-js@1.9.5)': dependencies: - '@tanstack/query-devtools': 5.71.5 - '@tanstack/solid-query': 5.71.9(solid-js@1.9.5) + '@tanstack/query-devtools': 5.72.2 + '@tanstack/solid-query': 5.72.2(solid-js@1.9.5) solid-js: 1.9.5 - '@tanstack/solid-query@5.71.9(solid-js@1.9.5)': + '@tanstack/solid-query@5.72.2(solid-js@1.9.5)': dependencies: - '@tanstack/query-core': 5.71.5 + '@tanstack/query-core': 5.72.2 solid-js: 1.9.5 '@tanstack/solid-store@0.7.0(solid-js@1.9.5)': @@ -19069,8 +18201,6 @@ snapshots: dependencies: '@types/node': 22.13.4 - '@types/braces@3.0.5': {} - '@types/connect-history-api-fallback@1.5.4': dependencies: '@types/express-serve-static-core': 5.0.6 @@ -19173,10 +18303,6 @@ snapshots: '@types/koa-compose': 3.2.8 '@types/node': 22.13.4 - '@types/micromatch@4.0.9': - dependencies: - '@types/braces': 3.0.5 - '@types/mime@1.3.5': {} '@types/node-forge@1.3.11': @@ -19273,7 +18399,7 @@ snapshots: '@typescript-eslint/types': 8.22.0 '@typescript-eslint/typescript-estree': 8.22.0(typescript@5.8.2) '@typescript-eslint/visitor-keys': 8.22.0 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 eslint: 9.22.0(jiti@2.4.2) typescript: 5.8.2 transitivePeerDependencies: @@ -19287,7 +18413,7 @@ snapshots: eslint: 9.22.0(jiti@2.4.2) json-stable-stringify-without-jsonify: 1.0.1 lodash.merge: 4.6.2 - semver: 7.7.0 + semver: 7.7.1 transitivePeerDependencies: - supports-color - typescript @@ -19306,7 +18432,7 @@ snapshots: dependencies: '@typescript-eslint/typescript-estree': 8.22.0(typescript@5.8.2) '@typescript-eslint/utils': 8.22.0(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.2) - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 eslint: 9.22.0(jiti@2.4.2) ts-api-utils: 2.0.1(typescript@5.8.2) typescript: 5.8.2 @@ -19317,7 +18443,7 @@ snapshots: dependencies: '@typescript-eslint/typescript-estree': 8.23.0(typescript@5.8.2) '@typescript-eslint/utils': 8.23.0(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.2) - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 eslint: 9.22.0(jiti@2.4.2) ts-api-utils: 2.0.1(typescript@5.8.2) typescript: 5.8.2 @@ -19332,11 +18458,11 @@ snapshots: dependencies: '@typescript-eslint/types': 8.22.0 '@typescript-eslint/visitor-keys': 8.22.0 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.5 - semver: 7.7.0 + semver: 7.7.1 ts-api-utils: 2.0.1(typescript@5.8.2) typescript: 5.8.2 transitivePeerDependencies: @@ -19346,11 +18472,11 @@ snapshots: dependencies: '@typescript-eslint/types': 8.23.0 '@typescript-eslint/visitor-keys': 8.23.0 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.5 - semver: 7.7.0 + semver: 7.7.1 ts-api-utils: 2.0.1(typescript@5.8.2) typescript: 5.8.2 transitivePeerDependencies: @@ -19388,16 +18514,16 @@ snapshots: '@typescript-eslint/types': 8.23.0 eslint-visitor-keys: 4.2.0 - '@vercel/nft@0.27.10(rollup@4.39.0)': + '@vercel/nft@0.29.2(rollup@4.38.0)': dependencies: '@mapbox/node-pre-gyp': 2.0.0 - '@rollup/pluginutils': 5.1.4(rollup@4.39.0) - acorn: 8.14.0 - acorn-import-attributes: 1.9.5(acorn@8.14.0) + '@rollup/pluginutils': 5.1.4(rollup@4.38.0) + acorn: 8.14.1 + acorn-import-attributes: 1.9.5(acorn@8.14.1) async-sema: 3.1.1 bindings: 1.5.0 estree-walker: 2.0.2 - glob: 7.2.3 + glob: 10.4.5 graceful-fs: 4.2.11 node-gyp-build: 4.8.4 picomatch: 4.0.2 @@ -19407,26 +18533,6 @@ snapshots: - rollup - supports-color - '@vinxi/listhen@1.5.6': - dependencies: - '@parcel/watcher': 2.5.1 - '@parcel/watcher-wasm': 2.3.0 - citty: 0.1.6 - clipboardy: 4.0.0 - consola: 3.4.0 - defu: 6.1.4 - get-port-please: 3.1.2 - h3: 1.13.0 - http-shutdown: 1.2.2 - jiti: 1.21.7 - mlly: 1.7.4 - node-forge: 1.3.1 - pathe: 1.1.2 - std-env: 3.8.0 - ufo: 1.5.4 - untun: 0.1.3 - uqr: 0.1.2 - '@vitejs/plugin-react@4.3.4(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0))': dependencies: '@babel/core': 7.26.8 @@ -19647,22 +18753,22 @@ snapshots: '@webpack-cli/configtest@2.1.1(webpack-cli@5.1.4)(webpack@5.97.1)': dependencies: - webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack-dev-server@5.2.0)(webpack@5.97.1) '@webpack-cli/info@2.0.2(webpack-cli@5.1.4)(webpack@5.97.1)': dependencies: - webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack-dev-server@5.2.0)(webpack@5.97.1) '@webpack-cli/serve@2.0.5(webpack-cli@5.1.4)(webpack-dev-server@5.2.0)(webpack@5.97.1)': dependencies: - webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack-dev-server@5.2.0)(webpack@5.97.1) optionalDependencies: webpack-dev-server: 5.2.0(webpack-cli@5.1.4)(webpack@5.97.1) - '@workos-inc/node@7.45.0(express@4.21.2)': + '@workos-inc/node@7.46.0(express@4.21.2)': dependencies: iron-session: 6.3.1(express@4.21.2) jose: 5.6.3 @@ -19704,19 +18810,19 @@ snapshots: mime-types: 2.1.35 negotiator: 0.6.3 - acorn-import-attributes@1.9.5(acorn@8.14.0): + acorn-import-attributes@1.9.5(acorn@8.14.1): dependencies: - acorn: 8.14.0 + acorn: 8.14.1 - acorn-jsx@5.3.2(acorn@8.14.0): + acorn-jsx@5.3.2(acorn@8.14.1): dependencies: - acorn: 8.14.0 + acorn: 8.14.1 - acorn@8.14.0: {} + acorn@8.14.1: {} agent-base@6.0.2: dependencies: - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 transitivePeerDependencies: - supports-color @@ -19773,10 +18879,6 @@ snapshots: alien-signals@0.4.14: {} - ansi-align@3.0.1: - dependencies: - string-width: 4.2.3 - ansi-colors@4.1.3: {} ansi-escapes@4.3.2: @@ -19911,7 +19013,7 @@ snapshots: '@babel/plugin-syntax-jsx': 7.25.9(@babel/core@7.26.8) '@babel/types': 7.26.8 html-entities: 2.3.3 - parse5: 7.2.1 + parse5: 7.3.0 validate-html-nesting: 1.2.2 babel-plugin-macros@3.1.0: @@ -19972,17 +19074,6 @@ snapshots: boolbase@1.0.0: {} - boxen@7.1.1: - dependencies: - ansi-align: 3.0.1 - camelcase: 7.0.1 - chalk: 5.4.1 - cli-boxes: 3.0.0 - string-width: 5.1.2 - type-fest: 2.19.0 - widest-line: 4.0.1 - wrap-ansi: 8.1.0 - brace-expansion@1.1.11: dependencies: balanced-match: 1.0.2 @@ -20023,19 +19114,19 @@ snapshots: bytes@3.1.2: {} - c12@2.0.1(magicast@0.3.5): + c12@3.0.2(magicast@0.3.5): dependencies: chokidar: 4.0.3 confbox: 0.1.8 defu: 6.1.4 dotenv: 16.4.7 - giget: 1.2.4 + exsolve: 1.0.4 + giget: 2.0.0 jiti: 2.4.2 - mlly: 1.7.4 - ohash: 1.1.4 - pathe: 1.1.2 + ohash: 2.0.11 + pathe: 2.0.3 perfect-debounce: 1.0.0 - pkg-types: 1.3.1 + pkg-types: 2.1.0 rc9: 2.1.2 optionalDependencies: magicast: 0.3.5 @@ -20061,8 +19152,6 @@ snapshots: camelcase-css@2.0.1: {} - camelcase@7.0.1: {} - caniuse-lite@1.0.30001696: {} chai@5.2.0: @@ -20085,12 +19174,33 @@ snapshots: chalk@5.4.1: {} - change-case@5.4.4: {} - char-regex@1.0.2: {} check-error@2.1.1: {} + cheerio-select@2.1.0: + dependencies: + boolbase: 1.0.0 + css-select: 5.1.0 + css-what: 6.1.0 + domelementtype: 2.3.0 + domhandler: 5.0.3 + domutils: 3.2.2 + + cheerio@1.0.0: + dependencies: + cheerio-select: 2.1.0 + dom-serializer: 2.0.0 + domhandler: 5.0.3 + domutils: 3.2.2 + encoding-sniffer: 0.2.0 + htmlparser2: 9.1.0 + parse5: 7.3.0 + parse5-htmlparser2-tree-adapter: 7.1.0 + parse5-parser-stream: 7.1.2 + undici: 6.21.2 + whatwg-mimetype: 4.0.0 + chokidar@3.6.0: dependencies: anymatch: 3.1.3 @@ -20107,15 +19217,13 @@ snapshots: dependencies: readdirp: 4.1.1 - chownr@2.0.0: {} - chownr@3.0.0: {} chrome-trace-event@1.0.4: {} citty@0.1.6: dependencies: - consola: 3.4.0 + consola: 3.4.2 cjs-module-lexer@1.4.3: {} @@ -20125,8 +19233,6 @@ snapshots: dependencies: source-map: 0.6.1 - cli-boxes@3.0.0: {} - cli-cursor@3.1.0: dependencies: restore-cursor: 3.1.0 @@ -20186,8 +19292,6 @@ snapshots: color-name@1.1.4: {} - colorette@1.4.0: {} - colorette@2.0.20: {} combinate@1.1.11: {} @@ -20259,9 +19363,11 @@ snapshots: confbox@0.1.8: {} + confbox@0.2.1: {} + connect-history-api-fallback@2.0.0: {} - consola@3.4.0: {} + consola@3.4.2: {} content-disposition@0.5.4: dependencies: @@ -20296,6 +19402,8 @@ snapshots: cookie-es@1.2.2: {} + cookie-es@2.0.0: {} + cookie-signature@1.0.6: {} cookie@0.5.0: {} @@ -20337,7 +19445,7 @@ snapshots: shebang-command: 2.0.0 which: 2.0.2 - crossws@0.3.3: + crossws@0.3.4: dependencies: uncrypto: 0.1.3 @@ -20349,6 +19457,14 @@ snapshots: domutils: 2.8.0 nth-check: 2.1.1 + css-select@5.1.0: + dependencies: + boolbase: 1.0.0 + css-what: 6.1.0 + domhandler: 5.0.3 + domutils: 3.2.2 + nth-check: 2.1.1 + css-what@6.1.0: {} css.escape@1.5.1: {} @@ -20373,12 +19489,7 @@ snapshots: dependencies: '@babel/runtime': 7.26.7 - dax-sh@0.39.2: - dependencies: - '@deno/shim-deno': 0.19.2 - undici-types: 5.28.4 - - db0@0.2.3: {} + db0@0.3.1: {} de-indent@1.0.2: {} @@ -20390,11 +19501,9 @@ snapshots: dependencies: ms: 2.1.3 - debug@4.4.0(supports-color@9.4.0): + debug@4.4.0: dependencies: ms: 2.1.3 - optionalDependencies: - supports-color: 9.4.0 decimal.js@10.5.0: {} @@ -20484,18 +19593,34 @@ snapshots: domhandler: 4.3.1 entities: 2.2.0 + dom-serializer@2.0.0: + dependencies: + domelementtype: 2.3.0 + domhandler: 5.0.3 + entities: 4.5.0 + domelementtype@2.3.0: {} domhandler@4.3.1: dependencies: domelementtype: 2.3.0 + domhandler@5.0.3: + dependencies: + domelementtype: 2.3.0 + domutils@2.8.0: dependencies: dom-serializer: 1.4.1 domelementtype: 2.3.0 domhandler: 4.3.1 + domutils@3.2.2: + dependencies: + dom-serializer: 2.0.0 + domelementtype: 2.3.0 + domhandler: 5.0.3 + dot-case@3.0.4: dependencies: no-case: 3.0.4 @@ -20539,6 +19664,11 @@ snapshots: encodeurl@2.0.0: {} + encoding-sniffer@0.2.0: + dependencies: + iconv-lite: 0.6.3 + whatwg-encoding: 3.1.1 + end-of-stream@1.4.4: dependencies: once: 1.4.0 @@ -20556,6 +19686,8 @@ snapshots: entities@4.5.0: {} + entities@6.0.0: {} + envinfo@7.14.0: {} environment@1.1.0: {} @@ -20564,6 +19696,8 @@ snapshots: dependencies: is-arrayish: 0.2.1 + error-stack-parser-es@1.0.5: {} + error-stack-parser@2.1.4: dependencies: stackframe: 1.3.4 @@ -20578,49 +19712,23 @@ snapshots: dependencies: es-errors: 1.3.0 - esbuild-plugin-solid@0.6.0(esbuild@0.25.0)(solid-js@1.9.5): + esbuild-plugin-solid@0.6.0(esbuild@0.25.2)(solid-js@1.9.5): dependencies: '@babel/core': 7.26.8 '@babel/preset-typescript': 7.26.0(@babel/core@7.26.8) babel-preset-solid: 1.9.3(@babel/core@7.26.8) - esbuild: 0.25.0 + esbuild: 0.25.2 solid-js: 1.9.5 transitivePeerDependencies: - supports-color - esbuild-register@3.6.0(esbuild@0.25.0): + esbuild-register@3.6.0(esbuild@0.25.2): dependencies: - debug: 4.4.0(supports-color@9.4.0) - esbuild: 0.25.0 + debug: 4.4.0 + esbuild: 0.25.2 transitivePeerDependencies: - supports-color - esbuild@0.20.2: - optionalDependencies: - '@esbuild/aix-ppc64': 0.20.2 - '@esbuild/android-arm': 0.20.2 - '@esbuild/android-arm64': 0.20.2 - '@esbuild/android-x64': 0.20.2 - '@esbuild/darwin-arm64': 0.20.2 - '@esbuild/darwin-x64': 0.20.2 - '@esbuild/freebsd-arm64': 0.20.2 - '@esbuild/freebsd-x64': 0.20.2 - '@esbuild/linux-arm': 0.20.2 - '@esbuild/linux-arm64': 0.20.2 - '@esbuild/linux-ia32': 0.20.2 - '@esbuild/linux-loong64': 0.20.2 - '@esbuild/linux-mips64el': 0.20.2 - '@esbuild/linux-ppc64': 0.20.2 - '@esbuild/linux-riscv64': 0.20.2 - '@esbuild/linux-s390x': 0.20.2 - '@esbuild/linux-x64': 0.20.2 - '@esbuild/netbsd-x64': 0.20.2 - '@esbuild/openbsd-x64': 0.20.2 - '@esbuild/sunos-x64': 0.20.2 - '@esbuild/win32-arm64': 0.20.2 - '@esbuild/win32-ia32': 0.20.2 - '@esbuild/win32-x64': 0.20.2 - esbuild@0.23.0: optionalDependencies: '@esbuild/aix-ppc64': 0.23.0 @@ -20703,33 +19811,33 @@ snapshots: '@esbuild/win32-ia32': 0.24.2 '@esbuild/win32-x64': 0.24.2 - esbuild@0.25.0: + esbuild@0.25.2: optionalDependencies: - '@esbuild/aix-ppc64': 0.25.0 - '@esbuild/android-arm': 0.25.0 - '@esbuild/android-arm64': 0.25.0 - '@esbuild/android-x64': 0.25.0 - '@esbuild/darwin-arm64': 0.25.0 - '@esbuild/darwin-x64': 0.25.0 - '@esbuild/freebsd-arm64': 0.25.0 - '@esbuild/freebsd-x64': 0.25.0 - '@esbuild/linux-arm': 0.25.0 - '@esbuild/linux-arm64': 0.25.0 - '@esbuild/linux-ia32': 0.25.0 - '@esbuild/linux-loong64': 0.25.0 - '@esbuild/linux-mips64el': 0.25.0 - '@esbuild/linux-ppc64': 0.25.0 - '@esbuild/linux-riscv64': 0.25.0 - '@esbuild/linux-s390x': 0.25.0 - '@esbuild/linux-x64': 0.25.0 - '@esbuild/netbsd-arm64': 0.25.0 - '@esbuild/netbsd-x64': 0.25.0 - '@esbuild/openbsd-arm64': 0.25.0 - '@esbuild/openbsd-x64': 0.25.0 - '@esbuild/sunos-x64': 0.25.0 - '@esbuild/win32-arm64': 0.25.0 - '@esbuild/win32-ia32': 0.25.0 - '@esbuild/win32-x64': 0.25.0 + '@esbuild/aix-ppc64': 0.25.2 + '@esbuild/android-arm': 0.25.2 + '@esbuild/android-arm64': 0.25.2 + '@esbuild/android-x64': 0.25.2 + '@esbuild/darwin-arm64': 0.25.2 + '@esbuild/darwin-x64': 0.25.2 + '@esbuild/freebsd-arm64': 0.25.2 + '@esbuild/freebsd-x64': 0.25.2 + '@esbuild/linux-arm': 0.25.2 + '@esbuild/linux-arm64': 0.25.2 + '@esbuild/linux-ia32': 0.25.2 + '@esbuild/linux-loong64': 0.25.2 + '@esbuild/linux-mips64el': 0.25.2 + '@esbuild/linux-ppc64': 0.25.2 + '@esbuild/linux-riscv64': 0.25.2 + '@esbuild/linux-s390x': 0.25.2 + '@esbuild/linux-x64': 0.25.2 + '@esbuild/netbsd-arm64': 0.25.2 + '@esbuild/netbsd-x64': 0.25.2 + '@esbuild/openbsd-arm64': 0.25.2 + '@esbuild/openbsd-x64': 0.25.2 + '@esbuild/sunos-x64': 0.25.2 + '@esbuild/win32-arm64': 0.25.2 + '@esbuild/win32-ia32': 0.25.2 + '@esbuild/win32-x64': 0.25.2 escalade@3.2.0: {} @@ -20744,7 +19852,7 @@ snapshots: eslint-compat-utils@0.5.1(eslint@9.22.0(jiti@2.4.2)): dependencies: eslint: 9.22.0(jiti@2.4.2) - semver: 7.7.0 + semver: 7.7.1 eslint-import-resolver-node@0.3.9: dependencies: @@ -20766,7 +19874,7 @@ snapshots: '@types/doctrine': 0.0.9 '@typescript-eslint/scope-manager': 8.23.0 '@typescript-eslint/utils': 8.23.0(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.2) - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 doctrine: 3.0.0 enhanced-resolve: 5.18.1 eslint: 9.22.0(jiti@2.4.2) @@ -20774,7 +19882,7 @@ snapshots: get-tsconfig: 4.10.0 is-glob: 4.0.3 minimatch: 9.0.5 - semver: 7.7.0 + semver: 7.7.1 stable-hash: 0.0.4 tslib: 2.8.1 transitivePeerDependencies: @@ -20791,7 +19899,7 @@ snapshots: globals: 15.14.0 ignore: 5.3.2 minimatch: 9.0.5 - semver: 7.7.0 + semver: 7.7.1 eslint-plugin-react-debug@1.26.2(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.2): dependencies: @@ -20974,7 +20082,7 @@ snapshots: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.6 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 escape-string-regexp: 4.0.0 eslint-scope: 8.3.0 eslint-visitor-keys: 4.2.0 @@ -21000,14 +20108,14 @@ snapshots: espree@10.3.0: dependencies: - acorn: 8.14.0 - acorn-jsx: 5.3.2(acorn@8.14.0) + acorn: 8.14.1 + acorn-jsx: 5.3.2(acorn@8.14.1) eslint-visitor-keys: 4.2.0 espree@9.6.1: dependencies: - acorn: 8.14.0 - acorn-jsx: 5.3.2(acorn@8.14.0) + acorn: 8.14.1 + acorn-jsx: 5.3.2(acorn@8.14.1) eslint-visitor-keys: 3.4.3 esprima@4.0.1: {} @@ -21094,6 +20202,8 @@ snapshots: transitivePeerDependencies: - supports-color + exsolve@1.0.4: {} + extend@3.0.2: {} fast-deep-equal@3.1.3: {} @@ -21289,10 +20399,6 @@ snapshots: jsonfile: 4.0.0 universalify: 0.1.2 - fs-minipass@2.1.0: - dependencies: - minipass: 3.3.6 - fs.realpath@1.0.0: {} fsevents@2.3.2: @@ -21337,16 +20443,14 @@ snapshots: dependencies: resolve-pkg-maps: 1.0.0 - giget@1.2.4: + giget@2.0.0: dependencies: citty: 0.1.6 - consola: 3.4.0 + consola: 3.4.2 defu: 6.1.4 node-fetch-native: 1.6.6 - nypm: 0.5.2 - ohash: 1.1.4 + nypm: 0.6.0 pathe: 2.0.3 - tar: 6.2.1 glob-parent@5.1.2: dependencies: @@ -21376,15 +20480,6 @@ snapshots: package-json-from-dist: 1.0.1 path-scurry: 2.0.0 - glob@7.2.3: - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 3.1.2 - once: 1.4.0 - path-is-absolute: 1.0.1 - glob@9.3.5: dependencies: fs.realpath: 1.0.0 @@ -21412,14 +20507,14 @@ snapshots: globals@15.14.0: {} - globby@14.0.2: + globby@14.1.0: dependencies: '@sindresorhus/merge-streams': 2.3.0 fast-glob: 3.3.3 - ignore: 5.3.2 - path-type: 5.0.0 + ignore: 7.0.3 + path-type: 6.0.0 slash: 5.1.0 - unicorn-magic: 0.1.0 + unicorn-magic: 0.3.0 globrex@0.1.2: {} @@ -21442,7 +20537,7 @@ snapshots: h3@1.13.0: dependencies: cookie-es: 1.2.2 - crossws: 0.3.3 + crossws: 0.3.4 defu: 6.1.4 destr: 2.0.3 iron-webcrypto: 1.2.1 @@ -21452,6 +20547,18 @@ snapshots: uncrypto: 0.1.3 unenv: 1.10.0 + h3@1.15.1: + dependencies: + cookie-es: 1.2.2 + crossws: 0.3.4 + defu: 6.1.4 + destr: 2.0.3 + iron-webcrypto: 1.2.1 + node-mock-http: 1.0.0 + radix3: 1.1.2 + ufo: 1.5.4 + uncrypto: 0.1.3 + handle-thing@2.0.1: {} has-flag@4.0.0: {} @@ -21514,7 +20621,7 @@ snapshots: tapable: 2.2.1 optionalDependencies: '@rspack/core': 1.2.2(@swc/helpers@0.5.15) - webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack-cli@5.1.4) htmlparser2@6.1.0: dependencies: @@ -21523,6 +20630,13 @@ snapshots: domutils: 2.8.0 entities: 2.2.0 + htmlparser2@9.1.0: + dependencies: + domelementtype: 2.3.0 + domhandler: 5.0.3 + domutils: 3.2.2 + entities: 4.5.0 + http-deceiver@1.2.7: {} http-errors@1.6.3: @@ -21545,7 +20659,7 @@ snapshots: http-proxy-agent@7.0.2: dependencies: agent-base: 7.1.3 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 transitivePeerDependencies: - supports-color @@ -21574,14 +20688,14 @@ snapshots: https-proxy-agent@5.0.1: dependencies: agent-base: 6.0.2 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 transitivePeerDependencies: - supports-color - https-proxy-agent@7.0.6(supports-color@9.4.0): + https-proxy-agent@7.0.6: dependencies: agent-base: 7.1.3 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 transitivePeerDependencies: - supports-color @@ -21605,6 +20719,8 @@ snapshots: ignore@5.3.2: {} + ignore@7.0.3: {} + immer@10.1.1: {} import-fresh@3.3.0: @@ -21619,19 +20735,10 @@ snapshots: pkg-dir: 4.2.0 resolve-cwd: 3.0.0 - import-meta-resolve@4.1.0: {} - imurmurhash@0.1.4: {} indent-string@4.0.0: {} - index-to-position@0.1.2: {} - - inflight@1.0.6: - dependencies: - once: 1.4.0 - wrappy: 1.0.2 - inherits@2.0.3: {} inherits@2.0.4: {} @@ -21642,11 +20749,11 @@ snapshots: interpret@3.1.1: {} - ioredis@5.4.2: + ioredis@5.6.0: dependencies: '@ioredis/commands': 1.2.0 cluster-key-slot: 1.1.2 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 denque: 2.1.0 lodash.defaults: 4.2.0 lodash.isarguments: 3.1.0 @@ -21795,8 +20902,6 @@ snapshots: isexe@2.0.0: {} - isexe@3.1.1: {} - isobject@3.0.1: {} isomorphic-rslog@0.0.6: {} @@ -21838,8 +20943,6 @@ snapshots: js-cookie@3.0.5: {} - js-levenshtein@1.1.6: {} - js-tokens@4.0.0: {} js-tokens@9.0.1: {} @@ -21861,7 +20964,7 @@ snapshots: form-data: 4.0.1 html-encoding-sniffer: 4.0.0 http-proxy-agent: 7.0.2 - https-proxy-agent: 7.0.6(supports-color@9.4.0) + https-proxy-agent: 7.0.6 is-potential-custom-element-name: 1.0.1 nwsapi: 2.2.16 parse5: 7.2.1 @@ -21919,6 +21022,8 @@ snapshots: kind-of@6.0.3: {} + kleur@4.1.5: {} + klona@2.0.6: {} knitwork@1.2.0: {} @@ -22016,8 +21121,8 @@ snapshots: '@parcel/watcher-wasm': 2.5.1 citty: 0.1.6 clipboardy: 4.0.0 - consola: 3.4.0 - crossws: 0.3.3 + consola: 3.4.2 + crossws: 0.3.4 defu: 6.1.4 get-port-please: 3.1.2 h3: 1.13.0 @@ -22026,7 +21131,7 @@ snapshots: mlly: 1.7.4 node-forge: 1.3.1 pathe: 1.1.2 - std-env: 3.8.0 + std-env: 3.8.1 ufo: 1.5.4 untun: 0.1.3 uqr: 0.1.2 @@ -22038,10 +21143,11 @@ snapshots: mlly: 1.7.4 pkg-types: 1.3.1 - local-pkg@1.0.0: + local-pkg@1.1.1: dependencies: mlly: 1.7.4 - pkg-types: 1.3.1 + pkg-types: 2.1.0 + quansync: 0.2.10 locate-path@5.0.0: dependencies: @@ -22218,33 +21324,20 @@ snapshots: minimist@1.2.8: {} - minipass@3.3.6: - dependencies: - yallist: 4.0.0 - minipass@4.2.8: {} - minipass@5.0.0: {} - minipass@7.1.2: {} - minizlib@2.1.2: - dependencies: - minipass: 3.3.6 - yallist: 4.0.0 - minizlib@3.0.1: dependencies: minipass: 7.1.2 rimraf: 5.0.10 - mkdirp@1.0.4: {} - mkdirp@3.0.1: {} mlly@1.7.4: dependencies: - acorn: 8.14.0 + acorn: 8.14.1 pathe: 2.0.3 pkg-types: 1.3.1 ufo: 1.5.4 @@ -22313,44 +21406,42 @@ snapshots: neo-async@2.6.2: {} - nitropack@2.10.4(typescript@5.8.2): + nitropack@2.11.8: dependencies: - '@cloudflare/kv-asset-handler': 0.3.4 - '@netlify/functions': 2.8.2 - '@rollup/plugin-alias': 5.1.1(rollup@4.39.0) - '@rollup/plugin-commonjs': 28.0.2(rollup@4.39.0) - '@rollup/plugin-inject': 5.0.5(rollup@4.39.0) - '@rollup/plugin-json': 6.1.0(rollup@4.39.0) - '@rollup/plugin-node-resolve': 15.3.1(rollup@4.39.0) - '@rollup/plugin-replace': 6.0.2(rollup@4.39.0) - '@rollup/plugin-terser': 0.4.4(rollup@4.39.0) - '@rollup/pluginutils': 5.1.4(rollup@4.39.0) - '@types/http-proxy': 1.17.15 - '@vercel/nft': 0.27.10(rollup@4.39.0) + '@cloudflare/kv-asset-handler': 0.4.0 + '@netlify/functions': 3.0.4 + '@rollup/plugin-alias': 5.1.1(rollup@4.38.0) + '@rollup/plugin-commonjs': 28.0.3(rollup@4.38.0) + '@rollup/plugin-inject': 5.0.5(rollup@4.38.0) + '@rollup/plugin-json': 6.1.0(rollup@4.38.0) + '@rollup/plugin-node-resolve': 16.0.1(rollup@4.38.0) + '@rollup/plugin-replace': 6.0.2(rollup@4.38.0) + '@rollup/plugin-terser': 0.4.4(rollup@4.38.0) + '@vercel/nft': 0.29.2(rollup@4.38.0) archiver: 7.0.1 - c12: 2.0.1(magicast@0.3.5) - chokidar: 3.6.0 + c12: 3.0.2(magicast@0.3.5) + chokidar: 4.0.3 citty: 0.1.6 compatx: 0.1.8 - confbox: 0.1.8 - consola: 3.4.0 - cookie-es: 1.2.2 + confbox: 0.2.1 + consola: 3.4.2 + cookie-es: 2.0.0 croner: 9.0.0 - crossws: 0.3.3 - db0: 0.2.3 + crossws: 0.3.4 + db0: 0.3.1 defu: 6.1.4 destr: 2.0.3 dot-prop: 9.0.0 - esbuild: 0.24.2 + esbuild: 0.25.2 escape-string-regexp: 5.0.0 etag: 1.8.1 - fs-extra: 11.3.0 - globby: 14.0.2 + exsolve: 1.0.4 + globby: 14.1.0 gzip-size: 7.0.0 - h3: 1.13.0 + h3: 1.15.1 hookable: 5.5.3 httpxy: 0.1.7 - ioredis: 5.4.2 + ioredis: 5.6.0 jiti: 2.4.2 klona: 2.0.6 knitwork: 1.2.0 @@ -22360,29 +21451,34 @@ snapshots: mime: 4.0.6 mlly: 1.7.4 node-fetch-native: 1.6.6 + node-mock-http: 1.0.0 ofetch: 1.4.1 - ohash: 1.1.4 - openapi-typescript: 7.6.0(typescript@5.8.2) - pathe: 1.1.2 + ohash: 2.0.11 + pathe: 2.0.3 perfect-debounce: 1.0.0 - pkg-types: 1.3.1 + pkg-types: 2.1.0 pretty-bytes: 6.1.1 radix3: 1.1.2 - rollup: 4.39.0 - rollup-plugin-visualizer: 5.14.0(rollup@4.39.0) + rollup: 4.38.0 + rollup-plugin-visualizer: 5.14.0(rollup@4.38.0) scule: 1.3.0 - semver: 7.7.0 + semver: 7.7.1 serve-placeholder: 2.0.2 serve-static: 1.16.2 - std-env: 3.8.0 + source-map: 0.7.4 + std-env: 3.8.1 ufo: 1.5.4 + ultrahtml: 1.5.3 uncrypto: 0.1.3 unctx: 2.4.1 - unenv: 1.10.0 - unimport: 3.14.6(rollup@4.39.0) - unstorage: 1.14.4(db0@0.2.3)(ioredis@5.4.2) - untyped: 1.5.2 + unenv: 2.0.0-rc.15 + unimport: 4.1.3 + unplugin-utils: 0.2.4 + unstorage: 1.15.0(db0@0.3.1)(ioredis@5.6.0) + untyped: 2.0.0 unwasm: 0.3.9 + youch: 4.1.0-beta.7 + youch-core: 0.3.2 transitivePeerDependencies: - '@azure/app-configuration' - '@azure/cosmos' @@ -22408,7 +21504,6 @@ snapshots: - rolldown - sqlite3 - supports-color - - typescript - uploadthing no-case@3.0.4: @@ -22445,6 +21540,8 @@ snapshots: node-machine-id@1.1.12: {} + node-mock-http@1.0.0: {} + node-releases@2.0.19: {} nopt@8.1.0: @@ -22496,7 +21593,7 @@ snapshots: open: 8.4.2 ora: 5.3.0 resolve.exports: 2.0.3 - semver: 7.7.0 + semver: 7.7.1 string-width: 4.2.3 tar-stream: 2.2.0 tmp: 0.2.3 @@ -22520,14 +21617,13 @@ snapshots: transitivePeerDependencies: - debug - nypm@0.5.2: + nypm@0.6.0: dependencies: citty: 0.1.6 - consola: 3.4.0 + consola: 3.4.2 pathe: 2.0.3 - pkg-types: 1.3.1 + pkg-types: 2.1.0 tinyexec: 0.3.2 - ufo: 1.5.4 object-assign@4.1.1: {} @@ -22556,6 +21652,8 @@ snapshots: ohash@1.1.4: {} + ohash@2.0.11: {} + on-finished@2.4.1: dependencies: ee-first: 1.1.1 @@ -22587,16 +21685,6 @@ snapshots: is-docker: 2.2.1 is-wsl: 2.2.0 - openapi-typescript@7.6.0(typescript@5.8.2): - dependencies: - '@redocly/openapi-core': 1.28.0(supports-color@9.4.0) - ansi-colors: 4.1.3 - change-case: 5.4.4 - parse-json: 8.1.0 - supports-color: 9.4.0 - typescript: 5.8.2 - yargs-parser: 21.1.1 - optionator@0.9.4: dependencies: deep-is: 0.1.4 @@ -22669,18 +21757,21 @@ snapshots: json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 - parse-json@8.1.0: - dependencies: - '@babel/code-frame': 7.26.2 - index-to-position: 0.1.2 - type-fest: 4.33.0 - parse-passwd@1.0.0: {} parse5-htmlparser2-tree-adapter@6.0.1: dependencies: parse5: 6.0.1 + parse5-htmlparser2-tree-adapter@7.1.0: + dependencies: + domhandler: 5.0.3 + parse5: 7.3.0 + + parse5-parser-stream@7.1.2: + dependencies: + parse5: 7.3.0 + parse5@5.1.1: {} parse5@6.0.1: {} @@ -22689,6 +21780,10 @@ snapshots: dependencies: entities: 4.5.0 + parse5@7.3.0: + dependencies: + entities: 6.0.0 + parseurl@1.3.3: {} pascal-case@3.1.2: @@ -22700,8 +21795,6 @@ snapshots: path-exists@4.0.0: {} - path-is-absolute@1.0.1: {} - path-key@3.1.1: {} path-key@4.0.0: {} @@ -22730,7 +21823,7 @@ snapshots: path-type@4.0.0: {} - path-type@5.0.0: {} + path-type@6.0.0: {} pathe@1.1.2: {} @@ -22760,6 +21853,12 @@ snapshots: mlly: 1.7.4 pathe: 2.0.3 + pkg-types@2.1.0: + dependencies: + confbox: 0.2.1 + exsolve: 1.0.4 + pathe: 2.0.3 + playwright-core@1.52.0: {} playwright@1.52.0: @@ -22897,6 +21996,8 @@ snapshots: dependencies: side-channel: 1.1.0 + quansync@0.2.10: {} + querystringify@2.2.0: {} queue-microtask@1.2.3: {} @@ -23157,45 +22258,45 @@ snapshots: glob: 11.0.1 package-json-from-dist: 1.0.1 - rollup-plugin-preserve-directives@0.4.0(rollup@4.39.0): + rollup-plugin-preserve-directives@0.4.0(rollup@4.38.0): dependencies: - '@rollup/pluginutils': 5.1.4(rollup@4.39.0) + '@rollup/pluginutils': 5.1.4(rollup@4.38.0) magic-string: 0.30.17 - rollup: 4.39.0 + rollup: 4.38.0 - rollup-plugin-visualizer@5.14.0(rollup@4.39.0): + rollup-plugin-visualizer@5.14.0(rollup@4.38.0): dependencies: open: 8.4.2 picomatch: 4.0.2 source-map: 0.7.4 yargs: 17.7.2 optionalDependencies: - rollup: 4.39.0 + rollup: 4.38.0 - rollup@4.39.0: + rollup@4.38.0: dependencies: '@types/estree': 1.0.7 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.39.0 - '@rollup/rollup-android-arm64': 4.39.0 - '@rollup/rollup-darwin-arm64': 4.39.0 - '@rollup/rollup-darwin-x64': 4.39.0 - '@rollup/rollup-freebsd-arm64': 4.39.0 - '@rollup/rollup-freebsd-x64': 4.39.0 - '@rollup/rollup-linux-arm-gnueabihf': 4.39.0 - '@rollup/rollup-linux-arm-musleabihf': 4.39.0 - '@rollup/rollup-linux-arm64-gnu': 4.39.0 - '@rollup/rollup-linux-arm64-musl': 4.39.0 - '@rollup/rollup-linux-loongarch64-gnu': 4.39.0 - '@rollup/rollup-linux-powerpc64le-gnu': 4.39.0 - '@rollup/rollup-linux-riscv64-gnu': 4.39.0 - '@rollup/rollup-linux-riscv64-musl': 4.39.0 - '@rollup/rollup-linux-s390x-gnu': 4.39.0 - '@rollup/rollup-linux-x64-gnu': 4.39.0 - '@rollup/rollup-linux-x64-musl': 4.39.0 - '@rollup/rollup-win32-arm64-msvc': 4.39.0 - '@rollup/rollup-win32-ia32-msvc': 4.39.0 - '@rollup/rollup-win32-x64-msvc': 4.39.0 + '@rollup/rollup-android-arm-eabi': 4.38.0 + '@rollup/rollup-android-arm64': 4.38.0 + '@rollup/rollup-darwin-arm64': 4.38.0 + '@rollup/rollup-darwin-x64': 4.38.0 + '@rollup/rollup-freebsd-arm64': 4.38.0 + '@rollup/rollup-freebsd-x64': 4.38.0 + '@rollup/rollup-linux-arm-gnueabihf': 4.38.0 + '@rollup/rollup-linux-arm-musleabihf': 4.38.0 + '@rollup/rollup-linux-arm64-gnu': 4.38.0 + '@rollup/rollup-linux-arm64-musl': 4.38.0 + '@rollup/rollup-linux-loongarch64-gnu': 4.38.0 + '@rollup/rollup-linux-powerpc64le-gnu': 4.38.0 + '@rollup/rollup-linux-riscv64-gnu': 4.38.0 + '@rollup/rollup-linux-riscv64-musl': 4.38.0 + '@rollup/rollup-linux-s390x-gnu': 4.38.0 + '@rollup/rollup-linux-x64-gnu': 4.38.0 + '@rollup/rollup-linux-x64-musl': 4.38.0 + '@rollup/rollup-win32-arm64-msvc': 4.38.0 + '@rollup/rollup-win32-ia32-msvc': 4.38.0 + '@rollup/rollup-win32-x64-msvc': 4.38.0 fsevents: 2.3.3 rrweb-cssom@0.7.1: {} @@ -23256,7 +22357,7 @@ snapshots: dependencies: lru-cache: 6.0.0 - semver@7.7.0: {} + semver@7.7.1: {} send@0.19.0: dependencies: @@ -23365,7 +22466,7 @@ snapshots: dependencies: '@kwsites/file-exists': 1.1.1 '@kwsites/promise-deferred': 1.1.1 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 transitivePeerDependencies: - supports-color @@ -23434,7 +22535,7 @@ snapshots: spdy-transport@3.0.0: dependencies: - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 detect-node: 2.1.0 hpack.js: 2.1.6 obuf: 1.1.2 @@ -23445,7 +22546,7 @@ snapshots: spdy@4.0.2: dependencies: - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 handle-thing: 2.0.1 http-deceiver: 1.2.7 select-hose: 2.0.0 @@ -23469,7 +22570,7 @@ snapshots: statuses@2.0.1: {} - std-env@3.8.0: {} + std-env@3.8.1: {} streamx@2.22.0: dependencies: @@ -23522,7 +22623,7 @@ snapshots: strip-json-comments@3.1.1: {} - strip-literal@2.1.1: + strip-literal@3.0.0: dependencies: js-tokens: 9.0.1 @@ -23546,6 +22647,8 @@ snapshots: dependencies: copy-anything: 3.0.5 + supports-color@10.0.0: {} + supports-color@7.2.0: dependencies: has-flag: 4.0.0 @@ -23554,8 +22657,6 @@ snapshots: dependencies: has-flag: 4.0.0 - supports-color@9.4.0: {} - supports-hyperlinks@3.1.0: dependencies: has-flag: 4.0.0 @@ -23567,7 +22668,7 @@ snapshots: dependencies: '@swc/core': 1.10.15(@swc/helpers@0.5.15) '@swc/counter': 0.1.3 - webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack-cli@5.1.4) swr@2.3.0(react@19.0.0): dependencies: @@ -23626,15 +22727,6 @@ snapshots: fast-fifo: 1.3.2 streamx: 2.22.0 - tar@6.2.1: - dependencies: - chownr: 2.0.0 - fs-minipass: 2.1.0 - minipass: 5.0.0 - minizlib: 2.1.2 - mkdirp: 1.0.4 - yallist: 4.0.0 - tar@7.4.3: dependencies: '@isaacs/fs-minipass': 4.0.1 @@ -23644,34 +22736,34 @@ snapshots: mkdirp: 3.0.1 yallist: 5.0.0 - terser-webpack-plugin@5.3.11(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack@5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)): + terser-webpack-plugin@5.3.11(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack@5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 schema-utils: 4.3.0 serialize-javascript: 6.0.2 terser: 5.37.0 - webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0) + webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2) optionalDependencies: '@swc/core': 1.10.15(@swc/helpers@0.5.15) - esbuild: 0.25.0 + esbuild: 0.25.2 - terser-webpack-plugin@5.3.11(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack@5.97.1): + terser-webpack-plugin@5.3.11(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack@5.97.1): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 schema-utils: 4.3.0 serialize-javascript: 6.0.2 terser: 5.37.0 - webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack-cli@5.1.4) optionalDependencies: '@swc/core': 1.10.15(@swc/helpers@0.5.15) - esbuild: 0.25.0 + esbuild: 0.25.2 terser@5.37.0: dependencies: '@jridgewell/source-map': 0.3.6 - acorn: 8.14.0 + acorn: 8.14.1 commander: 2.20.3 source-map-support: 0.5.21 @@ -23793,8 +22885,6 @@ snapshots: type-fest@0.21.3: {} - type-fest@2.19.0: {} - type-fest@4.33.0: {} type-is@1.6.18: @@ -23852,51 +22942,61 @@ snapshots: ufo@1.5.4: {} + ultrahtml@1.5.3: {} + unc-path-regex@0.1.2: {} uncrypto@0.1.3: {} unctx@2.4.1: dependencies: - acorn: 8.14.0 + acorn: 8.14.1 estree-walker: 3.0.3 magic-string: 0.30.17 - unplugin: 2.1.2 - - undici-types@5.28.4: {} + unplugin: 2.2.2 undici-types@6.20.0: {} + undici@6.21.2: {} + + undici@7.8.0: {} + unenv@1.10.0: dependencies: - consola: 3.4.0 + consola: 3.4.2 defu: 6.1.4 mime: 3.0.0 node-fetch-native: 1.6.6 pathe: 1.1.2 + unenv@2.0.0-rc.15: + dependencies: + defu: 6.1.4 + exsolve: 1.0.4 + ohash: 2.0.11 + pathe: 2.0.3 + ufo: 1.5.4 + unicode-emoji-modifier-base@1.0.0: {} - unicorn-magic@0.1.0: {} + unicorn-magic@0.3.0: {} - unimport@3.14.6(rollup@4.39.0): + unimport@4.1.3: dependencies: - '@rollup/pluginutils': 5.1.4(rollup@4.39.0) - acorn: 8.14.0 + acorn: 8.14.1 escape-string-regexp: 5.0.0 estree-walker: 3.0.3 - fast-glob: 3.3.3 - local-pkg: 1.0.0 + local-pkg: 1.1.1 magic-string: 0.30.17 mlly: 1.7.4 pathe: 2.0.3 picomatch: 4.0.2 - pkg-types: 1.3.1 + pkg-types: 2.1.0 scule: 1.3.0 - strip-literal: 2.1.1 - unplugin: 1.16.1 - transitivePeerDependencies: - - rollup + strip-literal: 3.0.0 + tinyglobby: 0.2.12 + unplugin: 2.2.2 + unplugin-utils: 0.2.4 universalify@0.1.2: {} @@ -23906,55 +23006,55 @@ snapshots: unpipe@1.0.0: {} + unplugin-utils@0.2.4: + dependencies: + pathe: 2.0.3 + picomatch: 4.0.2 + unplugin@1.0.1: dependencies: - acorn: 8.14.0 + acorn: 8.14.1 chokidar: 3.6.0 webpack-sources: 3.2.3 webpack-virtual-modules: 0.5.0 unplugin@1.16.1: dependencies: - acorn: 8.14.0 + acorn: 8.14.1 webpack-virtual-modules: 0.6.2 - unplugin@2.1.2: + unplugin@2.2.2: dependencies: - acorn: 8.14.0 + acorn: 8.14.1 webpack-virtual-modules: 0.6.2 - unstorage@1.14.4(db0@0.2.3)(ioredis@5.4.2): + unstorage@1.15.0(db0@0.3.1)(ioredis@5.6.0): dependencies: anymatch: 3.1.3 - chokidar: 3.6.0 + chokidar: 4.0.3 destr: 2.0.3 - h3: 1.13.0 + h3: 1.15.1 lru-cache: 10.4.3 node-fetch-native: 1.6.6 ofetch: 1.4.1 ufo: 1.5.4 optionalDependencies: - db0: 0.2.3 - ioredis: 5.4.2 + db0: 0.3.1 + ioredis: 5.6.0 untun@0.1.3: dependencies: citty: 0.1.6 - consola: 3.4.0 + consola: 3.4.2 pathe: 1.1.2 - untyped@1.5.2: + untyped@2.0.0: dependencies: - '@babel/core': 7.26.8 - '@babel/standalone': 7.26.7 - '@babel/types': 7.26.8 citty: 0.1.6 defu: 6.1.4 jiti: 2.4.2 knitwork: 1.2.0 scule: 1.3.0 - transitivePeerDependencies: - - supports-color unwasm@0.3.9: dependencies: @@ -23975,8 +23075,6 @@ snapshots: uqr@0.1.2: {} - uri-js-replace@1.0.1: {} - uri-js@4.4.1: dependencies: punycode: 2.3.1 @@ -23986,8 +23084,6 @@ snapshots: querystringify: 2.2.0 requires-port: 1.0.0 - urlpattern-polyfill@8.0.2: {} - use-callback-ref@1.3.3(@types/react@19.0.8)(react@19.0.0): dependencies: react: 19.0.0 @@ -24027,168 +23123,10 @@ snapshots: vary@1.1.2: {} - vinxi@0.5.1(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0): - dependencies: - '@babel/core': 7.26.8 - '@babel/plugin-syntax-jsx': 7.25.9(@babel/core@7.26.8) - '@babel/plugin-syntax-typescript': 7.25.9(@babel/core@7.26.8) - '@types/micromatch': 4.0.9 - '@vinxi/listhen': 1.5.6 - boxen: 7.1.1 - chokidar: 3.6.0 - citty: 0.1.6 - consola: 3.4.0 - crossws: 0.3.3 - dax-sh: 0.39.2 - defu: 6.1.4 - es-module-lexer: 1.6.0 - esbuild: 0.20.2 - fast-glob: 3.3.3 - get-port-please: 3.1.2 - h3: 1.13.0 - hookable: 5.5.3 - http-proxy: 1.18.1 - micromatch: 4.0.8 - nitropack: 2.10.4(typescript@5.8.2) - node-fetch-native: 1.6.6 - path-to-regexp: 6.3.0 - pathe: 1.1.2 - radix3: 1.1.2 - resolve: 1.22.10 - serve-placeholder: 2.0.2 - serve-static: 1.16.2 - ufo: 1.5.4 - unctx: 2.4.1 - unenv: 1.10.0 - unstorage: 1.14.4(db0@0.2.3)(ioredis@5.4.2) - vite: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) - zod: 3.24.2 - transitivePeerDependencies: - - '@azure/app-configuration' - - '@azure/cosmos' - - '@azure/data-tables' - - '@azure/identity' - - '@azure/keyvault-secrets' - - '@azure/storage-blob' - - '@capacitor/preferences' - - '@deno/kv' - - '@electric-sql/pglite' - - '@libsql/client' - - '@netlify/blobs' - - '@planetscale/database' - - '@types/node' - - '@upstash/redis' - - '@vercel/blob' - - '@vercel/kv' - - aws4fetch - - better-sqlite3 - - db0 - - debug - - drizzle-orm - - encoding - - idb-keyval - - ioredis - - jiti - - less - - lightningcss - - mysql2 - - rolldown - - sass - - sass-embedded - - sqlite3 - - stylus - - sugarss - - supports-color - - terser - - tsx - - typescript - - uploadthing - - xml2js - - yaml - - vinxi@0.5.3(@types/node@22.13.4)(db0@0.2.3)(ioredis@5.4.2)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(typescript@5.8.2)(yaml@2.7.0): - dependencies: - '@babel/core': 7.26.8 - '@babel/plugin-syntax-jsx': 7.25.9(@babel/core@7.26.8) - '@babel/plugin-syntax-typescript': 7.25.9(@babel/core@7.26.8) - '@types/micromatch': 4.0.9 - '@vinxi/listhen': 1.5.6 - boxen: 7.1.1 - chokidar: 3.6.0 - citty: 0.1.6 - consola: 3.4.0 - crossws: 0.3.3 - dax-sh: 0.39.2 - defu: 6.1.4 - es-module-lexer: 1.6.0 - esbuild: 0.20.2 - fast-glob: 3.3.3 - get-port-please: 3.1.2 - h3: 1.13.0 - hookable: 5.5.3 - http-proxy: 1.18.1 - micromatch: 4.0.8 - nitropack: 2.10.4(typescript@5.8.2) - node-fetch-native: 1.6.6 - path-to-regexp: 6.3.0 - pathe: 1.1.2 - radix3: 1.1.2 - resolve: 1.22.10 - serve-placeholder: 2.0.2 - serve-static: 1.16.2 - ufo: 1.5.4 - unctx: 2.4.1 - unenv: 1.10.0 - unstorage: 1.14.4(db0@0.2.3)(ioredis@5.4.2) - vite: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) - zod: 3.24.2 - transitivePeerDependencies: - - '@azure/app-configuration' - - '@azure/cosmos' - - '@azure/data-tables' - - '@azure/identity' - - '@azure/keyvault-secrets' - - '@azure/storage-blob' - - '@capacitor/preferences' - - '@deno/kv' - - '@electric-sql/pglite' - - '@libsql/client' - - '@netlify/blobs' - - '@planetscale/database' - - '@types/node' - - '@upstash/redis' - - '@vercel/blob' - - '@vercel/kv' - - aws4fetch - - better-sqlite3 - - db0 - - debug - - drizzle-orm - - encoding - - idb-keyval - - ioredis - - jiti - - less - - lightningcss - - mysql2 - - rolldown - - sass - - sass-embedded - - sqlite3 - - stylus - - sugarss - - supports-color - - terser - - tsx - - typescript - - uploadthing - - xml2js - - yaml - vite-node@3.0.6(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0): dependencies: cac: 6.7.14 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 es-module-lexer: 1.6.0 pathe: 2.0.3 vite: 6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0) @@ -24206,14 +23144,14 @@ snapshots: - tsx - yaml - vite-plugin-dts@4.0.3(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)): + vite-plugin-dts@4.0.3(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)): dependencies: '@microsoft/api-extractor': 7.47.4(@types/node@22.13.4) - '@rollup/pluginutils': 5.1.4(rollup@4.39.0) + '@rollup/pluginutils': 5.1.4(rollup@4.38.0) '@volar/typescript': 2.4.11 '@vue/language-core': 2.0.29(typescript@5.8.2) compare-versions: 6.1.1 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 kolorist: 1.8.0 local-pkg: 0.5.1 magic-string: 0.30.17 @@ -24226,14 +23164,14 @@ snapshots: - rollup - supports-color - vite-plugin-dts@4.5.0(@types/node@22.13.4)(rollup@4.39.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)): + vite-plugin-dts@4.5.0(@types/node@22.13.4)(rollup@4.38.0)(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)): dependencies: '@microsoft/api-extractor': 7.49.2(@types/node@22.13.4) - '@rollup/pluginutils': 5.1.4(rollup@4.39.0) + '@rollup/pluginutils': 5.1.4(rollup@4.38.0) '@volar/typescript': 2.4.11 '@vue/language-core': 2.2.0(typescript@5.8.2) compare-versions: 6.1.1 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 kolorist: 1.8.0 local-pkg: 0.5.1 magic-string: 0.30.17 @@ -24266,7 +23204,7 @@ snapshots: vite-tsconfig-paths@5.1.4(typescript@5.8.2)(vite@6.1.4(@types/node@22.13.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)): dependencies: - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 globrex: 0.1.2 tsconfck: 3.1.4(typescript@5.8.2) optionalDependencies: @@ -24279,7 +23217,7 @@ snapshots: dependencies: esbuild: 0.24.2 postcss: 8.5.3 - rollup: 4.39.0 + rollup: 4.38.0 optionalDependencies: '@types/node': 22.13.4 fsevents: 2.3.3 @@ -24303,11 +23241,11 @@ snapshots: '@vitest/spy': 3.0.6 '@vitest/utils': 3.0.6 chai: 5.2.0 - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 expect-type: 1.1.0 magic-string: 0.30.17 pathe: 2.0.3 - std-env: 3.8.0 + std-env: 3.8.1 tinybench: 2.9.0 tinyexec: 0.3.2 tinypool: 1.0.2 @@ -24338,14 +23276,14 @@ snapshots: vue-eslint-parser@9.4.3(eslint@9.22.0(jiti@2.4.2)): dependencies: - debug: 4.4.0(supports-color@9.4.0) + debug: 4.4.0 eslint: 9.22.0(jiti@2.4.2) eslint-scope: 7.2.2 eslint-visitor-keys: 3.4.3 espree: 9.6.1 esquery: 1.6.0 lodash: 4.17.21 - semver: 7.7.0 + semver: 7.7.1 transitivePeerDependencies: - supports-color @@ -24353,7 +23291,7 @@ snapshots: dependencies: '@volar/typescript': 2.4.11 '@vue/language-core': 2.0.29(typescript@5.8.2) - semver: 7.7.0 + semver: 7.7.1 typescript: 5.8.2 w3c-xmlserializer@5.0.0: @@ -24403,7 +23341,7 @@ snapshots: import-local: 3.2.0 interpret: 3.1.1 rechoir: 0.8.0 - webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack-cli@5.1.4) webpack-merge: 5.10.0 optionalDependencies: webpack-dev-server: 5.2.0(webpack-cli@5.1.4)(webpack@5.97.1) @@ -24417,7 +23355,7 @@ snapshots: range-parser: 1.2.1 schema-utils: 4.3.0 optionalDependencies: - webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack-cli@5.1.4) webpack-dev-server@5.2.0(webpack-cli@5.1.4)(webpack@5.97.1): dependencies: @@ -24449,7 +23387,7 @@ snapshots: webpack-dev-middleware: 7.4.2(webpack@5.97.1) ws: 8.18.0 optionalDependencies: - webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack-dev-server@5.2.0)(webpack@5.97.1) transitivePeerDependencies: - bufferutil @@ -24469,14 +23407,14 @@ snapshots: webpack-virtual-modules@0.6.2: {} - webpack@5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0): + webpack@5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2): dependencies: '@types/eslint-scope': 3.7.7 '@types/estree': 1.0.7 '@webassemblyjs/ast': 1.14.1 '@webassemblyjs/wasm-edit': 1.14.1 '@webassemblyjs/wasm-parser': 1.14.1 - acorn: 8.14.0 + acorn: 8.14.1 browserslist: 4.24.4 chrome-trace-event: 1.0.4 enhanced-resolve: 5.18.1 @@ -24491,7 +23429,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.11(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack@5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)) + terser-webpack-plugin: 5.3.11(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack@5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)) watchpack: 2.4.2 webpack-sources: 3.2.3 transitivePeerDependencies: @@ -24499,14 +23437,14 @@ snapshots: - esbuild - uglify-js - webpack@5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack-cli@5.1.4): + webpack@5.97.1(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack-cli@5.1.4): dependencies: '@types/eslint-scope': 3.7.7 '@types/estree': 1.0.7 '@webassemblyjs/ast': 1.14.1 '@webassemblyjs/wasm-edit': 1.14.1 '@webassemblyjs/wasm-parser': 1.14.1 - acorn: 8.14.0 + acorn: 8.14.1 browserslist: 4.24.4 chrome-trace-event: 1.0.4 enhanced-resolve: 5.18.1 @@ -24521,7 +23459,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.11(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.0)(webpack@5.97.1) + terser-webpack-plugin: 5.3.11(@swc/core@1.10.15(@swc/helpers@0.5.15))(esbuild@0.25.2)(webpack@5.97.1) watchpack: 2.4.2 webpack-sources: 3.2.3 optionalDependencies: @@ -24563,19 +23501,11 @@ snapshots: dependencies: isexe: 2.0.0 - which@4.0.0: - dependencies: - isexe: 3.1.1 - why-is-node-running@2.3.0: dependencies: siginfo: 2.0.0 stackback: 0.0.2 - widest-line@4.0.1: - dependencies: - string-width: 5.1.2 - wildcard@2.0.1: {} word-wrap@1.2.5: {} @@ -24604,6 +23534,13 @@ snapshots: xml-name-validator@5.0.0: {} + xmlbuilder2@3.1.1: + dependencies: + '@oozcitak/dom': 1.15.10 + '@oozcitak/infra': 1.0.8 + '@oozcitak/util': 8.3.8 + js-yaml: 3.14.1 + xmlchars@2.2.0: {} y18n@5.0.8: {} @@ -24614,8 +23551,6 @@ snapshots: yallist@5.0.0: {} - yaml-ast-parser@0.0.43: {} - yaml@1.10.2: {} yaml@2.7.0: {} @@ -24648,6 +23583,18 @@ snapshots: yoctocolors-cjs@2.1.2: {} + youch-core@0.3.2: + dependencies: + '@poppinss/exception': 1.2.1 + error-stack-parser-es: 1.0.5 + + youch@4.1.0-beta.7: + dependencies: + '@poppinss/dumper': 0.6.3 + '@speed-highlight/core': 1.2.7 + cookie: 1.0.2 + youch-core: 0.3.2 + zip-stream@6.0.1: dependencies: archiver-utils: 5.0.2 diff --git a/scripts/generateLabelerConfig.mjs b/scripts/generateLabelerConfig.mjs index 6b02b962fc..e38ef6e323 100644 --- a/scripts/generateLabelerConfig.mjs +++ b/scripts/generateLabelerConfig.mjs @@ -8,7 +8,7 @@ function generateLabelerConfig() { * Pairs of package labels and their corresponding paths * @type {Array<[string, string]>} **/ - const pairs = [] + let pairs = [] // Add subfolders in the packages folder, i.e. packages/** fs.readdirSync(path.resolve('packages')) @@ -28,6 +28,9 @@ function generateLabelerConfig() { } }) + // Sort by package name in alphabetical order + pairs.sort((a, b) => a[0].localeCompare(b[0])) + // Always add the docs folder pairs.push(['documentation', 'docs/**/*']) diff --git a/scripts/publish.js b/scripts/publish.js index 430c3a3c41..0f8c7d0e98 100644 --- a/scripts/publish.js +++ b/scripts/publish.js @@ -92,21 +92,13 @@ await publish({ name: '@tanstack/solid-start', packageDir: 'packages/solid-start', }, - { - name: '@tanstack/solid-start-client', - packageDir: 'packages/solid-start-client', - }, - { - name: '@tanstack/solid-start-config', - packageDir: 'packages/solid-start-config', - }, { name: '@tanstack/solid-start-plugin', packageDir: 'packages/solid-start-plugin', }, { - name: '@tanstack/solid-start-router-manifest', - packageDir: 'packages/solid-start-router-manifest', + name: '@tanstack/solid-start-client', + packageDir: 'packages/solid-start-client', }, { name: '@tanstack/solid-start-server', @@ -136,45 +128,21 @@ await publish({ name: '@tanstack/react-start-server', packageDir: 'packages/react-start-server', }, - { - name: '@tanstack/start-config', - packageDir: 'packages/start-config', - }, - { - name: '@tanstack/react-start-config', - packageDir: 'packages/react-start-config', - }, - { - name: '@tanstack/start-api-routes', - packageDir: 'packages/start-api-routes', - }, { name: '@tanstack/start-server-functions-fetcher', packageDir: 'packages/start-server-functions-fetcher', }, - { - name: '@tanstack/start-server-functions-handler', - packageDir: 'packages/start-server-functions-handler', - }, { name: '@tanstack/start-server-functions-client', packageDir: 'packages/start-server-functions-client', }, - { - name: '@tanstack/start-server-functions-ssr', - packageDir: 'packages/start-server-functions-ssr', - }, { name: '@tanstack/start-server-functions-server', packageDir: 'packages/start-server-functions-server', }, { - name: '@tanstack/react-start-router-manifest', - packageDir: 'packages/react-start-router-manifest', - }, - { - name: '@tanstack/start', - packageDir: 'packages/start', + name: '@tanstack/start-plugin-core', + packageDir: 'packages/start-plugin-core', }, { name: '@tanstack/router-utils',