Skip to content
Source
Sign inSign up
TanStack/router

fix(router-generator): include the parent route path in variable names for physical() mounts #8880

Openkarlshea(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/8880/headopened

Showing 13 changed files with 30 additions and 25 deletions (loading 10).

x
0 of 13 viewed, 13 left
5 additions and 0 deletions.changeset/router-generator-physical-variable-name.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/router-generator': patch
+---
+​
+Fix duplicate identifiers in the generated route tree when a virtual route config mounts `physical()` directories under different parents. A mounted file's variable name now includes the parent route's path, as the route id already did, so `route('/a', [physical('', 'a')])` and `route('/b', [physical('', 'b')])` with an `index.tsx` in each generate `AIndexRoute` and `BIndexRoute` instead of `IndexRoute` twice.
1 addition and 1 deletionpackages/router-generator/src/filesystem/virtual/getRouteNodes.tsModified
View file
@@ -183,7 +183,7 @@
createLiteralRoutePathSegmentMetadata(pathPrefix, parent, true)
const routePath = cleanPath(`${pathPrefix}${subtreeNode.routePath}`)
subtreeNode.variableName = routePathToVariable(
- `${routePathPrefix}/${removeExt(subtreeNode.filePath)}`,
+ `${pathPrefix}/${removeExt(subtreeNode.filePath)}`,
subtreeNode._routePathSegmentMetadata = joinRoutePathSegmentMetadata(
routePath,
24 additions and 24 deletionspackages/router-generator/tests/generator/virtual/routeTree.snapshot.tsModified
View file
@@ -15,11 +15,11 @@
import { Route as dbDashboardRouteImport } from './routes/db/dashboard'
import { Route as dbDashboardIndexRouteImport } from './routes/db/dashboard-index'
import { Route as dbDashboardInvoicesRouteImport } from './routes/db/dashboard-invoices'
-import { Route as HelloIndexRouteImport } from './routes/subtree/index'
+import { Route as LayoutHelloIndexRouteImport } from './routes/subtree/index'
import { Route as dbInvoicesIndexRouteImport } from './routes/db/invoices-index'
import { Route as dbInvoiceDetailRouteImport } from './routes/db/invoice-detail'