honojs-middleware/packages/bun-transpiler
Jonathan Haines b62061faec
chore: update vitest to v3.2 (#1220)
2025-06-20 06:59:04 +09:00
..
src refactor(bun-transpiler): enable isolated declarations (#1193) 2025-06-09 18:10:30 +09:00
CHANGELOG.md Version Packages (#1206) 2025-06-09 19:05:17 +09:00
README.md chore: add coverage badges (#1023) 2025-03-19 17:53:11 +09:00
package.json chore: update vitest to v3.2 (#1220) 2025-06-20 06:59:04 +09:00
tsconfig.build.json refactor(tsconfig): use `configDir` (#1238) 2025-06-19 16:52:41 +09:00
tsconfig.json refactor: composite build (#1230) 2025-06-16 11:23:47 +09:00
tsconfig.spec.json refactor(tsconfig): use `configDir` (#1238) 2025-06-19 16:52:41 +09:00

README.md

Bun Transpiler middleware for Hono

codecov

The Bun Transpiler middleware is a Hono middleware designed to transpile content such as TypeScript or TSX. You can place your script written in TypeScript in a directory and serve it using serveStatic. When you apply this middleware, your script will automatically be served transpiled into JavaScript code.

This middleware works only with Bun.

Usage

Installation

npm i @hono/bun-transpiler

Example

import { Hono } from 'hono'
import { serveStatic } from 'hono/bun'
import { bunTranspiler } from '@hono/bun-transpiler'

const app = new Hono()

app.get('/static/:scriptName{.+.tsx?}', bunTranspiler())
app.get('/static/*', serveStatic({ root: './' }))

export default app

Notes

  • This middleware does not have a cache feature. If you want to cache the transpiled code, use Cache Middleware or your own custom middleware.

Author

Florian Kapaun https://github.com/floriankapaun

Heavily inspired by esbuild-transpiler by Andres C. Rodriguez and Yusuke Wada.

License

MIT