Migrate core.global.js to named exports (#5451)

This is part of #5153 but is being prioritised because we want remove
the declareLegacyNamespace calls from the core/utils/*.js modules and
then reexport them explicitly via utils.js, and it turns out that
doing so results in the exports object of this module being passed to
Object.freeze - which fails on the global object, which can't be made
non-extensible!

The new name chosen for the former default export is globalThis, since
it is intended to have the same value as the global variable of that
name; see:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
This commit is contained in:
Christopher Allen
2021-09-14 14:39:29 +01:00
committed by GitHub
parent 09fb59f6ee
commit f9d0caa112
11 changed files with 38 additions and 33 deletions

View File

@@ -42,7 +42,7 @@ Blockly.JavaScript.addReservedWords(
// Magic variable.
'arguments,' +
// Everything in the current environment (835 items in Chrome, 104 in Node).
Object.getOwnPropertyNames(Blockly.utils.global).join(','));
Object.getOwnPropertyNames(Blockly.utils.global.globalThis).join(','));
/**
* Order of operation ENUMs.