Closed a-maas closed 2 weeks ago
this PR seems to be related: https://github.com/TanStack/router/pull/1259
do you want to provide a PR to fix this issue?
Thanks for the link, I didn't find that when searching for this issue before submitting. Yes, that PR and related issue look like a very similar issue to what I described above, though, the issue still persists.
I will take some time and try to work out a fix PR. Any guidance would be appreciated since I'm still pretty new to Vite and TSR.
@schiller-manuel it seems like there are two options to fix this. The problem stems from initially setting ROOT
to process.cwd()
, but later redefining ROOT
as vite's configured root. This leads to a mismatch if you have vite's root set to anything other than the process.cwd()
.
Option 1: To be consistent, use process.cwd()
everywhere, which would mean only changing this line to process.cwd()
instead of config.root
. I'm not sure if this would cause confusion or future issues for people using vite.root
.
Option 2: Use vite.root
, if set, everywhere, with a process.cwd()
fallback. This would have a few consequences:
tsr.config.json
would need to be placed at vite.root
, not project root, if they were different. In my case, it would need to be placed in ./app
instead of project root.tsr.config.json
, like routesDirectory
would need to be based on the vite.root
, instead of project root, if they are different.Seems like in the prior PR, you were weighing both of these options, and ended up going with Option 1, but Option 2 may be more desirable.
would option 2 be a breaking change?
Describe the bug
I've provided minimal example project that demonstrates a potential bug with the TanStack Router Vite Plugin not detecting and generating when using a non-standard vite
root
configuration. In this example, the viteroot
config is set toapp
in thevite.config.ts
file. With this configuration, TanStack Router does not detecttsr.config.json
in the project root, but will detect it if the file is moved to theapp
directory. Once moved to theapp
directory, the TanStack Router Vite plugin will successfully generate the routes onvite dev
boot, but will not detect and re-generate based on adding and removing files in theapp/routes
directory.Your Example Website or App
https://github.com/a-maas/ts-router-ex
Steps to Reproduce the Bug or Issue
npm install
npm run dev
test.tsx
file to theapp/routes
directory.Expected behavior
As a user, I expect the TanStack Router Vite plugin to re-generate routes when I add and remove files from the configured routes directory, even when Vite is configured with a non-standard
root
.Screenshots or Videos
No response
Platform
Additional context
No response