()
| 34 | } |
| 35 | |
| 36 | export async function importWasmModule(): Promise<RootType> { |
| 37 | if (wasmInstance) { |
| 38 | return wasmInstance; |
| 39 | } |
| 40 | if (!wasmLoadPromise) { |
| 41 | wasmLoadPromise = (async () => { |
| 42 | // Use dynamic import() to load ESM modules |
| 43 | // This works in Node.js and Jest (with --experimental-vm-modules) |
| 44 | const wasiShimModule: any = await import(WASI_SHIM_PATH); |
| 45 | const WASIShim = wasiShimModule.WASIShim; |
| 46 | const wasmModule: ModuleType = await import(WASM_MODULE_PATH); |
| 47 | const imports = { |
| 48 | ...new WASIShim().getImportObject(), |
| 49 | 'vercel:python-analysis/host-utils': createHostUtils(), |
| 50 | }; |
| 51 | const instance = await wasmModule.instantiate(getCoreModule, imports); |
| 52 | wasmInstance = instance; |
| 53 | return instance; |
| 54 | })(); |
| 55 | } |
| 56 | return wasmLoadPromise; |
| 57 | } |
no test coverage detected