-
-
Notifications
You must be signed in to change notification settings - Fork 885
Description
What is the feature you are proposing?
I began using Hono for my side project about a year ago. After a year this grew into a pretty chunky product that has hundreds if not thousands of different modules and endpoints.
The catch is the build time of the project. Since Hono is inferring the Context type for each route, and then extends it with the next router and so on, my application now takes about 8 minutes to compile in CI with esbuild. This increased our CI consumption (and the bills) by a lot, deploys take a lot of time, and I had to spend a lot of engineering hours just to make the DX for other contributors bearable.
I've had previous concern with the type inference mechanism - you have to compile your entire app (including your ORM, hidden business logic and etc) just to have RPC functionality for your frontend, which is essentially just the inputs/outputs for your API, and shouldn't be more than that. The solution in the docs page helped, but again - the compile times are killing it, it kills live-reload, requires additional setups, and etc.
Some temporary solutions I've implemented definitely helped:
- Wrap the entire app in the Nx monorepo.
- Split each router into buildable
esbuildlibrary. - Have the main router (which is also buildable) connect all of those together (inferring the types)
- Skip the type check in main router in the
developmentenvironment (because the main router took forever to make one hell of a type by joining the previous types together). - Live reload is now down from ~2mins to ~10secs.
Having said that, I think this is too much engineering to make a JS framework work for a small startup. It feels like the type inference solution is not going to play out long-term and I would like to hear your opinions on how this can be improved or if there's any plans to move to other models (I previously mentioned the contract model, where the input/output types for each request are known in advance and then each handler checks if it satisfies the type of IO).
It looks like few other problems derive from this mechanism for other people as well, causing to move to other frameworks #3450 (comment). I've mentioned this many times before, and so did the others. Thanks!