BunにはBun.serve()のHTML importという機能があり、HTMLファイルをそのままサーバーのroutesに渡すだけで、JSX/TSXのトランスパイル・バンドル・開発時のホットリロードまで面倒を見てくれます。
本スライドでは、この機能を使ってHono Web APIサーバーとReactフロントエンドを1プロセス・Bunオンリーで動かす最小構成を組み立てます。
from "react-dom/client"; import App from "./App"; const rootElement = document.getElementById("root"); if (!rootElement) { throw new Error('Root element "root" not found'); } createRoot(rootElement).render(<App />); 8
bun-windows-x64 な ど)に変えればクロスコンパイルも可能。 Web APIサーバーとGUIをまとめて1つの実 行ファイルとして配布できる。 Bun bun run compile [11ms] minify -54.83 KB (estimate) [1ms] bundle 27 modules [644ms] compile dist/server.exe ./dist/server.exe Started development server: http://localhost:3000 14