Faster routeTree formatting #3664
Closed
honzahruby
started this conversation in
Ideas
Replies: 1 comment 6 replies
-
|
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Our app has ~1000 routes and the generated routeTree file is about 26k lines of code.
The time to regenerate routes improved with #3366 (12s -> 3.4s), but formatting is still the main bottleneck.
I'm proposing two solutions to this issue:
Cache results of formatting
To minimize the size of the cache, I'm using a hash of the raw source as a key and the formatted output as a compressed buffer.
https://github.com/TanStack/router/compare/main...honzahruby:fast-route-gen-cache?expand=1
Measurements:
Skip formatting of the existing routeTree context
We always write the routeTree already formatted, so in most cases, it's safe to assume it is correctly formatted when being read. This would only not be true if the user had some custom formatting in place, which would be overridden by the default formatter anyway when regenerating the file due to route changes.
https://github.com/TanStack/router/compare/main...honzahruby:fast-route-gen?expand=1
Measurements:
Beta Was this translation helpful? Give feedback.
All reactions