@tanstack/router-generator
Advanced tools
Comparing version 1.82.10 to 1.83.0
import { RouteNode } from './types.js'; | ||
import { Config } from './config.js'; | ||
export declare const CONSTANTS: { | ||
APIRouteExportVariable: string; | ||
}; | ||
export declare function generator(config: Config): Promise<void>; | ||
@@ -4,0 +7,0 @@ /** |
@@ -9,2 +9,6 @@ import path from "node:path"; | ||
import { rootPathId } from "./filesystem/physical/rootPathId.js"; | ||
const CONSTANTS = { | ||
// When changing this, you'll want to update the import in `start/api/index.ts#defaultAPIFileRouteHandler` | ||
APIRouteExportVariable: "APIRoute" | ||
}; | ||
let latestTask = 0; | ||
@@ -152,9 +156,9 @@ const routeGroupPatternRegex = /\(.+\)/g; | ||
/(FileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g, | ||
(match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}` | ||
(_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}` | ||
).replace( | ||
/(import\s*\{.*)(create(Lazy)?FileRoute)(.*\}\s*from\s*['"]@tanstack\/react-router['"])/gs, | ||
(match, p1, p2, p3, p4) => `${p1}${node.isLazy ? "createLazyFileRoute" : "createFileRoute"}${p4}` | ||
(_, p1, __, ___, p4) => `${p1}${node.isLazy ? "createLazyFileRoute" : "createFileRoute"}${p4}` | ||
).replace( | ||
/create(Lazy)?FileRoute(\(\s*['"])([^\s]*)(['"],?\s*\))/g, | ||
(match, p1, p2, p3, p4) => `${node.isLazy ? "createLazyFileRoute" : "createFileRoute"}${p2}${escapedRoutePath}${p4}` | ||
(_, __, p2, ___, p4) => `${node.isLazy ? "createLazyFileRoute" : "createFileRoute"}${p2}${escapedRoutePath}${p4}` | ||
); | ||
@@ -257,3 +261,3 @@ } | ||
tsrPath: escapedRoutePath, | ||
tsrExportStart: `export const Route = createAPIFileRoute('${escapedRoutePath}')(`, | ||
tsrExportStart: `export const ${CONSTANTS.APIRouteExportVariable} = createAPIFileRoute('${escapedRoutePath}')(`, | ||
tsrExportEnd: ");" | ||
@@ -707,2 +711,3 @@ }); | ||
export { | ||
CONSTANTS, | ||
createRouteNodesByFullPath, | ||
@@ -709,0 +714,0 @@ createRouteNodesById, |
export { configSchema, getConfig } from './config.js'; | ||
export type { Config } from './config.js'; | ||
export { generator, startAPIRouteSegmentsFromTSRFilePath } from './generator.js'; | ||
export { generator, startAPIRouteSegmentsFromTSRFilePath, CONSTANTS, } from './generator.js'; | ||
export type { StartAPIRoutePathSegment } from './generator.js'; |
import { configSchema, getConfig } from "./config.js"; | ||
import { generator, startAPIRouteSegmentsFromTSRFilePath } from "./generator.js"; | ||
import { CONSTANTS, generator, startAPIRouteSegmentsFromTSRFilePath } from "./generator.js"; | ||
export { | ||
CONSTANTS, | ||
configSchema, | ||
@@ -5,0 +6,0 @@ generator, |
{ | ||
"name": "@tanstack/router-generator", | ||
"version": "1.82.10", | ||
"version": "1.83.0", | ||
"description": "Modern and scalable routing for React applications", | ||
@@ -5,0 +5,0 @@ "author": "Tanner Linsley", |
@@ -23,2 +23,7 @@ import path from 'node:path' | ||
export const CONSTANTS = { | ||
// When changing this, you'll want to update the import in `start/api/index.ts#defaultAPIFileRouteHandler` | ||
APIRouteExportVariable: 'APIRoute', | ||
} | ||
let latestTask = 0 | ||
@@ -225,7 +230,7 @@ const routeGroupPatternRegex = /\(.+\)/g | ||
/(FileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g, | ||
(match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`, | ||
(_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`, | ||
) | ||
.replace( | ||
/(import\s*\{.*)(create(Lazy)?FileRoute)(.*\}\s*from\s*['"]@tanstack\/react-router['"])/gs, | ||
(match, p1, p2, p3, p4) => | ||
(_, p1, __, ___, p4) => | ||
`${p1}${node.isLazy ? 'createLazyFileRoute' : 'createFileRoute'}${p4}`, | ||
@@ -235,3 +240,3 @@ ) | ||
/create(Lazy)?FileRoute(\(\s*['"])([^\s]*)(['"],?\s*\))/g, | ||
(match, p1, p2, p3, p4) => | ||
(_, __, p2, ___, p4) => | ||
`${node.isLazy ? 'createLazyFileRoute' : 'createFileRoute'}${p2}${escapedRoutePath}${p4}`, | ||
@@ -374,3 +379,3 @@ ) | ||
tsrPath: escapedRoutePath, | ||
tsrExportStart: `export const Route = createAPIFileRoute('${escapedRoutePath}')(`, | ||
tsrExportStart: `export const ${CONSTANTS.APIRouteExportVariable} = createAPIFileRoute('${escapedRoutePath}')(`, | ||
tsrExportEnd: ');', | ||
@@ -377,0 +382,0 @@ }) |
export { configSchema, getConfig } from './config' | ||
export type { Config } from './config' | ||
export { generator, startAPIRouteSegmentsFromTSRFilePath } from './generator' | ||
export { | ||
generator, | ||
startAPIRouteSegmentsFromTSRFilePath, | ||
CONSTANTS, | ||
} from './generator' | ||
export type { StartAPIRoutePathSegment } from './generator' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
351017
4538