fix(router-generator): fix layout/index conflict in virtual physical(… #6252
Merged
schiller-manuel(GitHub profile, opens in a new tab)merged 1 commit into
main fromrefs/pull/6252/head·merged by schiller-manuel(GitHub profile, opens in a new tab) …) routes
fixes #5421
Summary by CodeRabbit#
Bug Fixes
- Improved layout route fallback path handling to correctly resolve empty paths for layout routes.
Tests
- Added comprehensive test scenario for layout routes combined with virtual and physical route configurations.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-generator
🤖 Nx Cloud AI Fix Eligible#
To disable these notifications, a workspace admin can disable them [in workspace settings.](https://cloud.nx.app/orgs/6412ca9d1c251d000efa21ba/workspaces/6442f7de8226a6291646a813/settings/self-healing-ci?utm_source=pull-request&utm_medium=comment)An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.
View your CI Pipeline Execution ↗ for commit a6785871c2e686ee8f5946be888a1080f4d483a8
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...❌ Failed 16m 1s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 34s View ↗
☁️ Nx Cloud last updated this comment at
2025-12-30 01:56:46UTCMore templates
- tanstack-router-solid-example-authenticated-routes
- tanstack-router-solid-example-authenticated-routes-firebase
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-default-search-params
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-basic-virtual-file-based
- tanstack-router-solid-example-basic-virtual-inside-file-based
- tanstack-router-solid-example-deferred-data
- tanstack-router-solid-i18n-paraglide
- tanstack-router-solid-example-kitchen-sink
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-large-file-based
- tanstack-router-solid-example-location-masking
- tanstack-router-solid-example-navigation-blocking
- tanstack-router-solid-example-quickstart
- tanstack-router-solid-example-quickstart-esbuild-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-router-solid-example-quickstart-rspack-file-based
- tanstack-router-solid-example-quickstart-webpack-file-based
- @tanstack/router-solid-mono-simple
- router-solid-mono-simple-lazy
- router-solid-monorepo-solid-query
- tanstack-router-solid-example-scroll-restoration
- tanstack-solid-router-search-validator-adapters
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-authjs
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-bun-hosting
- tanstack-solid-start-example-convex-better-auth
- tanstack-solid-start-example-counter
- tanstack-solid-start-i18n-paraglide
- tanstack-solid-start-example-large
- tanstack-solid-start-streaming-data-from-server-functions
- tanstack-solid-start-example-supabase-basic
- tanstack-solid-start-tailwind-v4
- tanstack-router-solid-example-view-transitions
- tanstack-router-solid-example-with-framer-motion
- tanstack-router-solid-example-with-trpc
- tanstack-router-vue-example-basic-jsx
- tanstack-router-vue-example-basic-file-based-jsx
- tanstack-router-vue-example-basic-file-based-sfc
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-router-react-example-basic-authjs
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-rsc
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
@tanstack/arktype-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6252@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@6252@tanstack/history
npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6252@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@6252@tanstack/react-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@6252@tanstack/react-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@6252@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@6252@tanstack/react-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6252@tanstack/react-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6252@tanstack/react-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6252@tanstack/router-cli
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@6252@tanstack/router-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@6252@tanstack/router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@6252@tanstack/router-devtools-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@6252@tanstack/router-generator
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@6252@tanstack/router-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@6252@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@6252@tanstack/router-utils
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@6252@tanstack/router-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@6252@tanstack/solid-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@6252@tanstack/solid-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@6252@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@6252@tanstack/solid-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6252@tanstack/solid-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6252@tanstack/solid-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6252@tanstack/start-client-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6252@tanstack/start-fn-stubs
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-fn-stubs@6252@tanstack/start-plugin-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6252@tanstack/start-server-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6252@tanstack/start-static-server-functions
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@6252@tanstack/start-storage-context
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6252@tanstack/valibot-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6252@tanstack/virtual-file-routes
npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6252@tanstack/vue-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@6252@tanstack/vue-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@6252@tanstack/vue-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@6252@tanstack/vue-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6252@tanstack/vue-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6252@tanstack/vue-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6252@tanstack/zod-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6252commit:
a678587
Sign in to join this conversation.
📝 Walkthrough
Walkthrough#
Adds layout-aware fallback path handling in route node generation and introduces a comprehensive test case for the virtual-physical-layout-and-index scenario, enabling both
route.tsxandindex.tsxto coexist in physical virtual routes.Changes#
packages/router-generator/src/filesystem/physical/getRouteNodes.tsisLayoutRoutecheck to modify default fallback from'/'to''(empty string) forroutePathandoriginalRoutePathwhen layout routes have index tokens at the end; preserves existing behavior for non-layout routes.packages/router-generator/tests/generator/virtual-physical-layout-and-index/tsr.config.jsonroutesDirectory,generatedRouteTree, andvirtualRouteConfigpaths.packages/router-generator/tests/generator/virtual-physical-layout-and-index/routes.ts/featurepath.packages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/index.tsx,routes/__root.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/route.tsx,routes/feature/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.tsFileRoutesByFullPath,FileRoutesByTo,FileRoutesById,FileRouteTypes, route children), type-safe route mappings, module augmentation for@tanstack/react-router, and compositedrouteTreeconstant.Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs#
Suggested labels#
package: router-generatorSuggested reviewers#
Poem#
Pre-merge checks and finishing touches#
❌ Failed checks (1 warning)
@coderabbitai generate docstringsto improve docstring coverage.✅ Passed checks (4 passed)
✨ Finishing touches
📜 Recent review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between baa3d1dc2974be8c30f7884f63a394f19b2b4e21 and a6785871c2e686ee8f5946be888a1080f4d483a8.
📒 Files selected for processing (8)
packages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/__root.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/route.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/tsr.config.json🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Files:
packages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/route.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/__root.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.tspackages/router-generator/src/filesystem/physical/getRouteNodes.ts**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Files:
packages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/route.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/__root.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.tspackages/router-generator/src/filesystem/physical/getRouteNodes.ts🧠 Learnings (9)
📓 Common learnings
📚 Learning: 2025-12-17T02:17:55.086Z
Applied to files:
packages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/route.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/__root.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.tspackages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/tsr.config.json📚 Learning: 2025-10-08T08:11:47.088Z
Applied to files:
packages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/route.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/__root.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.tspackages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/tsr.config.json📚 Learning: 2025-10-01T18:31:35.420Z
Applied to files:
packages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/tsr.config.json📚 Learning: 2025-12-21T12:52:35.231Z
Applied to files:
packages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/route.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/__root.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.tspackages/router-generator/src/filesystem/physical/getRouteNodes.ts📚 Learning: 2025-12-06T15:03:07.223Z
Applied to files:
packages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/tsr.config.json📚 Learning: 2025-12-06T15:03:07.223Z
Applied to files:
packages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/route.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes.tspackages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/index.tsxpackages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.ts📚 Learning: 2025-11-02T16:16:24.898Z
Applied to files:
packages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.ts📚 Learning: 2025-10-01T18:30:26.591Z
Applied to files:
packages/router-generator/src/filesystem/physical/getRouteNodes.ts🧬 Code graph analysis (3)
packages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/index.tsx (3)
packages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/feature/route.tsx (3)
packages/router-generator/tests/generator/virtual-physical-layout-and-index/routes/__root.tsx (3)
🪛 ast-grep (0.40.3)
packages/router-generator/src/filesystem/physical/getRouteNodes.ts
[warning] 252-252: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns. Context: new RegExp(
/${config.indexToken}$) Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES](regexp-from-variable)
[warning] 257-257: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns. Context: new RegExp(
/${config.indexToken}$) Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES](regexp-from-variable)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (8)
Comment `@coderabbitai help` to get the list of available commands and usage tips.