T
TanStack•5mo ago
deep-jade

vinxi dev & tsr generate different `routeTree.gen.ts`

During CI we use tsr generate to generate the routeTree.gen.ts but it seems like this produces a different routeTree, even if we provide a tsr.config.json. Is there a way to trigger tsr so it provides the same options that the vite plugin does?
15 Replies
deep-jade
deep-jadeOP•5mo ago
Might actually belong in #start-questions
extended-salmon
extended-salmon•5mo ago
why do you use tsr generate ? the build command should just build the route tree
deep-jade
deep-jadeOP•5mo ago
because we run automated testing and we don't need a prod build for that we want runtime from commit to first tests completed to be as short as possible
extended-salmon
extended-salmon•5mo ago
so what diff do you see in the generated file?
deep-jade
deep-jadeOP•5mo ago
The problem specifically is that's it's seeing the api files as routes. Without tsr.config.json it doesn't pick up on the tsr config in app.config.ts, I'm assuming due to the fact it's tanstack start specific config file. If I make it so tsr.config.json mirrors the tsr setting in app.config.ts , so: { "appDirectory": "src", "virtualRouteConfig": "src/virtual-routes.ts", "routeFileIgnorePattern": ".(spec|test).ts" } then the route tree contains imports such as import { Route as ApiFooBarImport } from './routes/api/foo/bar' temporary workaround that we went with after posting this was adding the api folder in the routeFileIgnorePattern
extended-salmon
extended-salmon•5mo ago
cc @Sean Cassiere i think for start tsr is just not compatible so it would need to be aware of start being used
deep-jade
deep-jadeOP•5mo ago
Yeah either that or start needs its own cli
extended-salmon
extended-salmon•5mo ago
it will most likely get one, so that would be a nice use case
subsequent-cyan
subsequent-cyan•5mo ago
This probably also has a little bit to do with the different generator configs being used.
subsequent-cyan
subsequent-cyan•5mo ago
That being said, you should probably not be gitignoring your routeTree since its part of your source code. https://tanstack.com/router/latest/docs/framework/react/faq#should-i-commit-my-routetreegents-file-into-git
Frequently Asked Questions | TanStack Router React Docs
Welcome to the TanStack Router FAQ! Here you'll find answers to common questions about the TanStack Router. If you have a question that isn't answered here, please feel free to ask in the . Should I c...
deep-jade
deep-jadeOP•5mo ago
We do commit our routeTree but we have extra virtual routes during development, hence why we need to rebuild it Also am I correct in thinking that start uses tsr core logic under the hood but that it has a few default options, like ignoring the api files by default?
subsequent-cyan
subsequent-cyan•5mo ago
GitHub
router/packages/react-start-config/src/index.ts at fff694147b75e8cf...
🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering. - TanStack/router
subsequent-cyan
subsequent-cyan•5mo ago
We moved to that flag since it was causing issues for Router-only users. Definitely didn't consider your use case at the time 😅
deep-jade
deep-jadeOP•5mo ago
That's alright, the workaround using tsr.config.json with a regex ignoring the api folder works for us now. Actually we can use __enableAPIRoutesGeneration in tsr.config.json it seems
subsequent-cyan
subsequent-cyan•5mo ago
Yea that should be fine for now.

Did you find this page helpful?