@tanstack/router-vite-plugin 1.3.1 → 1.3.2

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.
@@ -69,16 +69,27 @@ async function getRouteNodes(config) {
69
69
 
70
70
  // Remove the index from the route path and
71
71
  // if the route path is empty, use `/'
72
+
73
+ let isRoute = routePath?.endsWith('/route');
74
+ let isComponent = routePath?.endsWith('/component');
75
+ let isErrorComponent = routePath?.endsWith('/errorComponent');
76
+ let isPendingComponent = routePath?.endsWith('/pendingComponent');
77
+ let isLoader = routePath?.endsWith('/loader');
78
+ routePath = routePath?.replace(/\/(component|errorComponent|pendingComponent|loader|route)$/, '');
72
79
  if (routePath === 'index') {
73
80
  routePath = '/';
74
- } else if (routePath.endsWith('/index')) {
75
- routePath = routePath.replace(/\/index$/, '/');
76
81
  }
82
+ routePath = routePath.replace(/\/index$/, '/') || '/';
77
83
  routeNodes.push({
78
84
  filePath,
79
85
  fullPath,
80
86
  routePath,
81
- variableName
87
+ variableName,
88
+ isRoute,
89
+ isComponent,
90
+ isErrorComponent,
91
+ isPendingComponent,
92
+ isLoader
82
93
  });
83
94
  }
84
95
  }));
@@ -112,7 +123,7 @@ async function generator(config) {
112
123
  const routePathIdPrefix = config.routeFilePrefix ?? '';
113
124
  let preRouteNodes = await getRouteNodes(config);
114
125
  const sortRouteNodes = nodes => {
115
- return multiSortBy(nodes, [d => d.routePath === '/' ? -1 : 1, d => d.routePath?.split('/').length, d => d.filePath?.match(/[./]index[.]/) ? 1 : -1, d => d.filePath?.match(/[./]route[.]/) ? -1 : 1, d => d.routePath?.endsWith('/') ? -1 : 1, d => d.routePath]).filter(d => d.routePath !== `/${routePathIdPrefix + rootPathId}`);
126
+ return multiSortBy(nodes, [d => d.routePath === '/' ? -1 : 1, d => d.routePath?.split('/').length, d => d.filePath?.match(/[./]index[.]/) ? 1 : -1, d => d.filePath?.match(/[./](component|errorComponent|pendingComponent|loader)[.]/) ? 1 : -1, d => d.filePath?.match(/[./]route[.]/) ? -1 : 1, d => d.routePath?.endsWith('/') ? -1 : 1, d => d.routePath]).filter(d => d.routePath !== `/${routePathIdPrefix + rootPathId}`);
116
127
  };
117
128
  preRouteNodes = sortRouteNodes(preRouteNodes);
118
129
  const routeTree = [];
@@ -122,16 +133,6 @@ async function generator(config) {
122
133
  // build up a tree based on the routeNodes' routePath
123
134
  let routeNodes = [];
124
135
  const handleNode = node => {
125
- if (config.future?.unstable_codeSplitting) {
126
- node.isRoute = node.routePath?.endsWith('/route');
127
- node.isComponent = node.routePath?.endsWith('/component');
128
- node.isErrorComponent = node.routePath?.endsWith('/errorComponent');
129
- node.isPendingComponent = node.routePath?.endsWith('/pendingComponent');
130
- node.isLoader = node.routePath?.endsWith('/loader');
131
- if (node.isComponent || node.isErrorComponent || node.isPendingComponent || node.isLoader || node.isRoute) {
132
- node.routePath = node.routePath?.replace(/\/(component|errorComponent|pendingComponent|loader|route)$/, '');
133
- }
134
- }
135
136
  const parentRoute = hasParentRoute(routeNodes, node.routePath);
136
137
  if (parentRoute) node.parent = parentRoute;
137
138
  node.path = node.parent ? node.routePath?.replace(node.parent.routePath, '') || '/' : node.routePath;
@@ -142,14 +143,18 @@ async function generator(config) {
142
143
  node.isNonLayout = first.endsWith('_');
143
144
  node.cleanedPath = removeUnderscores(node.path) ?? '';
144
145
  if (config.future?.unstable_codeSplitting) {
145
- if (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent) {
146
+ if (!node.isVirtual && (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent)) {
146
147
  routePiecesByPath[node.routePath] = routePiecesByPath[node.routePath] || {};
147
148
  routePiecesByPath[node.routePath][node.isLoader ? 'loader' : node.isErrorComponent ? 'errorComponent' : node.isPendingComponent ? 'pendingComponent' : 'component'] = node;
148
149
  const anchorRoute = routeNodes.find(d => d.routePath === node.routePath);
149
150
  if (!anchorRoute) {
150
151
  handleNode({
151
152
  ...node,
152
- isVirtual: true
153
+ isVirtual: true,
154
+ isLoader: false,
155
+ isComponent: false,
156
+ isErrorComponent: false,
157
+ isPendingComponent: false
153
158
  });
154
159
  }
155
160
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sources":["../../../../../../router-cli/src/generator.ts"],"sourcesContent":["import path from 'path'\nimport * as fs from 'fs/promises'\nimport * as prettier from 'prettier'\nimport { Config } from './config'\nimport { cleanPath, trimPathLeft } from '@tanstack/react-router'\n\nlet latestTask = 0\nexport const rootPathId = '__root'\nexport const fileRouteRegex = /new\\s+FileRoute\\(([^)]*)\\)/g\n\nexport type RouteNode = {\n filePath: string\n fullPath: string\n variableName: string\n routePath?: string\n cleanedPath?: string\n path?: string\n isNonPath?: boolean\n isNonLayout?: boolean\n isRoute?: boolean\n isLoader?: boolean\n isComponent?: boolean\n isErrorComponent?: boolean\n isPendingComponent?: boolean\n isVirtual?: boolean\n isRoot?: boolean\n children?: RouteNode[]\n parent?: RouteNode\n}\n\nasync function getRouteNodes(config: Config) {\n const { routeFilePrefix, routeFileIgnorePrefix } = config\n\n let routeNodes: RouteNode[] = []\n\n async function recurse(dir: string) {\n const fullDir = path.resolve(config.routesDirectory, dir)\n let dirList = await fs.readdir(fullDir)\n\n dirList = dirList.filter((d) => {\n if (\n d.startsWith('.') ||\n (routeFileIgnorePrefix && d.startsWith(routeFileIgnorePrefix))\n ) {\n return false\n }\n\n if (routeFilePrefix) {\n return d.startsWith(routeFilePrefix)\n }\n\n return true\n })\n\n await Promise.all(\n dirList.map(async (fileName) => {\n const fullPath = path.join(fullDir, fileName)\n const relativePath = path.join(dir, fileName)\n const stat = await fs.stat(fullPath)\n\n if (stat.isDirectory()) {\n await recurse(relativePath)\n } else {\n const filePath = path.join(dir, fileName)\n const filePathNoExt = removeExt(filePath)\n let routePath =\n replaceBackslash(\n cleanPath(`/${filePathNoExt.split('.').join('/')}`),\n ) ?? ''\n const variableName = fileToVariable(routePath)\n\n // Remove the index from the route path and\n // if the route path is empty, use `/'\n if (routePath === 'index') {\n routePath = '/'\n } else if (routePath.endsWith('/index')) {\n routePath = routePath.replace(/\\/index$/, '/')\n }\n\n routeNodes.push({\n filePath,\n fullPath,\n routePath,\n variableName,\n })\n }\n }),\n )\n\n return routeNodes\n }\n\n await recurse('./')\n\n return routeNodes\n}\n\nlet first = false\nlet skipMessage = false\n\ntype RouteSubNode = {\n component?: RouteNode\n errorComponent?: RouteNode\n pendingComponent?: RouteNode\n loader?: RouteNode\n}\n\nexport async function generator(config: Config) {\n console.log()\n\n if (!first) {\n console.log('🔄 Generating routes...')\n first = true\n } else if (skipMessage) {\n skipMessage = false\n } else {\n console.log('♻️ Regenerating routes...')\n }\n\n const taskId = latestTask + 1\n latestTask = taskId\n\n const checkLatest = () => {\n if (latestTask !== taskId) {\n skipMessage = true\n return false\n }\n\n return true\n }\n\n const start = Date.now()\n const routePathIdPrefix = config.routeFilePrefix ?? ''\n\n let preRouteNodes = await getRouteNodes(config)\n\n const sortRouteNodes = (nodes: RouteNode[]): RouteNode[] => {\n return multiSortBy(nodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.filePath?.match(/[./]index[.]/) ? 1 : -1),\n (d) => (d.filePath?.match(/[./]route[.]/) ? -1 : 1),\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => d.routePath !== `/${routePathIdPrefix + rootPathId}`)\n }\n\n preRouteNodes = sortRouteNodes(preRouteNodes)\n\n const routeTree: RouteNode[] = []\n const routePiecesByPath: Record<string, RouteSubNode> = {}\n\n // Loop over the flat list of routeNodes and\n // build up a tree based on the routeNodes' routePath\n let routeNodes: RouteNode[] = []\n\n const handleNode = (node: RouteNode) => {\n if (config.future?.unstable_codeSplitting) {\n node.isRoute = node.routePath?.endsWith('/route')\n node.isComponent = node.routePath?.endsWith('/component')\n node.isErrorComponent = node.routePath?.endsWith('/errorComponent')\n node.isPendingComponent = node.routePath?.endsWith('/pendingComponent')\n node.isLoader = node.routePath?.endsWith('/loader')\n\n if (\n node.isComponent ||\n node.isErrorComponent ||\n node.isPendingComponent ||\n node.isLoader ||\n node.isRoute\n ) {\n node.routePath = node.routePath?.replace(\n /\\/(component|errorComponent|pendingComponent|loader|route)$/,\n '',\n )\n }\n }\n\n const parentRoute = hasParentRoute(routeNodes, node.routePath)\n if (parentRoute) node.parent = parentRoute\n\n node.path = node.parent\n ? node.routePath?.replace(node.parent.routePath!, '') || '/'\n : node.routePath\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath?.split('/') ?? []\n let first = split[0] ?? trimmedPath ?? ''\n\n node.isNonPath = first.startsWith('_')\n node.isNonLayout = first.endsWith('_')\n\n node.cleanedPath = removeUnderscores(node.path) ?? ''\n\n if (config.future?.unstable_codeSplitting) {\n if (\n node.isLoader ||\n node.isComponent ||\n node.isErrorComponent ||\n node.isPendingComponent\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node.isLoader\n ? 'loader'\n : node.isErrorComponent\n ? 'errorComponent'\n : node.isPendingComponent\n ? 'pendingComponent'\n : 'component'\n ] = node\n\n const anchorRoute = routeNodes.find(\n (d) => d.routePath === node.routePath,\n )\n if (!anchorRoute) {\n handleNode({\n ...node,\n isVirtual: true,\n })\n }\n return\n }\n }\n\n if (node.parent) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n } else {\n routeTree.push(node)\n }\n\n routeNodes.push(node)\n }\n\n preRouteNodes.forEach((node) => handleNode(node))\n\n async function buildRouteConfig(\n nodes: RouteNode[],\n depth = 1,\n ): Promise<string> {\n const children = nodes.map(async (node) => {\n const routeCode = await fs.readFile(node.fullPath, 'utf-8')\n\n // Ensure the boilerplate for the route exists\n if (node.isRoot) {\n return\n }\n\n // Ensure that new FileRoute(anything?) is replaced with FileRoute(${node.routePath})\n // routePath can contain $ characters, which have special meaning when used in replace\n // so we have to escape it by turning all $ into $$. But since we do it through a replace call\n // we have to double escape it into $$$$. For more information, see\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement\n const escapedRoutePath = removeTrailingUnderscores(\n node.routePath?.replaceAll('$', '$$$$') ?? '',\n )\n const quote = config.quoteStyle === 'single' ? `'` : `\"`\n const replaced = routeCode.replace(\n fileRouteRegex,\n `new FileRoute(${quote}${escapedRoutePath}${quote})`,\n )\n\n if (replaced !== routeCode) {\n await fs.writeFile(node.fullPath, replaced)\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = await buildRouteConfig(node.children, depth + 1)\n return `${route}.addChildren([${spaces(depth * 4)}${childConfigs}])`\n }\n\n return route\n })\n\n return (await Promise.all(children)).filter(Boolean).join(`,`)\n }\n\n const routeConfigChildrenText = await buildRouteConfig(routeTree)\n\n const sortedRouteNodes = multiSortBy(routeNodes, [\n (d) =>\n d.routePath?.includes(`/${routePathIdPrefix + rootPathId}`) ? -1 : 1,\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(\"index'\") ? -1 : 1),\n (d) => d,\n ])\n\n const imports = Object.entries({\n FileRoute: sortedRouteNodes.some((d) => d.isVirtual),\n lazyFn: sortedRouteNodes.some(\n (node) => routePiecesByPath[node.routePath!]?.loader,\n ),\n lazyRouteComponent: sortedRouteNodes.some(\n (node) =>\n routePiecesByPath[node.routePath!]?.component ||\n routePiecesByPath[node.routePath!]?.errorComponent ||\n routePiecesByPath[node.routePath!]?.pendingComponent,\n ),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n\n const routeImports = [\n imports.length\n ? `import { ${imports.join(', ')} } from '@tanstack/react-router'\\n`\n : '',\n `import { Route as rootRoute } from './${sanitize(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, routePathIdPrefix + rootPathId),\n ),\n )}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }Import } from './${sanitize(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, node.filePath),\n ),\n ),\n )}'`\n }),\n '\\n',\n sortedRouteNodes\n .filter((d) => d.isVirtual)\n .map((node) => {\n return `const ${\n node.variableName\n }Import = new FileRoute('${removeTrailingUnderscores(\n node.routePath,\n )}').createRoute()`\n })\n .join('\\n'),\n '\\n',\n sortedRouteNodes\n .map((node) => {\n const loaderNode = routePiecesByPath[node.routePath!]?.loader\n const componentNode = routePiecesByPath[node.routePath!]?.component\n const errorComponentNode =\n routePiecesByPath[node.routePath!]?.errorComponent\n const pendingComponentNode =\n routePiecesByPath[node.routePath!]?.pendingComponent\n\n return [\n `const ${node.variableName}Route = ${node.variableName}Import.update({\n ${[\n node.isNonPath\n ? `id: '${node.path}'`\n : `path: '${node.cleanedPath}'`,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n } as any)`,\n loaderNode\n ? `.updateLoader({ loader: lazyFn(() => import('./${sanitize(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, loaderNode.filePath),\n ),\n ),\n )}'), 'loader') })`\n : '',\n componentNode || errorComponentNode || pendingComponentNode\n ? `.update({\n ${(\n [\n ['component', componentNode],\n ['errorComponent', errorComponentNode],\n ['pendingComponent', pendingComponentNode],\n ] as const\n )\n .filter((d) => d[1])\n .map((d) => {\n return `${\n d[0]\n }: lazyRouteComponent(() => import('./${sanitize(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, d[1]!.filePath),\n ),\n ),\n )}'), '${d[0]}')`\n })\n .join('\\n,')}\n })`\n : '',\n ].join('')\n })\n .join('\\n\\n'),\n `declare module '@tanstack/react-router' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n return `'${removeTrailingUnderscores(routeNode.routePath)}': {\n preLoaderRoute: typeof ${routeNode.variableName}Import\n parentRoute: typeof ${\n routeNode.parent?.variableName\n ? `${routeNode.parent?.variableName}Import`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`,\n ].join('\\n')\n\n const routeConfigFileContent = await prettier.format(routeImports, {\n semi: false,\n singleQuote: config.quoteStyle === 'single',\n parser: 'typescript',\n })\n\n const routeTreeContent = await fs\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err: any) => {\n if (err.code === 'ENOENT') {\n return undefined\n }\n throw err\n })\n\n if (!checkLatest()) return\n\n if (routeTreeContent !== routeConfigFileContent) {\n await fs.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n if (!checkLatest()) return\n await fs.writeFile(\n path.resolve(config.generatedRouteTree),\n routeConfigFileContent,\n )\n }\n\n console.log(\n `🌲 Processed ${routeNodes.length} routes in ${Date.now() - start}ms`,\n )\n}\n\nfunction fileToVariable(d: string): string {\n return (\n removeUnderscores(d)\n ?.replace(/\\$/g, '')\n ?.split(/[/-]/g)\n .map((d, i) => (i > 0 ? capitalize(d) : d))\n .join('')\n .replace(/([^a-zA-Z0-9]|[\\.])/gm, '') ?? ''\n )\n}\n\nexport function removeExt(d: string) {\n return d.substring(0, d.lastIndexOf('.')) || d\n}\n\nfunction spaces(d: number): string {\n return Array.from({ length: d })\n .map(() => ' ')\n .join('')\n}\n\nexport function multiSortBy<T>(\n arr: T[],\n accessors: ((item: T) => any)[] = [(d) => d],\n): T[] {\n return arr\n .map((d, i) => [d, i] as const)\n .sort(([a, ai], [b, bi]) => {\n for (const accessor of accessors) {\n const ao = accessor(a)\n const bo = accessor(b)\n\n if (typeof ao === 'undefined') {\n if (typeof bo === 'undefined') {\n continue\n }\n return 1\n }\n\n if (ao === bo) {\n continue\n }\n\n return ao > bo ? 1 : -1\n }\n\n return ai - bi\n })\n .map(([d]) => d)\n}\n\nfunction capitalize(s: string) {\n if (typeof s !== 'string') return ''\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nfunction sanitize(s?: string) {\n return replaceBackslash(s?.replace(/\\\\index/gi, ''))\n}\n\nfunction removeUnderscores(s?: string) {\n return s?.replace(/(^_|_$)/, '').replace(/(\\/_|_\\/)/, '/')\n}\n\nfunction removeTrailingUnderscores(s?: string) {\n return s?.replace(/(_$)/, '').replace(/(_\\/)/, '/')\n}\n\nfunction replaceBackslash(s?: string) {\n return s?.replace(/\\\\/gi, '/')\n}\n\nexport function hasParentRoute(\n routes: RouteNode[],\n routePathToCheck: string | undefined,\n): RouteNode | null {\n if (!routePathToCheck || routePathToCheck === '/') {\n return null\n }\n\n const sortedNodes = multiSortBy(routes, [\n (d) => d.routePath!.length * -1,\n (d) => d.variableName,\n ]).filter((d) => d.routePath !== `/${rootPathId}`)\n\n for (const route of sortedNodes) {\n if (route.routePath === '/') continue\n\n if (\n routePathToCheck.startsWith(`${route.routePath}/`) &&\n route.routePath !== routePathToCheck\n ) {\n return route\n }\n }\n const segments = routePathToCheck.split('/')\n segments.pop() // Remove the last segment\n const parentRoutePath = segments.join('/')\n\n return hasParentRoute(routes, parentRoutePath)\n}\n"],"names":["latestTask","rootPathId","fileRouteRegex","getRouteNodes","config","routeFilePrefix","routeFileIgnorePrefix","routeNodes","recurse","dir","fullDir","path","resolve","routesDirectory","dirList","fs","readdir","filter","d","startsWith","Promise","all","map","fileName","fullPath","join","relativePath","stat","isDirectory","filePath","filePathNoExt","removeExt","routePath","replaceBackslash","cleanPath","split","variableName","fileToVariable","endsWith","replace","push","first","skipMessage","generator","console","log","taskId","checkLatest","start","Date","now","routePathIdPrefix","preRouteNodes","sortRouteNodes","nodes","multiSortBy","length","match","routeTree","routePiecesByPath","handleNode","node","future","unstable_codeSplitting","isRoute","isComponent","isErrorComponent","isPendingComponent","isLoader","parentRoute","hasParentRoute","parent","trimmedPath","trimPathLeft","isNonPath","isNonLayout","cleanedPath","removeUnderscores","anchorRoute","find","isVirtual","children","forEach","buildRouteConfig","depth","routeCode","readFile","isRoot","escapedRoutePath","removeTrailingUnderscores","replaceAll","quote","quoteStyle","replaced","writeFile","route","childConfigs","spaces","Boolean","routeConfigChildrenText","sortedRouteNodes","includes","imports","Object","entries","FileRoute","some","lazyFn","loader","lazyRouteComponent","component","errorComponent","pendingComponent","routeImports","sanitize","relative","dirname","generatedRouteTree","loaderNode","componentNode","errorComponentNode","pendingComponentNode","routeNode","routeConfigFileContent","prettier","semi","singleQuote","parser","routeTreeContent","catch","err","code","undefined","mkdir","recursive","i","capitalize","substring","lastIndexOf","Array","from","arr","accessors","sort","a","ai","b","bi","accessor","ao","bo","s","charAt","toUpperCase","slice","routes","routePathToCheck","sortedNodes","segments","pop","parentRoutePath"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAIA,UAAU,GAAG,CAAC,CAAA;AACX,MAAMC,UAAU,GAAG,SAAQ;AAC3B,MAAMC,cAAc,GAAG,8BAA6B;AAsB3D,eAAeC,aAAaA,CAACC,MAAc,EAAE;EAC3C,MAAM;IAAEC,eAAe;AAAEC,IAAAA,qBAAAA;AAAsB,GAAC,GAAGF,MAAM,CAAA;EAEzD,IAAIG,UAAuB,GAAG,EAAE,CAAA;EAEhC,eAAeC,OAAOA,CAACC,GAAW,EAAE;IAClC,MAAMC,OAAO,GAAGC,IAAI,CAACC,OAAO,CAACR,MAAM,CAACS,eAAe,EAAEJ,GAAG,CAAC,CAAA;IACzD,IAAIK,OAAO,GAAG,MAAMC,aAAE,CAACC,OAAO,CAACN,OAAO,CAAC,CAAA;AAEvCI,IAAAA,OAAO,GAAGA,OAAO,CAACG,MAAM,CAAEC,CAAC,IAAK;AAC9B,MAAA,IACEA,CAAC,CAACC,UAAU,CAAC,GAAG,CAAC,IAChBb,qBAAqB,IAAIY,CAAC,CAACC,UAAU,CAACb,qBAAqB,CAAE,EAC9D;AACA,QAAA,OAAO,KAAK,CAAA;AACd,OAAA;AAEA,M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CAAA,CAAA,CAAC,IAClD+D,KAAK,CAAC/D,SAAS,KAAK4H,gBAAgB,EACpC;AACA,MAAA,OAAO7D,KAAK,CAAA;AACd,KAAA;AACF,GAAA;AACA,EAAA,MAAM+D,QAAQ,GAAGF,gBAAgB,CAACzH,KAAK,CAAC,GAAG,CAAC,CAAA;AAC5C2H,EAAAA,QAAQ,CAACC,GAAG,EAAE,CAAC;AACf,EAAA,MAAMC,eAAe,GAAGF,QAAQ,CAACrI,IAAI,CAAC,GAAG,CAAC,CAAA;AAE1C,EAAA,OAAO6C,cAAc,CAACqF,MAAM,EAAEK,eAAe,CAAC,CAAA;AAChD;;;;;;;;;"}
1
+ {"version":3,"file":"generator.js","sources":["../../../../../../router-cli/src/generator.ts"],"sourcesContent":["import path from 'path'\nimport * as fs from 'fs/promises'\nimport * as prettier from 'prettier'\nimport { Config } from './config'\nimport { cleanPath, trimPathLeft } from '@tanstack/react-router'\n\nlet latestTask = 0\nexport const rootPathId = '__root'\nexport const fileRouteRegex = /new\\s+FileRoute\\(([^)]*)\\)/g\n\nexport type RouteNode = {\n filePath: string\n fullPath: string\n variableName: string\n routePath?: string\n cleanedPath?: string\n path?: string\n isNonPath?: boolean\n isNonLayout?: boolean\n isRoute?: boolean\n isLoader?: boolean\n isComponent?: boolean\n isErrorComponent?: boolean\n isPendingComponent?: boolean\n isVirtual?: boolean\n isRoot?: boolean\n children?: RouteNode[]\n parent?: RouteNode\n}\n\nasync function getRouteNodes(config: Config) {\n const { routeFilePrefix, routeFileIgnorePrefix } = config\n\n let routeNodes: RouteNode[] = []\n\n async function recurse(dir: string) {\n const fullDir = path.resolve(config.routesDirectory, dir)\n let dirList = await fs.readdir(fullDir)\n\n dirList = dirList.filter((d) => {\n if (\n d.startsWith('.') ||\n (routeFileIgnorePrefix && d.startsWith(routeFileIgnorePrefix))\n ) {\n return false\n }\n\n if (routeFilePrefix) {\n return d.startsWith(routeFilePrefix)\n }\n\n return true\n })\n\n await Promise.all(\n dirList.map(async (fileName) => {\n const fullPath = path.join(fullDir, fileName)\n const relativePath = path.join(dir, fileName)\n const stat = await fs.stat(fullPath)\n\n if (stat.isDirectory()) {\n await recurse(relativePath)\n } else {\n const filePath = path.join(dir, fileName)\n const filePathNoExt = removeExt(filePath)\n let routePath =\n replaceBackslash(\n cleanPath(`/${filePathNoExt.split('.').join('/')}`),\n ) ?? ''\n const variableName = fileToVariable(routePath)\n\n // Remove the index from the route path and\n // if the route path is empty, use `/'\n\n let isRoute = routePath?.endsWith('/route')\n let isComponent = routePath?.endsWith('/component')\n let isErrorComponent = routePath?.endsWith('/errorComponent')\n let isPendingComponent = routePath?.endsWith('/pendingComponent')\n let isLoader = routePath?.endsWith('/loader')\n\n routePath = routePath?.replace(\n /\\/(component|errorComponent|pendingComponent|loader|route)$/,\n '',\n )\n\n if (routePath === 'index') {\n routePath = '/'\n }\n\n routePath = routePath.replace(/\\/index$/, '/') || '/'\n\n routeNodes.push({\n filePath,\n fullPath,\n routePath,\n variableName,\n isRoute,\n isComponent,\n isErrorComponent,\n isPendingComponent,\n isLoader,\n })\n }\n }),\n )\n\n return routeNodes\n }\n\n await recurse('./')\n\n return routeNodes\n}\n\nlet first = false\nlet skipMessage = false\n\ntype RouteSubNode = {\n component?: RouteNode\n errorComponent?: RouteNode\n pendingComponent?: RouteNode\n loader?: RouteNode\n}\n\nexport async function generator(config: Config) {\n console.log()\n\n if (!first) {\n console.log('🔄 Generating routes...')\n first = true\n } else if (skipMessage) {\n skipMessage = false\n } else {\n console.log('♻️ Regenerating routes...')\n }\n\n const taskId = latestTask + 1\n latestTask = taskId\n\n const checkLatest = () => {\n if (latestTask !== taskId) {\n skipMessage = true\n return false\n }\n\n return true\n }\n\n const start = Date.now()\n const routePathIdPrefix = config.routeFilePrefix ?? ''\n\n let preRouteNodes = await getRouteNodes(config)\n\n const sortRouteNodes = (nodes: RouteNode[]): RouteNode[] => {\n return multiSortBy(nodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.filePath?.match(/[./]index[.]/) ? 1 : -1),\n (d) =>\n d.filePath?.match(\n /[./](component|errorComponent|pendingComponent|loader)[.]/,\n )\n ? 1\n : -1,\n (d) => (d.filePath?.match(/[./]route[.]/) ? -1 : 1),\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => d.routePath !== `/${routePathIdPrefix + rootPathId}`)\n }\n\n preRouteNodes = sortRouteNodes(preRouteNodes)\n\n const routeTree: RouteNode[] = []\n const routePiecesByPath: Record<string, RouteSubNode> = {}\n\n // Loop over the flat list of routeNodes and\n // build up a tree based on the routeNodes' routePath\n let routeNodes: RouteNode[] = []\n\n const handleNode = (node: RouteNode) => {\n const parentRoute = hasParentRoute(routeNodes, node.routePath)\n if (parentRoute) node.parent = parentRoute\n\n node.path = node.parent\n ? node.routePath?.replace(node.parent.routePath!, '') || '/'\n : node.routePath\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath?.split('/') ?? []\n let first = split[0] ?? trimmedPath ?? ''\n\n node.isNonPath = first.startsWith('_')\n node.isNonLayout = first.endsWith('_')\n\n node.cleanedPath = removeUnderscores(node.path) ?? ''\n\n if (config.future?.unstable_codeSplitting) {\n if (\n !node.isVirtual &&\n (node.isLoader ||\n node.isComponent ||\n node.isErrorComponent ||\n node.isPendingComponent)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node.isLoader\n ? 'loader'\n : node.isErrorComponent\n ? 'errorComponent'\n : node.isPendingComponent\n ? 'pendingComponent'\n : 'component'\n ] = node\n\n const anchorRoute = routeNodes.find(\n (d) => d.routePath === node.routePath,\n )\n\n if (!anchorRoute) {\n handleNode({\n ...node,\n isVirtual: true,\n isLoader: false,\n isComponent: false,\n isErrorComponent: false,\n isPendingComponent: false,\n })\n }\n return\n }\n }\n\n if (node.parent) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n } else {\n routeTree.push(node)\n }\n\n routeNodes.push(node)\n }\n\n preRouteNodes.forEach((node) => handleNode(node))\n\n async function buildRouteConfig(\n nodes: RouteNode[],\n depth = 1,\n ): Promise<string> {\n const children = nodes.map(async (node) => {\n const routeCode = await fs.readFile(node.fullPath, 'utf-8')\n\n // Ensure the boilerplate for the route exists\n if (node.isRoot) {\n return\n }\n\n // Ensure that new FileRoute(anything?) is replaced with FileRoute(${node.routePath})\n // routePath can contain $ characters, which have special meaning when used in replace\n // so we have to escape it by turning all $ into $$. But since we do it through a replace call\n // we have to double escape it into $$$$. For more information, see\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement\n const escapedRoutePath = removeTrailingUnderscores(\n node.routePath?.replaceAll('$', '$$$$') ?? '',\n )\n const quote = config.quoteStyle === 'single' ? `'` : `\"`\n const replaced = routeCode.replace(\n fileRouteRegex,\n `new FileRoute(${quote}${escapedRoutePath}${quote})`,\n )\n\n if (replaced !== routeCode) {\n await fs.writeFile(node.fullPath, replaced)\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = await buildRouteConfig(node.children, depth + 1)\n return `${route}.addChildren([${spaces(depth * 4)}${childConfigs}])`\n }\n\n return route\n })\n\n return (await Promise.all(children)).filter(Boolean).join(`,`)\n }\n\n const routeConfigChildrenText = await buildRouteConfig(routeTree)\n\n const sortedRouteNodes = multiSortBy(routeNodes, [\n (d) =>\n d.routePath?.includes(`/${routePathIdPrefix + rootPathId}`) ? -1 : 1,\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(\"index'\") ? -1 : 1),\n (d) => d,\n ])\n\n const imports = Object.entries({\n FileRoute: sortedRouteNodes.some((d) => d.isVirtual),\n lazyFn: sortedRouteNodes.some(\n (node) => routePiecesByPath[node.routePath!]?.loader,\n ),\n lazyRouteComponent: sortedRouteNodes.some(\n (node) =>\n routePiecesByPath[node.routePath!]?.component ||\n routePiecesByPath[node.routePath!]?.errorComponent ||\n routePiecesByPath[node.routePath!]?.pendingComponent,\n ),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n\n const routeImports = [\n imports.length\n ? `import { ${imports.join(', ')} } from '@tanstack/react-router'\\n`\n : '',\n `import { Route as rootRoute } from './${sanitize(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, routePathIdPrefix + rootPathId),\n ),\n )}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }Import } from './${sanitize(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, node.filePath),\n ),\n ),\n )}'`\n }),\n '\\n',\n sortedRouteNodes\n .filter((d) => d.isVirtual)\n .map((node) => {\n return `const ${\n node.variableName\n }Import = new FileRoute('${removeTrailingUnderscores(\n node.routePath,\n )}').createRoute()`\n })\n .join('\\n'),\n '\\n',\n sortedRouteNodes\n .map((node) => {\n const loaderNode = routePiecesByPath[node.routePath!]?.loader\n const componentNode = routePiecesByPath[node.routePath!]?.component\n const errorComponentNode =\n routePiecesByPath[node.routePath!]?.errorComponent\n const pendingComponentNode =\n routePiecesByPath[node.routePath!]?.pendingComponent\n\n return [\n `const ${node.variableName}Route = ${node.variableName}Import.update({\n ${[\n node.isNonPath\n ? `id: '${node.path}'`\n : `path: '${node.cleanedPath}'`,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n } as any)`,\n loaderNode\n ? `.updateLoader({ loader: lazyFn(() => import('./${sanitize(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, loaderNode.filePath),\n ),\n ),\n )}'), 'loader') })`\n : '',\n componentNode || errorComponentNode || pendingComponentNode\n ? `.update({\n ${(\n [\n ['component', componentNode],\n ['errorComponent', errorComponentNode],\n ['pendingComponent', pendingComponentNode],\n ] as const\n )\n .filter((d) => d[1])\n .map((d) => {\n return `${\n d[0]\n }: lazyRouteComponent(() => import('./${sanitize(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, d[1]!.filePath),\n ),\n ),\n )}'), '${d[0]}')`\n })\n .join('\\n,')}\n })`\n : '',\n ].join('')\n })\n .join('\\n\\n'),\n `declare module '@tanstack/react-router' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n return `'${removeTrailingUnderscores(routeNode.routePath)}': {\n preLoaderRoute: typeof ${routeNode.variableName}Import\n parentRoute: typeof ${\n routeNode.parent?.variableName\n ? `${routeNode.parent?.variableName}Import`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`,\n ].join('\\n')\n\n const routeConfigFileContent = await prettier.format(routeImports, {\n semi: false,\n singleQuote: config.quoteStyle === 'single',\n parser: 'typescript',\n })\n\n const routeTreeContent = await fs\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err: any) => {\n if (err.code === 'ENOENT') {\n return undefined\n }\n throw err\n })\n\n if (!checkLatest()) return\n\n if (routeTreeContent !== routeConfigFileContent) {\n await fs.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n if (!checkLatest()) return\n await fs.writeFile(\n path.resolve(config.generatedRouteTree),\n routeConfigFileContent,\n )\n }\n\n console.log(\n `🌲 Processed ${routeNodes.length} routes in ${Date.now() - start}ms`,\n )\n}\n\nfunction fileToVariable(d: string): string {\n return (\n removeUnderscores(d)\n ?.replace(/\\$/g, '')\n ?.split(/[/-]/g)\n .map((d, i) => (i > 0 ? capitalize(d) : d))\n .join('')\n .replace(/([^a-zA-Z0-9]|[\\.])/gm, '') ?? ''\n )\n}\n\nexport function removeExt(d: string) {\n return d.substring(0, d.lastIndexOf('.')) || d\n}\n\nfunction spaces(d: number): string {\n return Array.from({ length: d })\n .map(() => ' ')\n .join('')\n}\n\nexport function multiSortBy<T>(\n arr: T[],\n accessors: ((item: T) => any)[] = [(d) => d],\n): T[] {\n return arr\n .map((d, i) => [d, i] as const)\n .sort(([a, ai], [b, bi]) => {\n for (const accessor of accessors) {\n const ao = accessor(a)\n const bo = accessor(b)\n\n if (typeof ao === 'undefined') {\n if (typeof bo === 'undefined') {\n continue\n }\n return 1\n }\n\n if (ao === bo) {\n continue\n }\n\n return ao > bo ? 1 : -1\n }\n\n return ai - bi\n })\n .map(([d]) => d)\n}\n\nfunction capitalize(s: string) {\n if (typeof s !== 'string') return ''\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nfunction sanitize(s?: string) {\n return replaceBackslash(s?.replace(/\\\\index/gi, ''))\n}\n\nfunction removeUnderscores(s?: string) {\n return s?.replace(/(^_|_$)/, '').replace(/(\\/_|_\\/)/, '/')\n}\n\nfunction removeTrailingUnderscores(s?: string) {\n return s?.replace(/(_$)/, '').replace(/(_\\/)/, '/')\n}\n\nfunction replaceBackslash(s?: string) {\n return s?.replace(/\\\\/gi, '/')\n}\n\nexport function hasParentRoute(\n routes: RouteNode[],\n routePathToCheck: string | undefined,\n): RouteNode | null {\n if (!routePathToCheck || routePathToCheck === '/') {\n return null\n }\n\n const sortedNodes = multiSortBy(routes, [\n (d) => d.routePath!.length * -1,\n (d) => d.variableName,\n ]).filter((d) => d.routePath !== `/${rootPathId}`)\n\n for (const route of sortedNodes) {\n if (route.routePath === '/') continue\n\n if (\n routePathToCheck.startsWith(`${route.routePath}/`) &&\n route.routePath !== routePathToCheck\n ) {\n return route\n }\n }\n const segments = routePathToCheck.split('/')\n segments.pop() // Remove the last segment\n const parentRoutePath = segments.join('/')\n\n return hasParentRoute(routes, parentRoutePath)\n}\n"],"names":["latestTask","rootPathId","fileRouteRegex","getRouteNodes","config","routeFilePrefix","routeFileIgnorePrefix","routeNodes","recurse","dir","fullDir","path","resolve","routesDirectory","dirList","fs","readdir","filter","d","startsWith","Promise","all","map","fileName","fullPath","join","relativePath","stat","isDirectory","filePath","filePathNoExt","removeExt","routePath","replaceBackslash","cleanPath","split","variableName","fileToVariable","isRoute","endsWith","isComponent","isErrorComponent","isPendingComponent","isLoader","replace","push","first","skipMessage","generator","console","log","taskId","checkLatest","start","Date","now","routePathIdPrefix","preRouteNodes","sortRouteNodes","nodes","multiSortBy","length","match","routeTree","routePiecesByPath","handleNode","node","parentRoute","hasParentRoute","parent","trimmedPath","trimPathLeft","isNonPath","isNonLayout","cleanedPath","removeUnderscores","future","unstable_codeSplitting","isVirtual","anchorRoute","find","children","forEach","buildRouteConfig","depth","routeCode","readFile","isRoot","escapedRoutePath","removeTrailingUnderscores","replaceAll","quote","quoteStyle","replaced","writeFile","route","childConfigs","spaces","Boolean","routeConfigChildrenText","sortedRouteNodes","includes","imports","Object","entries","FileRoute","some","lazyFn","loader","lazyRouteComponent","component","errorComponent","pendingComponent","routeImports","sanitize","relative","dirname","generatedRouteTree","loaderNode","componentNode","errorComponentNode","pendingComponentNode","routeNode","routeConfigFileContent","prettier","semi","singleQuote","parser","routeTreeContent","catch","err","code","undefined","mkdir","recursive","i","capitalize","substring","lastIndexOf","Array","from","arr","accessors","sort","a","ai","b","bi","accessor","ao","bo","s","charAt","toUpperCase","slice","routes","routePathToCheck","sortedNodes","segments","pop","parentRoutePath"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAIA,UAAU,GAAG,CAAC,CAAA;AACX,MAAMC,UAAU,GAAG,SAAQ;AAC3B,MAAMC,cAAc,GAAG,8BAA6B;AAsB3D,eAAeC,aAAaA,CAACC,MAAc,EAAE;EAC3C,MAAM;IAAEC,eAAe;AAAEC,IAAAA,qBAAAA;AAAsB,GAAC,GAAGF,MAAM,CAAA;EAEzD,IAAIG,UAAuB,GAAG,EAAE,CAAA;EAEhC,eAAeC,OAAOA,CAACC,GAAW,EAAE;IAClC,MAAMC,OAAO,GAAGC,IAAI,CAACC,OAAO,CAACR,MAAM,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CAAEC,CAAC,IAAKA,CAAC,CAACc,SAAS,KAAM,CAAG/B,CAAAA,EAAAA,UAAW,EAAC,CAAC,CAAA;AAElD,EAAA,KAAK,MAAM8F,KAAK,IAAI8D,WAAW,EAAE;AAC/B,IAAA,IAAI9D,KAAK,CAAC/D,SAAS,KAAK,GAAG,EAAE,SAAA;AAE7B,IAAA,IACE4H,gBAAgB,CAACzI,UAAU,CAAE,CAAA,EAAE4E,KAAK,CAAC/D,SAAU,CAAE,CAAA,CAAA,CAAC,IAClD+D,KAAK,CAAC/D,SAAS,KAAK4H,gBAAgB,EACpC;AACA,MAAA,OAAO7D,KAAK,CAAA;AACd,KAAA;AACF,GAAA;AACA,EAAA,MAAM+D,QAAQ,GAAGF,gBAAgB,CAACzH,KAAK,CAAC,GAAG,CAAC,CAAA;AAC5C2H,EAAAA,QAAQ,CAACC,GAAG,EAAE,CAAC;AACf,EAAA,MAAMC,eAAe,GAAGF,QAAQ,CAACrI,IAAI,CAAC,GAAG,CAAC,CAAA;AAE1C,EAAA,OAAO2C,cAAc,CAACuF,MAAM,EAAEK,eAAe,CAAC,CAAA;AAChD;;;;;;;;;"}
@@ -33038,16 +33038,27 @@ async function getRouteNodes(config) {
33038
33038
 
33039
33039
  // Remove the index from the route path and
33040
33040
  // if the route path is empty, use `/'
33041
+
33042
+ let isRoute = routePath?.endsWith('/route');
33043
+ let isComponent = routePath?.endsWith('/component');
33044
+ let isErrorComponent = routePath?.endsWith('/errorComponent');
33045
+ let isPendingComponent = routePath?.endsWith('/pendingComponent');
33046
+ let isLoader = routePath?.endsWith('/loader');
33047
+ routePath = routePath?.replace(/\/(component|errorComponent|pendingComponent|loader|route)$/, '');
33041
33048
  if (routePath === 'index') {
33042
33049
  routePath = '/';
33043
- } else if (routePath.endsWith('/index')) {
33044
- routePath = routePath.replace(/\/index$/, '/');
33045
33050
  }
33051
+ routePath = routePath.replace(/\/index$/, '/') || '/';
33046
33052
  routeNodes.push({
33047
33053
  filePath,
33048
33054
  fullPath,
33049
33055
  routePath,
33050
- variableName
33056
+ variableName,
33057
+ isRoute,
33058
+ isComponent,
33059
+ isErrorComponent,
33060
+ isPendingComponent,
33061
+ isLoader
33051
33062
  });
33052
33063
  }
33053
33064
  }));
@@ -33081,7 +33092,7 @@ async function generator(config) {
33081
33092
  const routePathIdPrefix = config.routeFilePrefix ?? '';
33082
33093
  let preRouteNodes = await getRouteNodes(config);
33083
33094
  const sortRouteNodes = nodes => {
33084
- return multiSortBy(nodes, [d => d.routePath === '/' ? -1 : 1, d => d.routePath?.split('/').length, d => d.filePath?.match(/[./]index[.]/) ? 1 : -1, d => d.filePath?.match(/[./]route[.]/) ? -1 : 1, d => d.routePath?.endsWith('/') ? -1 : 1, d => d.routePath]).filter(d => d.routePath !== `/${routePathIdPrefix + rootPathId}`);
33095
+ return multiSortBy(nodes, [d => d.routePath === '/' ? -1 : 1, d => d.routePath?.split('/').length, d => d.filePath?.match(/[./]index[.]/) ? 1 : -1, d => d.filePath?.match(/[./](component|errorComponent|pendingComponent|loader)[.]/) ? 1 : -1, d => d.filePath?.match(/[./]route[.]/) ? -1 : 1, d => d.routePath?.endsWith('/') ? -1 : 1, d => d.routePath]).filter(d => d.routePath !== `/${routePathIdPrefix + rootPathId}`);
33085
33096
  };
33086
33097
  preRouteNodes = sortRouteNodes(preRouteNodes);
33087
33098
  const routeTree = [];
@@ -33091,16 +33102,6 @@ async function generator(config) {
33091
33102
  // build up a tree based on the routeNodes' routePath
33092
33103
  let routeNodes = [];
33093
33104
  const handleNode = node => {
33094
- if (config.future?.unstable_codeSplitting) {
33095
- node.isRoute = node.routePath?.endsWith('/route');
33096
- node.isComponent = node.routePath?.endsWith('/component');
33097
- node.isErrorComponent = node.routePath?.endsWith('/errorComponent');
33098
- node.isPendingComponent = node.routePath?.endsWith('/pendingComponent');
33099
- node.isLoader = node.routePath?.endsWith('/loader');
33100
- if (node.isComponent || node.isErrorComponent || node.isPendingComponent || node.isLoader || node.isRoute) {
33101
- node.routePath = node.routePath?.replace(/\/(component|errorComponent|pendingComponent|loader|route)$/, '');
33102
- }
33103
- }
33104
33105
  const parentRoute = hasParentRoute(routeNodes, node.routePath);
33105
33106
  if (parentRoute) node.parent = parentRoute;
33106
33107
  node.path = node.parent ? node.routePath?.replace(node.parent.routePath, '') || '/' : node.routePath;
@@ -33111,14 +33112,18 @@ async function generator(config) {
33111
33112
  node.isNonLayout = first.endsWith('_');
33112
33113
  node.cleanedPath = removeUnderscores(node.path) ?? '';
33113
33114
  if (config.future?.unstable_codeSplitting) {
33114
- if (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent) {
33115
+ if (!node.isVirtual && (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent)) {
33115
33116
  routePiecesByPath[node.routePath] = routePiecesByPath[node.routePath] || {};
33116
33117
  routePiecesByPath[node.routePath][node.isLoader ? 'loader' : node.isErrorComponent ? 'errorComponent' : node.isPendingComponent ? 'pendingComponent' : 'component'] = node;
33117
33118
  const anchorRoute = routeNodes.find(d => d.routePath === node.routePath);
33118
33119
  if (!anchorRoute) {
33119
33120
  handleNode({
33120
33121
  ...node,
33121
- isVirtual: true
33122
+ isVirtual: true,
33123
+ isLoader: false,
33124
+ isComponent: false,
33125
+ isErrorComponent: false,
33126
+ isPendingComponent: false
33122
33127
  });
33123
33128
  }
33124
33129
  return;