fix: better handle wasm loading on node and browser
This commit is contained in:
parent
a9e94ba896
commit
23c8244a68
|
@ -1,5 +1,5 @@
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import baoWasm from "./wasm/bao.wasm";
|
import baoWasm from "./wasm.js";
|
||||||
import Go from "./go_wasm.js";
|
import Go from "./go_wasm.js";
|
||||||
|
|
||||||
export async function getVerifiableStream(
|
export async function getVerifiableStream(
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
import isNode from "detect-node";
|
||||||
|
export default async function (imports) {
|
||||||
|
if (isNode) {
|
||||||
|
const fs = await import("fs/promises");
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
const wasmPath = new URL("wasm/bao.wasm", import.meta.url);
|
||||||
|
|
||||||
|
const wasm = await fs.readFile(wasmPath);
|
||||||
|
|
||||||
|
return WebAssembly.instantiate(wasm, imports);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
return await import("./wasm/bao.wasm");
|
||||||
|
}
|
Loading…
Reference in New Issue