Thanks for the new method!
In fengari we currently use https://github.com/fengari-lua/fengari-interop/blob/8e59efb7...
const global_env = (function() {
/* global WorkerGlobalScope */ /* see https://github.com/sindresorhus/globals/issues/127 */
if (typeof process !== "undefined") {
/* node */
return global;
} else if (typeof window !== "undefined") {
/* browser window */
return window;
} else if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
/* web worker */
return self;
} else {
/* unknown global env */
return (0, eval)('this'); /* use non-strict mode to get global env */
}
})();
I created https://github.com/fengari-lua/fengari-interop/issues/45 to track.