@tanstack/router-vite-plugin 1.4.3 → 1.4.5

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.
@@ -17,12 +17,9 @@ var index = require('../../../node_modules/.pnpm/zod@3.21.4/node_modules/zod/lib
17
17
  const configSchema = index.default.object({
18
18
  routeFilePrefix: index.default.string().optional(),
19
19
  routeFileIgnorePrefix: index.default.string().optional().default('-'),
20
- routesDirectory: index.default.string(),
21
- generatedRouteTree: index.default.string(),
22
- quoteStyle: index.default.enum(['single', 'double']).optional().default('single'),
23
- future: index.default.object({
24
- unstable_codeSplitting: index.default.boolean().optional()
25
- }).optional()
20
+ routesDirectory: index.default.string().optional().default('./src/routes'),
21
+ generatedRouteTree: index.default.string().optional().default('./src/routeTree.gen.ts'),
22
+ quoteStyle: index.default.enum(['single', 'double']).optional().default('single')
26
23
  });
27
24
  path.resolve(process.cwd(), 'tsr.config.json');
28
25
 
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../../../../router-cli/src/config.ts"],"sourcesContent":["import path from 'path'\nimport { readFileSync } from 'fs'\nimport { z } from 'zod'\n\nexport const configSchema = z.object({\n routeFilePrefix: z.string().optional(),\n routeFileIgnorePrefix: z.string().optional().default('-'),\n routesDirectory: z.string(),\n generatedRouteTree: z.string(),\n quoteStyle: z.enum(['single', 'double']).optional().default('single'),\n future: z\n .object({\n unstable_codeSplitting: z.boolean().optional(),\n })\n .optional(),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\nconst configFilePathJson = path.resolve(process.cwd(), 'tsr.config.json')\n\nexport async function getConfig(): Promise<Config> {\n return configSchema.parse(\n JSON.parse(readFileSync(configFilePathJson, 'utf-8')),\n )\n}\n"],"names":["configSchema","z","object","routeFilePrefix","string","optional","routeFileIgnorePrefix","default","routesDirectory","generatedRouteTree","quoteStyle","enum","future","unstable_codeSplitting","boolean","path","resolve","process","cwd"],"mappings":";;;;;;;;;;;;;;;;MAIaA,YAAY,GAAGC,aAAC,CAACC,MAAM,CAAC;EACnCC,eAAe,EAAEF,aAAC,CAACG,MAAM,EAAE,CAACC,QAAQ,EAAE;AACtCC,EAAAA,qBAAqB,EAAEL,aAAC,CAACG,MAAM,EAAE,CAACC,QAAQ,EAAE,CAACE,OAAO,CAAC,GAAG,CAAC;AACzDC,EAAAA,eAAe,EAAEP,aAAC,CAACG,MAAM,EAAE;AAC3BK,EAAAA,kBAAkB,EAAER,aAAC,CAACG,MAAM,EAAE;AAC9BM,EAAAA,UAAU,EAAET,aAAC,CAACU,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAACN,QAAQ,EAAE,CAACE,OAAO,CAAC,QAAQ,CAAC;AACrEK,EAAAA,MAAM,EAAEX,aAAC,CACNC,MAAM,CAAC;IACNW,sBAAsB,EAAEZ,aAAC,CAACa,OAAO,EAAE,CAACT,QAAQ,EAAC;GAC9C,CAAC,CACDA,QAAQ,EAAC;AACd,CAAC,EAAC;AAIyBU,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,GAAG,EAAE,EAAE,iBAAiB;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../../../../router-cli/src/config.ts"],"sourcesContent":["import path from 'path'\nimport { readFileSync, existsSync } from 'fs'\nimport { z } from 'zod'\n\nexport const configSchema = z.object({\n routeFilePrefix: z.string().optional(),\n routeFileIgnorePrefix: z.string().optional().default('-'),\n routesDirectory: z.string().optional().default('./src/routes'),\n generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),\n quoteStyle: z.enum(['single', 'double']).optional().default('single'),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\nconst configFilePathJson = path.resolve(process.cwd(), 'tsr.config.json')\n\nexport async function getConfig(): Promise<Config> {\n const exists = existsSync(configFilePathJson)\n\n if (exists) {\n return configSchema.parse(\n JSON.parse(readFileSync(configFilePathJson, 'utf-8')),\n )\n }\n\n return configSchema.parse({})\n}\n"],"names":["configSchema","z","object","routeFilePrefix","string","optional","routeFileIgnorePrefix","default","routesDirectory","generatedRouteTree","quoteStyle","enum","path","resolve","process","cwd"],"mappings":";;;;;;;;;;;;;;;;MAIaA,YAAY,GAAGC,aAAC,CAACC,MAAM,CAAC;EACnCC,eAAe,EAAEF,aAAC,CAACG,MAAM,EAAE,CAACC,QAAQ,EAAE;AACtCC,EAAAA,qBAAqB,EAAEL,aAAC,CAACG,MAAM,EAAE,CAACC,QAAQ,EAAE,CAACE,OAAO,CAAC,GAAG,CAAC;AACzDC,EAAAA,eAAe,EAAEP,aAAC,CAACG,MAAM,EAAE,CAACC,QAAQ,EAAE,CAACE,OAAO,CAAC,cAAc,CAAC;AAC9DE,EAAAA,kBAAkB,EAAER,aAAC,CAACG,MAAM,EAAE,CAACC,QAAQ,EAAE,CAACE,OAAO,CAAC,wBAAwB,CAAC;AAC3EG,EAAAA,UAAU,EAAET,aAAC,CAACU,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAACN,QAAQ,EAAE,CAACE,OAAO,CAAC,QAAQ,CAAA;AACtE,CAAC,EAAC;AAIyBK,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,GAAG,EAAE,EAAE,iBAAiB;;;;"}
@@ -61,7 +61,7 @@ async function getRouteNodes(config) {
61
61
  const stat = await fs__namespace.stat(fullPath);
62
62
  if (stat.isDirectory()) {
63
63
  await recurse(relativePath);
64
- } else {
64
+ } else if (fullPath.match(/\.(tsx|ts|jsx|js)$/)) {
65
65
  const filePath = replaceBackslash(path.join(dir, fileName));
66
66
  const filePathNoExt = removeExt(filePath);
67
67
  let routePath = reactRouter.cleanPath(`/${filePathNoExt.split('.').join('/')}`) || '';
@@ -121,7 +121,7 @@ async function generator(config) {
121
121
  };
122
122
  const start = Date.now();
123
123
  const routePathIdPrefix = config.routeFilePrefix ?? '';
124
- const preRouteNodes = multiSortBy(await getRouteNodes(config), [d => d.routePath === '/' ? -1 : 1, d => d.routePath?.split('/').length, d => d.filePath?.match(/[./]index[.]/) ? 1 : -1, d => d.filePath?.match(/[./](component|errorComponent|pendingComponent|loader)[.]/) ? 1 : -1, d => d.filePath?.match(/[./]route[.]/) ? -1 : 1, d => d.routePath?.endsWith('/') ? -1 : 1, d => d.routePath]).filter(d => d.routePath !== `/${routePathIdPrefix + rootPathId}`);
124
+ const preRouteNodes = multiSortBy(await getRouteNodes(config), [d => d.routePath === '/' ? -1 : 1, d => d.routePath?.split('/').length, d => d.filePath?.match(/[./]index[.]/) ? 1 : -1, d => d.filePath?.match(/[./](component|errorComponent|pendingComponent|loader)[.]/) ? 1 : -1, d => d.filePath?.match(/[./]route[.]/) ? -1 : 1, d => d.routePath?.endsWith('/') ? -1 : 1, d => d.routePath]).filter(d => ![`/${routePathIdPrefix + rootPathId}`].includes(d.routePath || ''));
125
125
  const routeTree = [];
126
126
  const routePiecesByPath = {};
127
127
 
@@ -138,23 +138,21 @@ async function generator(config) {
138
138
  node.isNonPath = first.startsWith('_');
139
139
  node.isNonLayout = first.endsWith('_');
140
140
  node.cleanedPath = removeUnderscores(node.path) ?? '';
141
- if (config.future?.unstable_codeSplitting) {
142
- if (!node.isVirtual && (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent)) {
143
- routePiecesByPath[node.routePath] = routePiecesByPath[node.routePath] || {};
144
- routePiecesByPath[node.routePath][node.isLoader ? 'loader' : node.isErrorComponent ? 'errorComponent' : node.isPendingComponent ? 'pendingComponent' : 'component'] = node;
145
- const anchorRoute = routeNodes.find(d => d.routePath === node.routePath);
146
- if (!anchorRoute) {
147
- handleNode({
148
- ...node,
149
- isVirtual: true,
150
- isLoader: false,
151
- isComponent: false,
152
- isErrorComponent: false,
153
- isPendingComponent: false
154
- });
155
- }
156
- return;
141
+ if (!node.isVirtual && (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent)) {
142
+ routePiecesByPath[node.routePath] = routePiecesByPath[node.routePath] || {};
143
+ routePiecesByPath[node.routePath][node.isLoader ? 'loader' : node.isErrorComponent ? 'errorComponent' : node.isPendingComponent ? 'pendingComponent' : 'component'] = node;
144
+ const anchorRoute = routeNodes.find(d => d.routePath === node.routePath);
145
+ if (!anchorRoute) {
146
+ handleNode({
147
+ ...node,
148
+ isVirtual: true,
149
+ isLoader: false,
150
+ isComponent: false,
151
+ isErrorComponent: false,
152
+ isPendingComponent: false
153
+ });
157
154
  }
155
+ return;
158
156
  }
159
157
  if (node.parent) {
160
158
  node.parent.children = node.parent.children ?? [];
@@ -226,7 +224,7 @@ async function generator(config) {
226
224
  }`;
227
225
  }).join('\n')}
228
226
  }
229
- }`, `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`].join('\n');
227
+ }`, `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`].filter(Boolean).join('\n');
230
228
  const routeConfigFileContent = await index.format(routeImports, {
231
229
  semi: false,
232
230
  singleQuote: config.quoteStyle === 'single',
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sources":["../../../../../../router-cli/src/generator.ts"],"sourcesContent":["import path from 'path'\nimport * as fs from 'fs/promises'\nimport * as prettier from 'prettier'\nimport { Config } from './config'\nimport { cleanPath, trimPathLeft } from '@tanstack/react-router'\n\nlet latestTask = 0\nexport const rootPathId = '__root'\nexport const fileRouteRegex = /new\\s+FileRoute\\(([^)]*)\\)/g\n\nexport type RouteNode = {\n filePath: string\n fullPath: string\n variableName: string\n routePath?: string\n cleanedPath?: string\n path?: string\n isNonPath?: boolean\n isNonLayout?: boolean\n isRoute?: boolean\n isLoader?: boolean\n isComponent?: boolean\n isErrorComponent?: boolean\n isPendingComponent?: boolean\n isVirtual?: boolean\n isRoot?: boolean\n children?: RouteNode[]\n parent?: RouteNode\n}\n\nasync function getRouteNodes(config: Config) {\n const { routeFilePrefix, routeFileIgnorePrefix } = config\n\n let routeNodes: RouteNode[] = []\n\n async function recurse(dir: string) {\n const fullDir = path.resolve(config.routesDirectory, dir)\n let dirList = await fs.readdir(fullDir)\n\n dirList = dirList.filter((d) => {\n if (\n d.startsWith('.') ||\n (routeFileIgnorePrefix && d.startsWith(routeFileIgnorePrefix))\n ) {\n return false\n }\n\n if (routeFilePrefix) {\n return d.startsWith(routeFilePrefix)\n }\n\n return true\n })\n\n await Promise.all(\n dirList.map(async (fileName) => {\n const fullPath = path.join(fullDir, fileName)\n const relativePath = path.join(dir, fileName)\n const stat = await fs.stat(fullPath)\n\n if (stat.isDirectory()) {\n await recurse(relativePath)\n } else {\n const filePath = replaceBackslash(path.join(dir, fileName))\n const filePathNoExt = removeExt(filePath)\n let routePath =\n cleanPath(`/${filePathNoExt.split('.').join('/')}`) || ''\n const variableName = routePathToVariable(routePath)\n\n // Remove the index from the route path and\n // if the route path is empty, use `/'\n\n let isRoute = routePath?.endsWith('/route')\n let isComponent = routePath?.endsWith('/component')\n let isErrorComponent = routePath?.endsWith('/errorComponent')\n let isPendingComponent = routePath?.endsWith('/pendingComponent')\n let isLoader = routePath?.endsWith('/loader')\n\n routePath = routePath?.replace(\n /\\/(component|errorComponent|pendingComponent|loader|route)$/,\n '',\n )\n\n if (routePath === 'index') {\n routePath = '/'\n }\n\n routePath = routePath.replace(/\\/index$/, '/') || '/'\n\n routeNodes.push({\n filePath,\n fullPath,\n routePath,\n variableName,\n isRoute,\n isComponent,\n isErrorComponent,\n isPendingComponent,\n isLoader,\n })\n }\n }),\n )\n\n return routeNodes\n }\n\n await recurse('./')\n\n return routeNodes\n}\n\nlet first = false\nlet skipMessage = false\n\ntype RouteSubNode = {\n component?: RouteNode\n errorComponent?: RouteNode\n pendingComponent?: RouteNode\n loader?: RouteNode\n}\n\nexport async function generator(config: Config) {\n console.log()\n\n if (!first) {\n console.log('🔄 Generating routes...')\n first = true\n } else if (skipMessage) {\n skipMessage = false\n } else {\n console.log('♻️ Regenerating routes...')\n }\n\n const taskId = latestTask + 1\n latestTask = taskId\n\n const checkLatest = () => {\n if (latestTask !== taskId) {\n skipMessage = true\n return false\n }\n\n return true\n }\n\n const start = Date.now()\n const routePathIdPrefix = config.routeFilePrefix ?? ''\n\n const preRouteNodes = multiSortBy(await getRouteNodes(config), [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.filePath?.match(/[./]index[.]/) ? 1 : -1),\n (d) =>\n d.filePath?.match(\n /[./](component|errorComponent|pendingComponent|loader)[.]/,\n )\n ? 1\n : -1,\n (d) => (d.filePath?.match(/[./]route[.]/) ? -1 : 1),\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => d.routePath !== `/${routePathIdPrefix + rootPathId}`)\n\n const routeTree: RouteNode[] = []\n const routePiecesByPath: Record<string, RouteSubNode> = {}\n\n // Loop over the flat list of routeNodes and\n // build up a tree based on the routeNodes' routePath\n let routeNodes: RouteNode[] = []\n\n const handleNode = (node: RouteNode) => {\n const parentRoute = hasParentRoute(routeNodes, node.routePath)\n if (parentRoute) node.parent = parentRoute\n\n node.path = node.parent\n ? node.routePath?.replace(node.parent.routePath!, '') || '/'\n : node.routePath\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath?.split('/') ?? []\n let first = split[0] ?? trimmedPath ?? ''\n\n node.isNonPath = first.startsWith('_')\n node.isNonLayout = first.endsWith('_')\n\n node.cleanedPath = removeUnderscores(node.path) ?? ''\n\n if (config.future?.unstable_codeSplitting) {\n if (\n !node.isVirtual &&\n (node.isLoader ||\n node.isComponent ||\n node.isErrorComponent ||\n node.isPendingComponent)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node.isLoader\n ? 'loader'\n : node.isErrorComponent\n ? 'errorComponent'\n : node.isPendingComponent\n ? 'pendingComponent'\n : 'component'\n ] = node\n\n const anchorRoute = routeNodes.find(\n (d) => d.routePath === node.routePath,\n )\n\n if (!anchorRoute) {\n handleNode({\n ...node,\n isVirtual: true,\n isLoader: false,\n isComponent: false,\n isErrorComponent: false,\n isPendingComponent: false,\n })\n }\n return\n }\n }\n\n if (node.parent) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n } else {\n routeTree.push(node)\n }\n\n routeNodes.push(node)\n }\n\n preRouteNodes.forEach((node) => handleNode(node))\n\n async function buildRouteConfig(\n nodes: RouteNode[],\n depth = 1,\n ): Promise<string> {\n const children = nodes.map(async (node) => {\n const routeCode = await fs.readFile(node.fullPath, 'utf-8')\n\n // Ensure the boilerplate for the route exists\n if (node.isRoot) {\n return\n }\n\n // Ensure that new FileRoute(anything?) is replaced with FileRoute(${node.routePath})\n // routePath can contain $ characters, which have special meaning when used in replace\n // so we have to escape it by turning all $ into $$. But since we do it through a replace call\n // we have to double escape it into $$$$. For more information, see\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement\n const escapedRoutePath = removeTrailingUnderscores(\n node.routePath?.replaceAll('$', '$$$$') ?? '',\n )\n const quote = config.quoteStyle === 'single' ? `'` : `\"`\n const replaced = routeCode.replace(\n fileRouteRegex,\n `new FileRoute(${quote}${escapedRoutePath}${quote})`,\n )\n\n if (replaced !== routeCode) {\n await fs.writeFile(node.fullPath, replaced)\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = await buildRouteConfig(node.children, depth + 1)\n return `${route}.addChildren([${spaces(depth * 4)}${childConfigs}])`\n }\n\n return route\n })\n\n return (await Promise.all(children)).filter(Boolean).join(`,`)\n }\n\n const routeConfigChildrenText = await buildRouteConfig(routeTree)\n\n const sortedRouteNodes = multiSortBy(routeNodes, [\n (d) =>\n d.routePath?.includes(`/${routePathIdPrefix + rootPathId}`) ? -1 : 1,\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(\"index'\") ? -1 : 1),\n (d) => d,\n ])\n\n const imports = Object.entries({\n FileRoute: sortedRouteNodes.some((d) => d.isVirtual),\n lazyFn: sortedRouteNodes.some(\n (node) => routePiecesByPath[node.routePath!]?.loader,\n ),\n lazyRouteComponent: sortedRouteNodes.some(\n (node) =>\n routePiecesByPath[node.routePath!]?.component ||\n routePiecesByPath[node.routePath!]?.errorComponent ||\n routePiecesByPath[node.routePath!]?.pendingComponent,\n ),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n\n const routeImports = [\n imports.length\n ? `import { ${imports.join(', ')} } from '@tanstack/react-router'\\n`\n : '',\n `import { Route as rootRoute } from './${sanitize(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, routePathIdPrefix + rootPathId),\n ),\n )}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }Import } from './${sanitize(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, node.filePath),\n ),\n ),\n )}'`\n }),\n '\\n',\n sortedRouteNodes\n .filter((d) => d.isVirtual)\n .map((node) => {\n return `const ${\n node.variableName\n }Import = new FileRoute('${removeTrailingUnderscores(\n node.routePath,\n )}').createRoute()`\n })\n .join('\\n'),\n '\\n',\n sortedRouteNodes\n .map((node) => {\n const loaderNode = routePiecesByPath[node.routePath!]?.loader\n const componentNode = routePiecesByPath[node.routePath!]?.component\n const errorComponentNode =\n routePiecesByPath[node.routePath!]?.errorComponent\n const pendingComponentNode =\n routePiecesByPath[node.routePath!]?.pendingComponent\n\n return [\n `const ${node.variableName}Route = ${node.variableName}Import.update({\n ${[\n node.isNonPath\n ? `id: '${node.path}'`\n : `path: '${node.cleanedPath}'`,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n } as any)`,\n loaderNode\n ? `.updateLoader({ loader: lazyFn(() => import('./${sanitize(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, loaderNode.filePath),\n ),\n ),\n )}'), 'loader') })`\n : '',\n componentNode || errorComponentNode || pendingComponentNode\n ? `.update({\n ${(\n [\n ['component', componentNode],\n ['errorComponent', errorComponentNode],\n ['pendingComponent', pendingComponentNode],\n ] as const\n )\n .filter((d) => d[1])\n .map((d) => {\n return `${\n d[0]\n }: lazyRouteComponent(() => import('./${sanitize(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, d[1]!.filePath),\n ),\n ),\n )}'), '${d[0]}')`\n })\n .join('\\n,')}\n })`\n : '',\n ].join('')\n })\n .join('\\n\\n'),\n `declare module '@tanstack/react-router' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n return `'${removeTrailingUnderscores(routeNode.routePath)}': {\n preLoaderRoute: typeof ${routeNode.variableName}Import\n parentRoute: typeof ${\n routeNode.parent?.variableName\n ? `${routeNode.parent?.variableName}Import`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`,\n ].join('\\n')\n\n const routeConfigFileContent = await prettier.format(routeImports, {\n semi: false,\n singleQuote: config.quoteStyle === 'single',\n parser: 'typescript',\n })\n\n const routeTreeContent = await fs\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err: any) => {\n if (err.code === 'ENOENT') {\n return undefined\n }\n throw err\n })\n\n if (!checkLatest()) return\n\n if (routeTreeContent !== routeConfigFileContent) {\n await fs.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n if (!checkLatest()) return\n await fs.writeFile(\n path.resolve(config.generatedRouteTree),\n routeConfigFileContent,\n )\n }\n\n console.log(\n `🌲 Processed ${routeNodes.length} routes in ${Date.now() - start}ms`,\n )\n}\n\nfunction routePathToVariable(d: string): string {\n return (\n removeUnderscores(d)\n ?.replace(/\\/\\$\\//g, '/splat/')\n ?.replace(/\\$$/g, 'splat')\n ?.replace(/\\$/g, '')\n ?.split(/[/-]/g)\n .map((d, i) => (i > 0 ? capitalize(d) : d))\n .join('')\n .replace(/([^a-zA-Z0-9]|[\\.])/gm, '') ?? ''\n )\n}\n\nexport function removeExt(d: string) {\n return d.substring(0, d.lastIndexOf('.')) || d\n}\n\nfunction spaces(d: number): string {\n return Array.from({ length: d })\n .map(() => ' ')\n .join('')\n}\n\nexport function multiSortBy<T>(\n arr: T[],\n accessors: ((item: T) => any)[] = [(d) => d],\n): T[] {\n return arr\n .map((d, i) => [d, i] as const)\n .sort(([a, ai], [b, bi]) => {\n for (const accessor of accessors) {\n const ao = accessor(a)\n const bo = accessor(b)\n\n if (typeof ao === 'undefined') {\n if (typeof bo === 'undefined') {\n continue\n }\n return 1\n }\n\n if (ao === bo) {\n continue\n }\n\n return ao > bo ? 1 : -1\n }\n\n return ai - bi\n })\n .map(([d]) => d)\n}\n\nfunction capitalize(s: string) {\n if (typeof s !== 'string') return ''\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nfunction sanitize(s: string) {\n return replaceBackslash(s.replace(/\\\\index/gi, ''))\n}\n\nfunction removeUnderscores(s?: string) {\n return s?.replace(/(^_|_$)/, '').replace(/(\\/_|_\\/)/, '/')\n}\n\nfunction removeTrailingUnderscores(s?: string) {\n return s?.replace(/(_$)/, '').replace(/(_\\/)/, '/')\n}\n\nfunction replaceBackslash(s: string) {\n return s.replace(/\\\\/gi, '/')\n}\n\nexport function hasParentRoute(\n routes: RouteNode[],\n routePathToCheck: string | undefined,\n): RouteNode | null {\n if (!routePathToCheck || routePathToCheck === '/') {\n return null\n }\n\n const sortedNodes = multiSortBy(routes, [\n (d) => d.routePath!.length * -1,\n (d) => d.variableName,\n ]).filter((d) => d.routePath !== `/${rootPathId}`)\n\n for (const route of sortedNodes) {\n if (route.routePath === '/') continue\n\n if (\n routePathToCheck.startsWith(`${route.routePath}/`) &&\n route.routePath !== routePathToCheck\n ) {\n return route\n }\n }\n const segments = routePathToCheck.split('/')\n segments.pop() // Remove the last segment\n const parentRoutePath = segments.join('/')\n\n return hasParentRoute(routes, parentRoutePath)\n}\n"],"names":["latestTask","rootPathId","fileRouteRegex","getRouteNodes","config","routeFilePrefix","routeFileIgnorePrefix","routeNodes","recurse","dir","fullDir","path","resolve","routesDirectory","dirList","fs","readdir","filter","d","startsWith","Promise","all","map","fileName","fullPath","join","relativePath","stat","isDirectory","filePath","replaceBackslash","filePathNoExt","removeExt","routePath","cleanPath","split","variableName","routePathToVariable","isRoute","endsWith","isComponent","isErrorComponent","isPendingComponent","isLoader","replace","push","first","skipMessage","generator","console","log","taskId","checkLatest","start","Date","now","routePathIdPrefix","preRouteNodes","multiSortBy","length","match","routeTree","routePiecesByPath","handleNode","node","parentRoute","hasParentRoute","parent","trimmedPath","trimPathLeft","isNonPath","isNonLayout","cleanedPath","removeUnderscores","future","unstable_codeSplitting","isVirtual","anchorRoute","find","children","forEach","buildRouteConfig","nodes","depth","routeCode","readFile","isRoot","escapedRoutePath","removeTrailingUnderscores","replaceAll","quote","quoteStyle","replaced","writeFile","route","childConfigs","spaces","Boolean","routeConfigChildrenText","sortedRouteNodes","includes","imports","Object","entries","FileRoute","some","lazyFn","loader","lazyRouteComponent","component","errorComponent","pendingComponent","routeImports","sanitize","relative","dirname","generatedRouteTree","loaderNode","componentNode","errorComponentNode","pendingComponentNode","routeNode","routeConfigFileContent","prettier","semi","singleQuote","parser","routeTreeContent","catch","err","code","undefined","mkdir","recursive","i","capitalize","substring","lastIndexOf","Array","from","arr","accessors","sort","a","ai","b","bi","accessor","ao","bo","s","charAt","toUpperCase","slice","routes","routePathToCheck","sortedNodes","segments","pop","parentRoutePath"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAIA,UAAU,GAAG,CAAC,CAAA;AACX,MAAMC,UAAU,GAAG,SAAQ;AAC3B,MAAMC,cAAc,GAAG,8BAA6B;AAsB3D,eAAeC,aAAaA,CAACC,MAAc,EAAE;EAC3C,MAAM;IAAEC,eAAe;AAAEC,IAAAA,qBAAAA;AAAsB,GAAC,GAAGF,MAAM,CAAA;EAEzD,IAAIG,UAAuB,GAAG,EAAE,CAAA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0B,MAAM,GAAG,CAAC,CAAC,EAC9BzC,CAAC,IAAKA,CAAC,CAACkB,YAAY,CACtB,CAAC,CAACnB,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACe,SAAS,KAAM,CAAGhC,CAAAA,EAAAA,UAAW,EAAC,CAAC,CAAA;AAElD,EAAA,KAAK,MAAM6F,KAAK,IAAI8D,WAAW,EAAE;AAC/B,IAAA,IAAI9D,KAAK,CAAC7D,SAAS,KAAK,GAAG,EAAE,SAAA;AAE7B,IAAA,IACE0H,gBAAgB,CAACxI,UAAU,CAAE,CAAA,EAAE2E,KAAK,CAAC7D,SAAU,CAAE,CAAA,CAAA,CAAC,IAClD6D,KAAK,CAAC7D,SAAS,KAAK0H,gBAAgB,EACpC;AACA,MAAA,OAAO7D,KAAK,CAAA;AACd,KAAA;AACF,GAAA;AACA,EAAA,MAAM+D,QAAQ,GAAGF,gBAAgB,CAACxH,KAAK,CAAC,GAAG,CAAC,CAAA;AAC5C0H,EAAAA,QAAQ,CAACC,GAAG,EAAE,CAAC;AACf,EAAA,MAAMC,eAAe,GAAGF,QAAQ,CAACpI,IAAI,CAAC,GAAG,CAAC,CAAA;AAE1C,EAAA,OAAOyC,cAAc,CAACwF,MAAM,EAAEK,eAAe,CAAC,CAAA;AAChD;;;;;;;;;"}
1
+ {"version":3,"file":"generator.js","sources":["../../../../../../router-cli/src/generator.ts"],"sourcesContent":["import path from 'path'\nimport * as fs from 'fs/promises'\nimport * as prettier from 'prettier'\nimport { Config } from './config'\nimport { cleanPath, trimPathLeft } from '@tanstack/react-router'\nimport { existsSync } from 'fs'\n\nlet latestTask = 0\nexport const rootPathId = '__root'\nexport const fileRouteRegex = /new\\s+FileRoute\\(([^)]*)\\)/g\n\nexport type RouteNode = {\n filePath: string\n fullPath: string\n variableName: string\n routePath?: string\n cleanedPath?: string\n path?: string\n isNonPath?: boolean\n isNonLayout?: boolean\n isRoute?: boolean\n isLoader?: boolean\n isComponent?: boolean\n isErrorComponent?: boolean\n isPendingComponent?: boolean\n isVirtual?: boolean\n isRoot?: boolean\n children?: RouteNode[]\n parent?: RouteNode\n}\n\nasync function getRouteNodes(config: Config) {\n const { routeFilePrefix, routeFileIgnorePrefix } = config\n\n let routeNodes: RouteNode[] = []\n\n async function recurse(dir: string) {\n const fullDir = path.resolve(config.routesDirectory, dir)\n let dirList = await fs.readdir(fullDir)\n\n dirList = dirList.filter((d) => {\n if (\n d.startsWith('.') ||\n (routeFileIgnorePrefix && d.startsWith(routeFileIgnorePrefix))\n ) {\n return false\n }\n\n if (routeFilePrefix) {\n return d.startsWith(routeFilePrefix)\n }\n\n return true\n })\n\n await Promise.all(\n dirList.map(async (fileName) => {\n const fullPath = path.join(fullDir, fileName)\n const relativePath = path.join(dir, fileName)\n const stat = await fs.stat(fullPath)\n\n if (stat.isDirectory()) {\n await recurse(relativePath)\n } else if (fullPath.match(/\\.(tsx|ts|jsx|js)$/)) {\n const filePath = replaceBackslash(path.join(dir, fileName))\n const filePathNoExt = removeExt(filePath)\n let routePath =\n cleanPath(`/${filePathNoExt.split('.').join('/')}`) || ''\n const variableName = routePathToVariable(routePath)\n\n // Remove the index from the route path and\n // if the route path is empty, use `/'\n\n let isRoute = routePath?.endsWith('/route')\n let isComponent = routePath?.endsWith('/component')\n let isErrorComponent = routePath?.endsWith('/errorComponent')\n let isPendingComponent = routePath?.endsWith('/pendingComponent')\n let isLoader = routePath?.endsWith('/loader')\n\n routePath = routePath?.replace(\n /\\/(component|errorComponent|pendingComponent|loader|route)$/,\n '',\n )\n\n if (routePath === 'index') {\n routePath = '/'\n }\n\n routePath = routePath.replace(/\\/index$/, '/') || '/'\n\n routeNodes.push({\n filePath,\n fullPath,\n routePath,\n variableName,\n isRoute,\n isComponent,\n isErrorComponent,\n isPendingComponent,\n isLoader,\n })\n }\n }),\n )\n\n return routeNodes\n }\n\n await recurse('./')\n\n return routeNodes\n}\n\nlet first = false\nlet skipMessage = false\n\ntype RouteSubNode = {\n component?: RouteNode\n errorComponent?: RouteNode\n pendingComponent?: RouteNode\n loader?: RouteNode\n}\n\nexport async function generator(config: Config) {\n console.log()\n\n if (!first) {\n console.log('🔄 Generating routes...')\n first = true\n } else if (skipMessage) {\n skipMessage = false\n } else {\n console.log('♻️ Regenerating routes...')\n }\n\n const taskId = latestTask + 1\n latestTask = taskId\n\n const checkLatest = () => {\n if (latestTask !== taskId) {\n skipMessage = true\n return false\n }\n\n return true\n }\n\n const start = Date.now()\n const routePathIdPrefix = config.routeFilePrefix ?? ''\n\n const preRouteNodes = multiSortBy(await getRouteNodes(config), [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.filePath?.match(/[./]index[.]/) ? 1 : -1),\n (d) =>\n d.filePath?.match(\n /[./](component|errorComponent|pendingComponent|loader)[.]/,\n )\n ? 1\n : -1,\n (d) => (d.filePath?.match(/[./]route[.]/) ? -1 : 1),\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter(\n (d) => ![`/${routePathIdPrefix + rootPathId}`].includes(d.routePath || ''),\n )\n\n const routeTree: RouteNode[] = []\n const routePiecesByPath: Record<string, RouteSubNode> = {}\n\n // Loop over the flat list of routeNodes and\n // build up a tree based on the routeNodes' routePath\n let routeNodes: RouteNode[] = []\n\n const handleNode = (node: RouteNode) => {\n const parentRoute = hasParentRoute(routeNodes, node.routePath)\n if (parentRoute) node.parent = parentRoute\n\n node.path = node.parent\n ? node.routePath?.replace(node.parent.routePath!, '') || '/'\n : node.routePath\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath?.split('/') ?? []\n let first = split[0] ?? trimmedPath ?? ''\n\n node.isNonPath = first.startsWith('_')\n node.isNonLayout = first.endsWith('_')\n\n node.cleanedPath = removeUnderscores(node.path) ?? ''\n\n if (\n !node.isVirtual &&\n (node.isLoader ||\n node.isComponent ||\n node.isErrorComponent ||\n node.isPendingComponent)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node.isLoader\n ? 'loader'\n : node.isErrorComponent\n ? 'errorComponent'\n : node.isPendingComponent\n ? 'pendingComponent'\n : 'component'\n ] = node\n\n const anchorRoute = routeNodes.find((d) => d.routePath === node.routePath)\n\n if (!anchorRoute) {\n handleNode({\n ...node,\n isVirtual: true,\n isLoader: false,\n isComponent: false,\n isErrorComponent: false,\n isPendingComponent: false,\n })\n }\n return\n }\n\n if (node.parent) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n } else {\n routeTree.push(node)\n }\n\n routeNodes.push(node)\n }\n\n preRouteNodes.forEach((node) => handleNode(node))\n\n async function buildRouteConfig(\n nodes: RouteNode[],\n depth = 1,\n ): Promise<string> {\n const children = nodes.map(async (node) => {\n const routeCode = await fs.readFile(node.fullPath, 'utf-8')\n\n // Ensure the boilerplate for the route exists\n if (node.isRoot) {\n return\n }\n\n // Ensure that new FileRoute(anything?) is replaced with FileRoute(${node.routePath})\n // routePath can contain $ characters, which have special meaning when used in replace\n // so we have to escape it by turning all $ into $$. But since we do it through a replace call\n // we have to double escape it into $$$$. For more information, see\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement\n const escapedRoutePath = removeTrailingUnderscores(\n node.routePath?.replaceAll('$', '$$$$') ?? '',\n )\n const quote = config.quoteStyle === 'single' ? `'` : `\"`\n const replaced = routeCode.replace(\n fileRouteRegex,\n `new FileRoute(${quote}${escapedRoutePath}${quote})`,\n )\n\n if (replaced !== routeCode) {\n await fs.writeFile(node.fullPath, replaced)\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = await buildRouteConfig(node.children, depth + 1)\n return `${route}.addChildren([${spaces(depth * 4)}${childConfigs}])`\n }\n\n return route\n })\n\n return (await Promise.all(children)).filter(Boolean).join(`,`)\n }\n\n const routeConfigChildrenText = await buildRouteConfig(routeTree)\n\n const sortedRouteNodes = multiSortBy(routeNodes, [\n (d) =>\n d.routePath?.includes(`/${routePathIdPrefix + rootPathId}`) ? -1 : 1,\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(\"index'\") ? -1 : 1),\n (d) => d,\n ])\n\n const imports = Object.entries({\n FileRoute: sortedRouteNodes.some((d) => d.isVirtual),\n lazyFn: sortedRouteNodes.some(\n (node) => routePiecesByPath[node.routePath!]?.loader,\n ),\n lazyRouteComponent: sortedRouteNodes.some(\n (node) =>\n routePiecesByPath[node.routePath!]?.component ||\n routePiecesByPath[node.routePath!]?.errorComponent ||\n routePiecesByPath[node.routePath!]?.pendingComponent,\n ),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n\n const routeImports = [\n imports.length\n ? `import { ${imports.join(', ')} } from '@tanstack/react-router'\\n`\n : '',\n `import { Route as rootRoute } from './${sanitize(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, routePathIdPrefix + rootPathId),\n ),\n )}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }Import } from './${sanitize(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, node.filePath),\n ),\n ),\n )}'`\n }),\n '\\n',\n sortedRouteNodes\n .filter((d) => d.isVirtual)\n .map((node) => {\n return `const ${\n node.variableName\n }Import = new FileRoute('${removeTrailingUnderscores(\n node.routePath,\n )}').createRoute()`\n })\n .join('\\n'),\n '\\n',\n sortedRouteNodes\n .map((node) => {\n const loaderNode = routePiecesByPath[node.routePath!]?.loader\n const componentNode = routePiecesByPath[node.routePath!]?.component\n const errorComponentNode =\n routePiecesByPath[node.routePath!]?.errorComponent\n const pendingComponentNode =\n routePiecesByPath[node.routePath!]?.pendingComponent\n\n return [\n `const ${node.variableName}Route = ${node.variableName}Import.update({\n ${[\n node.isNonPath\n ? `id: '${node.path}'`\n : `path: '${node.cleanedPath}'`,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n } as any)`,\n loaderNode\n ? `.updateLoader({ loader: lazyFn(() => import('./${sanitize(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, loaderNode.filePath),\n ),\n ),\n )}'), 'loader') })`\n : '',\n componentNode || errorComponentNode || pendingComponentNode\n ? `.update({\n ${(\n [\n ['component', componentNode],\n ['errorComponent', errorComponentNode],\n ['pendingComponent', pendingComponentNode],\n ] as const\n )\n .filter((d) => d[1])\n .map((d) => {\n return `${\n d[0]\n }: lazyRouteComponent(() => import('./${sanitize(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, d[1]!.filePath),\n ),\n ),\n )}'), '${d[0]}')`\n })\n .join('\\n,')}\n })`\n : '',\n ].join('')\n })\n .join('\\n\\n'),\n `declare module '@tanstack/react-router' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n return `'${removeTrailingUnderscores(routeNode.routePath)}': {\n preLoaderRoute: typeof ${routeNode.variableName}Import\n parentRoute: typeof ${\n routeNode.parent?.variableName\n ? `${routeNode.parent?.variableName}Import`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`,\n ]\n .filter(Boolean)\n .join('\\n')\n\n const routeConfigFileContent = await prettier.format(routeImports, {\n semi: false,\n singleQuote: config.quoteStyle === 'single',\n parser: 'typescript',\n })\n\n const routeTreeContent = await fs\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err: any) => {\n if (err.code === 'ENOENT') {\n return undefined\n }\n throw err\n })\n\n if (!checkLatest()) return\n\n if (routeTreeContent !== routeConfigFileContent) {\n await fs.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n if (!checkLatest()) return\n await fs.writeFile(\n path.resolve(config.generatedRouteTree),\n routeConfigFileContent,\n )\n }\n\n console.log(\n `🌲 Processed ${routeNodes.length} routes in ${Date.now() - start}ms`,\n )\n}\n\nfunction routePathToVariable(d: string): string {\n return (\n removeUnderscores(d)\n ?.replace(/\\/\\$\\//g, '/splat/')\n ?.replace(/\\$$/g, 'splat')\n ?.replace(/\\$/g, '')\n ?.split(/[/-]/g)\n .map((d, i) => (i > 0 ? capitalize(d) : d))\n .join('')\n .replace(/([^a-zA-Z0-9]|[\\.])/gm, '') ?? ''\n )\n}\n\nexport function removeExt(d: string) {\n return d.substring(0, d.lastIndexOf('.')) || d\n}\n\nfunction spaces(d: number): string {\n return Array.from({ length: d })\n .map(() => ' ')\n .join('')\n}\n\nexport function multiSortBy<T>(\n arr: T[],\n accessors: ((item: T) => any)[] = [(d) => d],\n): T[] {\n return arr\n .map((d, i) => [d, i] as const)\n .sort(([a, ai], [b, bi]) => {\n for (const accessor of accessors) {\n const ao = accessor(a)\n const bo = accessor(b)\n\n if (typeof ao === 'undefined') {\n if (typeof bo === 'undefined') {\n continue\n }\n return 1\n }\n\n if (ao === bo) {\n continue\n }\n\n return ao > bo ? 1 : -1\n }\n\n return ai - bi\n })\n .map(([d]) => d)\n}\n\nfunction capitalize(s: string) {\n if (typeof s !== 'string') return ''\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nfunction sanitize(s: string) {\n return replaceBackslash(s.replace(/\\\\index/gi, ''))\n}\n\nfunction removeUnderscores(s?: string) {\n return s?.replace(/(^_|_$)/, '').replace(/(\\/_|_\\/)/, '/')\n}\n\nfunction removeTrailingUnderscores(s?: string) {\n return s?.replace(/(_$)/, '').replace(/(_\\/)/, '/')\n}\n\nfunction replaceBackslash(s: string) {\n return s.replace(/\\\\/gi, '/')\n}\n\nexport function hasParentRoute(\n routes: RouteNode[],\n routePathToCheck: string | undefined,\n): RouteNode | null {\n if (!routePathToCheck || routePathToCheck === '/') {\n return null\n }\n\n const sortedNodes = multiSortBy(routes, [\n (d) => d.routePath!.length * -1,\n (d) => d.variableName,\n ]).filter((d) => d.routePath !== `/${rootPathId}`)\n\n for (const route of sortedNodes) {\n if (route.routePath === '/') continue\n\n if (\n routePathToCheck.startsWith(`${route.routePath}/`) &&\n route.routePath !== routePathToCheck\n ) {\n return route\n }\n }\n const segments = routePathToCheck.split('/')\n segments.pop() // Remove the last segment\n const parentRoutePath = segments.join('/')\n\n return hasParentRoute(routes, parentRoutePath)\n}\n"],"names":["latestTask","rootPathId","fileRouteRegex","getRouteNodes","config","routeFilePrefix","routeFileIgnorePrefix","routeNodes","recurse","dir","fullDir","path","resolve","routesDirectory","dirList","fs","readdir","filter","d","startsWith","Promise","all","map","fileName","fullPath","join","relativePath","stat","isDirectory","match","filePath","replaceBackslash","filePathNoExt","removeExt","routePath","cleanPath","split","variableName","routePathToVariable","isRoute","endsWith","isComponent","isErrorComponent","isPendingComponent","isLoader","replace","push","first","skipMessage","generator","console","log","taskId","checkLatest","start","Date","now","routePathIdPrefix","preRouteNodes","multiSortBy","length","includes","routeTree","routePiecesByPath","handleNode","node","parentRoute","hasParentRoute","parent","trimmedPath","trimPathLeft","isNonPath","isNonLayout","cleanedPath","removeUnderscores","isVirtual","anchorRoute","find","children","forEach","buildRouteConfig","nodes","depth","routeCode","readFile","isRoot","escapedRoutePath","removeTrailingUnderscores","replaceAll","quote","quoteStyle","replaced","writeFile","route","childConfigs","spaces","Boolean","routeConfigChildrenText","sortedRouteNodes","imports","Object","entries","FileRoute","some","lazyFn","loader","lazyRouteComponent","component","errorComponent","pendingComponent","routeImports","sanitize","relative","dirname","generatedRouteTree","loaderNode","componentNode","errorComponentNode","pendingComponentNode","routeNode","routeConfigFileContent","prettier","semi","singleQuote","parser","routeTreeContent","catch","err","code","undefined","mkdir","recursive","i","capitalize","substring","lastIndexOf","Array","from","arr","accessors","sort","a","ai","b","bi","accessor","ao","bo","s","charAt","toUpperCase","slice","routes","routePathToCheck","sortedNodes","segments","pop","parentRoutePath"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;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z.object({
3978
3978
  routeFilePrefix: z.string().optional(),
3979
3979
  routeFileIgnorePrefix: z.string().optional().default('-'),
3980
- routesDirectory: z.string(),
3981
- generatedRouteTree: z.string(),
3982
- quoteStyle: z.enum(['single', 'double']).optional().default('single'),
3983
- future: z.object({
3984
- unstable_codeSplitting: z.boolean().optional()
3985
- }).optional()
3980
+ routesDirectory: z.string().optional().default('./src/routes'),
3981
+ generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),
3982
+ quoteStyle: z.enum(['single', 'double']).optional().default('single')
3986
3983
  });
3987
3984
  path.resolve(process.cwd(), 'tsr.config.json');
3988
3985
 
@@ -33030,7 +33027,7 @@ async function getRouteNodes(config) {
33030
33027
  const stat = await fs.stat(fullPath);
33031
33028
  if (stat.isDirectory()) {
33032
33029
  await recurse(relativePath);
33033
- } else {
33030
+ } else if (fullPath.match(/\.(tsx|ts|jsx|js)$/)) {
33034
33031
  const filePath = replaceBackslash(path.join(dir, fileName));
33035
33032
  const filePathNoExt = removeExt(filePath);
33036
33033
  let routePath = cleanPath(`/${filePathNoExt.split('.').join('/')}`) || '';
@@ -33090,7 +33087,7 @@ async function generator(config) {
33090
33087
  };
33091
33088
  const start = Date.now();
33092
33089
  const routePathIdPrefix = config.routeFilePrefix ?? '';
33093
- const preRouteNodes = multiSortBy(await getRouteNodes(config), [d => d.routePath === '/' ? -1 : 1, d => d.routePath?.split('/').length, d => d.filePath?.match(/[./]index[.]/) ? 1 : -1, d => d.filePath?.match(/[./](component|errorComponent|pendingComponent|loader)[.]/) ? 1 : -1, d => d.filePath?.match(/[./]route[.]/) ? -1 : 1, d => d.routePath?.endsWith('/') ? -1 : 1, d => d.routePath]).filter(d => d.routePath !== `/${routePathIdPrefix + rootPathId}`);
33090
+ const preRouteNodes = multiSortBy(await getRouteNodes(config), [d => d.routePath === '/' ? -1 : 1, d => d.routePath?.split('/').length, d => d.filePath?.match(/[./]index[.]/) ? 1 : -1, d => d.filePath?.match(/[./](component|errorComponent|pendingComponent|loader)[.]/) ? 1 : -1, d => d.filePath?.match(/[./]route[.]/) ? -1 : 1, d => d.routePath?.endsWith('/') ? -1 : 1, d => d.routePath]).filter(d => ![`/${routePathIdPrefix + rootPathId}`].includes(d.routePath || ''));
33094
33091
  const routeTree = [];
33095
33092
  const routePiecesByPath = {};
33096
33093
 
@@ -33107,23 +33104,21 @@ async function generator(config) {
33107
33104
  node.isNonPath = first.startsWith('_');
33108
33105
  node.isNonLayout = first.endsWith('_');
33109
33106
  node.cleanedPath = removeUnderscores(node.path) ?? '';
33110
- if (config.future?.unstable_codeSplitting) {
33111
- if (!node.isVirtual && (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent)) {
33112
- routePiecesByPath[node.routePath] = routePiecesByPath[node.routePath] || {};
33113
- routePiecesByPath[node.routePath][node.isLoader ? 'loader' : node.isErrorComponent ? 'errorComponent' : node.isPendingComponent ? 'pendingComponent' : 'component'] = node;
33114
- const anchorRoute = routeNodes.find(d => d.routePath === node.routePath);
33115
- if (!anchorRoute) {
33116
- handleNode({
33117
- ...node,
33118
- isVirtual: true,
33119
- isLoader: false,
33120
- isComponent: false,
33121
- isErrorComponent: false,
33122
- isPendingComponent: false
33123
- });
33124
- }
33125
- return;
33107
+ if (!node.isVirtual && (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent)) {
33108
+ routePiecesByPath[node.routePath] = routePiecesByPath[node.routePath] || {};
33109
+ routePiecesByPath[node.routePath][node.isLoader ? 'loader' : node.isErrorComponent ? 'errorComponent' : node.isPendingComponent ? 'pendingComponent' : 'component'] = node;
33110
+ const anchorRoute = routeNodes.find(d => d.routePath === node.routePath);
33111
+ if (!anchorRoute) {
33112
+ handleNode({
33113
+ ...node,
33114
+ isVirtual: true,
33115
+ isLoader: false,
33116
+ isComponent: false,
33117
+ isErrorComponent: false,
33118
+ isPendingComponent: false
33119
+ });
33126
33120
  }
33121
+ return;
33127
33122
  }
33128
33123
  if (node.parent) {
33129
33124
  node.parent.children = node.parent.children ?? [];
@@ -33195,7 +33190,7 @@ async function generator(config) {
33195
33190
  }`;
33196
33191
  }).join('\n')}
33197
33192
  }
33198
- }`, `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`].join('\n');
33193
+ }`, `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`].filter(Boolean).join('\n');
33199
33194
  const routeConfigFileContent = await format2(routeImports, {
33200
33195
  semi: false,
33201
33196
  singleQuote: config.quoteStyle === 'single',