Skip to content

Commit a17e9d1

Browse files
authored
Avoid adding hooks for globalThis in MODULARIZE mode (#22638)
Fixes: #22588
1 parent 463cb3a commit a17e9d1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/runtime_debug.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ function isExportedByForceFilesystem(name) {
5656
* their build, or no symbols that no longer exist.
5757
*/
5858
function hookGlobalSymbolAccess(sym, func) {
59+
#if MODULARIZE && !EXPORT_ES6
60+
// In MODULARIZE mode the generated code runs inside a function scope and not
61+
// the global scope, and JavaScript does not provide access to function scopes
62+
// so we cannot dynamically modify the scrope using `defineProperty` in this
63+
// case.
64+
//
65+
// In this mode we simply ignore requests for `hookGlobalSymbolAccess`. Since
66+
// this is a debug-only feature, skipping it is not major issue.
67+
#else
5968
if (typeof globalThis != 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
6069
Object.defineProperty(globalThis, sym, {
6170
configurable: true,
@@ -65,6 +74,7 @@ function hookGlobalSymbolAccess(sym, func) {
6574
}
6675
});
6776
}
77+
#endif
6878
}
6979

7080
function missingGlobal(sym, msg) {

0 commit comments

Comments
 (0)