Finding the Unused TRPC procedure...
after a big rewrite of the frontend I'm not using all the old mutations / queries
so now I have them there and I need a way to identify the unused ones ? the manual Ctr+Shif+F is taking tooo much time HHhH :feelsadman:
4 Replies
You can delete/comment routers and see where you get type issues from the paths
tried it but it's a big app ts takes a while hhhhh and we don't have that much time unfortunately
Hey, not sure if it's still of interest to you, but I was also interested in finding my unused trpc paths, so I wrote a script to detect them for me: https://gist.github.com/justinsmid/204a3c5b9507b4f65bdac69e72ecbdf5#file-detect-unused-trpc-endpoints-ts
It has a bunch of uppercased constants at the top of the file that you will probably need to adjust to your app (lines 17-33)
And it makes a few assumptions about how your trpc routes are defined. Namely:
- All names of router declaration variables end in
ROUTER_DECLARATION_SUFFIX
- Each nested router is declared in a separate file
I guess I don't have a way of confirming whether it actually catches all unused routes, but in my app we had 816 routes and it found 12 unused ones that I was able to remove.thanks man you saved me hours :feelsadman:
ll check and test it ...