@tanstack/router-generator 1.121.16 → 1.121.17

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.
Files changed (97) hide show
  1. package/package.json +4 -4
  2. package/dist/cjs/config.cjs +0 -140
  3. package/dist/cjs/config.cjs.map +0 -1
  4. package/dist/cjs/config.d.cts +0 -155
  5. package/dist/cjs/filesystem/physical/getRouteNodes.cjs +0 -204
  6. package/dist/cjs/filesystem/physical/getRouteNodes.cjs.map +0 -1
  7. package/dist/cjs/filesystem/physical/getRouteNodes.d.cts +0 -15
  8. package/dist/cjs/filesystem/physical/rootPathId.cjs +0 -5
  9. package/dist/cjs/filesystem/physical/rootPathId.cjs.map +0 -1
  10. package/dist/cjs/filesystem/physical/rootPathId.d.cts +0 -1
  11. package/dist/cjs/filesystem/virtual/config.cjs +0 -37
  12. package/dist/cjs/filesystem/virtual/config.cjs.map +0 -1
  13. package/dist/cjs/filesystem/virtual/config.d.cts +0 -3
  14. package/dist/cjs/filesystem/virtual/getRouteNodes.cjs +0 -192
  15. package/dist/cjs/filesystem/virtual/getRouteNodes.cjs.map +0 -1
  16. package/dist/cjs/filesystem/virtual/getRouteNodes.d.cts +0 -8
  17. package/dist/cjs/filesystem/virtual/loadConfigFile.cjs +0 -11
  18. package/dist/cjs/filesystem/virtual/loadConfigFile.cjs.map +0 -1
  19. package/dist/cjs/filesystem/virtual/loadConfigFile.d.cts +0 -1
  20. package/dist/cjs/generator.cjs +0 -970
  21. package/dist/cjs/generator.cjs.map +0 -1
  22. package/dist/cjs/generator.d.cts +0 -76
  23. package/dist/cjs/index.cjs +0 -35
  24. package/dist/cjs/index.cjs.map +0 -1
  25. package/dist/cjs/index.d.cts +0 -12
  26. package/dist/cjs/logger.cjs +0 -37
  27. package/dist/cjs/logger.cjs.map +0 -1
  28. package/dist/cjs/logger.d.cts +0 -10
  29. package/dist/cjs/plugin/default-generator-plugin.cjs +0 -101
  30. package/dist/cjs/plugin/default-generator-plugin.cjs.map +0 -1
  31. package/dist/cjs/plugin/default-generator-plugin.d.cts +0 -2
  32. package/dist/cjs/plugin/types.d.cts +0 -46
  33. package/dist/cjs/template.cjs +0 -110
  34. package/dist/cjs/template.cjs.map +0 -1
  35. package/dist/cjs/template.d.cts +0 -33
  36. package/dist/cjs/transform/default-transform-plugin.cjs +0 -95
  37. package/dist/cjs/transform/default-transform-plugin.cjs.map +0 -1
  38. package/dist/cjs/transform/default-transform-plugin.d.cts +0 -2
  39. package/dist/cjs/transform/transform.cjs +0 -374
  40. package/dist/cjs/transform/transform.cjs.map +0 -1
  41. package/dist/cjs/transform/transform.d.cts +0 -4
  42. package/dist/cjs/transform/types.d.cts +0 -43
  43. package/dist/cjs/transform/utils.cjs +0 -36
  44. package/dist/cjs/transform/utils.cjs.map +0 -1
  45. package/dist/cjs/transform/utils.d.cts +0 -2
  46. package/dist/cjs/types.d.cts +0 -47
  47. package/dist/cjs/utils.cjs +0 -438
  48. package/dist/cjs/utils.cjs.map +0 -1
  49. package/dist/cjs/utils.d.cts +0 -133
  50. package/dist/esm/config.d.ts +0 -155
  51. package/dist/esm/config.js +0 -140
  52. package/dist/esm/config.js.map +0 -1
  53. package/dist/esm/filesystem/physical/getRouteNodes.d.ts +0 -15
  54. package/dist/esm/filesystem/physical/getRouteNodes.js +0 -187
  55. package/dist/esm/filesystem/physical/getRouteNodes.js.map +0 -1
  56. package/dist/esm/filesystem/physical/rootPathId.d.ts +0 -1
  57. package/dist/esm/filesystem/physical/rootPathId.js +0 -5
  58. package/dist/esm/filesystem/physical/rootPathId.js.map +0 -1
  59. package/dist/esm/filesystem/virtual/config.d.ts +0 -3
  60. package/dist/esm/filesystem/virtual/config.js +0 -37
  61. package/dist/esm/filesystem/virtual/config.js.map +0 -1
  62. package/dist/esm/filesystem/virtual/getRouteNodes.d.ts +0 -8
  63. package/dist/esm/filesystem/virtual/getRouteNodes.js +0 -192
  64. package/dist/esm/filesystem/virtual/getRouteNodes.js.map +0 -1
  65. package/dist/esm/filesystem/virtual/loadConfigFile.d.ts +0 -1
  66. package/dist/esm/filesystem/virtual/loadConfigFile.js +0 -11
  67. package/dist/esm/filesystem/virtual/loadConfigFile.js.map +0 -1
  68. package/dist/esm/generator.d.ts +0 -76
  69. package/dist/esm/generator.js +0 -953
  70. package/dist/esm/generator.js.map +0 -1
  71. package/dist/esm/index.d.ts +0 -12
  72. package/dist/esm/index.js +0 -35
  73. package/dist/esm/index.js.map +0 -1
  74. package/dist/esm/logger.d.ts +0 -10
  75. package/dist/esm/logger.js +0 -37
  76. package/dist/esm/logger.js.map +0 -1
  77. package/dist/esm/plugin/default-generator-plugin.d.ts +0 -2
  78. package/dist/esm/plugin/default-generator-plugin.js +0 -101
  79. package/dist/esm/plugin/default-generator-plugin.js.map +0 -1
  80. package/dist/esm/plugin/types.d.ts +0 -46
  81. package/dist/esm/template.d.ts +0 -33
  82. package/dist/esm/template.js +0 -110
  83. package/dist/esm/template.js.map +0 -1
  84. package/dist/esm/transform/default-transform-plugin.d.ts +0 -2
  85. package/dist/esm/transform/default-transform-plugin.js +0 -95
  86. package/dist/esm/transform/default-transform-plugin.js.map +0 -1
  87. package/dist/esm/transform/transform.d.ts +0 -4
  88. package/dist/esm/transform/transform.js +0 -374
  89. package/dist/esm/transform/transform.js.map +0 -1
  90. package/dist/esm/transform/types.d.ts +0 -43
  91. package/dist/esm/transform/utils.d.ts +0 -2
  92. package/dist/esm/transform/utils.js +0 -36
  93. package/dist/esm/transform/utils.js.map +0 -1
  94. package/dist/esm/types.d.ts +0 -47
  95. package/dist/esm/utils.d.ts +0 -133
  96. package/dist/esm/utils.js +0 -420
  97. package/dist/esm/utils.js.map +0 -1
@@ -1,970 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const path = require("node:path");
4
- const fsp = require("node:fs/promises");
5
- const node_fs = require("node:fs");
6
- const crypto = require("node:crypto");
7
- const routerCore = require("@tanstack/router-core");
8
- const logger = require("./logger.cjs");
9
- const getRouteNodes$1 = require("./filesystem/physical/getRouteNodes.cjs");
10
- const getRouteNodes = require("./filesystem/virtual/getRouteNodes.cjs");
11
- const rootPathId = require("./filesystem/physical/rootPathId.cjs");
12
- const utils = require("./utils.cjs");
13
- const template = require("./template.cjs");
14
- const transform = require("./transform/transform.cjs");
15
- const defaultGeneratorPlugin = require("./plugin/default-generator-plugin.cjs");
16
- function _interopNamespaceDefault(e) {
17
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
18
- if (e) {
19
- for (const k in e) {
20
- if (k !== "default") {
21
- const d = Object.getOwnPropertyDescriptor(e, k);
22
- Object.defineProperty(n, k, d.get ? d : {
23
- enumerable: true,
24
- get: () => e[k]
25
- });
26
- }
27
- }
28
- }
29
- n.default = e;
30
- return Object.freeze(n);
31
- }
32
- const fsp__namespace = /* @__PURE__ */ _interopNamespaceDefault(fsp);
33
- const DefaultFileSystem = {
34
- stat: (filePath) => fsp__namespace.stat(filePath, { bigint: true }),
35
- mkdtempSync: node_fs.mkdtempSync,
36
- rename: (oldPath, newPath) => fsp__namespace.rename(oldPath, newPath),
37
- writeFile: (filePath, content) => fsp__namespace.writeFile(filePath, content),
38
- readFile: async (filePath) => {
39
- try {
40
- const fileHandle = await fsp__namespace.open(filePath, "r");
41
- const stat = await fileHandle.stat({ bigint: true });
42
- const fileContent = (await fileHandle.readFile()).toString();
43
- await fileHandle.close();
44
- return { stat, fileContent };
45
- } catch (e) {
46
- if ("code" in e) {
47
- if (e.code === "ENOENT") {
48
- return "file-not-existing";
49
- }
50
- }
51
- throw e;
52
- }
53
- }
54
- };
55
- function rerun(opts) {
56
- const { event, ...rest } = opts;
57
- return { rerun: true, event: event ?? { type: "rerun" }, ...rest };
58
- }
59
- function isRerun(result) {
60
- return typeof result === "object" && result !== null && "rerun" in result && result.rerun === true;
61
- }
62
- class Generator {
63
- constructor(opts) {
64
- this.routeNodeCache = /* @__PURE__ */ new Map();
65
- this.routeNodeShadowCache = /* @__PURE__ */ new Map();
66
- this.fileEventQueue = [];
67
- this.plugins = [defaultGeneratorPlugin.defaultGeneratorPlugin()];
68
- this.pluginsWithTransform = [];
69
- this.transformPlugins = [];
70
- this.routeGroupPatternRegex = /\(.+\)/g;
71
- this.physicalDirectories = [];
72
- this.config = opts.config;
73
- this.logger = logger.logging({ disabled: this.config.disableLogging });
74
- this.root = opts.root;
75
- this.fs = opts.fs || DefaultFileSystem;
76
- this.tmpDir = this.fs.mkdtempSync(
77
- path.join(this.config.tmpDir, "router-generator-")
78
- );
79
- this.generatedRouteTreePath = path.resolve(this.config.generatedRouteTree);
80
- this.targetTemplate = template.getTargetTemplate(this.config);
81
- this.routesDirectoryPath = this.getRoutesDirectoryPath();
82
- this.plugins.push(...opts.config.plugins || []);
83
- this.plugins.forEach((plugin) => {
84
- if ("transformPlugin" in plugin) {
85
- if (this.pluginsWithTransform.find((p) => p.name === plugin.name)) {
86
- throw new Error(
87
- `Plugin with name "${plugin.name}" is already registered for export ${plugin.transformPlugin.exportName}!`
88
- );
89
- }
90
- this.pluginsWithTransform.push(plugin);
91
- this.transformPlugins.push(plugin.transformPlugin);
92
- }
93
- });
94
- }
95
- getRoutesDirectoryPath() {
96
- return path.isAbsolute(this.config.routesDirectory) ? this.config.routesDirectory : path.resolve(this.root, this.config.routesDirectory);
97
- }
98
- getRoutesByFileMap() {
99
- return new Map(
100
- [...this.routeNodeCache.entries()].map(([filePath, cacheEntry]) => [
101
- filePath,
102
- { routePath: cacheEntry.routeId }
103
- ])
104
- );
105
- }
106
- async run(event) {
107
- if (event && event.type !== "rerun" && !this.isFileRelevantForRouteTreeGeneration(event.path)) {
108
- return;
109
- }
110
- this.fileEventQueue.push(event ?? { type: "rerun" });
111
- if (this.runPromise) {
112
- return this.runPromise;
113
- }
114
- this.runPromise = (async () => {
115
- do {
116
- const tempQueue = this.fileEventQueue;
117
- this.fileEventQueue = [];
118
- const remainingEvents = (await Promise.all(
119
- tempQueue.map(async (e) => {
120
- if (e.type === "update") {
121
- let cacheEntry;
122
- if (e.path === this.generatedRouteTreePath) {
123
- cacheEntry = this.routeTreeFileCache;
124
- } else {
125
- cacheEntry = this.routeNodeCache.get(e.path);
126
- }
127
- const change = await this.didFileChangeComparedToCache(
128
- { path: e.path },
129
- cacheEntry
130
- );
131
- if (change.result === false) {
132
- return null;
133
- }
134
- }
135
- return e;
136
- })
137
- )).filter((e) => e !== null);
138
- if (remainingEvents.length === 0) {
139
- break;
140
- }
141
- try {
142
- const start = performance.now();
143
- await this.generatorInternal();
144
- const end = performance.now();
145
- this.logger.info(
146
- `Generated route tree in ${Math.round(end - start)}ms`
147
- );
148
- } catch (err) {
149
- const errArray = !Array.isArray(err) ? [err] : err;
150
- const recoverableErrors = errArray.filter((e) => isRerun(e));
151
- if (recoverableErrors.length === errArray.length) {
152
- this.fileEventQueue.push(...recoverableErrors.map((e) => e.event));
153
- recoverableErrors.forEach((e) => {
154
- if (e.msg) {
155
- this.logger.info(e.msg);
156
- }
157
- });
158
- } else {
159
- const unrecoverableErrors = errArray.filter((e) => !isRerun(e));
160
- this.runPromise = void 0;
161
- throw new Error(
162
- unrecoverableErrors.map((e) => e.message).join()
163
- );
164
- }
165
- }
166
- } while (this.fileEventQueue.length);
167
- this.runPromise = void 0;
168
- })();
169
- return this.runPromise;
170
- }
171
- async generatorInternal() {
172
- let writeRouteTreeFile = false;
173
- let getRouteNodesResult;
174
- if (this.config.virtualRouteConfig) {
175
- getRouteNodesResult = await getRouteNodes.getRouteNodes(this.config, this.root);
176
- } else {
177
- getRouteNodesResult = await getRouteNodes$1.getRouteNodes(this.config, this.root);
178
- }
179
- const {
180
- rootRouteNode,
181
- routeNodes: beforeRouteNodes,
182
- physicalDirectories
183
- } = getRouteNodesResult;
184
- if (rootRouteNode === void 0) {
185
- let errorMessage = `rootRouteNode must not be undefined. Make sure you've added your root route into the route-tree.`;
186
- if (!this.config.virtualRouteConfig) {
187
- errorMessage += `
188
- Make sure that you add a "${rootPathId.rootPathId}.${this.config.disableTypes ? "js" : "tsx"}" file to your routes directory.
189
- Add the file in: "${this.config.routesDirectory}/${rootPathId.rootPathId}.${this.config.disableTypes ? "js" : "tsx"}"`;
190
- }
191
- throw new Error(errorMessage);
192
- }
193
- this.physicalDirectories = physicalDirectories;
194
- writeRouteTreeFile = await this.handleRootNode(rootRouteNode);
195
- const preRouteNodes = utils.multiSortBy(beforeRouteNodes, [
196
- (d) => d.routePath === "/" ? -1 : 1,
197
- (d) => {
198
- var _a;
199
- return (_a = d.routePath) == null ? void 0 : _a.split("/").length;
200
- },
201
- (d) => d.filePath.match(new RegExp(`[./]${this.config.indexToken}[.]`)) ? 1 : -1,
202
- (d) => d.filePath.match(
203
- /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/
204
- ) ? 1 : -1,
205
- (d) => d.filePath.match(new RegExp(`[./]${this.config.routeToken}[.]`)) ? -1 : 1,
206
- (d) => {
207
- var _a;
208
- return ((_a = d.routePath) == null ? void 0 : _a.endsWith("/")) ? -1 : 1;
209
- },
210
- (d) => d.routePath
211
- ]).filter((d) => ![`/${rootPathId.rootPathId}`].includes(d.routePath || ""));
212
- const routeFileAllResult = await Promise.allSettled(
213
- preRouteNodes.filter((n) => !n.isVirtualParentRoute && !n.isVirtual).map((n) => this.processRouteNodeFile(n))
214
- );
215
- const rejections = routeFileAllResult.filter(
216
- (result) => result.status === "rejected"
217
- );
218
- if (rejections.length > 0) {
219
- throw rejections.map((e) => e.reason);
220
- }
221
- const routeFileResult = routeFileAllResult.flatMap((result) => {
222
- if (result.status === "fulfilled" && result.value !== null) {
223
- return result.value;
224
- }
225
- return [];
226
- });
227
- routeFileResult.forEach((result) => {
228
- var _a;
229
- if (!((_a = result.node.exports) == null ? void 0 : _a.length)) {
230
- this.logger.warn(
231
- `Route file "${result.cacheEntry.fileContent}" does not export any route piece. This is likely a mistake.`
232
- );
233
- }
234
- });
235
- if (routeFileResult.find((r) => r.shouldWriteTree)) {
236
- writeRouteTreeFile = true;
237
- }
238
- if (!this.routeTreeFileCache) {
239
- const routeTreeFile = await this.fs.readFile(this.generatedRouteTreePath);
240
- if (routeTreeFile !== "file-not-existing") {
241
- this.routeTreeFileCache = {
242
- fileContent: routeTreeFile.fileContent,
243
- mtimeMs: routeTreeFile.stat.mtimeMs
244
- };
245
- }
246
- writeRouteTreeFile = true;
247
- } else {
248
- const routeTreeFileChange = await this.didFileChangeComparedToCache(
249
- { path: this.generatedRouteTreePath },
250
- this.routeTreeFileCache
251
- );
252
- if (routeTreeFileChange.result !== false) {
253
- writeRouteTreeFile = "force";
254
- if (routeTreeFileChange.result === true) {
255
- const routeTreeFile = await this.fs.readFile(
256
- this.generatedRouteTreePath
257
- );
258
- if (routeTreeFile !== "file-not-existing") {
259
- this.routeTreeFileCache = {
260
- fileContent: routeTreeFile.fileContent,
261
- mtimeMs: routeTreeFile.stat.mtimeMs
262
- };
263
- }
264
- }
265
- }
266
- }
267
- if (!writeRouteTreeFile) {
268
- for (const fullPath of this.routeNodeCache.keys()) {
269
- if (!this.routeNodeShadowCache.has(fullPath)) {
270
- writeRouteTreeFile = true;
271
- break;
272
- }
273
- }
274
- }
275
- if (!writeRouteTreeFile) {
276
- return;
277
- }
278
- let routeTreeContent = this.buildRouteTreeFileContent(
279
- rootRouteNode,
280
- preRouteNodes,
281
- routeFileResult
282
- );
283
- routeTreeContent = this.config.enableRouteTreeFormatting ? await utils.format(routeTreeContent, this.config) : routeTreeContent;
284
- let newMtimeMs;
285
- if (this.routeTreeFileCache) {
286
- if (writeRouteTreeFile !== "force" && this.routeTreeFileCache.fileContent === routeTreeContent) ;
287
- else {
288
- const newRouteTreeFileStat = await this.safeFileWrite({
289
- filePath: this.generatedRouteTreePath,
290
- newContent: routeTreeContent,
291
- strategy: {
292
- type: "mtime",
293
- expectedMtimeMs: this.routeTreeFileCache.mtimeMs
294
- }
295
- });
296
- newMtimeMs = newRouteTreeFileStat.mtimeMs;
297
- }
298
- } else {
299
- const newRouteTreeFileStat = await this.safeFileWrite({
300
- filePath: this.generatedRouteTreePath,
301
- newContent: routeTreeContent,
302
- strategy: {
303
- type: "new-file"
304
- }
305
- });
306
- newMtimeMs = newRouteTreeFileStat.mtimeMs;
307
- }
308
- if (newMtimeMs !== void 0) {
309
- this.routeTreeFileCache = {
310
- fileContent: routeTreeContent,
311
- mtimeMs: newMtimeMs
312
- };
313
- }
314
- this.routeNodeCache = this.routeNodeShadowCache;
315
- this.routeNodeShadowCache = /* @__PURE__ */ new Map();
316
- }
317
- buildRouteTreeFileContent(rootRouteNode, preRouteNodes, routeFileResult) {
318
- const getImportForRouteNode = (node, exportName) => {
319
- var _a;
320
- if ((_a = node.exports) == null ? void 0 : _a.includes(exportName)) {
321
- return {
322
- source: `./${this.getImportPath(node)}`,
323
- specifiers: [
324
- {
325
- imported: exportName,
326
- local: `${node.variableName}${exportName}Import`
327
- }
328
- ]
329
- };
330
- }
331
- return void 0;
332
- };
333
- const buildRouteTreeForExport = (plugin) => {
334
- var _a, _b, _c;
335
- const exportName = plugin.transformPlugin.exportName;
336
- const acc = {
337
- routeTree: [],
338
- routeNodes: [],
339
- routePiecesByPath: {}
340
- };
341
- for (const node of preRouteNodes) {
342
- if ((_a = node.exports) == null ? void 0 : _a.includes(plugin.transformPlugin.exportName)) {
343
- this.handleNode(node, acc);
344
- }
345
- }
346
- const sortedRouteNodes = utils.multiSortBy(acc.routeNodes, [
347
- (d) => {
348
- var _a2;
349
- return ((_a2 = d.routePath) == null ? void 0 : _a2.includes(`/${rootPathId.rootPathId}`)) ? -1 : 1;
350
- },
351
- (d) => {
352
- var _a2;
353
- return (_a2 = d.routePath) == null ? void 0 : _a2.split("/").length;
354
- },
355
- (d) => {
356
- var _a2;
357
- return ((_a2 = d.routePath) == null ? void 0 : _a2.endsWith(this.config.indexToken)) ? -1 : 1;
358
- },
359
- (d) => d
360
- ]);
361
- const pluginConfig = plugin.config({
362
- generator: this,
363
- rootRouteNode,
364
- sortedRouteNodes
365
- });
366
- const routeImports2 = sortedRouteNodes.filter((d) => !d.isVirtual).flatMap((node) => getImportForRouteNode(node, exportName) ?? []);
367
- const hasMatchingRouteFiles = acc.routeNodes.length > 0 || ((_b = rootRouteNode.exports) == null ? void 0 : _b.includes(exportName));
368
- const virtualRouteNodes = sortedRouteNodes.filter((d) => d.isVirtual).map((node) => {
369
- return `const ${node.variableName}${exportName}Import = ${plugin.createVirtualRouteCode({ node })}`;
370
- });
371
- if (!((_c = rootRouteNode.exports) == null ? void 0 : _c.includes(exportName)) && pluginConfig.virtualRootRoute) {
372
- virtualRouteNodes.unshift(
373
- `const ${rootRouteNode.variableName}${exportName}Import = ${plugin.createRootRouteCode()}`
374
- );
375
- }
376
- const imports = plugin.imports({
377
- sortedRouteNodes,
378
- acc,
379
- generator: this,
380
- rootRouteNode
381
- });
382
- const routeTreeConfig = utils.buildRouteTreeConfig(
383
- acc.routeTree,
384
- exportName,
385
- this.config.disableTypes
386
- );
387
- const createUpdateRoutes = sortedRouteNodes.map((node) => {
388
- var _a2, _b2, _c2, _d, _e;
389
- const loaderNode = (_a2 = acc.routePiecesByPath[node.routePath]) == null ? void 0 : _a2.loader;
390
- const componentNode = (_b2 = acc.routePiecesByPath[node.routePath]) == null ? void 0 : _b2.component;
391
- const errorComponentNode = (_c2 = acc.routePiecesByPath[node.routePath]) == null ? void 0 : _c2.errorComponent;
392
- const pendingComponentNode = (_d = acc.routePiecesByPath[node.routePath]) == null ? void 0 : _d.pendingComponent;
393
- const lazyComponentNode = (_e = acc.routePiecesByPath[node.routePath]) == null ? void 0 : _e.lazy;
394
- return [
395
- [
396
- `const ${node.variableName}${exportName} = ${node.variableName}${exportName}Import.update({
397
- ${[
398
- `id: '${node.path}'`,
399
- !node.isNonPath ? `path: '${node.cleanedPath}'` : void 0,
400
- `getParentRoute: () => ${utils.findParent(node, exportName)}`
401
- ].filter(Boolean).join(",")}
402
- }${this.config.disableTypes ? "" : "as any"})`,
403
- loaderNode ? `.updateLoader({ loader: lazyFn(() => import('./${utils.replaceBackslash(
404
- utils.removeExt(
405
- path.relative(
406
- path.dirname(this.config.generatedRouteTree),
407
- path.resolve(
408
- this.config.routesDirectory,
409
- loaderNode.filePath
410
- )
411
- ),
412
- this.config.addExtensions
413
- )
414
- )}'), 'loader') })` : "",
415
- componentNode || errorComponentNode || pendingComponentNode ? `.update({
416
- ${[
417
- ["component", componentNode],
418
- ["errorComponent", errorComponentNode],
419
- ["pendingComponent", pendingComponentNode]
420
- ].filter((d) => d[1]).map((d) => {
421
- return `${d[0]}: lazyRouteComponent(() => import('./${utils.replaceBackslash(
422
- utils.removeExt(
423
- path.relative(
424
- path.dirname(this.config.generatedRouteTree),
425
- path.resolve(
426
- this.config.routesDirectory,
427
- d[1].filePath
428
- )
429
- ),
430
- this.config.addExtensions
431
- )
432
- )}'), '${d[0]}')`;
433
- }).join("\n,")}
434
- })` : "",
435
- lazyComponentNode ? `.lazy(() => import('./${utils.replaceBackslash(
436
- utils.removeExt(
437
- path.relative(
438
- path.dirname(this.config.generatedRouteTree),
439
- path.resolve(
440
- this.config.routesDirectory,
441
- lazyComponentNode.filePath
442
- )
443
- ),
444
- this.config.addExtensions
445
- )
446
- )}').then((d) => d.${exportName}))` : ""
447
- ].join("")
448
- ].join("\n\n");
449
- });
450
- let fileRoutesByPathInterfacePerPlugin = "";
451
- let fileRoutesByFullPathPerPlugin = "";
452
- if (!this.config.disableTypes && hasMatchingRouteFiles) {
453
- fileRoutesByFullPathPerPlugin = [
454
- `export interface File${exportName}sByFullPath {
455
- ${[...utils.createRouteNodesByFullPath(acc.routeNodes).entries()].filter(([fullPath]) => fullPath).map(([fullPath, routeNode]) => {
456
- return `'${fullPath}': typeof ${utils.getResolvedRouteNodeVariableName(routeNode, exportName)}`;
457
- })}
458
- }`,
459
- `export interface File${exportName}sByTo {
460
- ${[...utils.createRouteNodesByTo(acc.routeNodes).entries()].filter(([to]) => to).map(([to, routeNode]) => {
461
- return `'${to}': typeof ${utils.getResolvedRouteNodeVariableName(routeNode, exportName)}`;
462
- })}
463
- }`,
464
- `export interface File${exportName}sById {
465
- '${routerCore.rootRouteId}': typeof root${exportName}Import,
466
- ${[...utils.createRouteNodesById(acc.routeNodes).entries()].map(([id, routeNode]) => {
467
- return `'${id}': typeof ${utils.getResolvedRouteNodeVariableName(routeNode, exportName)}`;
468
- })}
469
- }`,
470
- `export interface File${exportName}Types {
471
- file${exportName}sByFullPath: File${exportName}sByFullPath
472
- fullPaths: ${acc.routeNodes.length > 0 ? [...utils.createRouteNodesByFullPath(acc.routeNodes).keys()].filter((fullPath) => fullPath).map((fullPath) => `'${fullPath}'`).join("|") : "never"}
473
- file${exportName}sByTo: File${exportName}sByTo
474
- to: ${acc.routeNodes.length > 0 ? [...utils.createRouteNodesByTo(acc.routeNodes).keys()].filter((to) => to).map((to) => `'${to}'`).join("|") : "never"}
475
- id: ${[`'${routerCore.rootRouteId}'`, ...[...utils.createRouteNodesById(acc.routeNodes).keys()].map((id) => `'${id}'`)].join("|")}
476
- file${exportName}sById: File${exportName}sById
477
- }`,
478
- `export interface Root${exportName}Children {
479
- ${acc.routeTree.map((child) => `${child.variableName}${exportName}: typeof ${utils.getResolvedRouteNodeVariableName(child, exportName)}`).join(",")}
480
- }`
481
- ].join("\n");
482
- fileRoutesByPathInterfacePerPlugin = utils.buildFileRoutesByPathInterface({
483
- ...plugin.moduleAugmentation({ generator: this }),
484
- routeNodes: this.config.verboseFileRoutes !== false ? sortedRouteNodes : [
485
- ...routeFileResult.map(({ node }) => node),
486
- ...sortedRouteNodes.filter((d) => d.isVirtual)
487
- ],
488
- exportName
489
- });
490
- }
491
- let routeTree = "";
492
- if (hasMatchingRouteFiles) {
493
- routeTree = [
494
- `const root${exportName}Children${this.config.disableTypes ? "" : `: Root${exportName}Children`} = {
495
- ${acc.routeTree.map(
496
- (child) => `${child.variableName}${exportName}: ${utils.getResolvedRouteNodeVariableName(child, exportName)}`
497
- ).join(",")}
498
- }`,
499
- `export const ${utils.lowerCaseFirstChar(exportName)}Tree = root${exportName}Import._addFileChildren(root${exportName}Children)${this.config.disableTypes ? "" : `._addFileTypes<File${exportName}Types>()`}`
500
- ].join("\n");
501
- }
502
- return {
503
- routeImports: routeImports2,
504
- sortedRouteNodes,
505
- acc,
506
- virtualRouteNodes,
507
- routeTreeConfig,
508
- routeTree,
509
- imports,
510
- createUpdateRoutes,
511
- fileRoutesByFullPathPerPlugin,
512
- fileRoutesByPathInterfacePerPlugin
513
- };
514
- };
515
- const routeTrees = this.pluginsWithTransform.map((plugin) => ({
516
- exportName: plugin.transformPlugin.exportName,
517
- ...buildRouteTreeForExport(plugin)
518
- }));
519
- this.plugins.map((plugin) => {
520
- var _a;
521
- return (_a = plugin.onRouteTreesChanged) == null ? void 0 : _a.call(plugin, {
522
- routeTrees,
523
- rootRouteNode,
524
- generator: this
525
- });
526
- });
527
- let mergedImports = utils.mergeImportDeclarations(
528
- routeTrees.flatMap((d) => d.imports)
529
- );
530
- if (this.config.disableTypes) {
531
- mergedImports = mergedImports.filter((d) => d.importKind !== "type");
532
- }
533
- const importStatements = mergedImports.map(utils.buildImportString);
534
- let moduleAugmentation = "";
535
- if (this.config.verboseFileRoutes === false && !this.config.disableTypes) {
536
- moduleAugmentation = routeFileResult.map(({ node }) => {
537
- const getModuleDeclaration = (routeNode) => {
538
- if (!utils.isRouteNodeValidForAugmentation(routeNode)) {
539
- return "";
540
- }
541
- const moduleAugmentation2 = this.pluginsWithTransform.map((plugin) => {
542
- return plugin.routeModuleAugmentation({
543
- routeNode
544
- });
545
- }).filter(Boolean).join("\n");
546
- return `declare module './${this.getImportPath(routeNode)}' {
547
- ${moduleAugmentation2}
548
- }`;
549
- };
550
- return getModuleDeclaration(node);
551
- }).join("\n");
552
- }
553
- const routeImports = routeTrees.flatMap((t) => t.routeImports);
554
- const rootRouteImports = this.pluginsWithTransform.flatMap(
555
- (p) => getImportForRouteNode(rootRouteNode, p.transformPlugin.exportName) ?? []
556
- );
557
- if (rootRouteImports.length > 0) {
558
- routeImports.unshift(...rootRouteImports);
559
- }
560
- const routeTreeContent = [
561
- ...this.config.routeTreeFileHeader,
562
- `// This file was automatically generated by TanStack Router.
563
- // You should NOT make any changes in this file as it will be overwritten.
564
- // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.`,
565
- [...importStatements].join("\n"),
566
- utils.mergeImportDeclarations(routeImports).map(utils.buildImportString).join("\n"),
567
- routeTrees.flatMap((t) => t.virtualRouteNodes).join("\n"),
568
- routeTrees.flatMap((t) => t.createUpdateRoutes).join("\n"),
569
- routeTrees.map((t) => t.fileRoutesByFullPathPerPlugin).join("\n"),
570
- routeTrees.map((t) => t.fileRoutesByPathInterfacePerPlugin).join("\n"),
571
- moduleAugmentation,
572
- routeTrees.flatMap((t) => t.routeTreeConfig).join("\n"),
573
- routeTrees.map((t) => t.routeTree).join("\n"),
574
- ...this.config.routeTreeFileFooter
575
- ].filter(Boolean).join("\n\n");
576
- return routeTreeContent;
577
- }
578
- getImportPath(node) {
579
- return utils.replaceBackslash(
580
- utils.removeExt(
581
- path.relative(
582
- path.dirname(this.config.generatedRouteTree),
583
- path.resolve(this.config.routesDirectory, node.filePath)
584
- ),
585
- this.config.addExtensions
586
- )
587
- );
588
- }
589
- async processRouteNodeFile(node) {
590
- var _a, _b, _c, _d, _e;
591
- const result = await this.isRouteFileCacheFresh(node);
592
- if (result.status === "fresh") {
593
- node.exports = result.cacheEntry.exports;
594
- return {
595
- node,
596
- shouldWriteTree: result.exportsChanged,
597
- cacheEntry: result.cacheEntry
598
- };
599
- }
600
- const existingRouteFile = await this.fs.readFile(node.fullPath);
601
- if (existingRouteFile === "file-not-existing") {
602
- throw new Error(`⚠️ File ${node.fullPath} does not exist`);
603
- }
604
- const updatedCacheEntry = {
605
- fileContent: existingRouteFile.fileContent,
606
- mtimeMs: existingRouteFile.stat.mtimeMs,
607
- exports: [],
608
- routeId: node.routePath ?? "$$TSR_NO_ROUTE_PATH_ASSIGNED$$"
609
- };
610
- const escapedRoutePath = ((_a = node.routePath) == null ? void 0 : _a.replaceAll("$", "$$")) ?? "";
611
- let shouldWriteRouteFile = false;
612
- if (!existingRouteFile.fileContent) {
613
- shouldWriteRouteFile = true;
614
- if (node._fsRouteType === "lazy") {
615
- const tLazyRouteTemplate = this.targetTemplate.lazyRoute;
616
- updatedCacheEntry.fileContent = await template.fillTemplate(
617
- this.config,
618
- (((_b = this.config.customScaffolding) == null ? void 0 : _b.lazyRouteTemplate) || ((_c = this.config.customScaffolding) == null ? void 0 : _c.routeTemplate)) ?? tLazyRouteTemplate.template(),
619
- {
620
- tsrImports: tLazyRouteTemplate.imports.tsrImports(),
621
- tsrPath: escapedRoutePath.replaceAll(/\{(.+)\}/gm, "$1"),
622
- tsrExportStart: tLazyRouteTemplate.imports.tsrExportStart(escapedRoutePath),
623
- tsrExportEnd: tLazyRouteTemplate.imports.tsrExportEnd()
624
- }
625
- );
626
- updatedCacheEntry.exports = ["Route"];
627
- } else if (
628
- // Creating a new normal route file
629
- ["layout", "static"].some(
630
- (d) => d === node._fsRouteType
631
- ) || [
632
- "component",
633
- "pendingComponent",
634
- "errorComponent",
635
- "loader"
636
- ].every((d) => d !== node._fsRouteType)
637
- ) {
638
- const tRouteTemplate = this.targetTemplate.route;
639
- updatedCacheEntry.fileContent = await template.fillTemplate(
640
- this.config,
641
- ((_d = this.config.customScaffolding) == null ? void 0 : _d.routeTemplate) ?? tRouteTemplate.template(),
642
- {
643
- tsrImports: tRouteTemplate.imports.tsrImports(),
644
- tsrPath: escapedRoutePath.replaceAll(/\{(.+)\}/gm, "$1"),
645
- tsrExportStart: tRouteTemplate.imports.tsrExportStart(escapedRoutePath),
646
- tsrExportEnd: tRouteTemplate.imports.tsrExportEnd()
647
- }
648
- );
649
- updatedCacheEntry.exports = ["Route"];
650
- } else {
651
- return null;
652
- }
653
- } else {
654
- const transformResult = await transform.transform({
655
- source: updatedCacheEntry.fileContent,
656
- ctx: {
657
- target: this.config.target,
658
- routeId: escapedRoutePath,
659
- lazy: node._fsRouteType === "lazy",
660
- verboseFileRoutes: !(this.config.verboseFileRoutes === false)
661
- },
662
- plugins: this.transformPlugins
663
- });
664
- if (transformResult.result === "error") {
665
- throw new Error(
666
- `Error transforming route file ${node.fullPath}: ${transformResult.error}`
667
- );
668
- }
669
- updatedCacheEntry.exports = transformResult.exports;
670
- if (transformResult.result === "modified") {
671
- updatedCacheEntry.fileContent = transformResult.output;
672
- shouldWriteRouteFile = true;
673
- }
674
- }
675
- if (shouldWriteRouteFile) {
676
- const stats = await this.safeFileWrite({
677
- filePath: node.fullPath,
678
- newContent: updatedCacheEntry.fileContent,
679
- strategy: {
680
- type: "mtime",
681
- expectedMtimeMs: updatedCacheEntry.mtimeMs
682
- }
683
- });
684
- updatedCacheEntry.mtimeMs = stats.mtimeMs;
685
- }
686
- this.routeNodeShadowCache.set(node.fullPath, updatedCacheEntry);
687
- node.exports = updatedCacheEntry.exports;
688
- const shouldWriteTree = !routerCore.deepEqual(
689
- (_e = result.cacheEntry) == null ? void 0 : _e.exports,
690
- updatedCacheEntry.exports
691
- );
692
- return {
693
- node,
694
- shouldWriteTree,
695
- cacheEntry: updatedCacheEntry
696
- };
697
- }
698
- async didRouteFileChangeComparedToCache(file, cache) {
699
- const cacheEntry = this[cache].get(file.path);
700
- return this.didFileChangeComparedToCache(file, cacheEntry);
701
- }
702
- async didFileChangeComparedToCache(file, cacheEntry) {
703
- if (!cacheEntry) {
704
- return { result: "file-not-in-cache" };
705
- }
706
- let mtimeMs = file.mtimeMs;
707
- if (mtimeMs === void 0) {
708
- try {
709
- const currentStat = await this.fs.stat(file.path);
710
- mtimeMs = currentStat.mtimeMs;
711
- } catch {
712
- return { result: "cannot-stat-file" };
713
- }
714
- }
715
- return { result: mtimeMs !== cacheEntry.mtimeMs, mtimeMs, cacheEntry };
716
- }
717
- async safeFileWrite(opts) {
718
- const tmpPath = this.getTempFileName(opts.filePath);
719
- await this.fs.writeFile(tmpPath, opts.newContent);
720
- if (opts.strategy.type === "mtime") {
721
- const beforeStat = await this.fs.stat(opts.filePath);
722
- if (beforeStat.mtimeMs !== opts.strategy.expectedMtimeMs) {
723
- throw rerun({
724
- msg: `File ${opts.filePath} was modified by another process during processing.`,
725
- event: { type: "update", path: opts.filePath }
726
- });
727
- }
728
- } else {
729
- if (await utils.checkFileExists(opts.filePath)) {
730
- throw rerun({
731
- msg: `File ${opts.filePath} already exists. Cannot overwrite.`,
732
- event: { type: "update", path: opts.filePath }
733
- });
734
- }
735
- }
736
- const stat = await this.fs.stat(tmpPath);
737
- await this.fs.rename(tmpPath, opts.filePath);
738
- return stat;
739
- }
740
- getTempFileName(filePath) {
741
- const absPath = path.resolve(filePath);
742
- const hash = crypto.createHash("md5").update(absPath).digest("hex");
743
- return path.join(this.tmpDir, hash);
744
- }
745
- async isRouteFileCacheFresh(node) {
746
- const fileChangedCache = await this.didRouteFileChangeComparedToCache(
747
- { path: node.fullPath },
748
- "routeNodeCache"
749
- );
750
- if (fileChangedCache.result === false) {
751
- this.routeNodeShadowCache.set(node.fullPath, fileChangedCache.cacheEntry);
752
- return {
753
- status: "fresh",
754
- exportsChanged: false,
755
- cacheEntry: fileChangedCache.cacheEntry
756
- };
757
- }
758
- if (fileChangedCache.result === "cannot-stat-file") {
759
- throw new Error(`⚠️ expected route file to exist at ${node.fullPath}`);
760
- }
761
- const mtimeMs = fileChangedCache.result === true ? fileChangedCache.mtimeMs : void 0;
762
- const shadowCacheFileChange = await this.didRouteFileChangeComparedToCache(
763
- { path: node.fullPath, mtimeMs },
764
- "routeNodeShadowCache"
765
- );
766
- if (shadowCacheFileChange.result === "cannot-stat-file") {
767
- throw new Error(`⚠️ expected route file to exist at ${node.fullPath}`);
768
- }
769
- if (shadowCacheFileChange.result === false) {
770
- if (fileChangedCache.result === true) {
771
- if (routerCore.deepEqual(
772
- fileChangedCache.cacheEntry.exports,
773
- shadowCacheFileChange.cacheEntry.exports
774
- )) {
775
- return {
776
- status: "fresh",
777
- exportsChanged: false,
778
- cacheEntry: shadowCacheFileChange.cacheEntry
779
- };
780
- }
781
- return {
782
- status: "fresh",
783
- exportsChanged: true,
784
- cacheEntry: shadowCacheFileChange.cacheEntry
785
- };
786
- }
787
- }
788
- if (fileChangedCache.result === "file-not-in-cache") {
789
- return {
790
- status: "stale"
791
- };
792
- }
793
- return { status: "stale", cacheEntry: fileChangedCache.cacheEntry };
794
- }
795
- async handleRootNode(node) {
796
- var _a;
797
- const result = await this.isRouteFileCacheFresh(node);
798
- if (result.status === "fresh") {
799
- node.exports = result.cacheEntry.exports;
800
- this.routeNodeShadowCache.set(node.fullPath, result.cacheEntry);
801
- return result.exportsChanged;
802
- }
803
- const rootNodeFile = await this.fs.readFile(node.fullPath);
804
- if (rootNodeFile === "file-not-existing") {
805
- throw new Error(`⚠️ expected root route to exist at ${node.fullPath}`);
806
- }
807
- const updatedCacheEntry = {
808
- fileContent: rootNodeFile.fileContent,
809
- mtimeMs: rootNodeFile.stat.mtimeMs,
810
- exports: [],
811
- routeId: node.routePath ?? "$$TSR_NO_ROOT_ROUTE_PATH_ASSIGNED$$"
812
- };
813
- if (!rootNodeFile.fileContent) {
814
- const rootTemplate = this.targetTemplate.rootRoute;
815
- const rootRouteContent = await template.fillTemplate(
816
- this.config,
817
- rootTemplate.template(),
818
- {
819
- tsrImports: rootTemplate.imports.tsrImports(),
820
- tsrPath: rootPathId.rootPathId,
821
- tsrExportStart: rootTemplate.imports.tsrExportStart(),
822
- tsrExportEnd: rootTemplate.imports.tsrExportEnd()
823
- }
824
- );
825
- this.logger.log(`🟡 Creating ${node.fullPath}`);
826
- const stats = await this.safeFileWrite({
827
- filePath: node.fullPath,
828
- newContent: rootRouteContent,
829
- strategy: {
830
- type: "mtime",
831
- expectedMtimeMs: rootNodeFile.stat.mtimeMs
832
- }
833
- });
834
- updatedCacheEntry.fileContent = rootRouteContent;
835
- updatedCacheEntry.mtimeMs = stats.mtimeMs;
836
- }
837
- const rootRouteExports = [];
838
- for (const plugin of this.pluginsWithTransform) {
839
- const exportName = plugin.transformPlugin.exportName;
840
- if (rootNodeFile.fileContent.includes(`export const ${exportName}`)) {
841
- rootRouteExports.push(exportName);
842
- }
843
- }
844
- updatedCacheEntry.exports = rootRouteExports;
845
- node.exports = rootRouteExports;
846
- this.routeNodeShadowCache.set(node.fullPath, updatedCacheEntry);
847
- const shouldWriteTree = !routerCore.deepEqual(
848
- (_a = result.cacheEntry) == null ? void 0 : _a.exports,
849
- rootRouteExports
850
- );
851
- return shouldWriteTree;
852
- }
853
- handleNode(node, acc) {
854
- var _a;
855
- utils.resetRegex(this.routeGroupPatternRegex);
856
- let parentRoute = utils.hasParentRoute(acc.routeNodes, node, node.routePath);
857
- if ((parentRoute == null ? void 0 : parentRoute.isVirtualParentRoute) && ((_a = parentRoute.children) == null ? void 0 : _a.length)) {
858
- const possibleParentRoute = utils.hasParentRoute(
859
- parentRoute.children,
860
- node,
861
- node.routePath
862
- );
863
- if (possibleParentRoute) {
864
- parentRoute = possibleParentRoute;
865
- }
866
- }
867
- if (parentRoute) node.parent = parentRoute;
868
- node.path = utils.determineNodePath(node);
869
- const trimmedPath = utils.trimPathLeft(node.path ?? "");
870
- const split = trimmedPath.split("/");
871
- const lastRouteSegment = split[split.length - 1] ?? trimmedPath;
872
- node.isNonPath = lastRouteSegment.startsWith("_") || this.routeGroupPatternRegex.test(lastRouteSegment);
873
- node.cleanedPath = utils.removeGroups(
874
- utils.removeUnderscores(utils.removeLayoutSegments(node.path)) ?? ""
875
- );
876
- if (!node.isVirtual && [
877
- "lazy",
878
- "loader",
879
- "component",
880
- "pendingComponent",
881
- "errorComponent"
882
- ].some((d) => d === node._fsRouteType)) {
883
- acc.routePiecesByPath[node.routePath] = acc.routePiecesByPath[node.routePath] || {};
884
- acc.routePiecesByPath[node.routePath][node._fsRouteType === "lazy" ? "lazy" : node._fsRouteType === "loader" ? "loader" : node._fsRouteType === "errorComponent" ? "errorComponent" : node._fsRouteType === "pendingComponent" ? "pendingComponent" : "component"] = node;
885
- const anchorRoute = acc.routeNodes.find(
886
- (d) => d.routePath === node.routePath
887
- );
888
- if (!anchorRoute) {
889
- this.handleNode(
890
- {
891
- ...node,
892
- isVirtual: true,
893
- _fsRouteType: "static"
894
- },
895
- acc
896
- );
897
- }
898
- return;
899
- }
900
- const cleanedPathIsEmpty = (node.cleanedPath || "").length === 0;
901
- const nonPathRoute = node._fsRouteType === "pathless_layout" && node.isNonPath;
902
- node.isVirtualParentRequired = node._fsRouteType === "pathless_layout" || nonPathRoute ? !cleanedPathIsEmpty : false;
903
- if (!node.isVirtual && node.isVirtualParentRequired) {
904
- const parentRoutePath = utils.removeLastSegmentFromPath(node.routePath) || "/";
905
- const parentVariableName = utils.routePathToVariable(parentRoutePath);
906
- const anchorRoute = acc.routeNodes.find(
907
- (d) => d.routePath === parentRoutePath
908
- );
909
- if (!anchorRoute) {
910
- const parentNode = {
911
- ...node,
912
- path: utils.removeLastSegmentFromPath(node.path) || "/",
913
- filePath: utils.removeLastSegmentFromPath(node.filePath) || "/",
914
- fullPath: utils.removeLastSegmentFromPath(node.fullPath) || "/",
915
- routePath: parentRoutePath,
916
- variableName: parentVariableName,
917
- isVirtual: true,
918
- _fsRouteType: "layout",
919
- // layout since this route will wrap other routes
920
- isVirtualParentRoute: true,
921
- isVirtualParentRequired: false
922
- };
923
- parentNode.children = parentNode.children ?? [];
924
- parentNode.children.push(node);
925
- node.parent = parentNode;
926
- if (node._fsRouteType === "pathless_layout") {
927
- node.path = utils.determineNodePath(node);
928
- }
929
- this.handleNode(parentNode, acc);
930
- } else {
931
- anchorRoute.children = anchorRoute.children ?? [];
932
- anchorRoute.children.push(node);
933
- node.parent = anchorRoute;
934
- }
935
- }
936
- if (node.parent) {
937
- if (!node.isVirtualParentRequired) {
938
- node.parent.children = node.parent.children ?? [];
939
- node.parent.children.push(node);
940
- }
941
- } else {
942
- acc.routeTree.push(node);
943
- }
944
- acc.routeNodes.push(node);
945
- }
946
- // only process files that are relevant for the route tree generation
947
- isFileRelevantForRouteTreeGeneration(filePath) {
948
- if (filePath === this.generatedRouteTreePath) {
949
- return true;
950
- }
951
- if (filePath.startsWith(this.routesDirectoryPath)) {
952
- return true;
953
- }
954
- if (typeof this.config.virtualRouteConfig === "string" && filePath === this.config.virtualRouteConfig) {
955
- return true;
956
- }
957
- if (this.routeNodeCache.has(filePath)) {
958
- return true;
959
- }
960
- if (getRouteNodes$1.isVirtualConfigFile(path.basename(filePath))) {
961
- return true;
962
- }
963
- if (this.physicalDirectories.some((dir) => filePath.startsWith(dir))) {
964
- return true;
965
- }
966
- return false;
967
- }
968
- }
969
- exports.Generator = Generator;
970
- //# sourceMappingURL=generator.cjs.map