Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @tanstack/react-router plugin #856

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

nickrttn
Copy link
Contributor

This adds support for the file-based routing Vite/RsPack/RsBuild/Webpack plugin of @tanstack/react-router. The only reliable way I saw to parse the config files of those tools to generate the correct entries was through building an AST using TS.

I saw you've got some helpers for TS AST's in the codebase. Let me know if I can/need to use any of those.

Copy link

pkg-pr-new bot commented Nov 26, 2024

Open in Stackblitz

npm i https://pkg.pr.new/knip@856

commit: 8392b38

@webpro
Copy link
Collaborator

webpro commented Nov 26, 2024

Thanks for the PR, @nickrttn!

This adds support for the file-based routing Vite/RsPack/RsBuild/Webpack plugin of @tanstack/react-router. The only reliable way I saw to parse the config files of those tools to generate the correct entries was through building an AST using TS.

I see what you're doing here, why it's needed, and I find it nice you gave it a shot and impressive you pulled it off. Now to me, the question is whether the complexity of this plugin warrants users not having to also configure Knip, like so:

{
  "production": ["src/path/to/routeTree.gen.ts"],       // either one
  "tanstack-router": {
    "production": ["src/path/to/routeTree.gen.ts"],     // of these is fine
  }
}

How often generatedRouteTree is modified is relevant, I have no idea. I think the value routesDirectory is less important to find as route files are picked up through src/main.ts anyway. Maybe depending on the src/main.tsx is even preferable here as that file contains actual usage, and we don't need to !negate ignore patterns, right?

So far, I think none of the plugins use or need ts at all, so currently I'm a bit on the fence with this one. And perhaps I'm missing something as well. WDYT? Eager to hear what your thoughts are on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants