@tanstack/router-vite-plugin 1.2.6 → 1.3.0

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.
@@ -125,9 +125,11 @@ async function generator(config) {
125
125
  if (config.future?.unstable_codeSplitting) {
126
126
  node.isRoute = node.routePath?.endsWith('/route');
127
127
  node.isComponent = node.routePath?.endsWith('/component');
128
+ node.isErrorComponent = node.routePath?.endsWith('/errorComponent');
129
+ node.isPendingComponent = node.routePath?.endsWith('/pendingComponent');
128
130
  node.isLoader = node.routePath?.endsWith('/loader');
129
- if (node.isComponent || node.isLoader || node.isRoute) {
130
- node.routePath = node.routePath?.replace(/\/(component|loader|route)$/, '');
131
+ if (node.isComponent || node.isErrorComponent || node.isPendingComponent || node.isLoader || node.isRoute) {
132
+ node.routePath = node.routePath?.replace(/\/(component|errorComponent|pendingComponent|loader|route)$/, '');
131
133
  }
132
134
  }
133
135
  const parentRoute = hasParentRoute(routeNodes, node.routePath);
@@ -140,9 +142,9 @@ async function generator(config) {
140
142
  node.isNonLayout = first.endsWith('_');
141
143
  node.cleanedPath = removeUnderscores(node.path) ?? '';
142
144
  if (config.future?.unstable_codeSplitting) {
143
- if (node.isLoader || node.isComponent) {
145
+ if (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent) {
144
146
  routePiecesByPath[node.routePath] = routePiecesByPath[node.routePath] || {};
145
- routePiecesByPath[node.routePath][node.isLoader ? 'loader' : 'component'] = node;
147
+ routePiecesByPath[node.routePath][node.isLoader ? 'loader' : node.isErrorComponent ? 'errorComponent' : node.isPendingComponent ? 'pendingComponent' : 'component'] = node;
146
148
  const anchorRoute = routeNodes.find(d => d.routePath === node.routePath);
147
149
  if (!anchorRoute) {
148
150
  handleNode({
@@ -150,11 +152,6 @@ async function generator(config) {
150
152
  isVirtual: true
151
153
  });
152
154
  }
153
- // if (!node.parent) {
154
- // }
155
-
156
- // componentOrLoader.isVirtual = true
157
- // handleNode(componentOrLoader)
158
155
  return;
159
156
  }
160
157
  }
@@ -181,7 +178,7 @@ async function generator(config) {
181
178
  // so we have to escape it by turning all $ into $$. But since we do it through a replace call
182
179
  // we have to double escape it into $$$$. For more information, see
183
180
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement
184
- const escapedRoutePath = node.routePath?.replaceAll('$', '$$$$') ?? '';
181
+ const escapedRoutePath = removeTrailingUnderscores(node.routePath?.replaceAll('$', '$$$$') ?? '');
185
182
  const quote = config.quoteStyle === 'single' ? `'` : `"`;
186
183
  const replaced = routeCode.replace(fileRouteRegex, `new FileRoute(${quote}${escapedRoutePath}${quote})`);
187
184
  if (replaced !== routeCode) {
@@ -201,22 +198,28 @@ async function generator(config) {
201
198
  const imports = Object.entries({
202
199
  FileRoute: sortedRouteNodes.some(d => d.isVirtual),
203
200
  lazyFn: sortedRouteNodes.some(node => routePiecesByPath[node.routePath]?.loader),
204
- lazyRouteComponent: sortedRouteNodes.some(node => routePiecesByPath[node.routePath]?.component)
201
+ lazyRouteComponent: sortedRouteNodes.some(node => routePiecesByPath[node.routePath]?.component || routePiecesByPath[node.routePath]?.errorComponent || routePiecesByPath[node.routePath]?.pendingComponent)
205
202
  }).filter(d => d[1]).map(d => d[0]);
206
203
  const routeImports = [imports.length ? `import { ${imports.join(', ')} } from '@tanstack/react-router'\n` : '', `import { Route as rootRoute } from './${sanitize(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, routePathIdPrefix + rootPathId)))}'`, ...sortedRouteNodes.filter(d => !d.isVirtual).map(node => {
207
204
  return `import { Route as ${node.variableName}Import } from './${sanitize(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, node.filePath))))}'`;
208
205
  }), '\n', sortedRouteNodes.filter(d => d.isVirtual).map(node => {
209
- return `const ${node.variableName}Import = new FileRoute('${node.routePath}').createRoute()`;
206
+ return `const ${node.variableName}Import = new FileRoute('${removeTrailingUnderscores(node.routePath)}').createRoute()`;
210
207
  }).join('\n'), '\n', sortedRouteNodes.map(node => {
211
208
  const loaderNode = routePiecesByPath[node.routePath]?.loader;
212
209
  const componentNode = routePiecesByPath[node.routePath]?.component;
210
+ const errorComponentNode = routePiecesByPath[node.routePath]?.errorComponent;
211
+ const pendingComponentNode = routePiecesByPath[node.routePath]?.pendingComponent;
213
212
  return [`const ${node.variableName}Route = ${node.variableName}Import.update({
214
213
  ${[node.isNonPath ? `id: '${node.path}'` : `path: '${node.cleanedPath}'`, `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`].filter(Boolean).join(',')}
215
- } as any)`, loaderNode ? `.updateLoader({ loader: lazyFn(() => import('./${sanitize(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, loaderNode.filePath))))}'), 'loader') })` : '', componentNode ? `.update({ component: lazyRouteComponent(() => import('./${sanitize(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, componentNode.filePath))))}'), 'component') })` : ''].join('');
214
+ } as any)`, loaderNode ? `.updateLoader({ loader: lazyFn(() => import('./${sanitize(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, loaderNode.filePath))))}'), 'loader') })` : '', componentNode || errorComponentNode || pendingComponentNode ? `.update({
215
+ ${[['component', componentNode], ['errorComponent', errorComponentNode], ['pendingComponent', pendingComponentNode]].filter(d => d[1]).map(d => {
216
+ return `${d[0]}: lazyRouteComponent(() => import('./${sanitize(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, d[1].filePath))))}'), '${d[0]}')`;
217
+ }).join('\n,')}
218
+ })` : ''].join('');
216
219
  }).join('\n\n'), `declare module '@tanstack/react-router' {
217
220
  interface FileRoutesByPath {
218
221
  ${routeNodes.map(routeNode => {
219
- return `'${routeNode.routePath}': {
222
+ return `'${removeTrailingUnderscores(routeNode.routePath)}': {
220
223
  preLoaderRoute: typeof ${routeNode.variableName}Import
221
224
  parentRoute: typeof ${routeNode.parent?.variableName ? `${routeNode.parent?.variableName}Import` : 'rootRoute'}
222
225
  }`;
@@ -284,6 +287,9 @@ function sanitize(s) {
284
287
  function removeUnderscores(s) {
285
288
  return s?.replace(/(^_|_$)/, '').replace(/(\/_|_\/)/, '/');
286
289
  }
290
+ function removeTrailingUnderscores(s) {
291
+ return s?.replace(/(_$)/, '').replace(/(_\/)/, '/');
292
+ }
287
293
  function replaceBackslash(s) {
288
294
  return s?.replace(/\\/gi, '/');
289
295
  }
@@ -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 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 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.isLoader = node.routePath?.endsWith('/loader')\n\n if (node.isComponent || node.isLoader || node.isRoute) {\n node.routePath = node.routePath?.replace(\n /\\/(component|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 (node.isLoader || node.isComponent) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node.isLoader ? 'loader' : '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 // if (!node.parent) {\n // }\n\n // componentOrLoader.isVirtual = true\n // handleNode(componentOrLoader)\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 = node.routePath?.replaceAll('$', '$$$$') ?? ''\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) => routePiecesByPath[node.routePath!]?.component,\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 ${node.variableName}Import = new FileRoute('${node.routePath}').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\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\n ? `.update({ component: lazyRouteComponent(() => import('./${sanitize(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n componentNode.filePath,\n ),\n ),\n ),\n )}'), 'component') })`\n : '',\n ].join('')\n })\n .join('\\n\\n'),\n `declare module '@tanstack/react-router' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n return `'${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 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","isLoader","parentRoute","hasParentRoute","parent","trimmedPath","trimPathLeft","isNonPath","isNonLayout","cleanedPath","removeUnderscores","anchorRoute","find","isVirtual","children","forEach","buildRouteConfig","depth","routeCode","readFile","isRoot","escapedRoutePath","replaceAll","quote","quoteStyle","replaced","writeFile","route","childConfigs","spaces","Boolean","routeConfigChildrenText","sortedRouteNodes","includes","imports","Object","entries","FileRoute","some","lazyFn","loader","lazyRouteComponent","component","routeImports","sanitize","relative","dirname","generatedRouteTree","loaderNode","componentNode","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,GAA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AgB,IAAIA,gBAAgB,KAAK,GAAG,EAAE;AACjD,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;AAEA,EAAA,MAAMC,WAAW,GAAG/F,WAAW,CAAC6F,MAAM,EAAE,CACrClI,CAAC,IAAKA,CAAC,CAACc,SAAS,CAAEwB,MAAM,GAAG,CAAC,CAAC,EAC9BtC,CAAC,IAAKA,CAAC,CAACkB,YAAY,CACtB,CAAC,CAACnB,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACc,SAAS,KAAM,CAAG/B,CAAAA,EAAAA,UAAW,EAAC,CAAC,CAAA;AAElD,EAAA,KAAK,MAAM2F,KAAK,IAAI0D,WAAW,EAAE;AAC/B,IAAA,IAAI1D,KAAK,CAAC5D,SAAS,KAAK,GAAG,EAAE,SAAA;AAE7B,IAAA,IACEqH,gBAAgB,CAAClI,UAAU,CAAE,CAAA,EAAEyE,KAAK,CAAC5D,SAAU,CAAE,CAAA,CAAA,CAAC,IAClD4D,KAAK,CAAC5D,SAAS,KAAKqH,gBAAgB,EACpC;AACA,MAAA,OAAOzD,KAAK,CAAA;AACd,KAAA;AACF,GAAA;AACA,EAAA,MAAM2D,QAAQ,GAAGF,gBAAgB,CAAClH,KAAK,CAAC,GAAG,CAAC,CAAA;AAC5CoH,EAAAA,QAAQ,CAACC,GAAG,EAAE,CAAC;AACf,EAAA,MAAMC,eAAe,GAAGF,QAAQ,CAAC9H,IAAI,CAAC,GAAG,CAAC,CAAA;AAE1C,EAAA,OAAO2C,cAAc,CAACgF,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 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,MAAA,IAAID,eAAe,EAAE;AACnB,QAAA,OAAOa,CAAC,CAACC,UAAU,CAACd,eAAe,CAAC,CAAA;AACtC,OAAA;AAEA,MAAA,OAAO,IAAI,CAAA;AACb,KAAC,CAAC,CAAA;IAEF,MAAMe,OAAO,CAACC,GAAG,CACfP,OAAO,CAACQ,GAAG,CAAC,MAAOC,QAAQ,IAAK;MAC9B,MAAMC,QAAQ,GAAGb,IAAI,CAACc,IAAI,CAACf,OAAO,EAAEa,QAAQ,CAAC,CAAA;MAC7C,MAAMG,YAAY,GAAGf,IAAI,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c,CAACqF,MAAM,EAAEK,eAAe,CAAC,CAAA;AAChD;;;;;;;;;"}
@@ -33094,9 +33094,11 @@ async function generator(config) {
33094
33094
  if (config.future?.unstable_codeSplitting) {
33095
33095
  node.isRoute = node.routePath?.endsWith('/route');
33096
33096
  node.isComponent = node.routePath?.endsWith('/component');
33097
+ node.isErrorComponent = node.routePath?.endsWith('/errorComponent');
33098
+ node.isPendingComponent = node.routePath?.endsWith('/pendingComponent');
33097
33099
  node.isLoader = node.routePath?.endsWith('/loader');
33098
- if (node.isComponent || node.isLoader || node.isRoute) {
33099
- node.routePath = node.routePath?.replace(/\/(component|loader|route)$/, '');
33100
+ if (node.isComponent || node.isErrorComponent || node.isPendingComponent || node.isLoader || node.isRoute) {
33101
+ node.routePath = node.routePath?.replace(/\/(component|errorComponent|pendingComponent|loader|route)$/, '');
33100
33102
  }
33101
33103
  }
33102
33104
  const parentRoute = hasParentRoute(routeNodes, node.routePath);
@@ -33109,9 +33111,9 @@ async function generator(config) {
33109
33111
  node.isNonLayout = first.endsWith('_');
33110
33112
  node.cleanedPath = removeUnderscores(node.path) ?? '';
33111
33113
  if (config.future?.unstable_codeSplitting) {
33112
- if (node.isLoader || node.isComponent) {
33114
+ if (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent) {
33113
33115
  routePiecesByPath[node.routePath] = routePiecesByPath[node.routePath] || {};
33114
- routePiecesByPath[node.routePath][node.isLoader ? 'loader' : 'component'] = node;
33116
+ routePiecesByPath[node.routePath][node.isLoader ? 'loader' : node.isErrorComponent ? 'errorComponent' : node.isPendingComponent ? 'pendingComponent' : 'component'] = node;
33115
33117
  const anchorRoute = routeNodes.find(d => d.routePath === node.routePath);
33116
33118
  if (!anchorRoute) {
33117
33119
  handleNode({
@@ -33119,11 +33121,6 @@ async function generator(config) {
33119
33121
  isVirtual: true
33120
33122
  });
33121
33123
  }
33122
- // if (!node.parent) {
33123
- // }
33124
-
33125
- // componentOrLoader.isVirtual = true
33126
- // handleNode(componentOrLoader)
33127
33124
  return;
33128
33125
  }
33129
33126
  }
@@ -33150,7 +33147,7 @@ async function generator(config) {
33150
33147
  // so we have to escape it by turning all $ into $$. But since we do it through a replace call
33151
33148
  // we have to double escape it into $$$$. For more information, see
33152
33149
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement
33153
- const escapedRoutePath = node.routePath?.replaceAll('$', '$$$$') ?? '';
33150
+ const escapedRoutePath = removeTrailingUnderscores(node.routePath?.replaceAll('$', '$$$$') ?? '');
33154
33151
  const quote = config.quoteStyle === 'single' ? `'` : `"`;
33155
33152
  const replaced = routeCode.replace(fileRouteRegex, `new FileRoute(${quote}${escapedRoutePath}${quote})`);
33156
33153
  if (replaced !== routeCode) {
@@ -33170,22 +33167,28 @@ async function generator(config) {
33170
33167
  const imports = Object.entries({
33171
33168
  FileRoute: sortedRouteNodes.some(d => d.isVirtual),
33172
33169
  lazyFn: sortedRouteNodes.some(node => routePiecesByPath[node.routePath]?.loader),
33173
- lazyRouteComponent: sortedRouteNodes.some(node => routePiecesByPath[node.routePath]?.component)
33170
+ lazyRouteComponent: sortedRouteNodes.some(node => routePiecesByPath[node.routePath]?.component || routePiecesByPath[node.routePath]?.errorComponent || routePiecesByPath[node.routePath]?.pendingComponent)
33174
33171
  }).filter(d => d[1]).map(d => d[0]);
33175
33172
  const routeImports = [imports.length ? `import { ${imports.join(', ')} } from '@tanstack/react-router'\n` : '', `import { Route as rootRoute } from './${sanitize(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, routePathIdPrefix + rootPathId)))}'`, ...sortedRouteNodes.filter(d => !d.isVirtual).map(node => {
33176
33173
  return `import { Route as ${node.variableName}Import } from './${sanitize(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, node.filePath))))}'`;
33177
33174
  }), '\n', sortedRouteNodes.filter(d => d.isVirtual).map(node => {
33178
- return `const ${node.variableName}Import = new FileRoute('${node.routePath}').createRoute()`;
33175
+ return `const ${node.variableName}Import = new FileRoute('${removeTrailingUnderscores(node.routePath)}').createRoute()`;
33179
33176
  }).join('\n'), '\n', sortedRouteNodes.map(node => {
33180
33177
  const loaderNode = routePiecesByPath[node.routePath]?.loader;
33181
33178
  const componentNode = routePiecesByPath[node.routePath]?.component;
33179
+ const errorComponentNode = routePiecesByPath[node.routePath]?.errorComponent;
33180
+ const pendingComponentNode = routePiecesByPath[node.routePath]?.pendingComponent;
33182
33181
  return [`const ${node.variableName}Route = ${node.variableName}Import.update({
33183
33182
  ${[node.isNonPath ? `id: '${node.path}'` : `path: '${node.cleanedPath}'`, `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`].filter(Boolean).join(',')}
33184
- } as any)`, loaderNode ? `.updateLoader({ loader: lazyFn(() => import('./${sanitize(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, loaderNode.filePath))))}'), 'loader') })` : '', componentNode ? `.update({ component: lazyRouteComponent(() => import('./${sanitize(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, componentNode.filePath))))}'), 'component') })` : ''].join('');
33183
+ } as any)`, loaderNode ? `.updateLoader({ loader: lazyFn(() => import('./${sanitize(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, loaderNode.filePath))))}'), 'loader') })` : '', componentNode || errorComponentNode || pendingComponentNode ? `.update({
33184
+ ${[['component', componentNode], ['errorComponent', errorComponentNode], ['pendingComponent', pendingComponentNode]].filter(d => d[1]).map(d => {
33185
+ return `${d[0]}: lazyRouteComponent(() => import('./${sanitize(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, d[1].filePath))))}'), '${d[0]}')`;
33186
+ }).join('\n,')}
33187
+ })` : ''].join('');
33185
33188
  }).join('\n\n'), `declare module '@tanstack/react-router' {
33186
33189
  interface FileRoutesByPath {
33187
33190
  ${routeNodes.map(routeNode => {
33188
- return `'${routeNode.routePath}': {
33191
+ return `'${removeTrailingUnderscores(routeNode.routePath)}': {
33189
33192
  preLoaderRoute: typeof ${routeNode.variableName}Import
33190
33193
  parentRoute: typeof ${routeNode.parent?.variableName ? `${routeNode.parent?.variableName}Import` : 'rootRoute'}
33191
33194
  }`;
@@ -33253,6 +33256,9 @@ function sanitize(s) {
33253
33256
  function removeUnderscores(s) {
33254
33257
  return s?.replace(/(^_|_$)/, '').replace(/(\/_|_\/)/, '/');
33255
33258
  }
33259
+ function removeTrailingUnderscores(s) {
33260
+ return s?.replace(/(_$)/, '').replace(/(_\/)/, '/');
33261
+ }
33256
33262
  function replaceBackslash(s) {
33257
33263
  return s?.replace(/\\/gi, '/');
33258
33264
  }