@tanstack/router-cli 1.2.5 → 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.
@@ -126,9 +126,11 @@ async function generator(config) {
126
126
  if (config.future?.unstable_codeSplitting) {
127
127
  node.isRoute = node.routePath?.endsWith('/route');
128
128
  node.isComponent = node.routePath?.endsWith('/component');
129
+ node.isErrorComponent = node.routePath?.endsWith('/errorComponent');
130
+ node.isPendingComponent = node.routePath?.endsWith('/pendingComponent');
129
131
  node.isLoader = node.routePath?.endsWith('/loader');
130
- if (node.isComponent || node.isLoader || node.isRoute) {
131
- node.routePath = node.routePath?.replace(/\/(component|loader|route)$/, '');
132
+ if (node.isComponent || node.isErrorComponent || node.isPendingComponent || node.isLoader || node.isRoute) {
133
+ node.routePath = node.routePath?.replace(/\/(component|errorComponent|pendingComponent|loader|route)$/, '');
132
134
  }
133
135
  }
134
136
  const parentRoute = hasParentRoute(routeNodes, node.routePath);
@@ -141,9 +143,9 @@ async function generator(config) {
141
143
  node.isNonLayout = first.endsWith('_');
142
144
  node.cleanedPath = removeUnderscores(node.path) ?? '';
143
145
  if (config.future?.unstable_codeSplitting) {
144
- if (node.isLoader || node.isComponent) {
146
+ if (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent) {
145
147
  routePiecesByPath[node.routePath] = routePiecesByPath[node.routePath] || {};
146
- routePiecesByPath[node.routePath][node.isLoader ? 'loader' : 'component'] = node;
148
+ routePiecesByPath[node.routePath][node.isLoader ? 'loader' : node.isErrorComponent ? 'errorComponent' : node.isPendingComponent ? 'pendingComponent' : 'component'] = node;
147
149
  const anchorRoute = routeNodes.find(d => d.routePath === node.routePath);
148
150
  if (!anchorRoute) {
149
151
  handleNode({
@@ -151,11 +153,6 @@ async function generator(config) {
151
153
  isVirtual: true
152
154
  });
153
155
  }
154
- // if (!node.parent) {
155
- // }
156
-
157
- // componentOrLoader.isVirtual = true
158
- // handleNode(componentOrLoader)
159
156
  return;
160
157
  }
161
158
  }
@@ -182,7 +179,7 @@ async function generator(config) {
182
179
  // so we have to escape it by turning all $ into $$. But since we do it through a replace call
183
180
  // we have to double escape it into $$$$. For more information, see
184
181
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement
185
- const escapedRoutePath = node.routePath?.replaceAll('$', '$$$$') ?? '';
182
+ const escapedRoutePath = removeTrailingUnderscores(node.routePath?.replaceAll('$', '$$$$') ?? '');
186
183
  const quote = config.quoteStyle === 'single' ? `'` : `"`;
187
184
  const replaced = routeCode.replace(fileRouteRegex, `new FileRoute(${quote}${escapedRoutePath}${quote})`);
188
185
  if (replaced !== routeCode) {
@@ -202,22 +199,28 @@ async function generator(config) {
202
199
  const imports = Object.entries({
203
200
  FileRoute: sortedRouteNodes.some(d => d.isVirtual),
204
201
  lazyFn: sortedRouteNodes.some(node => routePiecesByPath[node.routePath]?.loader),
205
- lazyRouteComponent: sortedRouteNodes.some(node => routePiecesByPath[node.routePath]?.component)
202
+ lazyRouteComponent: sortedRouteNodes.some(node => routePiecesByPath[node.routePath]?.component || routePiecesByPath[node.routePath]?.errorComponent || routePiecesByPath[node.routePath]?.pendingComponent)
206
203
  }).filter(d => d[1]).map(d => d[0]);
207
204
  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 => {
208
205
  return `import { Route as ${node.variableName}Import } from './${sanitize(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, node.filePath))))}'`;
209
206
  }), '\n', sortedRouteNodes.filter(d => d.isVirtual).map(node => {
210
- return `const ${node.variableName}Import = new FileRoute('${node.routePath}').createRoute()`;
207
+ return `const ${node.variableName}Import = new FileRoute('${removeTrailingUnderscores(node.routePath)}').createRoute()`;
211
208
  }).join('\n'), '\n', sortedRouteNodes.map(node => {
212
209
  const loaderNode = routePiecesByPath[node.routePath]?.loader;
213
210
  const componentNode = routePiecesByPath[node.routePath]?.component;
211
+ const errorComponentNode = routePiecesByPath[node.routePath]?.errorComponent;
212
+ const pendingComponentNode = routePiecesByPath[node.routePath]?.pendingComponent;
214
213
  return [`const ${node.variableName}Route = ${node.variableName}Import.update({
215
214
  ${[node.isNonPath ? `id: '${node.path}'` : `path: '${node.cleanedPath}'`, `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`].filter(Boolean).join(',')}
216
- } 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('');
215
+ } 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({
216
+ ${[['component', componentNode], ['errorComponent', errorComponentNode], ['pendingComponent', pendingComponentNode]].filter(d => d[1]).map(d => {
217
+ return `${d[0]}: lazyRouteComponent(() => import('./${sanitize(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, d[1].filePath))))}'), '${d[0]}')`;
218
+ }).join('\n,')}
219
+ })` : ''].join('');
217
220
  }).join('\n\n'), `declare module '@tanstack/react-router' {
218
221
  interface FileRoutesByPath {
219
222
  ${routeNodes.map(routeNode => {
220
- return `'${routeNode.routePath}': {
223
+ return `'${removeTrailingUnderscores(routeNode.routePath)}': {
221
224
  preLoaderRoute: typeof ${routeNode.variableName}Import
222
225
  parentRoute: typeof ${routeNode.parent?.variableName ? `${routeNode.parent?.variableName}Import` : 'rootRoute'}
223
226
  }`;
@@ -285,6 +288,9 @@ function sanitize(s) {
285
288
  function removeUnderscores(s) {
286
289
  return s?.replace(/(^_|_$)/, '').replace(/(\/_|_\/)/, '/');
287
290
  }
291
+ function removeTrailingUnderscores(s) {
292
+ return s?.replace(/(_$)/, '').replace(/(_\/)/, '/');
293
+ }
288
294
  function replaceBackslash(s) {
289
295
  return s?.replace(/\\/gi, '/');
290
296
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sources":["../../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","format","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,CAA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gB,IAAIA,gBAAgB,KAAK,GAAG,EAAE;AACjD,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;AAEA,EAAA,MAAMC,WAAW,GAAGhG,WAAW,CAAC8F,MAAM,EAAE,CACrCnI,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,IAAI2D,WAAW,EAAE;AAC/B,IAAA,IAAI3D,KAAK,CAAC5D,SAAS,KAAK,GAAG,EAAE,SAAA;AAE7B,IAAA,IACEsH,gBAAgB,CAACnI,UAAU,CAAE,CAAA,EAAEyE,KAAK,CAAC5D,SAAU,CAAE,CAAA,CAAA,CAAC,IAClD4D,KAAK,CAAC5D,SAAS,KAAKsH,gBAAgB,EACpC;AACA,MAAA,OAAO1D,KAAK,CAAA;AACd,KAAA;AACF,GAAA;AACA,EAAA,MAAM4D,QAAQ,GAAGF,gBAAgB,CAACnH,KAAK,CAAC,GAAG,CAAC,CAAA;AAC5CqH,EAAAA,QAAQ,CAACC,GAAG,EAAE,CAAC;AACf,EAAA,MAAMC,eAAe,GAAGF,QAAQ,CAAC/H,IAAI,CAAC,GAAG,CAAC,CAAA;AAE1C,EAAA,OAAO2C,cAAc,CAACiF,MAAM,EAAEK,eAAe,CAAC,CAAA;AAChD;;;;;;;;;"}
1
+ {"version":3,"file":"generator.js","sources":["../../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","format","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,CAACc,I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O6C,cAAc,CAACsF,MAAM,EAAEK,eAAe,CAAC,CAAA;AAChD;;;;;;;;;"}
@@ -13,6 +13,8 @@ export type RouteNode = {
13
13
  isRoute?: boolean;
14
14
  isLoader?: boolean;
15
15
  isComponent?: boolean;
16
+ isErrorComponent?: boolean;
17
+ isPendingComponent?: boolean;
16
18
  isVirtual?: boolean;
17
19
  isRoot?: boolean;
18
20
  children?: RouteNode[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/router-cli",
3
3
  "author": "Tanner Linsley",
4
- "version": "1.2.5",
4
+ "version": "1.3.0",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
@@ -58,7 +58,7 @@
58
58
  "through2": "^4.0.2",
59
59
  "yargs": "^17.6.2",
60
60
  "zod": "^3.19.1",
61
- "@tanstack/react-router": "1.2.5"
61
+ "@tanstack/react-router": "1.3.0"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "rollup --config rollup.config.js"
package/src/generator.ts CHANGED
@@ -20,6 +20,8 @@ export type RouteNode = {
20
20
  isRoute?: boolean
21
21
  isLoader?: boolean
22
22
  isComponent?: boolean
23
+ isErrorComponent?: boolean
24
+ isPendingComponent?: boolean
23
25
  isVirtual?: boolean
24
26
  isRoot?: boolean
25
27
  children?: RouteNode[]
@@ -98,6 +100,8 @@ let skipMessage = false
98
100
 
99
101
  type RouteSubNode = {
100
102
  component?: RouteNode
103
+ errorComponent?: RouteNode
104
+ pendingComponent?: RouteNode
101
105
  loader?: RouteNode
102
106
  }
103
107
 
@@ -154,11 +158,19 @@ export async function generator(config: Config) {
154
158
  if (config.future?.unstable_codeSplitting) {
155
159
  node.isRoute = node.routePath?.endsWith('/route')
156
160
  node.isComponent = node.routePath?.endsWith('/component')
161
+ node.isErrorComponent = node.routePath?.endsWith('/errorComponent')
162
+ node.isPendingComponent = node.routePath?.endsWith('/pendingComponent')
157
163
  node.isLoader = node.routePath?.endsWith('/loader')
158
164
 
159
- if (node.isComponent || node.isLoader || node.isRoute) {
165
+ if (
166
+ node.isComponent ||
167
+ node.isErrorComponent ||
168
+ node.isPendingComponent ||
169
+ node.isLoader ||
170
+ node.isRoute
171
+ ) {
160
172
  node.routePath = node.routePath?.replace(
161
- /\/(component|loader|route)$/,
173
+ /\/(component|errorComponent|pendingComponent|loader|route)$/,
162
174
  '',
163
175
  )
164
176
  }
@@ -182,12 +194,23 @@ export async function generator(config: Config) {
182
194
  node.cleanedPath = removeUnderscores(node.path) ?? ''
183
195
 
184
196
  if (config.future?.unstable_codeSplitting) {
185
- if (node.isLoader || node.isComponent) {
197
+ if (
198
+ node.isLoader ||
199
+ node.isComponent ||
200
+ node.isErrorComponent ||
201
+ node.isPendingComponent
202
+ ) {
186
203
  routePiecesByPath[node.routePath!] =
187
204
  routePiecesByPath[node.routePath!] || {}
188
205
 
189
206
  routePiecesByPath[node.routePath!]![
190
- node.isLoader ? 'loader' : 'component'
207
+ node.isLoader
208
+ ? 'loader'
209
+ : node.isErrorComponent
210
+ ? 'errorComponent'
211
+ : node.isPendingComponent
212
+ ? 'pendingComponent'
213
+ : 'component'
191
214
  ] = node
192
215
 
193
216
  const anchorRoute = routeNodes.find(
@@ -199,11 +222,6 @@ export async function generator(config: Config) {
199
222
  isVirtual: true,
200
223
  })
201
224
  }
202
- // if (!node.parent) {
203
- // }
204
-
205
- // componentOrLoader.isVirtual = true
206
- // handleNode(componentOrLoader)
207
225
  return
208
226
  }
209
227
  }
@@ -237,7 +255,9 @@ export async function generator(config: Config) {
237
255
  // so we have to escape it by turning all $ into $$. But since we do it through a replace call
238
256
  // we have to double escape it into $$$$. For more information, see
239
257
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement
240
- const escapedRoutePath = node.routePath?.replaceAll('$', '$$$$') ?? ''
258
+ const escapedRoutePath = removeTrailingUnderscores(
259
+ node.routePath?.replaceAll('$', '$$$$') ?? '',
260
+ )
241
261
  const quote = config.quoteStyle === 'single' ? `'` : `"`
242
262
  const replaced = routeCode.replace(
243
263
  fileRouteRegex,
@@ -277,7 +297,10 @@ export async function generator(config: Config) {
277
297
  (node) => routePiecesByPath[node.routePath!]?.loader,
278
298
  ),
279
299
  lazyRouteComponent: sortedRouteNodes.some(
280
- (node) => routePiecesByPath[node.routePath!]?.component,
300
+ (node) =>
301
+ routePiecesByPath[node.routePath!]?.component ||
302
+ routePiecesByPath[node.routePath!]?.errorComponent ||
303
+ routePiecesByPath[node.routePath!]?.pendingComponent,
281
304
  ),
282
305
  })
283
306
  .filter((d) => d[1])
@@ -311,7 +334,11 @@ export async function generator(config: Config) {
311
334
  sortedRouteNodes
312
335
  .filter((d) => d.isVirtual)
313
336
  .map((node) => {
314
- return `const ${node.variableName}Import = new FileRoute('${node.routePath}').createRoute()`
337
+ return `const ${
338
+ node.variableName
339
+ }Import = new FileRoute('${removeTrailingUnderscores(
340
+ node.routePath,
341
+ )}').createRoute()`
315
342
  })
316
343
  .join('\n'),
317
344
  '\n',
@@ -319,6 +346,10 @@ export async function generator(config: Config) {
319
346
  .map((node) => {
320
347
  const loaderNode = routePiecesByPath[node.routePath!]?.loader
321
348
  const componentNode = routePiecesByPath[node.routePath!]?.component
349
+ const errorComponentNode =
350
+ routePiecesByPath[node.routePath!]?.errorComponent
351
+ const pendingComponentNode =
352
+ routePiecesByPath[node.routePath!]?.pendingComponent
322
353
 
323
354
  return [
324
355
  `const ${node.variableName}Route = ${node.variableName}Import.update({
@@ -341,18 +372,30 @@ export async function generator(config: Config) {
341
372
  ),
342
373
  )}'), 'loader') })`
343
374
  : '',
344
- componentNode
345
- ? `.update({ component: lazyRouteComponent(() => import('./${sanitize(
346
- removeExt(
347
- path.relative(
348
- path.dirname(config.generatedRouteTree),
349
- path.resolve(
350
- config.routesDirectory,
351
- componentNode.filePath,
375
+ componentNode || errorComponentNode || pendingComponentNode
376
+ ? `.update({
377
+ ${(
378
+ [
379
+ ['component', componentNode],
380
+ ['errorComponent', errorComponentNode],
381
+ ['pendingComponent', pendingComponentNode],
382
+ ] as const
383
+ )
384
+ .filter((d) => d[1])
385
+ .map((d) => {
386
+ return `${
387
+ d[0]
388
+ }: lazyRouteComponent(() => import('./${sanitize(
389
+ removeExt(
390
+ path.relative(
391
+ path.dirname(config.generatedRouteTree),
392
+ path.resolve(config.routesDirectory, d[1]!.filePath),
393
+ ),
352
394
  ),
353
- ),
354
- ),
355
- )}'), 'component') })`
395
+ )}'), '${d[0]}')`
396
+ })
397
+ .join('\n,')}
398
+ })`
356
399
  : '',
357
400
  ].join('')
358
401
  })
@@ -361,7 +404,7 @@ export async function generator(config: Config) {
361
404
  interface FileRoutesByPath {
362
405
  ${routeNodes
363
406
  .map((routeNode) => {
364
- return `'${routeNode.routePath}': {
407
+ return `'${removeTrailingUnderscores(routeNode.routePath)}': {
365
408
  preLoaderRoute: typeof ${routeNode.variableName}Import
366
409
  parentRoute: typeof ${
367
410
  routeNode.parent?.variableName
@@ -473,6 +516,10 @@ function removeUnderscores(s?: string) {
473
516
  return s?.replace(/(^_|_$)/, '').replace(/(\/_|_\/)/, '/')
474
517
  }
475
518
 
519
+ function removeTrailingUnderscores(s?: string) {
520
+ return s?.replace(/(_$)/, '').replace(/(_\/)/, '/')
521
+ }
522
+
476
523
  function replaceBackslash(s?: string) {
477
524
  return s?.replace(/\\/gi, '/')
478
525
  }