#vinxi dev & tsr generate different `routeTree.gen.ts`
22 messages · Page 1 of 1 (latest)
why do you use tsr generate ? the build command should just build the route tree
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
so what diff do you see in the generated file?
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
cc @onyx copper
i think for start tsr is just not compatible
so it would need to be aware of start being used
Yeah either that or start needs its own cli
it will most likely get one, so that would be a nice use case
This probably also has a little bit to do with the different generator configs being used.
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
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?
Yes! It's through an undocumented flag
https://github.com/TanStack/router/blob/fff694147b75e8cf109da92e60ae3378a4bf4d00/packages/react-start-config/src/index.ts#L220
We moved to that flag since it was causing issues for Router-only users.
Definitely didn't consider your use case at the time 😅