diff --git a/src/bindings/js.ts b/src/bindings/js.ts index a0590e0ab0..52335d68c8 100644 --- a/src/bindings/js.ts +++ b/src/bindings/js.ts @@ -871,9 +871,9 @@ export class JSBuilder extends ExportsWalker { sb.push(` } = await (async url => instantiate( await ( - typeof globalThis.fetch === "function" - ? WebAssembly.compileStreaming(globalThis.fetch(url)) - : WebAssembly.compile(await (await import("node:fs/promises")).readFile(url)) + globalThis.fetch && globalThis.WebAssembly.compileStreaming + ? globalThis.WebAssembly.compileStreaming(globalThis.fetch(url)) + : globalThis.WebAssembly.compile(await (await import("node:fs/promises")).readFile(url)) ), { `); let needsMaybeDefault = false; diff --git a/tests/compiler/bindings/esm.debug.js b/tests/compiler/bindings/esm.debug.js index 639841f351..19596d561d 100644 --- a/tests/compiler/bindings/esm.debug.js +++ b/tests/compiler/bindings/esm.debug.js @@ -371,9 +371,9 @@ export const { internrefFunction } = await (async url => instantiate( await ( - typeof globalThis.fetch === "function" - ? WebAssembly.compileStreaming(globalThis.fetch(url)) - : WebAssembly.compile(await (await import("node:fs/promises")).readFile(url)) + globalThis.fetch && globalThis.WebAssembly.compileStreaming + ? globalThis.WebAssembly.compileStreaming(globalThis.fetch(url)) + : globalThis.WebAssembly.compile(await (await import("node:fs/promises")).readFile(url)) ), { } ))(new URL("esm.debug.wasm", import.meta.url)); diff --git a/tests/compiler/bindings/esm.release.js b/tests/compiler/bindings/esm.release.js index 4f5fde306c..9097776036 100644 --- a/tests/compiler/bindings/esm.release.js +++ b/tests/compiler/bindings/esm.release.js @@ -371,9 +371,9 @@ export const { internrefFunction } = await (async url => instantiate( await ( - typeof globalThis.fetch === "function" - ? WebAssembly.compileStreaming(globalThis.fetch(url)) - : WebAssembly.compile(await (await import("node:fs/promises")).readFile(url)) + globalThis.fetch && globalThis.WebAssembly.compileStreaming + ? globalThis.WebAssembly.compileStreaming(globalThis.fetch(url)) + : globalThis.WebAssembly.compile(await (await import("node:fs/promises")).readFile(url)) ), { } ))(new URL("esm.release.wasm", import.meta.url));