-
Notifications
You must be signed in to change notification settings - Fork 573
Open
Labels
NeedsHelpCommunity contributions are welcome for this feature!Community contributions are welcome for this feature!enhancement
Description
I am using a gopherjs binary with QuickJS, which uses globalThis for its global. I wonder if it's possible to support globalThis in the prelude to work out of the box with QuickJS.
gopherjs/compiler/prelude/prelude.js
Line 17 in cfa0783
| throw new Error("no global object found"); |
if (typeof window !== "undefined") { /* web page */
$global = window;
} else if (typeof self !== "undefined") { /* web worker */
$global = self;
} else if (typeof global !== "undefined") { /* Node.js */
$global = global;
$global.require = require;
} else if (typeof globalThis !== "undefined") { /* QuickJS */
$global = globalThis;
} else { /* others (e.g. Nashorn) */
$global = this;
}It's not difficult to shim though so not a big deal either way.
https://github.com/wasilibs/go-prettier/blob/main/buildtools/wasm/global.ts#L1
(globalThis as any).self = globalThis;
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
NeedsHelpCommunity contributions are welcome for this feature!Community contributions are welcome for this feature!enhancement