Skip to content
Snippets Groups Projects
Commit 1061369a authored by Cheng Shao's avatar Cheng Shao :beach:
Browse files

wasm: fix dyld setImmediate usage in browser

The wasm dyld script used to only run in node and directly uses
setImmediate in globalThis. In case of browsers, it needs to import
setImmediate from the prelude, hence this commit.

(cherry picked from commit 9a697181)
(cherry picked from commit 5f261dcd)
parent e0abbbda
No related branches found
No related tags found
No related merge requests found
...@@ -91,7 +91,7 @@ import fs from "node:fs"; ...@@ -91,7 +91,7 @@ import fs from "node:fs";
import path from "node:path"; import path from "node:path";
import stream from "node:stream"; import stream from "node:stream";
import { WASI } from "node:wasi"; import { WASI } from "node:wasi";
import { JSValManager } from "./prelude.mjs"; import { JSValManager, setImmediate } from "./prelude.mjs";
import { parseRecord, parseSections } from "./post-link.mjs"; import { parseRecord, parseSections } from "./post-link.mjs";
// Make a consumer callback from a buffer. See Parser class // Make a consumer callback from a buffer. See Parser class
......
...@@ -39,7 +39,7 @@ export class JSValManager { ...@@ -39,7 +39,7 @@ export class JSValManager {
// To benchmark different setImmediate() implementations in the // To benchmark different setImmediate() implementations in the
// browser, use https://github.com/jphpsf/setImmediate-shim-demo as a // browser, use https://github.com/jphpsf/setImmediate-shim-demo as a
// starting point. // starting point.
const setImmediate = await (async () => { export const setImmediate = await (async () => {
// node, bun, or other scripts might have set this up in the browser // node, bun, or other scripts might have set this up in the browser
if (globalThis.setImmediate) { if (globalThis.setImmediate) {
return globalThis.setImmediate; return globalThis.setImmediate;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment