Skip to content

Virtual File Router with multiple routes to same file errors #5009

@michael-paulus-icev

Description

@michael-paulus-icev

Which project does this relate to?

Router

Describe the bug

I'm trying to use the virtual router to create multiple routes to the same file, but when I do that sometimes the cli generates fine, and other times it corrupts the file, or produces an error.

An example is using the basic-virtual-inside-file-based example and adding an extra route to the __virtual.ts

route('test/$postId', 'details.tsx'),
route('test2/$postId', 'details.tsx'),

PS C:\Users\michael.paulus\source\repos\basic-virtual-inside-file-based> pnpm tsr generate
Error: ENOENT: no such file or directory, stat 'C:\Users\michael.paulus\source\repos\basic-virtual-inside-file-based.tanstack\tmp\08307e97-e59a75fa1ec098da1584f7125f5f9699'
at C:\Users\michael.paulus\source\repos\basic-virtual-inside-file-based\node_modules.pnpm@[email protected]\node_modules@tanstack\router-generator\dist\cjs\generator.cjs:167:19
at async Module.generate (C:\Users\michael.paulus\source\repos\basic-virtual-inside-file-based\node_modules.pnpm@[email protected]\node_modules@tanstack\router-cli\dist\cjs\generate.cjs:10:5)
at async C:\Users\michael.paulus\source\repos\basic-virtual-inside-file-based\node_modules.pnpm@[email protected]\node_modules@tanstack\router-cli\dist\cjs\index.cjs:28:5

Your Example Website or App

n/a

Steps to Reproduce the Bug or Issue

Clone the basic-virtual-inside-file-based example

Open the posts/__virtual.ts
Add

route('test/$postId', 'details.tsx'),
route('test2/$postId', 'details.tsx'),

install the cli

run tsr generate

Expected behavior

I would expect that I can have multiple virtual routes pointing to the same file.

Screenshots or Videos

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions