Open
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
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;