Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"global is not defined" in setImmediate.js on v0.8.16 #290

Open
zhulin2609 opened this issue May 19, 2018 · 10 comments
Open

"global is not defined" in setImmediate.js on v0.8.16 #290

zhulin2609 opened this issue May 19, 2018 · 10 comments

Comments

@zhulin2609
Copy link

No description provided.

@aloha-zzz
Copy link

I have the same problem

@thomassuckow
Copy link

thomassuckow commented Jul 10, 2019

global got renamed to globalThis in the tc39 proposal

Edit:
For what it's worth:

interface Object {
  global: object;
  globalThis: object;
}

function polyfillGlobalThis ():object {
  if (typeof globalThis !== 'undefined') return globalThis
  Object.defineProperty(Object.prototype, 'globalThis', {
    get: function () {
      delete Object.prototype.globalThis
      this.globalThis = this
    },
    configurable: true
  })
  return globalThis
}
polyfillGlobalThis();

function polyfillGlobal ():object {
  if (typeof global !== 'undefined') return global
  Object.defineProperty(Object.prototype, 'global', {
    get: function () {
      delete Object.prototype.global
      this.global = this
    },
    configurable: true
  })
  return global
}
polyfillGlobal();

@frenzzy
Copy link

frenzzy commented Oct 2, 2019

probably to fix this issue need to change this line:

if (global.ErrorUtils) {

to

if (typeof global !== 'undefined' && global.ErrorUtils) {

PR: #355

@Stupidism
Copy link

Any news?

@shiyun
Copy link

shiyun commented Feb 19, 2021

I have the same problem

Me too!

@LukeXF
Copy link

LukeXF commented Apr 10, 2021

Still an issue, any update?

@joriewong
Copy link

Same issue

@k-kyler
Copy link

k-kyler commented Nov 7, 2021

This worked for me.

<script> const global = globalThis; </script>

@lamasagar
Copy link

lamasagar commented Apr 22, 2022

This worked for me.

<script> const global = globalThis; </script>

This worked but can any one explain what this is doing?

@thamizh-qwerty
Copy link

This worked for me.

<script> const global = globalThis; </script>

It does not works in angular + electronJS + contextIsolation = true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests