This is a simple and rudmentar prototyping of a lazy loader for Hono to be used with Deno and Deno Deploy. Maybe can be adapated for others runtimes.
Pushing the limits of what is possible with Deno Deploy, I developed a moderately small Api service (44 files, 10 endpoints and 3 handlers). The project supports Postgres with Drizzle, called postgres and redis. However, as the project scaled and more libraries were added I began to experience very long cold starts, an inconsistent average of (4 - 15sec).
After many tests I verified that there was a bottleneck in loading the files (handlers), deno deploy started taking a long time to load the files, when eliminating the imports the problem disappeared, in essence Hono does not support Lazy Loading, this gist provides a prototype for that. When initializing, a standard and generic server will be loaded, only importing when the current route handler is requested.