Skip to content

Commit a835094

Browse files
authored
fix: Fix bindings feature test on Node.js 18 (#2274)
1 parent 21cb8bb commit a835094

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

Diff for: src/bindings/js.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -871,9 +871,9 @@ export class JSBuilder extends ExportsWalker {
871871
sb.push(`
872872
} = await (async url => instantiate(
873873
await (
874-
typeof globalThis.fetch === "function"
875-
? WebAssembly.compileStreaming(globalThis.fetch(url))
876-
: WebAssembly.compile(await (await import("node:fs/promises")).readFile(url))
874+
globalThis.fetch && globalThis.WebAssembly.compileStreaming
875+
? globalThis.WebAssembly.compileStreaming(globalThis.fetch(url))
876+
: globalThis.WebAssembly.compile(await (await import("node:fs/promises")).readFile(url))
877877
), {
878878
`);
879879
let needsMaybeDefault = false;

Diff for: tests/compiler/bindings/esm.debug.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,9 @@ export const {
371371
internrefFunction
372372
} = await (async url => instantiate(
373373
await (
374-
typeof globalThis.fetch === "function"
375-
? WebAssembly.compileStreaming(globalThis.fetch(url))
376-
: WebAssembly.compile(await (await import("node:fs/promises")).readFile(url))
374+
globalThis.fetch && globalThis.WebAssembly.compileStreaming
375+
? globalThis.WebAssembly.compileStreaming(globalThis.fetch(url))
376+
: globalThis.WebAssembly.compile(await (await import("node:fs/promises")).readFile(url))
377377
), {
378378
}
379379
))(new URL("esm.debug.wasm", import.meta.url));

Diff for: tests/compiler/bindings/esm.release.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,9 @@ export const {
371371
internrefFunction
372372
} = await (async url => instantiate(
373373
await (
374-
typeof globalThis.fetch === "function"
375-
? WebAssembly.compileStreaming(globalThis.fetch(url))
376-
: WebAssembly.compile(await (await import("node:fs/promises")).readFile(url))
374+
globalThis.fetch && globalThis.WebAssembly.compileStreaming
375+
? globalThis.WebAssembly.compileStreaming(globalThis.fetch(url))
376+
: globalThis.WebAssembly.compile(await (await import("node:fs/promises")).readFile(url))
377377
), {
378378
}
379379
))(new URL("esm.release.wasm", import.meta.url));

0 commit comments

Comments
 (0)