mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
23 lines
490 B
TypeScript
23 lines
490 B
TypeScript
import type _ESBuild from "esbuild-wasm";
|
|
|
|
type ESBuild = typeof _ESBuild;
|
|
|
|
let promise: Promise<ESBuild> | undefined;
|
|
|
|
export function getEsbuild(): Promise<ESBuild> {
|
|
if (!promise) {
|
|
promise = loadEsbuild();
|
|
}
|
|
return promise;
|
|
}
|
|
|
|
async function loadEsbuild(): Promise<ESBuild> {
|
|
const { default: esbuild } = await import("esbuild-wasm");
|
|
|
|
await esbuild.initialize({
|
|
worker: false,
|
|
wasmURL: "https://esm.sh/[email protected]/esbuild.wasm",
|
|
});
|
|
|
|
return esbuild;
|
|
} |