fix transpiler caching, jsx runtime
This commit is contained in:
parent
d320b2d74e
commit
6dde10c2ae
|
|
@ -75,14 +75,15 @@ const transpileCache: Record<string, string> = {}
|
||||||
|
|
||||||
// Transpile the frontend *.ts file at `path` to JavaScript.
|
// Transpile the frontend *.ts file at `path` to JavaScript.
|
||||||
export async function transpile(path: string): Promise<string> {
|
export async function transpile(path: string): Promise<string> {
|
||||||
const code = await Bun.file(path).text()
|
|
||||||
|
|
||||||
const { mtime } = await stat(path)
|
const { mtime } = await stat(path)
|
||||||
const key = `${path}?${mtime}`
|
const key = `${path}?${mtime}`
|
||||||
|
|
||||||
let cached = transpileCache[key]
|
let cached = transpileCache[key]
|
||||||
if (!cached) {
|
if (!cached) {
|
||||||
|
const code = await Bun.file(path).text()
|
||||||
cached = transpiler.transformSync(code)
|
cached = transpiler.transformSync(code)
|
||||||
|
cached = cached.replaceAll(/\bjsxDEV_?\w*\(/g, "jsx(")
|
||||||
|
|
||||||
transpileCache[key] = cached
|
transpileCache[key] = cached
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user