Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Should routeTree.gen.ts be gitignored?#1218

AnsweredbySeanCassiere
psnehanshu asked this question inQ&A
Discussion options

I belive it should be, but I want to hear what other people are doing.

You must be logged in to vote

I've honestly gotten into the mindset of just saving yourroute-tree file in git. Purely, because the file is essential to your application running and having the typecheck phase pass correctly.


Updated Answer: Don't gitignore yourrouteTree.gen.ts file. This file is part of your application. It's simply managed by TanStack Router.

Replies: 3 comments 11 replies

Comment options

If you are using router-cli you could probablygitignore the file and generate it priot to a build.

This changes however if you are using the vite-plugin, since the default vite-build script has you runtsc before the build. In this scenario, your build would never get past thetsc check.

IMHO: I just check-in the file (routeTree.gen.ts) in git, because I can't be bothered solving the vite-build script.

You must be logged in to vote
9 replies
@gual
Comment options

I used theRouter CLI, created a
"router:generate": "tsr generate", in thepackage.json so I can use it in my build process.

@mrlubos
Comment options

@SeanCassiere has anything changed since the last year? Still the same guidance?

@SeanCassiere
Comment options

I've honestly gotten into the mindset of just saving yourroute-tree file in git. Purely, because the file is essential to your application running and having the typecheck phase pass correctly.


Updated Answer: Don't gitignore yourrouteTree.gen.ts file. This file is part of your application. It's simply managed by TanStack Router.

Answer selected bySeanCassiere
@SeanCassiere
Comment options

I'll probably create a FAQ section and chuck this in there.

@mrlubos
Comment options

FAQ would be nice! A counterpoint I can offer is that dependencies are also essential to your application running and would fail typecheck if not installed, yet we don't keep them in git. Even more similar, I work on codegen (see my profile) and the same question arises there. I went from yes to no on the same question. It's not that difficult to generate everything that's needed onpostinstall or with a Vite plugin – you're doing that already anyway! In fact, I looked at the TanStack Router Vite plugin when working on mine, so I suspect it might just work™. A practical argument I hear for not committing the generated files is it makes switching between branches easier as there won't be any conflicts.

@SeanCassiere
Comment options

The FAQ is up -https://tanstack.com/router/latest/docs/framework/react/faq

@mrlubos, I get what you mean. My only argument against the conflict point is, that this isn't like yourpackage-lock where some trailing commas pretty much always guarantee a conflict. So conflicts really should be at the minimum. The route tree also serves as an accurate point-in-time snapshot as to what TanStack Router would've used at runtime.

@SneakySensei
Comment options

Comment options

I'm using GitHub Actions so I just had to add:```- name: Generate routes file run: | docker compose run --rm --no-deps react npm run router:generate```
On Wed, Apr 24, 2024, at 8:54 AM, HappilyCoding wrote:> I used the Router CLI <https://tanstack.com/router/latest/docs/framework/react/guide/file-based-routing#router-cli>, created a `"router:generate": "tsr generate",` in the `package.json` so I can use it in my build process.> Could you please explain further? You probably modified other parts of the package.json or the docker or dockercompose files in order for tsr generate to be called automatically in the build process. It'd be awesome if you could share those changes. Also, to be frank, I'm unsure why tsr CLI is needed at all, according to the official doccumentation <https://tanstack.com/router/v1/docs/framework/react/quick-start> I don't believe it should be, specially considering since that's basically the configuration this project has. — Reply to this email directly, view it on GitHub <#1218 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAMS7NRIPY654RAYUIGO2JDY67BTTAVCNFSM6AAAAABDX27WTOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TEMJUG4ZDS>. You are receiving this because you commented.Message ID: ***@***.***>
You must be logged in to vote
0 replies
Comment options

tsc is just a compile check so I moved it after the build:

"build":"vite build && tsc"
You must be logged in to vote
2 replies
@psnehanshu
Comment options

What's the point of building if typecheck failed? It should ideally be

"build":"tsc --noEmit && vite build"
@jessetabak
Comment options

The point is that tsc will always fail if there's no generated route-tree file, which I have git ignored.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
7 participants
@psnehanshu@gual@jessetabak@mrlubos@SeanCassiere@SneakySensei@andreilgeorgescu

[8]ページ先頭

©2009-2025 Movatter.jp