Use hono with Turborepo's JIT packages?
I'm trying to setup a monorepo with Turborepo. One of the concepts are just-in-time packages. These packages export TypeScript files and are transpiled by the consuming application. My understanding is that these types of packages require a bundler. However, the hono server typically just relies on
tsc
.
https://turborepo.com/docs/core-concepts/internal-packages#compilation-strategies
Is there still a way I can use just-in-time packages with hono?7 Replies
hono does not rely on anything
the hono templates are the ones that rely on tsc
you can use vite or whatever just fine (there is even special support for vite)
hono does nothing weird that wouldn't work with any common javascript toolchain
Hey @Arjix ! Thanks. Maybe I phrased it wrong. I used the hono starter template and that uses
tsc
to create transpiled output and tsx
to run the dev-server. I'm not an expert but JIT packages define their outputs via the exports property of package.json
:
The special part is that typescript is exported directly. So when transpiling the server code I need to be able to resolve that dependency. I don't think tsx
nor tsc
can do that out of the back. How would you go about importing a JIT package in hono?what environment do you have?
node, bun, deno, xxx?
doesn't really matter, as long as the versions are recent, you should be able to directly run the code w/o
tsc
/tsx
e.g. for node, https://nodejs.org/en/learn/typescript/run-nativelyNode.js — Running TypeScript Natively
Node.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.
deno has built-in support for years now, bun had built-in support from the start iirc
if you are using cloudflare workers, then the template will have
vite
configured
did you encounter an issue or are you just theorisingI had some problems but I think this was due to a misconfiguration of
paths
which I can't use in this case. But I now back to using precompiled packages and aggressive caching.
But thanks for your help @Arjix ! I think my question was not very precise or actionable - sorry for that. The gist was that I'm not sure if it's recommended to bundle hono with something like webpack/rollup etc. When the module export points to a typescript file, I'd have to use a bundler or run TS in production (which I'm not comfortable with)."recommended" is a strong word
it's up to someone's preferences, really
hono is not a "framework", just a library
since it's built on web standards, and bundlers are designed for web standards
I can't see it having issues
otherwise, you wouldn't be able to bundle your frontend code, which also uses web standards