Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Conversation

Josh-Cena
Copy link
Contributor

Fix #24. See also facebook/docusaurus#6915

I'm not sure if there are significant risks in doing so, but it certainly looks more scalable than monkey-patching each useful global to the global scope. I'm also fine with putting this behind an opt-in flag, but after all, simply merging all enumerable properties on global doesn't seem very useful.

@Josh-Cena
Copy link
Contributor Author

/ping @pierrec Really appreciate it if you can take a look and give feedback on how we can properly address this

@pierrec pierrec merged commit 7f0ebb2 into pierrec:master Mar 22, 2022
@Josh-Cena Josh-Cena deleted the include-non-enum-props branch March 22, 2022 07:01
@slorber
Copy link

slorber commented Mar 23, 2022

Reporting 2 issues we have on Docusaurus with the new version:

  • forwarding globalThis: ReferenceError: Prism is not defined (this might be Docusaurus's fault)
  • forwarding Object: TypeError: chalk_1.default.bold is not a function (don't know why)

I don't know if this PR is safe by default but I suggest providing the ability to at least exclude some globals. (tried scope with undefined values and didn't work)

Here's the list of globals before:

[
  "global",
  "clearInterval",
  "clearTimeout",
  "setInterval",
  "setTimeout",
  "queueMicrotask",
  "performance",
  "clearImmediate",
  "setImmediate",
  "__extends",
  "__assign",
  "__rest",
  "__decorate",
  "__param",
  "__metadata",
  "__awaiter",
  "__generator",
  "__exportStar",
  "__createBinding",
  "__values",
  "__read",
  "__spread",
  "__spreadArrays",
  "__spreadArray",
  "__await",
  "__asyncGenerator",
  "__asyncDelegator",
  "__asyncValues",
  "__makeTemplateObject",
  "__importStar",
  "__importDefault",
  "__classPrivateFieldGet",
  "__classPrivateFieldSet",
  "consola",
  "console",
  "process",
  "URL"
]

And here's the list after:

[
  "Object",
  "Function",
  "Array",
  "Number",
  "parseFloat",
  "parseInt",
  "Infinity",
  "NaN",
  "undefined",
  "Boolean",
  "String",
  "Symbol",
  "Date",
  "Promise",
  "RegExp",
  "Error",
  "AggregateError",
  "EvalError",
  "RangeError",
  "ReferenceError",
  "SyntaxError",
  "TypeError",
  "URIError",
  "globalThis",
  "JSON",
  "Math",
  "console",
  "Intl",
  "ArrayBuffer",
  "Uint8Array",
  "Int8Array",
  "Uint16Array",
  "Int16Array",
  "Uint32Array",
  "Int32Array",
  "Float32Array",
  "Float64Array",
  "Uint8ClampedArray",
  "BigUint64Array",
  "BigInt64Array",
  "DataView",
  "Map",
  "BigInt",
  "Set",
  "WeakMap",
  "WeakSet",
  "Proxy",
  "Reflect",
  "FinalizationRegistry",
  "WeakRef",
  "decodeURI",
  "decodeURIComponent",
  "encodeURI",
  "encodeURIComponent",
  "escape",
  "unescape",
  "eval",
  "isFinite",
  "isNaN",
  "global",
  "process",
  "Buffer",
  "atob",
  "btoa",
  "URL",
  "URLSearchParams",
  "TextEncoder",
  "TextDecoder",
  "AbortController",
  "AbortSignal",
  "EventTarget",
  "Event",
  "MessageChannel",
  "MessagePort",
  "MessageEvent",
  "clearInterval",
  "clearTimeout",
  "setInterval",
  "setTimeout",
  "queueMicrotask",
  "performance",
  "clearImmediate",
  "setImmediate",
  "SharedArrayBuffer",
  "Atomics",
  "WebAssembly",
  "__extends",
  "__assign",
  "__rest",
  "__decorate",
  "__param",
  "__metadata",
  "__awaiter",
  "__generator",
  "__exportStar",
  "__createBinding",
  "__values",
  "__read",
  "__spread",
  "__spreadArrays",
  "__spreadArray",
  "__await",
  "__asyncGenerator",
  "__asyncDelegator",
  "__asyncValues",
  "__makeTemplateObject",
  "__importStar",
  "__importDefault",
  "__classPrivateFieldGet",
  "__classPrivateFieldSet",
  "consola"
]

@Josh-Cena
Copy link
Contributor Author

Josh-Cena commented Mar 23, 2022

@slorber The second one is unrelated, it's because of custom JS transpilers and ESM interop problems. But I can indeed reproduce this first problem now, I shouldn't have forwarded anything in the ES standard (and hence already in the sandbox scope)...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Buffer is undefined with includeGlobals: true

3 participants