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?
Turborepo
Internal Packages | Turborepo
Learn how to build Internal Packages in your monorepo.
7 Replies
Arjix
Arjix4mo ago
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
florian.jsx
florian.jsxOP4mo ago
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:
"exports": {
"./button": "./src/button.tsx",
"./card": "./src/card.tsx"
},
"exports": {
"./button": "./src/button.tsx",
"./card": "./src/card.tsx"
},
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?
Arjix
Arjix4mo ago
what environment do you have? node, bun, deno, xxx?
Arjix
Arjix4mo ago
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-natively
Node.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.
Arjix
Arjix4mo ago
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 theorising
florian.jsx
florian.jsxOP4mo ago
I 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).
Arjix
Arjix4mo ago
"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

Did you find this page helpful?