fbjs icon indicating copy to clipboard operation
fbjs copied to clipboard

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

Open zhulin2609 opened this issue 7 years ago • 10 comments

zhulin2609 avatar May 19 '18 13:05 zhulin2609

I have the same problem

aloha-zzz avatar Jun 10 '18 05:06 aloha-zzz

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();

thomassuckow avatar Jul 10 '19 19:07 thomassuckow

probably to fix this issue need to change this line: https://github.com/facebook/fbjs/blob/35d7693c0908820af5a0ed2635dbae45ab6feeb8/packages/fbjs/src/stubs/ErrorUtils.js#L12 to

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

PR: #355

frenzzy avatar Oct 02 '19 21:10 frenzzy

Any news?

Stupidism avatar Sep 11 '20 06:09 Stupidism

I have the same problem

Me too!

shiyun avatar Feb 19 '21 05:02 shiyun

Still an issue, any update?

LukeXF avatar Apr 10 '21 19:04 LukeXF

Same issue

joriewong avatar Jun 07 '21 08:06 joriewong

This worked for me.

k-kyler avatar Nov 07 '21 09:11 k-kyler

This worked for me.

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

lamasagar avatar Apr 22 '22 03:04 lamasagar

This worked for me.

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

thamizh-qwerty avatar Feb 28 '23 13:02 thamizh-qwerty