@tanstack/router-generator 1.120.4-alpha.1 → 1.120.4-alpha.12

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.
@@ -226,6 +226,9 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
226
226
  (_, __, p2, ___, p4) => `${node._fsRouteType === "lazy" ? "createLazyFileRoute" : "createFileRoute"}`
227
227
  );
228
228
  } else {
229
+ if (!routeCode.split("\n").some((line) => line.trim().startsWith("export const Route"))) {
230
+ return;
231
+ }
229
232
  replaced = routeCode.replace(
230
233
  /(FileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
231
234
  (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`
@@ -1 +1 @@
1
- {"version":3,"file":"generator.cjs","sources":["../../src/generator.ts"],"sourcesContent":["import path from 'node:path'\nimport * as fs from 'node:fs'\nimport * as fsp from 'node:fs/promises'\nimport {\n format,\n logging,\n multiSortBy,\n removeExt,\n removeUnderscores,\n replaceBackslash,\n resetRegex,\n routePathToVariable,\n trimPathLeft,\n writeIfDifferent,\n} from './utils'\nimport { getRouteNodes as physicalGetRouteNodes } from './filesystem/physical/getRouteNodes'\nimport { getRouteNodes as virtualGetRouteNodes } from './filesystem/virtual/getRouteNodes'\nimport { rootPathId } from './filesystem/physical/rootPathId'\nimport { fillTemplate, getTargetTemplate } from './template'\nimport type { FsRouteType, GetRouteNodesResult, RouteNode } from './types'\nimport type { Config } from './config'\n\n// Maybe import this from `@tanstack/router-core` in the future???\nconst rootRouteId = '__root__'\n\nlet latestTask = 0\nconst routeGroupPatternRegex = /\\(.+\\)/g\nconst possiblyNestedRouteGroupPatternRegex = /\\([^/]+\\)\\/?/g\n\nlet isFirst = false\nlet skipMessage = false\n\ntype RouteSubNode = {\n component?: RouteNode\n errorComponent?: RouteNode\n pendingComponent?: RouteNode\n loader?: RouteNode\n lazy?: RouteNode\n}\n\nexport async function generator(config: Config, root: string) {\n const ROUTE_TEMPLATE = getTargetTemplate(config.target)\n const logger = logging({ disabled: config.disableLogging })\n logger.log('')\n\n if (!isFirst) {\n logger.log('♻️ Generating routes...')\n isFirst = true\n } else if (skipMessage) {\n skipMessage = false\n } else {\n logger.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\n const TYPES_DISABLED = config.disableTypes\n\n let getRouteNodesResult: GetRouteNodesResult\n\n if (config.virtualRouteConfig) {\n getRouteNodesResult = await virtualGetRouteNodes(config, root)\n } else {\n getRouteNodesResult = await physicalGetRouteNodes(config, root)\n }\n\n const { rootRouteNode, routeNodes: beforeRouteNodes } = getRouteNodesResult\n if (rootRouteNode === undefined) {\n let errorMessage = `rootRouteNode must not be undefined. Make sure you've added your root route into the route-tree.`\n if (!config.virtualRouteConfig) {\n errorMessage += `\\nMake sure that you add a \"${rootPathId}.${config.disableTypes ? 'js' : 'tsx'}\" file to your routes directory.\\nAdd the file in: \"${config.routesDirectory}/${rootPathId}.${config.disableTypes ? 'js' : 'tsx'}\"`\n }\n throw new Error(errorMessage)\n }\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.indexToken}[.]`)) ? 1 : -1,\n (d) =>\n d.filePath.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.routeToken}[.]`)) ? -1 : 1,\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ''))\n\n const routeTree: Array<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 const routeNodes: Array<RouteNode> = []\n\n // the handleRootNode function is not being collapsed into the handleNode function\n // because it requires only a subset of the logic that the handleNode function requires\n // and it's easier to read and maintain this way\n const handleRootNode = async (node?: RouteNode) => {\n if (!node) {\n // currently this is not being handled, but it could be in the future\n // for example to handle a virtual root route\n return\n }\n\n // from here on, we are only handling the root node that's present in the file system\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n if (!routeCode) {\n const _rootTemplate = ROUTE_TEMPLATE.rootRoute\n const replaced = await fillTemplate(config, _rootTemplate.template(), {\n tsrImports: _rootTemplate.imports.tsrImports(),\n tsrPath: rootPathId,\n tsrExportStart: _rootTemplate.imports.tsrExportStart(),\n tsrExportEnd: _rootTemplate.imports.tsrExportEnd(),\n })\n\n await writeIfDifferent(\n node.fullPath,\n '', // Empty string because the file doesn't exist yet\n replaced,\n {\n beforeWrite: () => {\n logger.log(`🟡 Creating ${node.fullPath}`)\n },\n },\n )\n }\n }\n\n await handleRootNode(rootRouteNode)\n\n const handleNode = async (node: RouteNode) => {\n // Do not remove this as we need to set the lastIndex to 0 as it\n // is necessary to reset the regex's index when using the global flag\n // otherwise it might not match the next time it's used\n resetRegex(routeGroupPatternRegex)\n\n let parentRoute = hasParentRoute(routeNodes, node, node.routePath)\n\n // if the parent route is a virtual parent route, we need to find the real parent route\n if (parentRoute?.isVirtualParentRoute && parentRoute.children?.length) {\n // only if this sub-parent route returns a valid parent route, we use it, if not leave it as it\n const possibleParentRoute = hasParentRoute(\n parentRoute.children,\n node,\n node.routePath,\n )\n if (possibleParentRoute) {\n parentRoute = possibleParentRoute\n }\n }\n\n if (parentRoute) node.parent = parentRoute\n\n node.path = determineNodePath(node)\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath.split('/')\n const lastRouteSegment = split[split.length - 1] ?? trimmedPath\n\n node.isNonPath =\n lastRouteSegment.startsWith('_') ||\n routeGroupPatternRegex.test(lastRouteSegment)\n\n node.cleanedPath = removeGroups(\n removeUnderscores(removeLayoutSegments(node.path)) ?? '',\n )\n\n // Ensure the boilerplate for the route exists, which can be skipped for virtual parent routes and virtual routes\n if (!node.isVirtualParentRoute && !node.isVirtual) {\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n const escapedRoutePath = node.routePath?.replaceAll('$', '$$') ?? ''\n\n let replaced = routeCode\n\n const tRouteTemplate = ROUTE_TEMPLATE.route\n const tLazyRouteTemplate = ROUTE_TEMPLATE.lazyRoute\n\n if (!routeCode) {\n // Creating a new lazy route file\n if (node._fsRouteType === 'lazy') {\n // Check by default check if the user has a specific lazy route template\n // If not, check if the user has a route template and use that instead\n replaced = await fillTemplate(\n config,\n (config.customScaffolding?.lazyRouteTemplate ||\n config.customScaffolding?.routeTemplate) ??\n tLazyRouteTemplate.template(),\n {\n tsrImports: tLazyRouteTemplate.imports.tsrImports(),\n tsrPath: escapedRoutePath.replaceAll(/\\{(.+)\\}/gm, '$1'),\n tsrExportStart:\n tLazyRouteTemplate.imports.tsrExportStart(escapedRoutePath),\n tsrExportEnd: tLazyRouteTemplate.imports.tsrExportEnd(),\n },\n )\n } else if (\n // Creating a new normal route file\n (['layout', 'static'] satisfies Array<FsRouteType>).some(\n (d) => d === node._fsRouteType,\n ) ||\n (\n [\n 'component',\n 'pendingComponent',\n 'errorComponent',\n 'loader',\n ] satisfies Array<FsRouteType>\n ).every((d) => d !== node._fsRouteType)\n ) {\n replaced = await fillTemplate(\n config,\n config.customScaffolding?.routeTemplate ??\n tRouteTemplate.template(),\n {\n tsrImports: tRouteTemplate.imports.tsrImports(),\n tsrPath: escapedRoutePath.replaceAll(/\\{(.+)\\}/gm, '$1'),\n tsrExportStart:\n tRouteTemplate.imports.tsrExportStart(escapedRoutePath),\n tsrExportEnd: tRouteTemplate.imports.tsrExportEnd(),\n },\n )\n }\n } else if (config.verboseFileRoutes === false) {\n // Check if the route file has a Route export\n if (\n !routeCode\n .split('\\n')\n .some((line) => line.trim().startsWith('export const Route'))\n ) {\n return\n }\n\n // Update the existing route file\n replaced = routeCode\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n new RegExp(\n `(import\\\\s*\\\\{)(.*)(create(Lazy)?FileRoute)(.*)(\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gs',\n ),\n (_, p1, p2, ___, ____, p5, p6) => {\n const beforeCreateFileRoute = () => {\n if (!p2) return ''\n\n let trimmed = p2.trim()\n\n if (trimmed.endsWith(',')) {\n trimmed = trimmed.slice(0, -1)\n }\n\n return trimmed\n }\n\n const afterCreateFileRoute = () => {\n if (!p5) return ''\n\n let trimmed = p5.trim()\n\n if (trimmed.startsWith(',')) {\n trimmed = trimmed.slice(1)\n }\n\n return trimmed\n }\n\n const newImport = () => {\n const before = beforeCreateFileRoute()\n const after = afterCreateFileRoute()\n\n if (!before) return after\n\n if (!after) return before\n\n return `${before},${after}`\n }\n\n const middle = newImport()\n\n if (middle === '') return ''\n\n return `${p1} ${newImport()} ${p6}`\n },\n )\n .replace(\n /create(Lazy)?FileRoute(\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, __, p2, ___, p4) =>\n `${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}`,\n )\n } else {\n replaced = routeCode\n // fix wrong ids\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n // fix missing ids\n .replace(\n /((FileRoute)(\\s*)(\\({))/g,\n (_, __, p2, p3, p4) => `${p2}('${escapedRoutePath}')${p3}${p4}`,\n )\n .replace(\n new RegExp(\n `(import\\\\s*\\\\{.*)(create(Lazy)?FileRoute)(.*\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gs',\n ),\n (_, p1, __, ___, p4) =>\n `${p1}${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}${p4}`,\n )\n .replace(\n /create(Lazy)?FileRoute(\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, __, p2, ___, p4) =>\n `${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}${p2}${escapedRoutePath}${p4}`,\n )\n\n // check whether the import statement is already present\n const regex = new RegExp(\n `(import\\\\s*\\\\{.*)(create(Lazy)?FileRoute)(.*\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gm',\n )\n if (!replaced.match(regex)) {\n replaced = [\n `import { ${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'} } from '@tanstack/${ROUTE_TEMPLATE.subPkg}'`,\n ...replaced.split('\\n'),\n ].join('\\n')\n }\n }\n\n await writeIfDifferent(node.fullPath, routeCode, replaced, {\n beforeWrite: () => {\n logger.log(`🟡 Updating ${node.fullPath}`)\n },\n })\n }\n\n if (\n !node.isVirtual &&\n (\n [\n 'lazy',\n 'loader',\n 'component',\n 'pendingComponent',\n 'errorComponent',\n ] satisfies Array<FsRouteType>\n ).some((d) => d === node._fsRouteType)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node._fsRouteType === 'lazy'\n ? 'lazy'\n : node._fsRouteType === 'loader'\n ? 'loader'\n : node._fsRouteType === 'errorComponent'\n ? 'errorComponent'\n : node._fsRouteType === 'pendingComponent'\n ? 'pendingComponent'\n : 'component'\n ] = node\n\n const anchorRoute = routeNodes.find((d) => d.routePath === node.routePath)\n\n if (!anchorRoute) {\n await handleNode({\n ...node,\n isVirtual: true,\n _fsRouteType: 'static',\n })\n }\n return\n }\n\n const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0\n const nonPathRoute =\n node._fsRouteType === 'pathless_layout' && node.isNonPath\n\n node.isVirtualParentRequired =\n node._fsRouteType === 'pathless_layout' || nonPathRoute\n ? !cleanedPathIsEmpty\n : false\n\n if (!node.isVirtual && node.isVirtualParentRequired) {\n const parentRoutePath = removeLastSegmentFromPath(node.routePath) || '/'\n const parentVariableName = routePathToVariable(parentRoutePath)\n\n const anchorRoute = routeNodes.find(\n (d) => d.routePath === parentRoutePath,\n )\n\n if (!anchorRoute) {\n const parentNode: RouteNode = {\n ...node,\n path: removeLastSegmentFromPath(node.path) || '/',\n filePath: removeLastSegmentFromPath(node.filePath) || '/',\n fullPath: removeLastSegmentFromPath(node.fullPath) || '/',\n routePath: parentRoutePath,\n variableName: parentVariableName,\n isVirtual: true,\n _fsRouteType: 'layout', // layout since this route will wrap other routes\n isVirtualParentRoute: true,\n isVirtualParentRequired: false,\n }\n\n parentNode.children = parentNode.children ?? []\n parentNode.children.push(node)\n\n node.parent = parentNode\n\n if (node._fsRouteType === 'pathless_layout') {\n // since `node.path` is used as the `id` on the route definition, we need to update it\n node.path = determineNodePath(node)\n }\n\n await handleNode(parentNode)\n } else {\n anchorRoute.children = anchorRoute.children ?? []\n anchorRoute.children.push(node)\n\n node.parent = anchorRoute\n }\n }\n\n if (node.parent) {\n if (!node.isVirtualParentRequired) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n }\n } else {\n routeTree.push(node)\n }\n\n routeNodes.push(node)\n }\n\n for (const node of preRouteNodes) {\n await handleNode(node)\n }\n\n // This is run against the `preRouteNodes` array since it\n // has the flattened Route nodes and not the full tree\n // Since TSR allows multiple way of defining a route,\n // we need to ensure that a user hasn't defined the\n // same route in multiple ways (i.e. `flat`, `nested`, `virtual`)\n checkRouteFullPathUniqueness(\n preRouteNodes.filter(\n (d) => d.children === undefined && 'lazy' !== d._fsRouteType,\n ),\n config,\n )\n\n function buildRouteTreeConfig(nodes: Array<RouteNode>, depth = 1): string {\n const children = nodes.map((node) => {\n if (node._fsRouteType === '__root') {\n return\n }\n\n if (node._fsRouteType === 'pathless_layout' && !node.children?.length) {\n return\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = buildRouteTreeConfig(node.children, depth + 1)\n\n const childrenDeclaration = TYPES_DISABLED\n ? ''\n : `interface ${route}Children {\n ${node.children.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const children = `const ${route}Children${TYPES_DISABLED ? '' : `: ${route}Children`} = {\n ${node.children.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const routeWithChildren = `const ${route}WithChildren = ${route}._addFileChildren(${route}Children)`\n\n return [\n childConfigs,\n childrenDeclaration,\n children,\n routeWithChildren,\n ].join('\\n\\n')\n }\n\n return undefined\n })\n\n return children.filter(Boolean).join('\\n\\n')\n }\n\n const routeConfigChildrenText = buildRouteTreeConfig(routeTree)\n\n const sortedRouteNodes = multiSortBy(routeNodes, [\n (d) => (d.routePath?.includes(`/${rootPathId}`) ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(config.indexToken) ? -1 : 1),\n (d) => d,\n ])\n\n const typeImports = Object.entries({\n // Used for augmentation of regular routes\n CreateFileRoute:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some(\n (d) => isRouteNodeValidForAugmentation(d) && d._fsRouteType !== 'lazy',\n ),\n // Used for augmentation of lazy (`.lazy`) routes\n CreateLazyFileRoute:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some(\n (node) =>\n routePiecesByPath[node.routePath!]?.lazy &&\n isRouteNodeValidForAugmentation(node),\n ),\n // Used in the process of augmenting the routes\n FileRoutesByPath:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some((d) => isRouteNodeValidForAugmentation(d)),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n .sort((a, b) => a.localeCompare(b))\n\n const imports = Object.entries({\n createFileRoute: 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 virtualRouteNodes = sortedRouteNodes.filter((d) => d.isVirtual)\n\n function getImportPath(node: RouteNode) {\n return replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, node.filePath),\n ),\n config.addExtensions,\n ),\n )\n }\n\n const routeImports = [\n ...config.routeTreeFileHeader,\n `// This file was automatically generated by TanStack Router.\n// You should NOT make any changes in this file as it will be overwritten.\n// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.`,\n [\n imports.length\n ? `import { ${imports.join(', ')} } from '${ROUTE_TEMPLATE.fullPkg}'`\n : '',\n !TYPES_DISABLED && typeImports.length\n ? `import type { ${typeImports.join(', ')} } from '${ROUTE_TEMPLATE.fullPkg}'`\n : '',\n ]\n .filter(Boolean)\n .join('\\n'),\n '// Import Routes',\n [\n `import { Route as rootRoute } from './${getImportPath(rootRouteNode)}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }RouteImport } from './${getImportPath(node)}'`\n }),\n ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }RouteImport = createFileRoute('${node.routePath}')()`\n })\n .join('\\n'),\n '// Create/Update Routes',\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 const lazyComponentNode = routePiecesByPath[node.routePath!]?.lazy\n\n return [\n [\n `const ${node.variableName}Route = ${node.variableName}RouteImport.update({\n ${[\n `id: '${node.path}'`,\n !node.isNonPath ? `path: '${node.cleanedPath}'` : undefined,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n }${TYPES_DISABLED ? '' : 'as any'})`,\n loaderNode\n ? `.updateLoader({ loader: lazyFn(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, loaderNode.filePath),\n ),\n config.addExtensions,\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('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, d[1]!.filePath),\n ),\n config.addExtensions,\n ),\n )}'), '${d[0]}')`\n })\n .join('\\n,')}\n })`\n : '',\n lazyComponentNode\n ? `.lazy(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n lazyComponentNode.filePath,\n ),\n ),\n config.addExtensions,\n ),\n )}').then((d) => d.Route))`\n : '',\n ].join(''),\n ].join('\\n\\n')\n })\n .join('\\n\\n'),\n ...(TYPES_DISABLED\n ? []\n : [\n '// Populate the FileRoutesByPath interface',\n `declare module '${ROUTE_TEMPLATE.fullPkg}' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n const filePathId = routeNode.routePath\n\n return `'${filePathId}': {\n id: '${filePathId}'\n path: '${inferPath(routeNode)}'\n fullPath: '${inferFullPath(routeNode)}'\n preLoaderRoute: typeof ${routeNode.variableName}RouteImport\n parentRoute: typeof ${\n routeNode.isVirtualParentRequired\n ? `${routeNode.parent?.variableName}Route`\n : routeNode.parent?.variableName\n ? `${routeNode.parent.variableName}RouteImport`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n ]),\n ...(TYPES_DISABLED\n ? []\n : config.verboseFileRoutes !== false\n ? []\n : [\n `// Add type-safety to the createFileRoute function across the route tree`,\n routeNodes\n .map((routeNode) => {\n function getModuleDeclaration(routeNode?: RouteNode) {\n if (!isRouteNodeValidForAugmentation(routeNode)) {\n return ''\n }\n return `declare module './${getImportPath(routeNode)}' {\n const ${routeNode._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}: ${\n routeNode._fsRouteType === 'lazy'\n ? `CreateLazyFileRoute<FileRoutesByPath['${routeNode.routePath}']['preLoaderRoute']>}`\n : `CreateFileRoute<\n '${routeNode.routePath}',\n FileRoutesByPath['${routeNode.routePath}']['parentRoute'],\n FileRoutesByPath['${routeNode.routePath}']['id'],\n FileRoutesByPath['${routeNode.routePath}']['path'],\n FileRoutesByPath['${routeNode.routePath}']['fullPath']\n >\n }`\n }`\n }\n return (\n getModuleDeclaration(routeNode) +\n getModuleDeclaration(\n routePiecesByPath[routeNode.routePath!]?.lazy,\n )\n )\n })\n .join('\\n'),\n ]),\n '// Create and export the route tree',\n routeConfigChildrenText,\n ...(TYPES_DISABLED\n ? []\n : [\n `export interface FileRoutesByFullPath {\n ${[...createRouteNodesByFullPath(routeNodes).entries()].map(\n ([fullPath, routeNode]) => {\n return `'${fullPath}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n },\n )}\n}`,\n `export interface FileRoutesByTo {\n ${[...createRouteNodesByTo(routeNodes).entries()].map(([to, routeNode]) => {\n return `'${to}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRoutesById {\n '${rootRouteId}': typeof rootRoute,\n ${[...createRouteNodesById(routeNodes).entries()].map(([id, routeNode]) => {\n return `'${id}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRouteTypes {\n fileRoutesByFullPath: FileRoutesByFullPath\n fullPaths: ${routeNodes.length > 0 ? [...createRouteNodesByFullPath(routeNodes).keys()].map((fullPath) => `'${fullPath}'`).join('|') : 'never'}\n fileRoutesByTo: FileRoutesByTo\n to: ${routeNodes.length > 0 ? [...createRouteNodesByTo(routeNodes).keys()].map((to) => `'${to}'`).join('|') : 'never'}\n id: ${[`'${rootRouteId}'`, ...[...createRouteNodesById(routeNodes).keys()].map((id) => `'${id}'`)].join('|')}\n fileRoutesById: FileRoutesById\n}`,\n `export interface RootRouteChildren {\n ${routeTree.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n ]),\n `const rootRouteChildren${TYPES_DISABLED ? '' : ': RootRouteChildren'} = {\n ${routeTree.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n `export const routeTree = rootRoute._addFileChildren(rootRouteChildren)${TYPES_DISABLED ? '' : '._addFileTypes<FileRouteTypes>()'}`,\n ...config.routeTreeFileFooter,\n ]\n .filter(Boolean)\n .join('\\n\\n')\n\n const createRouteManifest = () => {\n const routesManifest = {\n [rootRouteId]: {\n filePath: rootRouteNode.filePath,\n children: routeTree.map((d) => d.routePath),\n },\n ...Object.fromEntries(\n routeNodes.map((d) => {\n const filePathId = d.routePath\n\n return [\n filePathId,\n {\n filePath: d.filePath,\n parent: d.parent?.routePath ? d.parent.routePath : undefined,\n children: d.children?.map((childRoute) => childRoute.routePath),\n },\n ]\n }),\n ),\n }\n\n return JSON.stringify(\n {\n routes: routesManifest,\n },\n null,\n 2,\n )\n }\n\n const includeManifest = ['react', 'solid']\n const routeConfigFileContent =\n config.disableManifestGeneration || !includeManifest.includes(config.target)\n ? routeImports\n : [\n routeImports,\n '\\n',\n '/* ROUTE_MANIFEST_START',\n createRouteManifest(),\n 'ROUTE_MANIFEST_END */',\n ].join('\\n')\n\n if (!checkLatest()) return\n\n const existingRouteTreeContent = await fsp\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return ''\n }\n\n throw err\n })\n\n if (!checkLatest()) return\n\n // Ensure the directory exists\n await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n\n if (!checkLatest()) return\n\n // Write the route tree file, if it has changed\n const routeTreeWriteResult = await writeIfDifferent(\n path.resolve(config.generatedRouteTree),\n config.enableRouteTreeFormatting\n ? await format(existingRouteTreeContent, config)\n : existingRouteTreeContent,\n config.enableRouteTreeFormatting\n ? await format(routeConfigFileContent, config)\n : routeConfigFileContent,\n {\n beforeWrite: () => {\n logger.log(`🟡 Updating ${config.generatedRouteTree}`)\n },\n },\n )\n if (routeTreeWriteResult && !checkLatest()) {\n return\n }\n\n logger.log(\n `✅ Processed ${routeNodes.length === 1 ? 'route' : 'routes'} in ${\n Date.now() - start\n }ms`,\n )\n}\n\n// function removeTrailingUnderscores(s?: string) {\n// return s?.replaceAll(/(_$)/gi, '').replaceAll(/(_\\/)/gi, '/')\n// }\n\nfunction removeGroups(s: string) {\n return s.replace(possiblyNestedRouteGroupPatternRegex, '')\n}\n\n/**\n * Checks if a given RouteNode is valid for augmenting it with typing based on conditions.\n * Also asserts that the RouteNode is defined.\n *\n * @param routeNode - The RouteNode to check.\n * @returns A boolean indicating whether the RouteNode is defined.\n */\nfunction isRouteNodeValidForAugmentation(\n routeNode?: RouteNode,\n): routeNode is RouteNode {\n if (!routeNode || routeNode.isVirtual) {\n return false\n }\n return true\n}\n\n/**\n * The `node.path` is used as the `id` in the route definition.\n * This function checks if the given node has a parent and if so, it determines the correct path for the given node.\n * @param node - The node to determine the path for.\n * @returns The correct path for the given node.\n */\nfunction determineNodePath(node: RouteNode) {\n return (node.path = node.parent\n ? node.routePath?.replace(node.parent.routePath ?? '', '') || '/'\n : node.routePath)\n}\n\n/**\n * Removes the last segment from a given path. Segments are considered to be separated by a '/'.\n *\n * @param {string} routePath - The path from which to remove the last segment. Defaults to '/'.\n * @returns {string} The path with the last segment removed.\n * @example\n * removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'\n */\nfunction removeLastSegmentFromPath(routePath: string = '/'): string {\n const segments = routePath.split('/')\n segments.pop() // Remove the last segment\n return segments.join('/')\n}\n\n/**\n * Removes all segments from a given path that start with an underscore ('_').\n *\n * @param {string} routePath - The path from which to remove segments. Defaults to '/'.\n * @returns {string} The path with all underscore-prefixed segments removed.\n * @example\n * removeLayoutSegments('/workspace/_auth/foo') // '/workspace/foo'\n */\nfunction removeLayoutSegments(routePath: string = '/'): string {\n const segments = routePath.split('/')\n const newSegments = segments.filter((segment) => !segment.startsWith('_'))\n return newSegments.join('/')\n}\n\nfunction hasParentRoute(\n routes: Array<RouteNode>,\n node: 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\n const segments = routePathToCheck.split('/')\n segments.pop() // Remove the last segment\n const parentRoutePath = segments.join('/')\n\n return hasParentRoute(routes, node, parentRoutePath)\n}\n\n/**\n * Gets the final variable name for a route\n */\nconst getResolvedRouteNodeVariableName = (routeNode: RouteNode): string => {\n return routeNode.children?.length\n ? `${routeNode.variableName}RouteWithChildren`\n : `${routeNode.variableName}Route`\n}\n\n/**\n * Creates a map from fullPath to routeNode\n */\nconst createRouteNodesByFullPath = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => [inferFullPath(routeNode), routeNode]),\n )\n}\n\n/**\n * Create a map from 'to' to a routeNode\n */\nconst createRouteNodesByTo = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n dedupeBranchesAndIndexRoutes(routeNodes).map((routeNode) => [\n inferTo(routeNode),\n routeNode,\n ]),\n )\n}\n\n/**\n * Create a map from 'id' to a routeNode\n */\nconst createRouteNodesById = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => {\n const id = routeNode.routePath ?? ''\n return [id, routeNode]\n }),\n )\n}\n\n/**\n * Infers the full path for use by TS\n */\nconst inferFullPath = (routeNode: RouteNode): string => {\n const fullPath = removeGroups(\n removeUnderscores(removeLayoutSegments(routeNode.routePath)) ?? '',\n )\n\n return routeNode.cleanedPath === '/' ? fullPath : fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Infers the path for use by TS\n */\nconst inferPath = (routeNode: RouteNode): string => {\n return routeNode.cleanedPath === '/'\n ? routeNode.cleanedPath\n : (routeNode.cleanedPath?.replace(/\\/$/, '') ?? '')\n}\n\n/**\n * Infers to path\n */\nconst inferTo = (routeNode: RouteNode): string => {\n const fullPath = inferFullPath(routeNode)\n\n if (fullPath === '/') return fullPath\n\n return fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Dedupes branches and index routes\n */\nconst dedupeBranchesAndIndexRoutes = (\n routes: Array<RouteNode>,\n): Array<RouteNode> => {\n return routes.filter((route) => {\n if (route.children?.find((child) => child.cleanedPath === '/')) return false\n return true\n })\n}\n\nfunction checkUnique<TElement>(routes: Array<TElement>, key: keyof TElement) {\n // Check no two routes have the same `key`\n // if they do, throw an error with the conflicting filePaths\n const keys = routes.map((d) => d[key])\n const uniqueKeys = new Set(keys)\n if (keys.length !== uniqueKeys.size) {\n const duplicateKeys = keys.filter((d, i) => keys.indexOf(d) !== i)\n const conflictingFiles = routes.filter((d) =>\n duplicateKeys.includes(d[key]),\n )\n return conflictingFiles\n }\n return undefined\n}\n\nfunction checkRouteFullPathUniqueness(\n _routes: Array<RouteNode>,\n config: Config,\n) {\n const routes = _routes.map((d) => {\n const inferredFullPath = inferFullPath(d)\n return { ...d, inferredFullPath }\n })\n\n const conflictingFiles = checkUnique(routes, 'inferredFullPath')\n\n if (conflictingFiles !== undefined) {\n const errorMessage = `Conflicting configuration paths were found for the following route${conflictingFiles.length > 1 ? 's' : ''}: ${conflictingFiles\n .map((p) => `\"${p.inferredFullPath}\"`)\n .join(', ')}.\nPlease ensure each Route has a unique full path.\nConflicting files: \\n ${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join('\\n ')}\\n`\n throw new Error(errorMessage)\n }\n}\n"],"names":["getTargetTemplate","logging","virtualGetRouteNodes","physicalGetRouteNodes","rootPathId","multiSortBy","fs","fillTemplate","writeIfDifferent","resetRegex","trimPathLeft","removeUnderscores","routePathToVariable","children","replaceBackslash","removeExt","routeNode","fsp","format"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,cAAc;AAEpB,IAAI,aAAa;AACjB,MAAM,yBAAyB;AAC/B,MAAM,uCAAuC;AAE7C,IAAI,UAAU;AACd,IAAI,cAAc;AAUI,eAAA,UAAU,QAAgB,MAAc;AACtD,QAAA,iBAAiBA,SAAAA,kBAAkB,OAAO,MAAM;AACtD,QAAM,SAASC,MAAAA,QAAQ,EAAE,UAAU,OAAO,gBAAgB;AAC1D,SAAO,IAAI,EAAE;AAEb,MAAI,CAAC,SAAS;AACZ,WAAO,IAAI,0BAA0B;AAC3B,cAAA;AAAA,aACD,aAAa;AACR,kBAAA;AAAA,EAAA,OACT;AACL,WAAO,IAAI,4BAA4B;AAAA,EAAA;AAGzC,QAAM,SAAS,aAAa;AACf,eAAA;AAEb,QAAM,cAAc,MAAM;AACxB,QAAI,eAAe,QAAQ;AACX,oBAAA;AACP,aAAA;AAAA,IAAA;AAGF,WAAA;AAAA,EACT;AAEM,QAAA,QAAQ,KAAK,IAAI;AAEvB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\nimport * as fs from 'node:fs'\nimport * as fsp from 'node:fs/promises'\nimport {\n format,\n logging,\n multiSortBy,\n removeExt,\n removeUnderscores,\n replaceBackslash,\n resetRegex,\n routePathToVariable,\n trimPathLeft,\n writeIfDifferent,\n} from './utils'\nimport { getRouteNodes as physicalGetRouteNodes } from './filesystem/physical/getRouteNodes'\nimport { getRouteNodes as virtualGetRouteNodes } from './filesystem/virtual/getRouteNodes'\nimport { rootPathId } from './filesystem/physical/rootPathId'\nimport { fillTemplate, getTargetTemplate } from './template'\nimport type { FsRouteType, GetRouteNodesResult, RouteNode } from './types'\nimport type { Config } from './config'\n\n// Maybe import this from `@tanstack/router-core` in the future???\nconst rootRouteId = '__root__'\n\nlet latestTask = 0\nconst routeGroupPatternRegex = /\\(.+\\)/g\nconst possiblyNestedRouteGroupPatternRegex = /\\([^/]+\\)\\/?/g\n\nlet isFirst = false\nlet skipMessage = false\n\ntype RouteSubNode = {\n component?: RouteNode\n errorComponent?: RouteNode\n pendingComponent?: RouteNode\n loader?: RouteNode\n lazy?: RouteNode\n}\n\nexport async function generator(config: Config, root: string) {\n const ROUTE_TEMPLATE = getTargetTemplate(config.target)\n const logger = logging({ disabled: config.disableLogging })\n logger.log('')\n\n if (!isFirst) {\n logger.log('♻️ Generating routes...')\n isFirst = true\n } else if (skipMessage) {\n skipMessage = false\n } else {\n logger.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\n const TYPES_DISABLED = config.disableTypes\n\n let getRouteNodesResult: GetRouteNodesResult\n\n if (config.virtualRouteConfig) {\n getRouteNodesResult = await virtualGetRouteNodes(config, root)\n } else {\n getRouteNodesResult = await physicalGetRouteNodes(config, root)\n }\n\n const { rootRouteNode, routeNodes: beforeRouteNodes } = getRouteNodesResult\n if (rootRouteNode === undefined) {\n let errorMessage = `rootRouteNode must not be undefined. Make sure you've added your root route into the route-tree.`\n if (!config.virtualRouteConfig) {\n errorMessage += `\\nMake sure that you add a \"${rootPathId}.${config.disableTypes ? 'js' : 'tsx'}\" file to your routes directory.\\nAdd the file in: \"${config.routesDirectory}/${rootPathId}.${config.disableTypes ? 'js' : 'tsx'}\"`\n }\n throw new Error(errorMessage)\n }\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.indexToken}[.]`)) ? 1 : -1,\n (d) =>\n d.filePath.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.routeToken}[.]`)) ? -1 : 1,\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ''))\n\n const routeTree: Array<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 const routeNodes: Array<RouteNode> = []\n\n // the handleRootNode function is not being collapsed into the handleNode function\n // because it requires only a subset of the logic that the handleNode function requires\n // and it's easier to read and maintain this way\n const handleRootNode = async (node?: RouteNode) => {\n if (!node) {\n // currently this is not being handled, but it could be in the future\n // for example to handle a virtual root route\n return\n }\n\n // from here on, we are only handling the root node that's present in the file system\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n if (!routeCode) {\n const _rootTemplate = ROUTE_TEMPLATE.rootRoute\n const replaced = await fillTemplate(config, _rootTemplate.template(), {\n tsrImports: _rootTemplate.imports.tsrImports(),\n tsrPath: rootPathId,\n tsrExportStart: _rootTemplate.imports.tsrExportStart(),\n tsrExportEnd: _rootTemplate.imports.tsrExportEnd(),\n })\n\n await writeIfDifferent(\n node.fullPath,\n '', // Empty string because the file doesn't exist yet\n replaced,\n {\n beforeWrite: () => {\n logger.log(`🟡 Creating ${node.fullPath}`)\n },\n },\n )\n }\n }\n\n await handleRootNode(rootRouteNode)\n\n const handleNode = async (node: RouteNode) => {\n // Do not remove this as we need to set the lastIndex to 0 as it\n // is necessary to reset the regex's index when using the global flag\n // otherwise it might not match the next time it's used\n resetRegex(routeGroupPatternRegex)\n\n let parentRoute = hasParentRoute(routeNodes, node, node.routePath)\n\n // if the parent route is a virtual parent route, we need to find the real parent route\n if (parentRoute?.isVirtualParentRoute && parentRoute.children?.length) {\n // only if this sub-parent route returns a valid parent route, we use it, if not leave it as it\n const possibleParentRoute = hasParentRoute(\n parentRoute.children,\n node,\n node.routePath,\n )\n if (possibleParentRoute) {\n parentRoute = possibleParentRoute\n }\n }\n\n if (parentRoute) node.parent = parentRoute\n\n node.path = determineNodePath(node)\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath.split('/')\n const lastRouteSegment = split[split.length - 1] ?? trimmedPath\n\n node.isNonPath =\n lastRouteSegment.startsWith('_') ||\n routeGroupPatternRegex.test(lastRouteSegment)\n\n node.cleanedPath = removeGroups(\n removeUnderscores(removeLayoutSegments(node.path)) ?? '',\n )\n\n // Ensure the boilerplate for the route exists, which can be skipped for virtual parent routes and virtual routes\n if (!node.isVirtualParentRoute && !node.isVirtual) {\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n const escapedRoutePath = node.routePath?.replaceAll('$', '$$') ?? ''\n\n let replaced = routeCode\n\n const tRouteTemplate = ROUTE_TEMPLATE.route\n const tLazyRouteTemplate = ROUTE_TEMPLATE.lazyRoute\n\n if (!routeCode) {\n // Creating a new lazy route file\n if (node._fsRouteType === 'lazy') {\n // Check by default check if the user has a specific lazy route template\n // If not, check if the user has a route template and use that instead\n replaced = await fillTemplate(\n config,\n (config.customScaffolding?.lazyRouteTemplate ||\n config.customScaffolding?.routeTemplate) ??\n tLazyRouteTemplate.template(),\n {\n tsrImports: tLazyRouteTemplate.imports.tsrImports(),\n tsrPath: escapedRoutePath.replaceAll(/\\{(.+)\\}/gm, '$1'),\n tsrExportStart:\n tLazyRouteTemplate.imports.tsrExportStart(escapedRoutePath),\n tsrExportEnd: tLazyRouteTemplate.imports.tsrExportEnd(),\n },\n )\n } else if (\n // Creating a new normal route file\n (['layout', 'static'] satisfies Array<FsRouteType>).some(\n (d) => d === node._fsRouteType,\n ) ||\n (\n [\n 'component',\n 'pendingComponent',\n 'errorComponent',\n 'loader',\n ] satisfies Array<FsRouteType>\n ).every((d) => d !== node._fsRouteType)\n ) {\n replaced = await fillTemplate(\n config,\n config.customScaffolding?.routeTemplate ??\n tRouteTemplate.template(),\n {\n tsrImports: tRouteTemplate.imports.tsrImports(),\n tsrPath: escapedRoutePath.replaceAll(/\\{(.+)\\}/gm, '$1'),\n tsrExportStart:\n tRouteTemplate.imports.tsrExportStart(escapedRoutePath),\n tsrExportEnd: tRouteTemplate.imports.tsrExportEnd(),\n },\n )\n }\n } else if (config.verboseFileRoutes === false) {\n // Check if the route file has a Route export\n if (\n !routeCode\n .split('\\n')\n .some((line) => line.trim().startsWith('export const Route'))\n ) {\n return\n }\n\n // Update the existing route file\n replaced = routeCode\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n new RegExp(\n `(import\\\\s*\\\\{)(.*)(create(Lazy)?FileRoute)(.*)(\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gs',\n ),\n (_, p1, p2, ___, ____, p5, p6) => {\n const beforeCreateFileRoute = () => {\n if (!p2) return ''\n\n let trimmed = p2.trim()\n\n if (trimmed.endsWith(',')) {\n trimmed = trimmed.slice(0, -1)\n }\n\n return trimmed\n }\n\n const afterCreateFileRoute = () => {\n if (!p5) return ''\n\n let trimmed = p5.trim()\n\n if (trimmed.startsWith(',')) {\n trimmed = trimmed.slice(1)\n }\n\n return trimmed\n }\n\n const newImport = () => {\n const before = beforeCreateFileRoute()\n const after = afterCreateFileRoute()\n\n if (!before) return after\n\n if (!after) return before\n\n return `${before},${after}`\n }\n\n const middle = newImport()\n\n if (middle === '') return ''\n\n return `${p1} ${newImport()} ${p6}`\n },\n )\n .replace(\n /create(Lazy)?FileRoute(\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, __, p2, ___, p4) =>\n `${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}`,\n )\n } else {\n // Check if the route file has a Route export\n if (\n !routeCode\n .split('\\n')\n .some((line) => line.trim().startsWith('export const Route'))\n ) {\n return\n }\n\n // Update the existing route file\n replaced = routeCode\n // fix wrong ids\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n // fix missing ids\n .replace(\n /((FileRoute)(\\s*)(\\({))/g,\n (_, __, p2, p3, p4) => `${p2}('${escapedRoutePath}')${p3}${p4}`,\n )\n .replace(\n new RegExp(\n `(import\\\\s*\\\\{.*)(create(Lazy)?FileRoute)(.*\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gs',\n ),\n (_, p1, __, ___, p4) =>\n `${p1}${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}${p4}`,\n )\n .replace(\n /create(Lazy)?FileRoute(\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, __, p2, ___, p4) =>\n `${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}${p2}${escapedRoutePath}${p4}`,\n )\n\n // check whether the import statement is already present\n const regex = new RegExp(\n `(import\\\\s*\\\\{.*)(create(Lazy)?FileRoute)(.*\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gm',\n )\n if (!replaced.match(regex)) {\n replaced = [\n `import { ${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'} } from '@tanstack/${ROUTE_TEMPLATE.subPkg}'`,\n ...replaced.split('\\n'),\n ].join('\\n')\n }\n }\n\n await writeIfDifferent(node.fullPath, routeCode, replaced, {\n beforeWrite: () => {\n logger.log(`🟡 Updating ${node.fullPath}`)\n },\n })\n }\n\n if (\n !node.isVirtual &&\n (\n [\n 'lazy',\n 'loader',\n 'component',\n 'pendingComponent',\n 'errorComponent',\n ] satisfies Array<FsRouteType>\n ).some((d) => d === node._fsRouteType)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node._fsRouteType === 'lazy'\n ? 'lazy'\n : node._fsRouteType === 'loader'\n ? 'loader'\n : node._fsRouteType === 'errorComponent'\n ? 'errorComponent'\n : node._fsRouteType === 'pendingComponent'\n ? 'pendingComponent'\n : 'component'\n ] = node\n\n const anchorRoute = routeNodes.find((d) => d.routePath === node.routePath)\n\n if (!anchorRoute) {\n await handleNode({\n ...node,\n isVirtual: true,\n _fsRouteType: 'static',\n })\n }\n return\n }\n\n const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0\n const nonPathRoute =\n node._fsRouteType === 'pathless_layout' && node.isNonPath\n\n node.isVirtualParentRequired =\n node._fsRouteType === 'pathless_layout' || nonPathRoute\n ? !cleanedPathIsEmpty\n : false\n\n if (!node.isVirtual && node.isVirtualParentRequired) {\n const parentRoutePath = removeLastSegmentFromPath(node.routePath) || '/'\n const parentVariableName = routePathToVariable(parentRoutePath)\n\n const anchorRoute = routeNodes.find(\n (d) => d.routePath === parentRoutePath,\n )\n\n if (!anchorRoute) {\n const parentNode: RouteNode = {\n ...node,\n path: removeLastSegmentFromPath(node.path) || '/',\n filePath: removeLastSegmentFromPath(node.filePath) || '/',\n fullPath: removeLastSegmentFromPath(node.fullPath) || '/',\n routePath: parentRoutePath,\n variableName: parentVariableName,\n isVirtual: true,\n _fsRouteType: 'layout', // layout since this route will wrap other routes\n isVirtualParentRoute: true,\n isVirtualParentRequired: false,\n }\n\n parentNode.children = parentNode.children ?? []\n parentNode.children.push(node)\n\n node.parent = parentNode\n\n if (node._fsRouteType === 'pathless_layout') {\n // since `node.path` is used as the `id` on the route definition, we need to update it\n node.path = determineNodePath(node)\n }\n\n await handleNode(parentNode)\n } else {\n anchorRoute.children = anchorRoute.children ?? []\n anchorRoute.children.push(node)\n\n node.parent = anchorRoute\n }\n }\n\n if (node.parent) {\n if (!node.isVirtualParentRequired) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n }\n } else {\n routeTree.push(node)\n }\n\n routeNodes.push(node)\n }\n\n for (const node of preRouteNodes) {\n await handleNode(node)\n }\n\n // This is run against the `preRouteNodes` array since it\n // has the flattened Route nodes and not the full tree\n // Since TSR allows multiple way of defining a route,\n // we need to ensure that a user hasn't defined the\n // same route in multiple ways (i.e. `flat`, `nested`, `virtual`)\n checkRouteFullPathUniqueness(\n preRouteNodes.filter(\n (d) => d.children === undefined && 'lazy' !== d._fsRouteType,\n ),\n config,\n )\n\n function buildRouteTreeConfig(nodes: Array<RouteNode>, depth = 1): string {\n const children = nodes.map((node) => {\n if (node._fsRouteType === '__root') {\n return\n }\n\n if (node._fsRouteType === 'pathless_layout' && !node.children?.length) {\n return\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = buildRouteTreeConfig(node.children, depth + 1)\n\n const childrenDeclaration = TYPES_DISABLED\n ? ''\n : `interface ${route}Children {\n ${node.children.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const children = `const ${route}Children${TYPES_DISABLED ? '' : `: ${route}Children`} = {\n ${node.children.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const routeWithChildren = `const ${route}WithChildren = ${route}._addFileChildren(${route}Children)`\n\n return [\n childConfigs,\n childrenDeclaration,\n children,\n routeWithChildren,\n ].join('\\n\\n')\n }\n\n return undefined\n })\n\n return children.filter(Boolean).join('\\n\\n')\n }\n\n const routeConfigChildrenText = buildRouteTreeConfig(routeTree)\n\n const sortedRouteNodes = multiSortBy(routeNodes, [\n (d) => (d.routePath?.includes(`/${rootPathId}`) ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(config.indexToken) ? -1 : 1),\n (d) => d,\n ])\n\n const typeImports = Object.entries({\n // Used for augmentation of regular routes\n CreateFileRoute:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some(\n (d) => isRouteNodeValidForAugmentation(d) && d._fsRouteType !== 'lazy',\n ),\n // Used for augmentation of lazy (`.lazy`) routes\n CreateLazyFileRoute:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some(\n (node) =>\n routePiecesByPath[node.routePath!]?.lazy &&\n isRouteNodeValidForAugmentation(node),\n ),\n // Used in the process of augmenting the routes\n FileRoutesByPath:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some((d) => isRouteNodeValidForAugmentation(d)),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n .sort((a, b) => a.localeCompare(b))\n\n const imports = Object.entries({\n createFileRoute: 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 virtualRouteNodes = sortedRouteNodes.filter((d) => d.isVirtual)\n\n function getImportPath(node: RouteNode) {\n return replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, node.filePath),\n ),\n config.addExtensions,\n ),\n )\n }\n\n const routeImports = [\n ...config.routeTreeFileHeader,\n `// This file was automatically generated by TanStack Router.\n// You should NOT make any changes in this file as it will be overwritten.\n// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.`,\n [\n imports.length\n ? `import { ${imports.join(', ')} } from '${ROUTE_TEMPLATE.fullPkg}'`\n : '',\n !TYPES_DISABLED && typeImports.length\n ? `import type { ${typeImports.join(', ')} } from '${ROUTE_TEMPLATE.fullPkg}'`\n : '',\n ]\n .filter(Boolean)\n .join('\\n'),\n '// Import Routes',\n [\n `import { Route as rootRoute } from './${getImportPath(rootRouteNode)}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }RouteImport } from './${getImportPath(node)}'`\n }),\n ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }RouteImport = createFileRoute('${node.routePath}')()`\n })\n .join('\\n'),\n '// Create/Update Routes',\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 const lazyComponentNode = routePiecesByPath[node.routePath!]?.lazy\n\n return [\n [\n `const ${node.variableName}Route = ${node.variableName}RouteImport.update({\n ${[\n `id: '${node.path}'`,\n !node.isNonPath ? `path: '${node.cleanedPath}'` : undefined,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n }${TYPES_DISABLED ? '' : 'as any'})`,\n loaderNode\n ? `.updateLoader({ loader: lazyFn(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, loaderNode.filePath),\n ),\n config.addExtensions,\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('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, d[1]!.filePath),\n ),\n config.addExtensions,\n ),\n )}'), '${d[0]}')`\n })\n .join('\\n,')}\n })`\n : '',\n lazyComponentNode\n ? `.lazy(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n lazyComponentNode.filePath,\n ),\n ),\n config.addExtensions,\n ),\n )}').then((d) => d.Route))`\n : '',\n ].join(''),\n ].join('\\n\\n')\n })\n .join('\\n\\n'),\n ...(TYPES_DISABLED\n ? []\n : [\n '// Populate the FileRoutesByPath interface',\n `declare module '${ROUTE_TEMPLATE.fullPkg}' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n const filePathId = routeNode.routePath\n\n return `'${filePathId}': {\n id: '${filePathId}'\n path: '${inferPath(routeNode)}'\n fullPath: '${inferFullPath(routeNode)}'\n preLoaderRoute: typeof ${routeNode.variableName}RouteImport\n parentRoute: typeof ${\n routeNode.isVirtualParentRequired\n ? `${routeNode.parent?.variableName}Route`\n : routeNode.parent?.variableName\n ? `${routeNode.parent.variableName}RouteImport`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n ]),\n ...(TYPES_DISABLED\n ? []\n : config.verboseFileRoutes !== false\n ? []\n : [\n `// Add type-safety to the createFileRoute function across the route tree`,\n routeNodes\n .map((routeNode) => {\n function getModuleDeclaration(routeNode?: RouteNode) {\n if (!isRouteNodeValidForAugmentation(routeNode)) {\n return ''\n }\n return `declare module './${getImportPath(routeNode)}' {\n const ${routeNode._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}: ${\n routeNode._fsRouteType === 'lazy'\n ? `CreateLazyFileRoute<FileRoutesByPath['${routeNode.routePath}']['preLoaderRoute']>}`\n : `CreateFileRoute<\n '${routeNode.routePath}',\n FileRoutesByPath['${routeNode.routePath}']['parentRoute'],\n FileRoutesByPath['${routeNode.routePath}']['id'],\n FileRoutesByPath['${routeNode.routePath}']['path'],\n FileRoutesByPath['${routeNode.routePath}']['fullPath']\n >\n }`\n }`\n }\n return (\n getModuleDeclaration(routeNode) +\n getModuleDeclaration(\n routePiecesByPath[routeNode.routePath!]?.lazy,\n )\n )\n })\n .join('\\n'),\n ]),\n '// Create and export the route tree',\n routeConfigChildrenText,\n ...(TYPES_DISABLED\n ? []\n : [\n `export interface FileRoutesByFullPath {\n ${[...createRouteNodesByFullPath(routeNodes).entries()].map(\n ([fullPath, routeNode]) => {\n return `'${fullPath}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n },\n )}\n}`,\n `export interface FileRoutesByTo {\n ${[...createRouteNodesByTo(routeNodes).entries()].map(([to, routeNode]) => {\n return `'${to}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRoutesById {\n '${rootRouteId}': typeof rootRoute,\n ${[...createRouteNodesById(routeNodes).entries()].map(([id, routeNode]) => {\n return `'${id}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRouteTypes {\n fileRoutesByFullPath: FileRoutesByFullPath\n fullPaths: ${routeNodes.length > 0 ? [...createRouteNodesByFullPath(routeNodes).keys()].map((fullPath) => `'${fullPath}'`).join('|') : 'never'}\n fileRoutesByTo: FileRoutesByTo\n to: ${routeNodes.length > 0 ? [...createRouteNodesByTo(routeNodes).keys()].map((to) => `'${to}'`).join('|') : 'never'}\n id: ${[`'${rootRouteId}'`, ...[...createRouteNodesById(routeNodes).keys()].map((id) => `'${id}'`)].join('|')}\n fileRoutesById: FileRoutesById\n}`,\n `export interface RootRouteChildren {\n ${routeTree.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n ]),\n `const rootRouteChildren${TYPES_DISABLED ? '' : ': RootRouteChildren'} = {\n ${routeTree.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n `export const routeTree = rootRoute._addFileChildren(rootRouteChildren)${TYPES_DISABLED ? '' : '._addFileTypes<FileRouteTypes>()'}`,\n ...config.routeTreeFileFooter,\n ]\n .filter(Boolean)\n .join('\\n\\n')\n\n const createRouteManifest = () => {\n const routesManifest = {\n [rootRouteId]: {\n filePath: rootRouteNode.filePath,\n children: routeTree.map((d) => d.routePath),\n },\n ...Object.fromEntries(\n routeNodes.map((d) => {\n const filePathId = d.routePath\n\n return [\n filePathId,\n {\n filePath: d.filePath,\n parent: d.parent?.routePath ? d.parent.routePath : undefined,\n children: d.children?.map((childRoute) => childRoute.routePath),\n },\n ]\n }),\n ),\n }\n\n return JSON.stringify(\n {\n routes: routesManifest,\n },\n null,\n 2,\n )\n }\n\n const includeManifest = ['react', 'solid']\n const routeConfigFileContent =\n config.disableManifestGeneration || !includeManifest.includes(config.target)\n ? routeImports\n : [\n routeImports,\n '\\n',\n '/* ROUTE_MANIFEST_START',\n createRouteManifest(),\n 'ROUTE_MANIFEST_END */',\n ].join('\\n')\n\n if (!checkLatest()) return\n\n const existingRouteTreeContent = await fsp\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return ''\n }\n\n throw err\n })\n\n if (!checkLatest()) return\n\n // Ensure the directory exists\n await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n\n if (!checkLatest()) return\n\n // Write the route tree file, if it has changed\n const routeTreeWriteResult = await writeIfDifferent(\n path.resolve(config.generatedRouteTree),\n config.enableRouteTreeFormatting\n ? await format(existingRouteTreeContent, config)\n : existingRouteTreeContent,\n config.enableRouteTreeFormatting\n ? await format(routeConfigFileContent, config)\n : routeConfigFileContent,\n {\n beforeWrite: () => {\n logger.log(`🟡 Updating ${config.generatedRouteTree}`)\n },\n },\n )\n if (routeTreeWriteResult && !checkLatest()) {\n return\n }\n\n logger.log(\n `✅ Processed ${routeNodes.length === 1 ? 'route' : 'routes'} in ${\n Date.now() - start\n }ms`,\n )\n}\n\n// function removeTrailingUnderscores(s?: string) {\n// return s?.replaceAll(/(_$)/gi, '').replaceAll(/(_\\/)/gi, '/')\n// }\n\nfunction removeGroups(s: string) {\n return s.replace(possiblyNestedRouteGroupPatternRegex, '')\n}\n\n/**\n * Checks if a given RouteNode is valid for augmenting it with typing based on conditions.\n * Also asserts that the RouteNode is defined.\n *\n * @param routeNode - The RouteNode to check.\n * @returns A boolean indicating whether the RouteNode is defined.\n */\nfunction isRouteNodeValidForAugmentation(\n routeNode?: RouteNode,\n): routeNode is RouteNode {\n if (!routeNode || routeNode.isVirtual) {\n return false\n }\n return true\n}\n\n/**\n * The `node.path` is used as the `id` in the route definition.\n * This function checks if the given node has a parent and if so, it determines the correct path for the given node.\n * @param node - The node to determine the path for.\n * @returns The correct path for the given node.\n */\nfunction determineNodePath(node: RouteNode) {\n return (node.path = node.parent\n ? node.routePath?.replace(node.parent.routePath ?? '', '') || '/'\n : node.routePath)\n}\n\n/**\n * Removes the last segment from a given path. Segments are considered to be separated by a '/'.\n *\n * @param {string} routePath - The path from which to remove the last segment. Defaults to '/'.\n * @returns {string} The path with the last segment removed.\n * @example\n * removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'\n */\nfunction removeLastSegmentFromPath(routePath: string = '/'): string {\n const segments = routePath.split('/')\n segments.pop() // Remove the last segment\n return segments.join('/')\n}\n\n/**\n * Removes all segments from a given path that start with an underscore ('_').\n *\n * @param {string} routePath - The path from which to remove segments. Defaults to '/'.\n * @returns {string} The path with all underscore-prefixed segments removed.\n * @example\n * removeLayoutSegments('/workspace/_auth/foo') // '/workspace/foo'\n */\nfunction removeLayoutSegments(routePath: string = '/'): string {\n const segments = routePath.split('/')\n const newSegments = segments.filter((segment) => !segment.startsWith('_'))\n return newSegments.join('/')\n}\n\nfunction hasParentRoute(\n routes: Array<RouteNode>,\n node: 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\n const segments = routePathToCheck.split('/')\n segments.pop() // Remove the last segment\n const parentRoutePath = segments.join('/')\n\n return hasParentRoute(routes, node, parentRoutePath)\n}\n\n/**\n * Gets the final variable name for a route\n */\nconst getResolvedRouteNodeVariableName = (routeNode: RouteNode): string => {\n return routeNode.children?.length\n ? `${routeNode.variableName}RouteWithChildren`\n : `${routeNode.variableName}Route`\n}\n\n/**\n * Creates a map from fullPath to routeNode\n */\nconst createRouteNodesByFullPath = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => [inferFullPath(routeNode), routeNode]),\n )\n}\n\n/**\n * Create a map from 'to' to a routeNode\n */\nconst createRouteNodesByTo = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n dedupeBranchesAndIndexRoutes(routeNodes).map((routeNode) => [\n inferTo(routeNode),\n routeNode,\n ]),\n )\n}\n\n/**\n * Create a map from 'id' to a routeNode\n */\nconst createRouteNodesById = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => {\n const id = routeNode.routePath ?? ''\n return [id, routeNode]\n }),\n )\n}\n\n/**\n * Infers the full path for use by TS\n */\nconst inferFullPath = (routeNode: RouteNode): string => {\n const fullPath = removeGroups(\n removeUnderscores(removeLayoutSegments(routeNode.routePath)) ?? '',\n )\n\n return routeNode.cleanedPath === '/' ? fullPath : fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Infers the path for use by TS\n */\nconst inferPath = (routeNode: RouteNode): string => {\n return routeNode.cleanedPath === '/'\n ? routeNode.cleanedPath\n : (routeNode.cleanedPath?.replace(/\\/$/, '') ?? '')\n}\n\n/**\n * Infers to path\n */\nconst inferTo = (routeNode: RouteNode): string => {\n const fullPath = inferFullPath(routeNode)\n\n if (fullPath === '/') return fullPath\n\n return fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Dedupes branches and index routes\n */\nconst dedupeBranchesAndIndexRoutes = (\n routes: Array<RouteNode>,\n): Array<RouteNode> => {\n return routes.filter((route) => {\n if (route.children?.find((child) => child.cleanedPath === '/')) return false\n return true\n })\n}\n\nfunction checkUnique<TElement>(routes: Array<TElement>, key: keyof TElement) {\n // Check no two routes have the same `key`\n // if they do, throw an error with the conflicting filePaths\n const keys = routes.map((d) => d[key])\n const uniqueKeys = new Set(keys)\n if (keys.length !== uniqueKeys.size) {\n const duplicateKeys = keys.filter((d, i) => keys.indexOf(d) !== i)\n const conflictingFiles = routes.filter((d) =>\n duplicateKeys.includes(d[key]),\n )\n return conflictingFiles\n }\n return undefined\n}\n\nfunction checkRouteFullPathUniqueness(\n _routes: Array<RouteNode>,\n config: Config,\n) {\n const routes = _routes.map((d) => {\n const inferredFullPath = inferFullPath(d)\n return { ...d, inferredFullPath }\n })\n\n const conflictingFiles = checkUnique(routes, 'inferredFullPath')\n\n if (conflictingFiles !== undefined) {\n const errorMessage = `Conflicting configuration paths were found for the following route${conflictingFiles.length > 1 ? 's' : ''}: ${conflictingFiles\n .map((p) => `\"${p.inferredFullPath}\"`)\n .join(', ')}.\nPlease ensure each Route has a unique full path.\nConflicting files: \\n ${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join('\\n ')}\\n`\n throw new Error(errorMessage)\n }\n}\n"],"names":["getTargetTemplate","logging","virtualGetRouteNodes","physicalGetRouteNodes","rootPathId","multiSortBy","fs","fillTemplate","writeIfDifferent","resetRegex","trimPathLeft","removeUnderscores","routePathToVariable","children","replaceBackslash","removeExt","routeNode","fsp","format"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,cAAc;AAEpB,IAAI,aAAa;AACjB,MAAM,yBAAyB;AAC/B,MAAM,uCAAuC;AAE7C,IAAI,UAAU;AACd,IAAI,cAAc;AAUI,eAAA,UAAU,QAAgB,MAAc;AACtD,QAAA,iBAAiBA,SAAAA,kBAAkB,OAAO,MAAM;AACtD,QAAM,SAASC,MAAAA,QAAQ,EAAE,UAAU,OAAO,gBAAgB;AAC1D,SAAO,IAAI,EAAE;AAEb,MAAI,CAAC,SAAS;AACZ,WAAO,IAAI,0BAA0B;AAC3B,cAAA;AAAA,aACD,aAAa;AACR,kBAAA;AAAA,EAAA,OACT;AACL,WAAO,IAAI,4BAA4B;AAAA,EAAA;AAGzC,QAAM,SAAS,aAAa;AACf,eAAA;AAEb,QAAM,cAAc,MAAM;AACxB,QAAI,eAAe,QAAQ;AACX,oBAAA;AACP,aAAA;AAAA,IAAA;AAGF,WAAA;AAAA,EACT;AAEM,QAAA,QAAQ,KAAK,IAAI;AAEvB,QAAM,iBAAiB,OAAO;AAE1B,MAAA;AAEJ,MAAI,OAAO,oBAAoB;AACP,0BAAA,MAAMC,cAAAA,cAAqB,QAAQ,IAAI;AAAA,EAAA,OACxD;AACiB,0BAAA,MAAMC,gBAAAA,cAAsB,QAAQ,IAAI;AAAA,EAAA;AAGhE,QAAM,EAAE,eAAe,YAAY,iBAAqB,IAAA;AACxD,MAAI,kBAAkB,QAAW;AAC/B,QAAI,eAAe;AACf,QAAA,CAAC,OAAO,oBAAoB;AACd,sBAAA;AAAA,4BAA+BC,WAAAA,UAAU,IAAI,OAAO,eAAe,OAAO,KAAK;AAAA,oBAAuD,OAAO,eAAe,IAAIA,qBAAU,IAAI,OAAO,eAAe,OAAO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C/B,QAAA,aAAa,IAAI,IAAI,IAAI;AAC3B,MAAA,KAAK,WAAW,WAAW,MAAM;AAC7B,UAAA,gBAAgB,KAAK,OAAO,CAAC,GAAG,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;AACjE,UAAM,mBAAmB,OAAO;AAAA,MAAO,CAAC,MACtC,cAAc,SAAS,EAAE,GAAG,CAAC;AAAA,IAC/B;AACO,WAAA;AAAA,EAAA;AAEF,SAAA;AACT;AAEA,SAAS,6BACP,SACA,QACA;AACA,QAAM,SAAS,QAAQ,IAAI,CAAC,MAAM;AAC1B,UAAA,mBAAmB,cAAc,CAAC;AACjC,WAAA,EAAE,GAAG,GAAG,iBAAiB;AAAA,EAAA,CACjC;AAEK,QAAA,mBAAmB,YAAY,QAAQ,kBAAkB;AAE/D,MAAI,qBAAqB,QAAW;AAClC,UAAM,eAAe,qEAAqE,iBAAiB,SAAS,IAAI,MAAM,EAAE,KAAK,iBAClI,IAAI,CAAC,MAAM,IAAI,EAAE,gBAAgB,GAAG,EACpC,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA,GAEO,iBAAiB,IAAI,CAAC,MAAM,KAAK,QAAQ,OAAO,iBAAiB,EAAE,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAAA;AACvG,UAAA,IAAI,MAAM,YAAY;AAAA,EAAA;AAEhC;;"}
@@ -206,6 +206,9 @@ Add the file in: "${config.routesDirectory}/${rootPathId}.${config.disableTypes
206
206
  (_, __, p2, ___, p4) => `${node._fsRouteType === "lazy" ? "createLazyFileRoute" : "createFileRoute"}`
207
207
  );
208
208
  } else {
209
+ if (!routeCode.split("\n").some((line) => line.trim().startsWith("export const Route"))) {
210
+ return;
211
+ }
209
212
  replaced = routeCode.replace(
210
213
  /(FileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
211
214
  (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sources":["../../src/generator.ts"],"sourcesContent":["import path from 'node:path'\nimport * as fs from 'node:fs'\nimport * as fsp from 'node:fs/promises'\nimport {\n format,\n logging,\n multiSortBy,\n removeExt,\n removeUnderscores,\n replaceBackslash,\n resetRegex,\n routePathToVariable,\n trimPathLeft,\n writeIfDifferent,\n} from './utils'\nimport { getRouteNodes as physicalGetRouteNodes } from './filesystem/physical/getRouteNodes'\nimport { getRouteNodes as virtualGetRouteNodes } from './filesystem/virtual/getRouteNodes'\nimport { rootPathId } from './filesystem/physical/rootPathId'\nimport { fillTemplate, getTargetTemplate } from './template'\nimport type { FsRouteType, GetRouteNodesResult, RouteNode } from './types'\nimport type { Config } from './config'\n\n// Maybe import this from `@tanstack/router-core` in the future???\nconst rootRouteId = '__root__'\n\nlet latestTask = 0\nconst routeGroupPatternRegex = /\\(.+\\)/g\nconst possiblyNestedRouteGroupPatternRegex = /\\([^/]+\\)\\/?/g\n\nlet isFirst = false\nlet skipMessage = false\n\ntype RouteSubNode = {\n component?: RouteNode\n errorComponent?: RouteNode\n pendingComponent?: RouteNode\n loader?: RouteNode\n lazy?: RouteNode\n}\n\nexport async function generator(config: Config, root: string) {\n const ROUTE_TEMPLATE = getTargetTemplate(config.target)\n const logger = logging({ disabled: config.disableLogging })\n logger.log('')\n\n if (!isFirst) {\n logger.log('♻️ Generating routes...')\n isFirst = true\n } else if (skipMessage) {\n skipMessage = false\n } else {\n logger.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\n const TYPES_DISABLED = config.disableTypes\n\n let getRouteNodesResult: GetRouteNodesResult\n\n if (config.virtualRouteConfig) {\n getRouteNodesResult = await virtualGetRouteNodes(config, root)\n } else {\n getRouteNodesResult = await physicalGetRouteNodes(config, root)\n }\n\n const { rootRouteNode, routeNodes: beforeRouteNodes } = getRouteNodesResult\n if (rootRouteNode === undefined) {\n let errorMessage = `rootRouteNode must not be undefined. Make sure you've added your root route into the route-tree.`\n if (!config.virtualRouteConfig) {\n errorMessage += `\\nMake sure that you add a \"${rootPathId}.${config.disableTypes ? 'js' : 'tsx'}\" file to your routes directory.\\nAdd the file in: \"${config.routesDirectory}/${rootPathId}.${config.disableTypes ? 'js' : 'tsx'}\"`\n }\n throw new Error(errorMessage)\n }\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.indexToken}[.]`)) ? 1 : -1,\n (d) =>\n d.filePath.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.routeToken}[.]`)) ? -1 : 1,\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ''))\n\n const routeTree: Array<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 const routeNodes: Array<RouteNode> = []\n\n // the handleRootNode function is not being collapsed into the handleNode function\n // because it requires only a subset of the logic that the handleNode function requires\n // and it's easier to read and maintain this way\n const handleRootNode = async (node?: RouteNode) => {\n if (!node) {\n // currently this is not being handled, but it could be in the future\n // for example to handle a virtual root route\n return\n }\n\n // from here on, we are only handling the root node that's present in the file system\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n if (!routeCode) {\n const _rootTemplate = ROUTE_TEMPLATE.rootRoute\n const replaced = await fillTemplate(config, _rootTemplate.template(), {\n tsrImports: _rootTemplate.imports.tsrImports(),\n tsrPath: rootPathId,\n tsrExportStart: _rootTemplate.imports.tsrExportStart(),\n tsrExportEnd: _rootTemplate.imports.tsrExportEnd(),\n })\n\n await writeIfDifferent(\n node.fullPath,\n '', // Empty string because the file doesn't exist yet\n replaced,\n {\n beforeWrite: () => {\n logger.log(`🟡 Creating ${node.fullPath}`)\n },\n },\n )\n }\n }\n\n await handleRootNode(rootRouteNode)\n\n const handleNode = async (node: RouteNode) => {\n // Do not remove this as we need to set the lastIndex to 0 as it\n // is necessary to reset the regex's index when using the global flag\n // otherwise it might not match the next time it's used\n resetRegex(routeGroupPatternRegex)\n\n let parentRoute = hasParentRoute(routeNodes, node, node.routePath)\n\n // if the parent route is a virtual parent route, we need to find the real parent route\n if (parentRoute?.isVirtualParentRoute && parentRoute.children?.length) {\n // only if this sub-parent route returns a valid parent route, we use it, if not leave it as it\n const possibleParentRoute = hasParentRoute(\n parentRoute.children,\n node,\n node.routePath,\n )\n if (possibleParentRoute) {\n parentRoute = possibleParentRoute\n }\n }\n\n if (parentRoute) node.parent = parentRoute\n\n node.path = determineNodePath(node)\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath.split('/')\n const lastRouteSegment = split[split.length - 1] ?? trimmedPath\n\n node.isNonPath =\n lastRouteSegment.startsWith('_') ||\n routeGroupPatternRegex.test(lastRouteSegment)\n\n node.cleanedPath = removeGroups(\n removeUnderscores(removeLayoutSegments(node.path)) ?? '',\n )\n\n // Ensure the boilerplate for the route exists, which can be skipped for virtual parent routes and virtual routes\n if (!node.isVirtualParentRoute && !node.isVirtual) {\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n const escapedRoutePath = node.routePath?.replaceAll('$', '$$') ?? ''\n\n let replaced = routeCode\n\n const tRouteTemplate = ROUTE_TEMPLATE.route\n const tLazyRouteTemplate = ROUTE_TEMPLATE.lazyRoute\n\n if (!routeCode) {\n // Creating a new lazy route file\n if (node._fsRouteType === 'lazy') {\n // Check by default check if the user has a specific lazy route template\n // If not, check if the user has a route template and use that instead\n replaced = await fillTemplate(\n config,\n (config.customScaffolding?.lazyRouteTemplate ||\n config.customScaffolding?.routeTemplate) ??\n tLazyRouteTemplate.template(),\n {\n tsrImports: tLazyRouteTemplate.imports.tsrImports(),\n tsrPath: escapedRoutePath.replaceAll(/\\{(.+)\\}/gm, '$1'),\n tsrExportStart:\n tLazyRouteTemplate.imports.tsrExportStart(escapedRoutePath),\n tsrExportEnd: tLazyRouteTemplate.imports.tsrExportEnd(),\n },\n )\n } else if (\n // Creating a new normal route file\n (['layout', 'static'] satisfies Array<FsRouteType>).some(\n (d) => d === node._fsRouteType,\n ) ||\n (\n [\n 'component',\n 'pendingComponent',\n 'errorComponent',\n 'loader',\n ] satisfies Array<FsRouteType>\n ).every((d) => d !== node._fsRouteType)\n ) {\n replaced = await fillTemplate(\n config,\n config.customScaffolding?.routeTemplate ??\n tRouteTemplate.template(),\n {\n tsrImports: tRouteTemplate.imports.tsrImports(),\n tsrPath: escapedRoutePath.replaceAll(/\\{(.+)\\}/gm, '$1'),\n tsrExportStart:\n tRouteTemplate.imports.tsrExportStart(escapedRoutePath),\n tsrExportEnd: tRouteTemplate.imports.tsrExportEnd(),\n },\n )\n }\n } else if (config.verboseFileRoutes === false) {\n // Check if the route file has a Route export\n if (\n !routeCode\n .split('\\n')\n .some((line) => line.trim().startsWith('export const Route'))\n ) {\n return\n }\n\n // Update the existing route file\n replaced = routeCode\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n new RegExp(\n `(import\\\\s*\\\\{)(.*)(create(Lazy)?FileRoute)(.*)(\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gs',\n ),\n (_, p1, p2, ___, ____, p5, p6) => {\n const beforeCreateFileRoute = () => {\n if (!p2) return ''\n\n let trimmed = p2.trim()\n\n if (trimmed.endsWith(',')) {\n trimmed = trimmed.slice(0, -1)\n }\n\n return trimmed\n }\n\n const afterCreateFileRoute = () => {\n if (!p5) return ''\n\n let trimmed = p5.trim()\n\n if (trimmed.startsWith(',')) {\n trimmed = trimmed.slice(1)\n }\n\n return trimmed\n }\n\n const newImport = () => {\n const before = beforeCreateFileRoute()\n const after = afterCreateFileRoute()\n\n if (!before) return after\n\n if (!after) return before\n\n return `${before},${after}`\n }\n\n const middle = newImport()\n\n if (middle === '') return ''\n\n return `${p1} ${newImport()} ${p6}`\n },\n )\n .replace(\n /create(Lazy)?FileRoute(\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, __, p2, ___, p4) =>\n `${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}`,\n )\n } else {\n replaced = routeCode\n // fix wrong ids\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n // fix missing ids\n .replace(\n /((FileRoute)(\\s*)(\\({))/g,\n (_, __, p2, p3, p4) => `${p2}('${escapedRoutePath}')${p3}${p4}`,\n )\n .replace(\n new RegExp(\n `(import\\\\s*\\\\{.*)(create(Lazy)?FileRoute)(.*\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gs',\n ),\n (_, p1, __, ___, p4) =>\n `${p1}${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}${p4}`,\n )\n .replace(\n /create(Lazy)?FileRoute(\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, __, p2, ___, p4) =>\n `${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}${p2}${escapedRoutePath}${p4}`,\n )\n\n // check whether the import statement is already present\n const regex = new RegExp(\n `(import\\\\s*\\\\{.*)(create(Lazy)?FileRoute)(.*\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gm',\n )\n if (!replaced.match(regex)) {\n replaced = [\n `import { ${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'} } from '@tanstack/${ROUTE_TEMPLATE.subPkg}'`,\n ...replaced.split('\\n'),\n ].join('\\n')\n }\n }\n\n await writeIfDifferent(node.fullPath, routeCode, replaced, {\n beforeWrite: () => {\n logger.log(`🟡 Updating ${node.fullPath}`)\n },\n })\n }\n\n if (\n !node.isVirtual &&\n (\n [\n 'lazy',\n 'loader',\n 'component',\n 'pendingComponent',\n 'errorComponent',\n ] satisfies Array<FsRouteType>\n ).some((d) => d === node._fsRouteType)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node._fsRouteType === 'lazy'\n ? 'lazy'\n : node._fsRouteType === 'loader'\n ? 'loader'\n : node._fsRouteType === 'errorComponent'\n ? 'errorComponent'\n : node._fsRouteType === 'pendingComponent'\n ? 'pendingComponent'\n : 'component'\n ] = node\n\n const anchorRoute = routeNodes.find((d) => d.routePath === node.routePath)\n\n if (!anchorRoute) {\n await handleNode({\n ...node,\n isVirtual: true,\n _fsRouteType: 'static',\n })\n }\n return\n }\n\n const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0\n const nonPathRoute =\n node._fsRouteType === 'pathless_layout' && node.isNonPath\n\n node.isVirtualParentRequired =\n node._fsRouteType === 'pathless_layout' || nonPathRoute\n ? !cleanedPathIsEmpty\n : false\n\n if (!node.isVirtual && node.isVirtualParentRequired) {\n const parentRoutePath = removeLastSegmentFromPath(node.routePath) || '/'\n const parentVariableName = routePathToVariable(parentRoutePath)\n\n const anchorRoute = routeNodes.find(\n (d) => d.routePath === parentRoutePath,\n )\n\n if (!anchorRoute) {\n const parentNode: RouteNode = {\n ...node,\n path: removeLastSegmentFromPath(node.path) || '/',\n filePath: removeLastSegmentFromPath(node.filePath) || '/',\n fullPath: removeLastSegmentFromPath(node.fullPath) || '/',\n routePath: parentRoutePath,\n variableName: parentVariableName,\n isVirtual: true,\n _fsRouteType: 'layout', // layout since this route will wrap other routes\n isVirtualParentRoute: true,\n isVirtualParentRequired: false,\n }\n\n parentNode.children = parentNode.children ?? []\n parentNode.children.push(node)\n\n node.parent = parentNode\n\n if (node._fsRouteType === 'pathless_layout') {\n // since `node.path` is used as the `id` on the route definition, we need to update it\n node.path = determineNodePath(node)\n }\n\n await handleNode(parentNode)\n } else {\n anchorRoute.children = anchorRoute.children ?? []\n anchorRoute.children.push(node)\n\n node.parent = anchorRoute\n }\n }\n\n if (node.parent) {\n if (!node.isVirtualParentRequired) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n }\n } else {\n routeTree.push(node)\n }\n\n routeNodes.push(node)\n }\n\n for (const node of preRouteNodes) {\n await handleNode(node)\n }\n\n // This is run against the `preRouteNodes` array since it\n // has the flattened Route nodes and not the full tree\n // Since TSR allows multiple way of defining a route,\n // we need to ensure that a user hasn't defined the\n // same route in multiple ways (i.e. `flat`, `nested`, `virtual`)\n checkRouteFullPathUniqueness(\n preRouteNodes.filter(\n (d) => d.children === undefined && 'lazy' !== d._fsRouteType,\n ),\n config,\n )\n\n function buildRouteTreeConfig(nodes: Array<RouteNode>, depth = 1): string {\n const children = nodes.map((node) => {\n if (node._fsRouteType === '__root') {\n return\n }\n\n if (node._fsRouteType === 'pathless_layout' && !node.children?.length) {\n return\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = buildRouteTreeConfig(node.children, depth + 1)\n\n const childrenDeclaration = TYPES_DISABLED\n ? ''\n : `interface ${route}Children {\n ${node.children.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const children = `const ${route}Children${TYPES_DISABLED ? '' : `: ${route}Children`} = {\n ${node.children.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const routeWithChildren = `const ${route}WithChildren = ${route}._addFileChildren(${route}Children)`\n\n return [\n childConfigs,\n childrenDeclaration,\n children,\n routeWithChildren,\n ].join('\\n\\n')\n }\n\n return undefined\n })\n\n return children.filter(Boolean).join('\\n\\n')\n }\n\n const routeConfigChildrenText = buildRouteTreeConfig(routeTree)\n\n const sortedRouteNodes = multiSortBy(routeNodes, [\n (d) => (d.routePath?.includes(`/${rootPathId}`) ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(config.indexToken) ? -1 : 1),\n (d) => d,\n ])\n\n const typeImports = Object.entries({\n // Used for augmentation of regular routes\n CreateFileRoute:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some(\n (d) => isRouteNodeValidForAugmentation(d) && d._fsRouteType !== 'lazy',\n ),\n // Used for augmentation of lazy (`.lazy`) routes\n CreateLazyFileRoute:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some(\n (node) =>\n routePiecesByPath[node.routePath!]?.lazy &&\n isRouteNodeValidForAugmentation(node),\n ),\n // Used in the process of augmenting the routes\n FileRoutesByPath:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some((d) => isRouteNodeValidForAugmentation(d)),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n .sort((a, b) => a.localeCompare(b))\n\n const imports = Object.entries({\n createFileRoute: 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 virtualRouteNodes = sortedRouteNodes.filter((d) => d.isVirtual)\n\n function getImportPath(node: RouteNode) {\n return replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, node.filePath),\n ),\n config.addExtensions,\n ),\n )\n }\n\n const routeImports = [\n ...config.routeTreeFileHeader,\n `// This file was automatically generated by TanStack Router.\n// You should NOT make any changes in this file as it will be overwritten.\n// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.`,\n [\n imports.length\n ? `import { ${imports.join(', ')} } from '${ROUTE_TEMPLATE.fullPkg}'`\n : '',\n !TYPES_DISABLED && typeImports.length\n ? `import type { ${typeImports.join(', ')} } from '${ROUTE_TEMPLATE.fullPkg}'`\n : '',\n ]\n .filter(Boolean)\n .join('\\n'),\n '// Import Routes',\n [\n `import { Route as rootRoute } from './${getImportPath(rootRouteNode)}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }RouteImport } from './${getImportPath(node)}'`\n }),\n ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }RouteImport = createFileRoute('${node.routePath}')()`\n })\n .join('\\n'),\n '// Create/Update Routes',\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 const lazyComponentNode = routePiecesByPath[node.routePath!]?.lazy\n\n return [\n [\n `const ${node.variableName}Route = ${node.variableName}RouteImport.update({\n ${[\n `id: '${node.path}'`,\n !node.isNonPath ? `path: '${node.cleanedPath}'` : undefined,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n }${TYPES_DISABLED ? '' : 'as any'})`,\n loaderNode\n ? `.updateLoader({ loader: lazyFn(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, loaderNode.filePath),\n ),\n config.addExtensions,\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('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, d[1]!.filePath),\n ),\n config.addExtensions,\n ),\n )}'), '${d[0]}')`\n })\n .join('\\n,')}\n })`\n : '',\n lazyComponentNode\n ? `.lazy(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n lazyComponentNode.filePath,\n ),\n ),\n config.addExtensions,\n ),\n )}').then((d) => d.Route))`\n : '',\n ].join(''),\n ].join('\\n\\n')\n })\n .join('\\n\\n'),\n ...(TYPES_DISABLED\n ? []\n : [\n '// Populate the FileRoutesByPath interface',\n `declare module '${ROUTE_TEMPLATE.fullPkg}' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n const filePathId = routeNode.routePath\n\n return `'${filePathId}': {\n id: '${filePathId}'\n path: '${inferPath(routeNode)}'\n fullPath: '${inferFullPath(routeNode)}'\n preLoaderRoute: typeof ${routeNode.variableName}RouteImport\n parentRoute: typeof ${\n routeNode.isVirtualParentRequired\n ? `${routeNode.parent?.variableName}Route`\n : routeNode.parent?.variableName\n ? `${routeNode.parent.variableName}RouteImport`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n ]),\n ...(TYPES_DISABLED\n ? []\n : config.verboseFileRoutes !== false\n ? []\n : [\n `// Add type-safety to the createFileRoute function across the route tree`,\n routeNodes\n .map((routeNode) => {\n function getModuleDeclaration(routeNode?: RouteNode) {\n if (!isRouteNodeValidForAugmentation(routeNode)) {\n return ''\n }\n return `declare module './${getImportPath(routeNode)}' {\n const ${routeNode._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}: ${\n routeNode._fsRouteType === 'lazy'\n ? `CreateLazyFileRoute<FileRoutesByPath['${routeNode.routePath}']['preLoaderRoute']>}`\n : `CreateFileRoute<\n '${routeNode.routePath}',\n FileRoutesByPath['${routeNode.routePath}']['parentRoute'],\n FileRoutesByPath['${routeNode.routePath}']['id'],\n FileRoutesByPath['${routeNode.routePath}']['path'],\n FileRoutesByPath['${routeNode.routePath}']['fullPath']\n >\n }`\n }`\n }\n return (\n getModuleDeclaration(routeNode) +\n getModuleDeclaration(\n routePiecesByPath[routeNode.routePath!]?.lazy,\n )\n )\n })\n .join('\\n'),\n ]),\n '// Create and export the route tree',\n routeConfigChildrenText,\n ...(TYPES_DISABLED\n ? []\n : [\n `export interface FileRoutesByFullPath {\n ${[...createRouteNodesByFullPath(routeNodes).entries()].map(\n ([fullPath, routeNode]) => {\n return `'${fullPath}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n },\n )}\n}`,\n `export interface FileRoutesByTo {\n ${[...createRouteNodesByTo(routeNodes).entries()].map(([to, routeNode]) => {\n return `'${to}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRoutesById {\n '${rootRouteId}': typeof rootRoute,\n ${[...createRouteNodesById(routeNodes).entries()].map(([id, routeNode]) => {\n return `'${id}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRouteTypes {\n fileRoutesByFullPath: FileRoutesByFullPath\n fullPaths: ${routeNodes.length > 0 ? [...createRouteNodesByFullPath(routeNodes).keys()].map((fullPath) => `'${fullPath}'`).join('|') : 'never'}\n fileRoutesByTo: FileRoutesByTo\n to: ${routeNodes.length > 0 ? [...createRouteNodesByTo(routeNodes).keys()].map((to) => `'${to}'`).join('|') : 'never'}\n id: ${[`'${rootRouteId}'`, ...[...createRouteNodesById(routeNodes).keys()].map((id) => `'${id}'`)].join('|')}\n fileRoutesById: FileRoutesById\n}`,\n `export interface RootRouteChildren {\n ${routeTree.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n ]),\n `const rootRouteChildren${TYPES_DISABLED ? '' : ': RootRouteChildren'} = {\n ${routeTree.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n `export const routeTree = rootRoute._addFileChildren(rootRouteChildren)${TYPES_DISABLED ? '' : '._addFileTypes<FileRouteTypes>()'}`,\n ...config.routeTreeFileFooter,\n ]\n .filter(Boolean)\n .join('\\n\\n')\n\n const createRouteManifest = () => {\n const routesManifest = {\n [rootRouteId]: {\n filePath: rootRouteNode.filePath,\n children: routeTree.map((d) => d.routePath),\n },\n ...Object.fromEntries(\n routeNodes.map((d) => {\n const filePathId = d.routePath\n\n return [\n filePathId,\n {\n filePath: d.filePath,\n parent: d.parent?.routePath ? d.parent.routePath : undefined,\n children: d.children?.map((childRoute) => childRoute.routePath),\n },\n ]\n }),\n ),\n }\n\n return JSON.stringify(\n {\n routes: routesManifest,\n },\n null,\n 2,\n )\n }\n\n const includeManifest = ['react', 'solid']\n const routeConfigFileContent =\n config.disableManifestGeneration || !includeManifest.includes(config.target)\n ? routeImports\n : [\n routeImports,\n '\\n',\n '/* ROUTE_MANIFEST_START',\n createRouteManifest(),\n 'ROUTE_MANIFEST_END */',\n ].join('\\n')\n\n if (!checkLatest()) return\n\n const existingRouteTreeContent = await fsp\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return ''\n }\n\n throw err\n })\n\n if (!checkLatest()) return\n\n // Ensure the directory exists\n await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n\n if (!checkLatest()) return\n\n // Write the route tree file, if it has changed\n const routeTreeWriteResult = await writeIfDifferent(\n path.resolve(config.generatedRouteTree),\n config.enableRouteTreeFormatting\n ? await format(existingRouteTreeContent, config)\n : existingRouteTreeContent,\n config.enableRouteTreeFormatting\n ? await format(routeConfigFileContent, config)\n : routeConfigFileContent,\n {\n beforeWrite: () => {\n logger.log(`🟡 Updating ${config.generatedRouteTree}`)\n },\n },\n )\n if (routeTreeWriteResult && !checkLatest()) {\n return\n }\n\n logger.log(\n `✅ Processed ${routeNodes.length === 1 ? 'route' : 'routes'} in ${\n Date.now() - start\n }ms`,\n )\n}\n\n// function removeTrailingUnderscores(s?: string) {\n// return s?.replaceAll(/(_$)/gi, '').replaceAll(/(_\\/)/gi, '/')\n// }\n\nfunction removeGroups(s: string) {\n return s.replace(possiblyNestedRouteGroupPatternRegex, '')\n}\n\n/**\n * Checks if a given RouteNode is valid for augmenting it with typing based on conditions.\n * Also asserts that the RouteNode is defined.\n *\n * @param routeNode - The RouteNode to check.\n * @returns A boolean indicating whether the RouteNode is defined.\n */\nfunction isRouteNodeValidForAugmentation(\n routeNode?: RouteNode,\n): routeNode is RouteNode {\n if (!routeNode || routeNode.isVirtual) {\n return false\n }\n return true\n}\n\n/**\n * The `node.path` is used as the `id` in the route definition.\n * This function checks if the given node has a parent and if so, it determines the correct path for the given node.\n * @param node - The node to determine the path for.\n * @returns The correct path for the given node.\n */\nfunction determineNodePath(node: RouteNode) {\n return (node.path = node.parent\n ? node.routePath?.replace(node.parent.routePath ?? '', '') || '/'\n : node.routePath)\n}\n\n/**\n * Removes the last segment from a given path. Segments are considered to be separated by a '/'.\n *\n * @param {string} routePath - The path from which to remove the last segment. Defaults to '/'.\n * @returns {string} The path with the last segment removed.\n * @example\n * removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'\n */\nfunction removeLastSegmentFromPath(routePath: string = '/'): string {\n const segments = routePath.split('/')\n segments.pop() // Remove the last segment\n return segments.join('/')\n}\n\n/**\n * Removes all segments from a given path that start with an underscore ('_').\n *\n * @param {string} routePath - The path from which to remove segments. Defaults to '/'.\n * @returns {string} The path with all underscore-prefixed segments removed.\n * @example\n * removeLayoutSegments('/workspace/_auth/foo') // '/workspace/foo'\n */\nfunction removeLayoutSegments(routePath: string = '/'): string {\n const segments = routePath.split('/')\n const newSegments = segments.filter((segment) => !segment.startsWith('_'))\n return newSegments.join('/')\n}\n\nfunction hasParentRoute(\n routes: Array<RouteNode>,\n node: 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\n const segments = routePathToCheck.split('/')\n segments.pop() // Remove the last segment\n const parentRoutePath = segments.join('/')\n\n return hasParentRoute(routes, node, parentRoutePath)\n}\n\n/**\n * Gets the final variable name for a route\n */\nconst getResolvedRouteNodeVariableName = (routeNode: RouteNode): string => {\n return routeNode.children?.length\n ? `${routeNode.variableName}RouteWithChildren`\n : `${routeNode.variableName}Route`\n}\n\n/**\n * Creates a map from fullPath to routeNode\n */\nconst createRouteNodesByFullPath = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => [inferFullPath(routeNode), routeNode]),\n )\n}\n\n/**\n * Create a map from 'to' to a routeNode\n */\nconst createRouteNodesByTo = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n dedupeBranchesAndIndexRoutes(routeNodes).map((routeNode) => [\n inferTo(routeNode),\n routeNode,\n ]),\n )\n}\n\n/**\n * Create a map from 'id' to a routeNode\n */\nconst createRouteNodesById = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => {\n const id = routeNode.routePath ?? ''\n return [id, routeNode]\n }),\n )\n}\n\n/**\n * Infers the full path for use by TS\n */\nconst inferFullPath = (routeNode: RouteNode): string => {\n const fullPath = removeGroups(\n removeUnderscores(removeLayoutSegments(routeNode.routePath)) ?? '',\n )\n\n return routeNode.cleanedPath === '/' ? fullPath : fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Infers the path for use by TS\n */\nconst inferPath = (routeNode: RouteNode): string => {\n return routeNode.cleanedPath === '/'\n ? routeNode.cleanedPath\n : (routeNode.cleanedPath?.replace(/\\/$/, '') ?? '')\n}\n\n/**\n * Infers to path\n */\nconst inferTo = (routeNode: RouteNode): string => {\n const fullPath = inferFullPath(routeNode)\n\n if (fullPath === '/') return fullPath\n\n return fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Dedupes branches and index routes\n */\nconst dedupeBranchesAndIndexRoutes = (\n routes: Array<RouteNode>,\n): Array<RouteNode> => {\n return routes.filter((route) => {\n if (route.children?.find((child) => child.cleanedPath === '/')) return false\n return true\n })\n}\n\nfunction checkUnique<TElement>(routes: Array<TElement>, key: keyof TElement) {\n // Check no two routes have the same `key`\n // if they do, throw an error with the conflicting filePaths\n const keys = routes.map((d) => d[key])\n const uniqueKeys = new Set(keys)\n if (keys.length !== uniqueKeys.size) {\n const duplicateKeys = keys.filter((d, i) => keys.indexOf(d) !== i)\n const conflictingFiles = routes.filter((d) =>\n duplicateKeys.includes(d[key]),\n )\n return conflictingFiles\n }\n return undefined\n}\n\nfunction checkRouteFullPathUniqueness(\n _routes: Array<RouteNode>,\n config: Config,\n) {\n const routes = _routes.map((d) => {\n const inferredFullPath = inferFullPath(d)\n return { ...d, inferredFullPath }\n })\n\n const conflictingFiles = checkUnique(routes, 'inferredFullPath')\n\n if (conflictingFiles !== undefined) {\n const errorMessage = `Conflicting configuration paths were found for the following route${conflictingFiles.length > 1 ? 's' : ''}: ${conflictingFiles\n .map((p) => `\"${p.inferredFullPath}\"`)\n .join(', ')}.\nPlease ensure each Route has a unique full path.\nConflicting files: \\n ${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join('\\n ')}\\n`\n throw new Error(errorMessage)\n }\n}\n"],"names":["virtualGetRouteNodes","physicalGetRouteNodes","children","routeNode"],"mappings":";;;;;;;;AAuBA,MAAM,cAAc;AAEpB,IAAI,aAA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,SAAS,IAAI,MAAM,EAAE,KAAK,iBAClI,IAAI,CAAC,MAAM,IAAI,EAAE,gBAAgB,GAAG,EACpC,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA,GAEO,iBAAiB,IAAI,CAAC,MAAM,KAAK,QAAQ,OAAO,iBAAiB,EAAE,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAAA;AACvG,UAAA,IAAI,MAAM,YAAY;AAAA,EAAA;AAEhC;"}
1
+ {"version":3,"file":"generator.js","sources":["../../src/generator.ts"],"sourcesContent":["import path from 'node:path'\nimport * as fs from 'node:fs'\nimport * as fsp from 'node:fs/promises'\nimport {\n format,\n logging,\n multiSortBy,\n removeExt,\n removeUnderscores,\n replaceBackslash,\n resetRegex,\n routePathToVariable,\n trimPathLeft,\n writeIfDifferent,\n} from './utils'\nimport { getRouteNodes as physicalGetRouteNodes } from './filesystem/physical/getRouteNodes'\nimport { getRouteNodes as virtualGetRouteNodes } from './filesystem/virtual/getRouteNodes'\nimport { rootPathId } from './filesystem/physical/rootPathId'\nimport { fillTemplate, getTargetTemplate } from './template'\nimport type { FsRouteType, GetRouteNodesResult, RouteNode } from './types'\nimport type { Config } from './config'\n\n// Maybe import this from `@tanstack/router-core` in the future???\nconst rootRouteId = '__root__'\n\nlet latestTask = 0\nconst routeGroupPatternRegex = /\\(.+\\)/g\nconst possiblyNestedRouteGroupPatternRegex = /\\([^/]+\\)\\/?/g\n\nlet isFirst = false\nlet skipMessage = false\n\ntype RouteSubNode = {\n component?: RouteNode\n errorComponent?: RouteNode\n pendingComponent?: RouteNode\n loader?: RouteNode\n lazy?: RouteNode\n}\n\nexport async function generator(config: Config, root: string) {\n const ROUTE_TEMPLATE = getTargetTemplate(config.target)\n const logger = logging({ disabled: config.disableLogging })\n logger.log('')\n\n if (!isFirst) {\n logger.log('♻️ Generating routes...')\n isFirst = true\n } else if (skipMessage) {\n skipMessage = false\n } else {\n logger.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\n const TYPES_DISABLED = config.disableTypes\n\n let getRouteNodesResult: GetRouteNodesResult\n\n if (config.virtualRouteConfig) {\n getRouteNodesResult = await virtualGetRouteNodes(config, root)\n } else {\n getRouteNodesResult = await physicalGetRouteNodes(config, root)\n }\n\n const { rootRouteNode, routeNodes: beforeRouteNodes } = getRouteNodesResult\n if (rootRouteNode === undefined) {\n let errorMessage = `rootRouteNode must not be undefined. Make sure you've added your root route into the route-tree.`\n if (!config.virtualRouteConfig) {\n errorMessage += `\\nMake sure that you add a \"${rootPathId}.${config.disableTypes ? 'js' : 'tsx'}\" file to your routes directory.\\nAdd the file in: \"${config.routesDirectory}/${rootPathId}.${config.disableTypes ? 'js' : 'tsx'}\"`\n }\n throw new Error(errorMessage)\n }\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.indexToken}[.]`)) ? 1 : -1,\n (d) =>\n d.filePath.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.routeToken}[.]`)) ? -1 : 1,\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ''))\n\n const routeTree: Array<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 const routeNodes: Array<RouteNode> = []\n\n // the handleRootNode function is not being collapsed into the handleNode function\n // because it requires only a subset of the logic that the handleNode function requires\n // and it's easier to read and maintain this way\n const handleRootNode = async (node?: RouteNode) => {\n if (!node) {\n // currently this is not being handled, but it could be in the future\n // for example to handle a virtual root route\n return\n }\n\n // from here on, we are only handling the root node that's present in the file system\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n if (!routeCode) {\n const _rootTemplate = ROUTE_TEMPLATE.rootRoute\n const replaced = await fillTemplate(config, _rootTemplate.template(), {\n tsrImports: _rootTemplate.imports.tsrImports(),\n tsrPath: rootPathId,\n tsrExportStart: _rootTemplate.imports.tsrExportStart(),\n tsrExportEnd: _rootTemplate.imports.tsrExportEnd(),\n })\n\n await writeIfDifferent(\n node.fullPath,\n '', // Empty string because the file doesn't exist yet\n replaced,\n {\n beforeWrite: () => {\n logger.log(`🟡 Creating ${node.fullPath}`)\n },\n },\n )\n }\n }\n\n await handleRootNode(rootRouteNode)\n\n const handleNode = async (node: RouteNode) => {\n // Do not remove this as we need to set the lastIndex to 0 as it\n // is necessary to reset the regex's index when using the global flag\n // otherwise it might not match the next time it's used\n resetRegex(routeGroupPatternRegex)\n\n let parentRoute = hasParentRoute(routeNodes, node, node.routePath)\n\n // if the parent route is a virtual parent route, we need to find the real parent route\n if (parentRoute?.isVirtualParentRoute && parentRoute.children?.length) {\n // only if this sub-parent route returns a valid parent route, we use it, if not leave it as it\n const possibleParentRoute = hasParentRoute(\n parentRoute.children,\n node,\n node.routePath,\n )\n if (possibleParentRoute) {\n parentRoute = possibleParentRoute\n }\n }\n\n if (parentRoute) node.parent = parentRoute\n\n node.path = determineNodePath(node)\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath.split('/')\n const lastRouteSegment = split[split.length - 1] ?? trimmedPath\n\n node.isNonPath =\n lastRouteSegment.startsWith('_') ||\n routeGroupPatternRegex.test(lastRouteSegment)\n\n node.cleanedPath = removeGroups(\n removeUnderscores(removeLayoutSegments(node.path)) ?? '',\n )\n\n // Ensure the boilerplate for the route exists, which can be skipped for virtual parent routes and virtual routes\n if (!node.isVirtualParentRoute && !node.isVirtual) {\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n const escapedRoutePath = node.routePath?.replaceAll('$', '$$') ?? ''\n\n let replaced = routeCode\n\n const tRouteTemplate = ROUTE_TEMPLATE.route\n const tLazyRouteTemplate = ROUTE_TEMPLATE.lazyRoute\n\n if (!routeCode) {\n // Creating a new lazy route file\n if (node._fsRouteType === 'lazy') {\n // Check by default check if the user has a specific lazy route template\n // If not, check if the user has a route template and use that instead\n replaced = await fillTemplate(\n config,\n (config.customScaffolding?.lazyRouteTemplate ||\n config.customScaffolding?.routeTemplate) ??\n tLazyRouteTemplate.template(),\n {\n tsrImports: tLazyRouteTemplate.imports.tsrImports(),\n tsrPath: escapedRoutePath.replaceAll(/\\{(.+)\\}/gm, '$1'),\n tsrExportStart:\n tLazyRouteTemplate.imports.tsrExportStart(escapedRoutePath),\n tsrExportEnd: tLazyRouteTemplate.imports.tsrExportEnd(),\n },\n )\n } else if (\n // Creating a new normal route file\n (['layout', 'static'] satisfies Array<FsRouteType>).some(\n (d) => d === node._fsRouteType,\n ) ||\n (\n [\n 'component',\n 'pendingComponent',\n 'errorComponent',\n 'loader',\n ] satisfies Array<FsRouteType>\n ).every((d) => d !== node._fsRouteType)\n ) {\n replaced = await fillTemplate(\n config,\n config.customScaffolding?.routeTemplate ??\n tRouteTemplate.template(),\n {\n tsrImports: tRouteTemplate.imports.tsrImports(),\n tsrPath: escapedRoutePath.replaceAll(/\\{(.+)\\}/gm, '$1'),\n tsrExportStart:\n tRouteTemplate.imports.tsrExportStart(escapedRoutePath),\n tsrExportEnd: tRouteTemplate.imports.tsrExportEnd(),\n },\n )\n }\n } else if (config.verboseFileRoutes === false) {\n // Check if the route file has a Route export\n if (\n !routeCode\n .split('\\n')\n .some((line) => line.trim().startsWith('export const Route'))\n ) {\n return\n }\n\n // Update the existing route file\n replaced = routeCode\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n new RegExp(\n `(import\\\\s*\\\\{)(.*)(create(Lazy)?FileRoute)(.*)(\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gs',\n ),\n (_, p1, p2, ___, ____, p5, p6) => {\n const beforeCreateFileRoute = () => {\n if (!p2) return ''\n\n let trimmed = p2.trim()\n\n if (trimmed.endsWith(',')) {\n trimmed = trimmed.slice(0, -1)\n }\n\n return trimmed\n }\n\n const afterCreateFileRoute = () => {\n if (!p5) return ''\n\n let trimmed = p5.trim()\n\n if (trimmed.startsWith(',')) {\n trimmed = trimmed.slice(1)\n }\n\n return trimmed\n }\n\n const newImport = () => {\n const before = beforeCreateFileRoute()\n const after = afterCreateFileRoute()\n\n if (!before) return after\n\n if (!after) return before\n\n return `${before},${after}`\n }\n\n const middle = newImport()\n\n if (middle === '') return ''\n\n return `${p1} ${newImport()} ${p6}`\n },\n )\n .replace(\n /create(Lazy)?FileRoute(\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, __, p2, ___, p4) =>\n `${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}`,\n )\n } else {\n // Check if the route file has a Route export\n if (\n !routeCode\n .split('\\n')\n .some((line) => line.trim().startsWith('export const Route'))\n ) {\n return\n }\n\n // Update the existing route file\n replaced = routeCode\n // fix wrong ids\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n // fix missing ids\n .replace(\n /((FileRoute)(\\s*)(\\({))/g,\n (_, __, p2, p3, p4) => `${p2}('${escapedRoutePath}')${p3}${p4}`,\n )\n .replace(\n new RegExp(\n `(import\\\\s*\\\\{.*)(create(Lazy)?FileRoute)(.*\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gs',\n ),\n (_, p1, __, ___, p4) =>\n `${p1}${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}${p4}`,\n )\n .replace(\n /create(Lazy)?FileRoute(\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, __, p2, ___, p4) =>\n `${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}${p2}${escapedRoutePath}${p4}`,\n )\n\n // check whether the import statement is already present\n const regex = new RegExp(\n `(import\\\\s*\\\\{.*)(create(Lazy)?FileRoute)(.*\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gm',\n )\n if (!replaced.match(regex)) {\n replaced = [\n `import { ${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'} } from '@tanstack/${ROUTE_TEMPLATE.subPkg}'`,\n ...replaced.split('\\n'),\n ].join('\\n')\n }\n }\n\n await writeIfDifferent(node.fullPath, routeCode, replaced, {\n beforeWrite: () => {\n logger.log(`🟡 Updating ${node.fullPath}`)\n },\n })\n }\n\n if (\n !node.isVirtual &&\n (\n [\n 'lazy',\n 'loader',\n 'component',\n 'pendingComponent',\n 'errorComponent',\n ] satisfies Array<FsRouteType>\n ).some((d) => d === node._fsRouteType)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node._fsRouteType === 'lazy'\n ? 'lazy'\n : node._fsRouteType === 'loader'\n ? 'loader'\n : node._fsRouteType === 'errorComponent'\n ? 'errorComponent'\n : node._fsRouteType === 'pendingComponent'\n ? 'pendingComponent'\n : 'component'\n ] = node\n\n const anchorRoute = routeNodes.find((d) => d.routePath === node.routePath)\n\n if (!anchorRoute) {\n await handleNode({\n ...node,\n isVirtual: true,\n _fsRouteType: 'static',\n })\n }\n return\n }\n\n const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0\n const nonPathRoute =\n node._fsRouteType === 'pathless_layout' && node.isNonPath\n\n node.isVirtualParentRequired =\n node._fsRouteType === 'pathless_layout' || nonPathRoute\n ? !cleanedPathIsEmpty\n : false\n\n if (!node.isVirtual && node.isVirtualParentRequired) {\n const parentRoutePath = removeLastSegmentFromPath(node.routePath) || '/'\n const parentVariableName = routePathToVariable(parentRoutePath)\n\n const anchorRoute = routeNodes.find(\n (d) => d.routePath === parentRoutePath,\n )\n\n if (!anchorRoute) {\n const parentNode: RouteNode = {\n ...node,\n path: removeLastSegmentFromPath(node.path) || '/',\n filePath: removeLastSegmentFromPath(node.filePath) || '/',\n fullPath: removeLastSegmentFromPath(node.fullPath) || '/',\n routePath: parentRoutePath,\n variableName: parentVariableName,\n isVirtual: true,\n _fsRouteType: 'layout', // layout since this route will wrap other routes\n isVirtualParentRoute: true,\n isVirtualParentRequired: false,\n }\n\n parentNode.children = parentNode.children ?? []\n parentNode.children.push(node)\n\n node.parent = parentNode\n\n if (node._fsRouteType === 'pathless_layout') {\n // since `node.path` is used as the `id` on the route definition, we need to update it\n node.path = determineNodePath(node)\n }\n\n await handleNode(parentNode)\n } else {\n anchorRoute.children = anchorRoute.children ?? []\n anchorRoute.children.push(node)\n\n node.parent = anchorRoute\n }\n }\n\n if (node.parent) {\n if (!node.isVirtualParentRequired) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n }\n } else {\n routeTree.push(node)\n }\n\n routeNodes.push(node)\n }\n\n for (const node of preRouteNodes) {\n await handleNode(node)\n }\n\n // This is run against the `preRouteNodes` array since it\n // has the flattened Route nodes and not the full tree\n // Since TSR allows multiple way of defining a route,\n // we need to ensure that a user hasn't defined the\n // same route in multiple ways (i.e. `flat`, `nested`, `virtual`)\n checkRouteFullPathUniqueness(\n preRouteNodes.filter(\n (d) => d.children === undefined && 'lazy' !== d._fsRouteType,\n ),\n config,\n )\n\n function buildRouteTreeConfig(nodes: Array<RouteNode>, depth = 1): string {\n const children = nodes.map((node) => {\n if (node._fsRouteType === '__root') {\n return\n }\n\n if (node._fsRouteType === 'pathless_layout' && !node.children?.length) {\n return\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = buildRouteTreeConfig(node.children, depth + 1)\n\n const childrenDeclaration = TYPES_DISABLED\n ? ''\n : `interface ${route}Children {\n ${node.children.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const children = `const ${route}Children${TYPES_DISABLED ? '' : `: ${route}Children`} = {\n ${node.children.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const routeWithChildren = `const ${route}WithChildren = ${route}._addFileChildren(${route}Children)`\n\n return [\n childConfigs,\n childrenDeclaration,\n children,\n routeWithChildren,\n ].join('\\n\\n')\n }\n\n return undefined\n })\n\n return children.filter(Boolean).join('\\n\\n')\n }\n\n const routeConfigChildrenText = buildRouteTreeConfig(routeTree)\n\n const sortedRouteNodes = multiSortBy(routeNodes, [\n (d) => (d.routePath?.includes(`/${rootPathId}`) ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(config.indexToken) ? -1 : 1),\n (d) => d,\n ])\n\n const typeImports = Object.entries({\n // Used for augmentation of regular routes\n CreateFileRoute:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some(\n (d) => isRouteNodeValidForAugmentation(d) && d._fsRouteType !== 'lazy',\n ),\n // Used for augmentation of lazy (`.lazy`) routes\n CreateLazyFileRoute:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some(\n (node) =>\n routePiecesByPath[node.routePath!]?.lazy &&\n isRouteNodeValidForAugmentation(node),\n ),\n // Used in the process of augmenting the routes\n FileRoutesByPath:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some((d) => isRouteNodeValidForAugmentation(d)),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n .sort((a, b) => a.localeCompare(b))\n\n const imports = Object.entries({\n createFileRoute: 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 virtualRouteNodes = sortedRouteNodes.filter((d) => d.isVirtual)\n\n function getImportPath(node: RouteNode) {\n return replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, node.filePath),\n ),\n config.addExtensions,\n ),\n )\n }\n\n const routeImports = [\n ...config.routeTreeFileHeader,\n `// This file was automatically generated by TanStack Router.\n// You should NOT make any changes in this file as it will be overwritten.\n// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.`,\n [\n imports.length\n ? `import { ${imports.join(', ')} } from '${ROUTE_TEMPLATE.fullPkg}'`\n : '',\n !TYPES_DISABLED && typeImports.length\n ? `import type { ${typeImports.join(', ')} } from '${ROUTE_TEMPLATE.fullPkg}'`\n : '',\n ]\n .filter(Boolean)\n .join('\\n'),\n '// Import Routes',\n [\n `import { Route as rootRoute } from './${getImportPath(rootRouteNode)}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }RouteImport } from './${getImportPath(node)}'`\n }),\n ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }RouteImport = createFileRoute('${node.routePath}')()`\n })\n .join('\\n'),\n '// Create/Update Routes',\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 const lazyComponentNode = routePiecesByPath[node.routePath!]?.lazy\n\n return [\n [\n `const ${node.variableName}Route = ${node.variableName}RouteImport.update({\n ${[\n `id: '${node.path}'`,\n !node.isNonPath ? `path: '${node.cleanedPath}'` : undefined,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n }${TYPES_DISABLED ? '' : 'as any'})`,\n loaderNode\n ? `.updateLoader({ loader: lazyFn(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, loaderNode.filePath),\n ),\n config.addExtensions,\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('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, d[1]!.filePath),\n ),\n config.addExtensions,\n ),\n )}'), '${d[0]}')`\n })\n .join('\\n,')}\n })`\n : '',\n lazyComponentNode\n ? `.lazy(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n lazyComponentNode.filePath,\n ),\n ),\n config.addExtensions,\n ),\n )}').then((d) => d.Route))`\n : '',\n ].join(''),\n ].join('\\n\\n')\n })\n .join('\\n\\n'),\n ...(TYPES_DISABLED\n ? []\n : [\n '// Populate the FileRoutesByPath interface',\n `declare module '${ROUTE_TEMPLATE.fullPkg}' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n const filePathId = routeNode.routePath\n\n return `'${filePathId}': {\n id: '${filePathId}'\n path: '${inferPath(routeNode)}'\n fullPath: '${inferFullPath(routeNode)}'\n preLoaderRoute: typeof ${routeNode.variableName}RouteImport\n parentRoute: typeof ${\n routeNode.isVirtualParentRequired\n ? `${routeNode.parent?.variableName}Route`\n : routeNode.parent?.variableName\n ? `${routeNode.parent.variableName}RouteImport`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n ]),\n ...(TYPES_DISABLED\n ? []\n : config.verboseFileRoutes !== false\n ? []\n : [\n `// Add type-safety to the createFileRoute function across the route tree`,\n routeNodes\n .map((routeNode) => {\n function getModuleDeclaration(routeNode?: RouteNode) {\n if (!isRouteNodeValidForAugmentation(routeNode)) {\n return ''\n }\n return `declare module './${getImportPath(routeNode)}' {\n const ${routeNode._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}: ${\n routeNode._fsRouteType === 'lazy'\n ? `CreateLazyFileRoute<FileRoutesByPath['${routeNode.routePath}']['preLoaderRoute']>}`\n : `CreateFileRoute<\n '${routeNode.routePath}',\n FileRoutesByPath['${routeNode.routePath}']['parentRoute'],\n FileRoutesByPath['${routeNode.routePath}']['id'],\n FileRoutesByPath['${routeNode.routePath}']['path'],\n FileRoutesByPath['${routeNode.routePath}']['fullPath']\n >\n }`\n }`\n }\n return (\n getModuleDeclaration(routeNode) +\n getModuleDeclaration(\n routePiecesByPath[routeNode.routePath!]?.lazy,\n )\n )\n })\n .join('\\n'),\n ]),\n '// Create and export the route tree',\n routeConfigChildrenText,\n ...(TYPES_DISABLED\n ? []\n : [\n `export interface FileRoutesByFullPath {\n ${[...createRouteNodesByFullPath(routeNodes).entries()].map(\n ([fullPath, routeNode]) => {\n return `'${fullPath}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n },\n )}\n}`,\n `export interface FileRoutesByTo {\n ${[...createRouteNodesByTo(routeNodes).entries()].map(([to, routeNode]) => {\n return `'${to}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRoutesById {\n '${rootRouteId}': typeof rootRoute,\n ${[...createRouteNodesById(routeNodes).entries()].map(([id, routeNode]) => {\n return `'${id}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRouteTypes {\n fileRoutesByFullPath: FileRoutesByFullPath\n fullPaths: ${routeNodes.length > 0 ? [...createRouteNodesByFullPath(routeNodes).keys()].map((fullPath) => `'${fullPath}'`).join('|') : 'never'}\n fileRoutesByTo: FileRoutesByTo\n to: ${routeNodes.length > 0 ? [...createRouteNodesByTo(routeNodes).keys()].map((to) => `'${to}'`).join('|') : 'never'}\n id: ${[`'${rootRouteId}'`, ...[...createRouteNodesById(routeNodes).keys()].map((id) => `'${id}'`)].join('|')}\n fileRoutesById: FileRoutesById\n}`,\n `export interface RootRouteChildren {\n ${routeTree.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n ]),\n `const rootRouteChildren${TYPES_DISABLED ? '' : ': RootRouteChildren'} = {\n ${routeTree.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n `export const routeTree = rootRoute._addFileChildren(rootRouteChildren)${TYPES_DISABLED ? '' : '._addFileTypes<FileRouteTypes>()'}`,\n ...config.routeTreeFileFooter,\n ]\n .filter(Boolean)\n .join('\\n\\n')\n\n const createRouteManifest = () => {\n const routesManifest = {\n [rootRouteId]: {\n filePath: rootRouteNode.filePath,\n children: routeTree.map((d) => d.routePath),\n },\n ...Object.fromEntries(\n routeNodes.map((d) => {\n const filePathId = d.routePath\n\n return [\n filePathId,\n {\n filePath: d.filePath,\n parent: d.parent?.routePath ? d.parent.routePath : undefined,\n children: d.children?.map((childRoute) => childRoute.routePath),\n },\n ]\n }),\n ),\n }\n\n return JSON.stringify(\n {\n routes: routesManifest,\n },\n null,\n 2,\n )\n }\n\n const includeManifest = ['react', 'solid']\n const routeConfigFileContent =\n config.disableManifestGeneration || !includeManifest.includes(config.target)\n ? routeImports\n : [\n routeImports,\n '\\n',\n '/* ROUTE_MANIFEST_START',\n createRouteManifest(),\n 'ROUTE_MANIFEST_END */',\n ].join('\\n')\n\n if (!checkLatest()) return\n\n const existingRouteTreeContent = await fsp\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return ''\n }\n\n throw err\n })\n\n if (!checkLatest()) return\n\n // Ensure the directory exists\n await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n\n if (!checkLatest()) return\n\n // Write the route tree file, if it has changed\n const routeTreeWriteResult = await writeIfDifferent(\n path.resolve(config.generatedRouteTree),\n config.enableRouteTreeFormatting\n ? await format(existingRouteTreeContent, config)\n : existingRouteTreeContent,\n config.enableRouteTreeFormatting\n ? await format(routeConfigFileContent, config)\n : routeConfigFileContent,\n {\n beforeWrite: () => {\n logger.log(`🟡 Updating ${config.generatedRouteTree}`)\n },\n },\n )\n if (routeTreeWriteResult && !checkLatest()) {\n return\n }\n\n logger.log(\n `✅ Processed ${routeNodes.length === 1 ? 'route' : 'routes'} in ${\n Date.now() - start\n }ms`,\n )\n}\n\n// function removeTrailingUnderscores(s?: string) {\n// return s?.replaceAll(/(_$)/gi, '').replaceAll(/(_\\/)/gi, '/')\n// }\n\nfunction removeGroups(s: string) {\n return s.replace(possiblyNestedRouteGroupPatternRegex, '')\n}\n\n/**\n * Checks if a given RouteNode is valid for augmenting it with typing based on conditions.\n * Also asserts that the RouteNode is defined.\n *\n * @param routeNode - The RouteNode to check.\n * @returns A boolean indicating whether the RouteNode is defined.\n */\nfunction isRouteNodeValidForAugmentation(\n routeNode?: RouteNode,\n): routeNode is RouteNode {\n if (!routeNode || routeNode.isVirtual) {\n return false\n }\n return true\n}\n\n/**\n * The `node.path` is used as the `id` in the route definition.\n * This function checks if the given node has a parent and if so, it determines the correct path for the given node.\n * @param node - The node to determine the path for.\n * @returns The correct path for the given node.\n */\nfunction determineNodePath(node: RouteNode) {\n return (node.path = node.parent\n ? node.routePath?.replace(node.parent.routePath ?? '', '') || '/'\n : node.routePath)\n}\n\n/**\n * Removes the last segment from a given path. Segments are considered to be separated by a '/'.\n *\n * @param {string} routePath - The path from which to remove the last segment. Defaults to '/'.\n * @returns {string} The path with the last segment removed.\n * @example\n * removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'\n */\nfunction removeLastSegmentFromPath(routePath: string = '/'): string {\n const segments = routePath.split('/')\n segments.pop() // Remove the last segment\n return segments.join('/')\n}\n\n/**\n * Removes all segments from a given path that start with an underscore ('_').\n *\n * @param {string} routePath - The path from which to remove segments. Defaults to '/'.\n * @returns {string} The path with all underscore-prefixed segments removed.\n * @example\n * removeLayoutSegments('/workspace/_auth/foo') // '/workspace/foo'\n */\nfunction removeLayoutSegments(routePath: string = '/'): string {\n const segments = routePath.split('/')\n const newSegments = segments.filter((segment) => !segment.startsWith('_'))\n return newSegments.join('/')\n}\n\nfunction hasParentRoute(\n routes: Array<RouteNode>,\n node: 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\n const segments = routePathToCheck.split('/')\n segments.pop() // Remove the last segment\n const parentRoutePath = segments.join('/')\n\n return hasParentRoute(routes, node, parentRoutePath)\n}\n\n/**\n * Gets the final variable name for a route\n */\nconst getResolvedRouteNodeVariableName = (routeNode: RouteNode): string => {\n return routeNode.children?.length\n ? `${routeNode.variableName}RouteWithChildren`\n : `${routeNode.variableName}Route`\n}\n\n/**\n * Creates a map from fullPath to routeNode\n */\nconst createRouteNodesByFullPath = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => [inferFullPath(routeNode), routeNode]),\n )\n}\n\n/**\n * Create a map from 'to' to a routeNode\n */\nconst createRouteNodesByTo = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n dedupeBranchesAndIndexRoutes(routeNodes).map((routeNode) => [\n inferTo(routeNode),\n routeNode,\n ]),\n )\n}\n\n/**\n * Create a map from 'id' to a routeNode\n */\nconst createRouteNodesById = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => {\n const id = routeNode.routePath ?? ''\n return [id, routeNode]\n }),\n )\n}\n\n/**\n * Infers the full path for use by TS\n */\nconst inferFullPath = (routeNode: RouteNode): string => {\n const fullPath = removeGroups(\n removeUnderscores(removeLayoutSegments(routeNode.routePath)) ?? '',\n )\n\n return routeNode.cleanedPath === '/' ? fullPath : fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Infers the path for use by TS\n */\nconst inferPath = (routeNode: RouteNode): string => {\n return routeNode.cleanedPath === '/'\n ? routeNode.cleanedPath\n : (routeNode.cleanedPath?.replace(/\\/$/, '') ?? '')\n}\n\n/**\n * Infers to path\n */\nconst inferTo = (routeNode: RouteNode): string => {\n const fullPath = inferFullPath(routeNode)\n\n if (fullPath === '/') return fullPath\n\n return fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Dedupes branches and index routes\n */\nconst dedupeBranchesAndIndexRoutes = (\n routes: Array<RouteNode>,\n): Array<RouteNode> => {\n return routes.filter((route) => {\n if (route.children?.find((child) => child.cleanedPath === '/')) return false\n return true\n })\n}\n\nfunction checkUnique<TElement>(routes: Array<TElement>, key: keyof TElement) {\n // Check no two routes have the same `key`\n // if they do, throw an error with the conflicting filePaths\n const keys = routes.map((d) => d[key])\n const uniqueKeys = new Set(keys)\n if (keys.length !== uniqueKeys.size) {\n const duplicateKeys = keys.filter((d, i) => keys.indexOf(d) !== i)\n const conflictingFiles = routes.filter((d) =>\n duplicateKeys.includes(d[key]),\n )\n return conflictingFiles\n }\n return undefined\n}\n\nfunction checkRouteFullPathUniqueness(\n _routes: Array<RouteNode>,\n config: Config,\n) {\n const routes = _routes.map((d) => {\n const inferredFullPath = inferFullPath(d)\n return { ...d, inferredFullPath }\n })\n\n const conflictingFiles = checkUnique(routes, 'inferredFullPath')\n\n if (conflictingFiles !== undefined) {\n const errorMessage = `Conflicting configuration paths were found for the following route${conflictingFiles.length > 1 ? 's' : ''}: ${conflictingFiles\n .map((p) => `\"${p.inferredFullPath}\"`)\n .join(', ')}.\nPlease ensure each Route has a unique full path.\nConflicting files: \\n ${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join('\\n ')}\\n`\n throw new Error(errorMessage)\n }\n}\n"],"names":["virtualGetRouteNodes","physicalGetRouteNodes","children","routeNode"],"mappings":";;;;;;;;AAuBA,MAAM,cAAc;AAEpB,IAAI,aAAa;AACjB,MAAM,yBAAyB;AAC/B,MAAM,uCAAuC;AAE7C,IAAI,UAAU;AACd,IAAI,cAAc;AAUI,eAAA,UAAU,QAAgB,MAAc;AACtD,QAAA,iBAAiB,kBAAkB,OAAO,MAAM;AACtD,QAAM,SAAS,QAAQ,EAAE,UAAU,OAAO,gBAAgB;AAC1D,SAAO,IAAI,EAAE;AAEb,MAAI,CAAC,SAAS;AACZ,WAAO,IAAI,0BAA0B;AAC3B,cAAA;AAAA,aACD,aAAa;AACR,kBAAA;AAAA,EAAA,OACT;AACL,WAAO,IAAI,4BAA4B;AAAA,EAAA;AAGzC,QAAM,SAAS,aAAa;AACf,eAAA;AAEb,QAAM,cAAc,MAAM;AACxB,QAAI,eAAe,QAAQ;AACX,oBAAA;AACP,aAAA;AAAA,IAAA;AAGF,WAAA;AAAA,EACT;AAEM,QAAA,QAAQ,KAAK,IAAI;AAEvB,QAAM,iBAAiB,OAAO;AAE1B,MAAA;AAEJ,MAAI,OAAO,oBAAoB;AACP,0BAAA,MAAMA,cAAqB,QAAQ,IAAI;AAAA,EAAA,OACxD;AACiB,0BAAA,MAAMC,gBAAsB,QAAQ,IAAI;AAAA,EAAA;AAGhE,QAAM,EAAE,eAAe,YAAY,iBAAqB,IAAA;AACxD,MAAI,kBAAkB,QAAW;A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QAAA,aAAa,IAAI,IAAI,IAAI;AAC3B,MAAA,KAAK,WAAW,WAAW,MAAM;AAC7B,UAAA,gBAAgB,KAAK,OAAO,CAAC,GAAG,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;AACjE,UAAM,mBAAmB,OAAO;AAAA,MAAO,CAAC,MACtC,cAAc,SAAS,EAAE,GAAG,CAAC;AAAA,IAC/B;AACO,WAAA;AAAA,EAAA;AAEF,SAAA;AACT;AAEA,SAAS,6BACP,SACA,QACA;AACA,QAAM,SAAS,QAAQ,IAAI,CAAC,MAAM;AAC1B,UAAA,mBAAmB,cAAc,CAAC;AACjC,WAAA,EAAE,GAAG,GAAG,iBAAiB;AAAA,EAAA,CACjC;AAEK,QAAA,mBAAmB,YAAY,QAAQ,kBAAkB;AAE/D,MAAI,qBAAqB,QAAW;AAClC,UAAM,eAAe,qEAAqE,iBAAiB,SAAS,IAAI,MAAM,EAAE,KAAK,iBAClI,IAAI,CAAC,MAAM,IAAI,EAAE,gBAAgB,GAAG,EACpC,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA,GAEO,iBAAiB,IAAI,CAAC,MAAM,KAAK,QAAQ,OAAO,iBAAiB,EAAE,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAAA;AACvG,UAAA,IAAI,MAAM,YAAY;AAAA,EAAA;AAEhC;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/router-generator",
3
- "version": "1.120.4-alpha.1",
3
+ "version": "1.120.4-alpha.12",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -55,7 +55,7 @@
55
55
  "@tanstack/virtual-file-routes": "^1.120.4-alpha.1"
56
56
  },
57
57
  "peerDependencies": {
58
- "@tanstack/react-router": "^1.120.4-alpha.1"
58
+ "@tanstack/react-router": "^1.120.4-alpha.12"
59
59
  },
60
60
  "peerDependenciesMeta": {
61
61
  "@tanstack/react-router": {
package/src/generator.ts CHANGED
@@ -310,6 +310,16 @@ export async function generator(config: Config, root: string) {
310
310
  `${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}`,
311
311
  )
312
312
  } else {
313
+ // Check if the route file has a Route export
314
+ if (
315
+ !routeCode
316
+ .split('\n')
317
+ .some((line) => line.trim().startsWith('export const Route'))
318
+ ) {
319
+ return
320
+ }
321
+
322
+ // Update the existing route file
313
323
  replaced = routeCode
314
324
  // fix wrong ids
315
325
  .replace(