Skip to content

Commit 038cd12

Browse files
1 parent b1c061a commit 038cd12

19 files changed

Lines changed: 390 additions & 1 deletion

File tree

‎.changeset/quiet-rivers-serve.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/router-generator': patch
3+
---
4+
5+
Resolve tsconfig path aliases when loading virtual route config files.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { createJiti } from 'jiti'
22

33
export async function loadConfigFile(filePath: string) {
4-
const jiti = createJiti(filePath, { interopDefault: false })
4+
const jiti = createJiti(filePath, {
5+
interopDefault: false,
6+
tsconfigPaths: true,
7+
})
58
const loaded = await jiti.import<any>(filePath)
69
return loaded
710
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { physical } from '@tanstack/virtual-file-routes'
2+
3+
export const helloSubtree = physical('/hello', 'subtree')
Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
/* eslint-disable */
2+
3+
// @ts-nocheck
4+
5+
// noinspection JSUnusedGlobalSymbols
6+
7+
// This file was automatically generated by TanStack Router.
8+
// You should NOT make any changes in this file as it will be overwritten.
9+
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
10+
11+
import { Route as rootRouteImport } from './routes/root'
12+
import { Route as layoutRouteImport } from './routes/layout'
13+
import { Route as indexRouteImport } from './routes/index'
14+
import { Route as dbDashboardRouteImport } from './routes/db/dashboard'
15+
import { Route as pagesRouteImport } from './routes/pages'
16+
import { Route as HelloIndexRouteImport } from './routes/subtree/index'
17+
import { Route as dbDashboardInvoicesRouteImport } from './routes/db/dashboard-invoices'
18+
import { Route as dbDashboardIndexRouteImport } from './routes/db/dashboard-index'
19+
import { Route as HelloFooIndexRouteImport } from './routes/subtree/foo/index'
20+
import { Route as HelloFooIdRouteImport } from './routes/subtree/foo/$id'
21+
import { Route as dbInvoiceDetailRouteImport } from './routes/db/invoice-detail'
22+
import { Route as dbInvoicesIndexRouteImport } from './routes/db/invoices-index'
23+
24+
const layoutRoute = layoutRouteImport.update({
25+
id: '/_layout',
26+
getParentRoute: () => rootRouteImport,
27+
} as any)
28+
const indexRoute = indexRouteImport.update({
29+
id: '/',
30+
path: '/',
31+
getParentRoute: () => rootRouteImport,
32+
} as any)
33+
const dbDashboardRoute = dbDashboardRouteImport.update({
34+
id: '/dashboard',
35+
path: '/dashboard',
36+
getParentRoute: () => layoutRoute,
37+
} as any)
38+
const pagesRoute = pagesRouteImport.update({
39+
id: '/$lang/',
40+
path: '/$lang/',
41+
getParentRoute: () => rootRouteImport,
42+
} as any)
43+
const HelloIndexRoute = HelloIndexRouteImport.update({
44+
id: '/hello/',
45+
path: '/hello/',
46+
getParentRoute: () => layoutRoute,
47+
} as any)
48+
const dbDashboardInvoicesRoute = dbDashboardInvoicesRouteImport.update({
49+
id: '/invoices',
50+
path: '/invoices',
51+
getParentRoute: () => dbDashboardRoute,
52+
} as any)
53+
const dbDashboardIndexRoute = dbDashboardIndexRouteImport.update({
54+
id: '/',
55+
path: '/',
56+
getParentRoute: () => dbDashboardRoute,
57+
} as any)
58+
const HelloFooIndexRoute = HelloFooIndexRouteImport.update({
59+
id: '/hello/foo/',
60+
path: '/hello/foo/',
61+
getParentRoute: () => layoutRoute,
62+
} as any)
63+
const HelloFooIdRoute = HelloFooIdRouteImport.update({
64+
id: '/hello/foo/$id',
65+
path: '/hello/foo/$id',
66+
getParentRoute: () => layoutRoute,
67+
} as any)
68+
const dbInvoiceDetailRoute = dbInvoiceDetailRouteImport.update({
69+
id: '/$id',
70+
path: '/$id',
71+
getParentRoute: () => dbDashboardInvoicesRoute,
72+
} as any)
73+
const dbInvoicesIndexRoute = dbInvoicesIndexRouteImport.update({
74+
id: '/',
75+
path: '/',
76+
getParentRoute: () => dbDashboardInvoicesRoute,
77+
} as any)
78+
79+
export interface FileRoutesByFullPath {
80+
'/': typeof indexRoute
81+
'/$lang/': typeof pagesRoute
82+
'/dashboard': typeof dbDashboardRouteWithChildren
83+
'/dashboard/': typeof dbDashboardIndexRoute
84+
'/dashboard/invoices': typeof dbDashboardInvoicesRouteWithChildren
85+
'/hello/': typeof HelloIndexRoute
86+
'/dashboard/invoices/': typeof dbInvoicesIndexRoute
87+
'/dashboard/invoices/$id': typeof dbInvoiceDetailRoute
88+
'/hello/foo/$id': typeof HelloFooIdRoute
89+
'/hello/foo/': typeof HelloFooIndexRoute
90+
}
91+
export interface FileRoutesByTo {
92+
'/': typeof indexRoute
93+
'/$lang': typeof pagesRoute
94+
'/dashboard': typeof dbDashboardIndexRoute
95+
'/hello': typeof HelloIndexRoute
96+
'/dashboard/invoices': typeof dbInvoicesIndexRoute
97+
'/dashboard/invoices/$id': typeof dbInvoiceDetailRoute
98+
'/hello/foo/$id': typeof HelloFooIdRoute
99+
'/hello/foo': typeof HelloFooIndexRoute
100+
}
101+
export interface FileRoutesById {
102+
__root__: typeof rootRouteImport
103+
'/': typeof indexRoute
104+
'/_layout': typeof layoutRouteWithChildren
105+
'/$lang/': typeof pagesRoute
106+
'/_layout/dashboard': typeof dbDashboardRouteWithChildren
107+
'/_layout/dashboard/': typeof dbDashboardIndexRoute
108+
'/_layout/dashboard/invoices': typeof dbDashboardInvoicesRouteWithChildren
109+
'/_layout/hello/': typeof HelloIndexRoute
110+
'/_layout/dashboard/invoices/': typeof dbInvoicesIndexRoute
111+
'/_layout/dashboard/invoices/$id': typeof dbInvoiceDetailRoute
112+
'/_layout/hello/foo/$id': typeof HelloFooIdRoute
113+
'/_layout/hello/foo/': typeof HelloFooIndexRoute
114+
}
115+
export interface FileRouteTypes {
116+
fileRoutesByFullPath: FileRoutesByFullPath
117+
fullPaths:
118+
| '/'
119+
| '/$lang/'
120+
| '/dashboard'
121+
| '/dashboard/'
122+
| '/dashboard/invoices'
123+
| '/hello/'
124+
| '/dashboard/invoices/'
125+
| '/dashboard/invoices/$id'
126+
| '/hello/foo/$id'
127+
| '/hello/foo/'
128+
fileRoutesByTo: FileRoutesByTo
129+
to:
130+
| '/'
131+
| '/$lang'
132+
| '/dashboard'
133+
| '/hello'
134+
| '/dashboard/invoices'
135+
| '/dashboard/invoices/$id'
136+
| '/hello/foo/$id'
137+
| '/hello/foo'
138+
id:
139+
| '__root__'
140+
| '/'
141+
| '/_layout'
142+
| '/$lang/'
143+
| '/_layout/dashboard'
144+
| '/_layout/dashboard/'
145+
| '/_layout/dashboard/invoices'
146+
| '/_layout/hello/'
147+
| '/_layout/dashboard/invoices/'
148+
| '/_layout/dashboard/invoices/$id'
149+
| '/_layout/hello/foo/$id'
150+
| '/_layout/hello/foo/'
151+
fileRoutesById: FileRoutesById
152+
}
153+
export interface RootRouteChildren {
154+
indexRoute: typeof indexRoute
155+
layoutRoute: typeof layoutRouteWithChildren
156+
pagesRoute: typeof pagesRoute
157+
}
158+
159+
declare module '@tanstack/react-router' {
160+
interface FileRoutesByPath {
161+
'/_layout': {
162+
id: '/_layout'
163+
path: ''
164+
fullPath: '/'
165+
preLoaderRoute: typeof layoutRouteImport
166+
parentRoute: typeof rootRouteImport
167+
}
168+
'/': {
169+
id: '/'
170+
path: '/'
171+
fullPath: '/'
172+
preLoaderRoute: typeof indexRouteImport
173+
parentRoute: typeof rootRouteImport
174+
}
175+
'/_layout/dashboard': {
176+
id: '/_layout/dashboard'
177+
path: '/dashboard'
178+
fullPath: '/dashboard'
179+
preLoaderRoute: typeof dbDashboardRouteImport
180+
parentRoute: typeof layoutRoute
181+
}
182+
'/$lang/': {
183+
id: '/$lang/'
184+
path: '/$lang'
185+
fullPath: '/$lang/'
186+
preLoaderRoute: typeof pagesRouteImport
187+
parentRoute: typeof rootRouteImport
188+
}
189+
'/_layout/hello/': {
190+
id: '/_layout/hello/'
191+
path: '/hello'
192+
fullPath: '/hello/'
193+
preLoaderRoute: typeof HelloIndexRouteImport
194+
parentRoute: typeof layoutRoute
195+
}
196+
'/_layout/dashboard/invoices': {
197+
id: '/_layout/dashboard/invoices'
198+
path: '/invoices'
199+
fullPath: '/dashboard/invoices'
200+
preLoaderRoute: typeof dbDashboardInvoicesRouteImport
201+
parentRoute: typeof dbDashboardRoute
202+
}
203+
'/_layout/dashboard/': {
204+
id: '/_layout/dashboard/'
205+
path: '/'
206+
fullPath: '/dashboard/'
207+
preLoaderRoute: typeof dbDashboardIndexRouteImport
208+
parentRoute: typeof dbDashboardRoute
209+
}
210+
'/_layout/hello/foo/': {
211+
id: '/_layout/hello/foo/'
212+
path: '/hello/foo'
213+
fullPath: '/hello/foo/'
214+
preLoaderRoute: typeof HelloFooIndexRouteImport
215+
parentRoute: typeof layoutRoute
216+
}
217+
'/_layout/hello/foo/$id': {
218+
id: '/_layout/hello/foo/$id'
219+
path: '/hello/foo/$id'
220+
fullPath: '/hello/foo/$id'
221+
preLoaderRoute: typeof HelloFooIdRouteImport
222+
parentRoute: typeof layoutRoute
223+
}
224+
'/_layout/dashboard/invoices/$id': {
225+
id: '/_layout/dashboard/invoices/$id'
226+
path: '/$id'
227+
fullPath: '/dashboard/invoices/$id'
228+
preLoaderRoute: typeof dbInvoiceDetailRouteImport
229+
parentRoute: typeof dbDashboardInvoicesRoute
230+
}
231+
'/_layout/dashboard/invoices/': {
232+
id: '/_layout/dashboard/invoices/'
233+
path: '/'
234+
fullPath: '/dashboard/invoices/'
235+
preLoaderRoute: typeof dbInvoicesIndexRouteImport
236+
parentRoute: typeof dbDashboardInvoicesRoute
237+
}
238+
}
239+
}
240+
241+
interface dbDashboardInvoicesRouteChildren {
242+
dbInvoicesIndexRoute: typeof dbInvoicesIndexRoute
243+
dbInvoiceDetailRoute: typeof dbInvoiceDetailRoute
244+
}
245+
246+
const dbDashboardInvoicesRouteChildren: dbDashboardInvoicesRouteChildren = {
247+
dbInvoicesIndexRoute: dbInvoicesIndexRoute,
248+
dbInvoiceDetailRoute: dbInvoiceDetailRoute,
249+
}
250+
251+
const dbDashboardInvoicesRouteWithChildren =
252+
dbDashboardInvoicesRoute._addFileChildren(dbDashboardInvoicesRouteChildren)
253+
254+
interface dbDashboardRouteChildren {
255+
dbDashboardIndexRoute: typeof dbDashboardIndexRoute
256+
dbDashboardInvoicesRoute: typeof dbDashboardInvoicesRouteWithChildren
257+
}
258+
259+
const dbDashboardRouteChildren: dbDashboardRouteChildren = {
260+
dbDashboardIndexRoute: dbDashboardIndexRoute,
261+
dbDashboardInvoicesRoute: dbDashboardInvoicesRouteWithChildren,
262+
}
263+
264+
const dbDashboardRouteWithChildren = dbDashboardRoute._addFileChildren(
265+
dbDashboardRouteChildren,
266+
)
267+
268+
interface layoutRouteChildren {
269+
dbDashboardRoute: typeof dbDashboardRouteWithChildren
270+
HelloIndexRoute: typeof HelloIndexRoute
271+
HelloFooIdRoute: typeof HelloFooIdRoute
272+
HelloFooIndexRoute: typeof HelloFooIndexRoute
273+
}
274+
275+
const layoutRouteChildren: layoutRouteChildren = {
276+
dbDashboardRoute: dbDashboardRouteWithChildren,
277+
HelloIndexRoute: HelloIndexRoute,
278+
HelloFooIdRoute: HelloFooIdRoute,
279+
HelloFooIndexRoute: HelloFooIndexRoute,
280+
}
281+
282+
const layoutRouteWithChildren =
283+
layoutRoute._addFileChildren(layoutRouteChildren)
284+
285+
const rootRouteChildren: RootRouteChildren = {
286+
indexRoute: indexRoute,
287+
layoutRoute: layoutRouteWithChildren,
288+
pagesRoute: pagesRoute,
289+
}
290+
export const routeTree = rootRouteImport
291+
._addFileChildren(rootRouteChildren)
292+
._addFileTypes<FileRouteTypes>()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// @ts-nocheck
2+
3+
import { index, layout, rootRoute, route } from '@tanstack/virtual-file-routes'
4+
import { helloSubtree } from '@/virtual-routes'
5+
6+
export default rootRoute('root.tsx', [
7+
index('index.tsx'),
8+
route('$lang', [index('pages.tsx')]),
9+
layout('layout.tsx', [
10+
route('/dashboard', 'db/dashboard.tsx', [
11+
index('db/dashboard-index.tsx'),
12+
route('/invoices', 'db/dashboard-invoices.tsx', [
13+
index('db/invoices-index.tsx'),
14+
route('$id', 'db/invoice-detail.tsx'),
15+
]),
16+
]),
17+
helloSubtree,
18+
]),
19+
])
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createFileRoute } from '@tanstack/react-router'
2+
export const Route = createFileRoute('/_layout/dashboard/')({
3+
component: () => <div>Hello !</div>,
4+
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createFileRoute } from '@tanstack/react-router'
2+
export const Route = createFileRoute('/_layout/dashboard/invoices')({
3+
component: () => <div>Hello !</div>,
4+
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createFileRoute } from '@tanstack/react-router'
2+
export const Route = createFileRoute('/_layout/dashboard')({
3+
component: () => <div>Hello !</div>,
4+
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createFileRoute } from '@tanstack/react-router'
2+
export const Route = createFileRoute('/_layout/dashboard/invoices/$id')({
3+
component: () => <div>Hello /_layout/dashboard/invoices/$id!</div>,
4+
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createFileRoute } from '@tanstack/react-router'
2+
export const Route = createFileRoute('/_layout/dashboard/invoices/')({
3+
component: () => <div>Hello /_layout/dashboard/invoices/!</div>,
4+
})

0 commit comments

Comments
 (0)