Optimize transform speed

This commit is contained in:
2024-01-11 11:04:16 +08:00
parent 309d5892c7
commit 528dff1487
3 changed files with 21 additions and 2 deletions

View File

@@ -9,11 +9,17 @@ class Compiler {
void esbuild.initialize({ worker: true, wasmURL: wasm }).then(() => {
this.init = true
})
} catch (e) {}
} catch (e) {
/* empty */
}
}
transform = (code: string, loader: Loader) =>
new Promise<boolean>((resolve) => {
if (this.init) {
resolve(true)
return
}
const timer = setInterval(() => {
if (this.init) {
clearInterval(timer)