@tanstack/router-generator 1.166.29 → 1.166.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/cjs/config.cjs +0 -1
  2. package/dist/cjs/config.cjs.map +1 -1
  3. package/dist/cjs/config.d.cts +0 -3
  4. package/dist/cjs/filesystem/physical/getRouteNodes.cjs +5 -4
  5. package/dist/cjs/filesystem/physical/getRouteNodes.cjs.map +1 -1
  6. package/dist/cjs/filesystem/virtual/getRouteNodes.cjs +2 -2
  7. package/dist/cjs/filesystem/virtual/getRouteNodes.cjs.map +1 -1
  8. package/dist/cjs/generator.cjs +1 -44
  9. package/dist/cjs/generator.cjs.map +1 -1
  10. package/dist/cjs/index.cjs +0 -2
  11. package/dist/cjs/index.d.cts +1 -2
  12. package/dist/cjs/template.cjs +15 -12
  13. package/dist/cjs/template.cjs.map +1 -1
  14. package/dist/cjs/transform/transform.cjs +283 -266
  15. package/dist/cjs/transform/transform.cjs.map +1 -1
  16. package/dist/cjs/transform/transform.d.cts +1 -3
  17. package/dist/cjs/transform/types.d.cts +1 -7
  18. package/dist/cjs/utils.cjs +0 -16
  19. package/dist/cjs/utils.cjs.map +1 -1
  20. package/dist/cjs/utils.d.cts +0 -24
  21. package/dist/esm/config.d.ts +0 -3
  22. package/dist/esm/config.js +0 -1
  23. package/dist/esm/config.js.map +1 -1
  24. package/dist/esm/filesystem/physical/getRouteNodes.js +6 -5
  25. package/dist/esm/filesystem/physical/getRouteNodes.js.map +1 -1
  26. package/dist/esm/filesystem/virtual/getRouteNodes.js +3 -3
  27. package/dist/esm/filesystem/virtual/getRouteNodes.js.map +1 -1
  28. package/dist/esm/generator.js +2 -45
  29. package/dist/esm/generator.js.map +1 -1
  30. package/dist/esm/index.d.ts +1 -2
  31. package/dist/esm/index.js +1 -2
  32. package/dist/esm/template.js +15 -12
  33. package/dist/esm/template.js.map +1 -1
  34. package/dist/esm/transform/transform.d.ts +1 -3
  35. package/dist/esm/transform/transform.js +280 -265
  36. package/dist/esm/transform/transform.js.map +1 -1
  37. package/dist/esm/transform/types.d.ts +1 -7
  38. package/dist/esm/utils.d.ts +0 -24
  39. package/dist/esm/utils.js +1 -15
  40. package/dist/esm/utils.js.map +1 -1
  41. package/package.json +4 -4
  42. package/src/config.ts +0 -1
  43. package/src/filesystem/physical/getRouteNodes.ts +10 -4
  44. package/src/filesystem/virtual/getRouteNodes.ts +7 -2
  45. package/src/generator.ts +0 -66
  46. package/src/index.ts +1 -7
  47. package/src/template.ts +16 -36
  48. package/src/transform/transform.ts +633 -446
  49. package/src/transform/types.ts +1 -8
  50. package/src/utils.ts +5 -43
  51. package/dist/cjs/transform/utils.cjs +0 -34
  52. package/dist/cjs/transform/utils.cjs.map +0 -1
  53. package/dist/cjs/transform/utils.d.cts +0 -2
  54. package/dist/esm/transform/utils.d.ts +0 -2
  55. package/dist/esm/transform/utils.js +0 -34
  56. package/dist/esm/transform/utils.js.map +0 -1
  57. package/src/transform/utils.ts +0 -42
package/src/generator.ts CHANGED
@@ -25,10 +25,8 @@ import {
25
25
  findParent,
26
26
  format,
27
27
  getImportForRouteNode,
28
- getImportPath,
29
28
  getResolvedRouteNodeVariableName,
30
29
  hasParentRoute,
31
- isRouteNodeValidForAugmentation,
32
30
  isSegmentPathless,
33
31
  mergeImportDeclarations,
34
32
  multiSortBy,
@@ -658,38 +656,6 @@ export class Generator {
658
656
  }
659
657
  imports.push(runtimeImport)
660
658
  }
661
- if (config.verboseFileRoutes === false) {
662
- const typeImport: ImportDeclaration = {
663
- specifiers: [],
664
- source: this.targetTemplate.fullPkg,
665
- importKind: 'type',
666
- }
667
- let needsCreateFileRoute = false
668
- let needsCreateLazyFileRoute = false
669
- for (const node of sortedRouteNodes) {
670
- if (isRouteNodeValidForAugmentation(node)) {
671
- if (node._fsRouteType !== 'lazy') {
672
- needsCreateFileRoute = true
673
- }
674
- if (acc.routePiecesByPath[node.routePath!]?.lazy) {
675
- needsCreateLazyFileRoute = true
676
- }
677
- }
678
- if (needsCreateFileRoute && needsCreateLazyFileRoute) break
679
- }
680
- if (needsCreateFileRoute) {
681
- typeImport.specifiers.push({ imported: 'CreateFileRoute' })
682
- }
683
- if (needsCreateLazyFileRoute) {
684
- typeImport.specifiers.push({ imported: 'CreateLazyFileRoute' })
685
- }
686
-
687
- if (typeImport.specifiers.length > 0) {
688
- typeImport.specifiers.push({ imported: 'FileRoutesByPath' })
689
- imports.push(typeImport)
690
- }
691
- }
692
-
693
659
  const routeTreeConfig = buildRouteTreeConfig(
694
660
  acc.routeTree,
695
661
  config.disableTypes,
@@ -963,36 +929,6 @@ ${acc.routeTree.map((child) => `${child.variableName}Route: typeof ${getResolved
963
929
 
964
930
  const importStatements = mergedImports.map(buildImportString)
965
931
 
966
- let moduleAugmentation = ''
967
- if (config.verboseFileRoutes === false && !config.disableTypes) {
968
- moduleAugmentation = opts.routeFileResult
969
- .map((node) => {
970
- const getModuleDeclaration = (routeNode?: RouteNode) => {
971
- if (!isRouteNodeValidForAugmentation(routeNode)) {
972
- return ''
973
- }
974
- let moduleAugmentation = ''
975
- if (routeNode._fsRouteType === 'lazy') {
976
- moduleAugmentation = `const createLazyFileRoute: CreateLazyFileRoute<FileRoutesByPath['${routeNode.routePath}']['preLoaderRoute']>`
977
- } else {
978
- moduleAugmentation = `const createFileRoute: CreateFileRoute<'${routeNode.routePath}',
979
- FileRoutesByPath['${routeNode.routePath}']['parentRoute'],
980
- FileRoutesByPath['${routeNode.routePath}']['id'],
981
- FileRoutesByPath['${routeNode.routePath}']['path'],
982
- FileRoutesByPath['${routeNode.routePath}']['fullPath']
983
- >
984
- `
985
- }
986
-
987
- return `declare module './${getImportPath(routeNode, config, this.generatedRouteTreePath)}' {
988
- ${moduleAugmentation}
989
- }`
990
- }
991
- return getModuleDeclaration(node)
992
- })
993
- .join('\n')
994
- }
995
-
996
932
  const rootRouteImport = getImportForRouteNode(
997
933
  rootRouteNode,
998
934
  config,
@@ -1020,7 +956,6 @@ ${acc.routeTree.map((child) => `${child.variableName}Route: typeof ${getResolved
1020
956
  createUpdateRoutes.join('\n'),
1021
957
  fileRoutesByFullPath,
1022
958
  fileRoutesByPathInterface,
1023
- moduleAugmentation,
1024
959
  routeTreeConfig.join('\n'),
1025
960
  routeTree,
1026
961
  ...footer,
@@ -1138,7 +1073,6 @@ ${acc.routeTree.map((child) => `${child.variableName}Route: typeof ${getResolved
1138
1073
  target: this.config.target,
1139
1074
  routeId: escapedRoutePath,
1140
1075
  lazy: node._fsRouteType === 'lazy',
1141
- verboseFileRoutes: !(this.config.verboseFileRoutes === false),
1142
1076
  },
1143
1077
  node,
1144
1078
  })
package/src/index.ts CHANGED
@@ -45,10 +45,4 @@ export { getRouteNodes as virtualGetRouteNodes } from './filesystem/virtual/getR
45
45
 
46
46
  export { rootPathId } from './filesystem/physical/rootPathId'
47
47
 
48
- export { ensureStringArgument } from './transform/utils'
49
-
50
- export type {
51
- TransformImportsConfig,
52
- TransformContext,
53
- TransformOptions,
54
- } from './transform/types'
48
+ export type { TransformContext, TransformOptions } from './transform/types'
package/src/template.ts CHANGED
@@ -44,6 +44,10 @@ export type TargetTemplate = {
44
44
  }
45
45
  }
46
46
 
47
+ function serializeRoutePath(routePath: string) {
48
+ return JSON.stringify(routePath)
49
+ }
50
+
47
51
  export function getTargetTemplate(config: Config): TargetTemplate {
48
52
  const target = config.target
49
53
  switch (target) {
@@ -77,13 +81,9 @@ export function getTargetTemplate(config: Config): TargetTemplate {
77
81
  ].join(''),
78
82
  imports: {
79
83
  tsrImports: () =>
80
- config.verboseFileRoutes === false
81
- ? ''
82
- : "import { createFileRoute } from '@tanstack/react-router';",
84
+ "import { createFileRoute } from '@tanstack/react-router';",
83
85
  tsrExportStart: (routePath) =>
84
- config.verboseFileRoutes === false
85
- ? 'export const Route = createFileRoute('
86
- : `export const Route = createFileRoute('${routePath}')(`,
86
+ `export const Route = createFileRoute(${serializeRoutePath(routePath)})(`,
87
87
  tsrExportEnd: () => ');',
88
88
  },
89
89
  },
@@ -97,13 +97,9 @@ export function getTargetTemplate(config: Config): TargetTemplate {
97
97
  ].join(''),
98
98
  imports: {
99
99
  tsrImports: () =>
100
- config.verboseFileRoutes === false
101
- ? ''
102
- : "import { createLazyFileRoute } from '@tanstack/react-router';",
100
+ "import { createLazyFileRoute } from '@tanstack/react-router';",
103
101
  tsrExportStart: (routePath) =>
104
- config.verboseFileRoutes === false
105
- ? 'export const Route = createLazyFileRoute('
106
- : `export const Route = createLazyFileRoute('${routePath}')(`,
102
+ `export const Route = createLazyFileRoute(${serializeRoutePath(routePath)})(`,
107
103
  tsrExportEnd: () => ');',
108
104
  },
109
105
  },
@@ -138,13 +134,9 @@ export function getTargetTemplate(config: Config): TargetTemplate {
138
134
  ].join(''),
139
135
  imports: {
140
136
  tsrImports: () =>
141
- config.verboseFileRoutes === false
142
- ? ''
143
- : "import { createFileRoute } from '@tanstack/solid-router';",
137
+ "import { createFileRoute } from '@tanstack/solid-router';",
144
138
  tsrExportStart: (routePath) =>
145
- config.verboseFileRoutes === false
146
- ? 'export const Route = createFileRoute('
147
- : `export const Route = createFileRoute('${routePath}')(`,
139
+ `export const Route = createFileRoute(${serializeRoutePath(routePath)})(`,
148
140
  tsrExportEnd: () => ');',
149
141
  },
150
142
  },
@@ -158,14 +150,10 @@ export function getTargetTemplate(config: Config): TargetTemplate {
158
150
  ].join(''),
159
151
  imports: {
160
152
  tsrImports: () =>
161
- config.verboseFileRoutes === false
162
- ? ''
163
- : "import { createLazyFileRoute } from '@tanstack/solid-router';",
153
+ "import { createLazyFileRoute } from '@tanstack/solid-router';",
164
154
 
165
155
  tsrExportStart: (routePath) =>
166
- config.verboseFileRoutes === false
167
- ? 'export const Route = createLazyFileRoute('
168
- : `export const Route = createLazyFileRoute('${routePath}')(`,
156
+ `export const Route = createLazyFileRoute(${serializeRoutePath(routePath)})(`,
169
157
 
170
158
  tsrExportEnd: () => ');',
171
159
  },
@@ -202,13 +190,9 @@ export function getTargetTemplate(config: Config): TargetTemplate {
202
190
  ].join(''),
203
191
  imports: {
204
192
  tsrImports: () =>
205
- config.verboseFileRoutes === false
206
- ? ''
207
- : "import { createFileRoute } from '@tanstack/vue-router';",
193
+ "import { createFileRoute } from '@tanstack/vue-router';",
208
194
  tsrExportStart: (routePath) =>
209
- config.verboseFileRoutes === false
210
- ? 'export const Route = createFileRoute('
211
- : `export const Route = createFileRoute('${routePath}')(`,
195
+ `export const Route = createFileRoute(${serializeRoutePath(routePath)})(`,
212
196
  tsrExportEnd: () => ');',
213
197
  },
214
198
  },
@@ -223,14 +207,10 @@ export function getTargetTemplate(config: Config): TargetTemplate {
223
207
  ].join(''),
224
208
  imports: {
225
209
  tsrImports: () =>
226
- config.verboseFileRoutes === false
227
- ? ''
228
- : "import { createLazyFileRoute } from '@tanstack/vue-router';",
210
+ "import { createLazyFileRoute } from '@tanstack/vue-router';",
229
211
 
230
212
  tsrExportStart: (routePath) =>
231
- config.verboseFileRoutes === false
232
- ? 'export const Route = createLazyFileRoute('
233
- : `export const Route = createLazyFileRoute('${routePath}')(`,
213
+ `export const Route = createLazyFileRoute(${serializeRoutePath(routePath)})(`,
234
214
 
235
215
  tsrExportEnd: () => ');',
236
216
  },