fix transpiler caching, jsx runtime

This commit is contained in:
Chris Wanstrath 2025-09-27 16:52:40 -07:00
parent d320b2d74e
commit 6dde10c2ae

View File

@ -75,14 +75,15 @@ const transpileCache: Record<string, string> = {}
// Transpile the frontend *.ts file at `path` to JavaScript.
export async function transpile(path: string): Promise<string> {
const code = await Bun.file(path).text()
const { mtime } = await stat(path)
const key = `${path}?${mtime}`
let cached = transpileCache[key]
if (!cached) {
const code = await Bun.file(path).text()
cached = transpiler.transformSync(code)
cached = cached.replaceAll(/\bjsxDEV_?\w*\(/g, "jsx(")
transpileCache[key] = cached
}