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-jadeOP•5mo ago
Might actually belong in #start-questions
extended-salmon•5mo ago
why do you use
tsr generate
? the build command should just build the route treedeep-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•5mo ago
so what diff do you see in the generated file?
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•5mo ago
cc @Sean Cassiere
i think for start
tsr
is just not compatible
so it would need to be aware of start being useddeep-jadeOP•5mo ago
Yeah either that or start needs its own cli
extended-salmon•5mo ago
it will most likely get one, so that would be a nice use case
subsequent-cyan•5mo ago
This probably also has a little bit to do with the different generator configs being used.
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-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•5mo ago
Yes! It's through an undocumented flag
https://github.com/TanStack/router/blob/fff694147b75e8cf109da92e60ae3378a4bf4d00/packages/react-start-config/src/index.ts#L220
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•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-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 seemssubsequent-cyan•5mo ago
Yea that should be fine for now.