Skip to content

Commit

Permalink
Avoid adding hooks for globalThis in MODULARIZE mode (emscripten-core…
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 authored Sep 30, 2024
1 parent 463cb3a commit a17e9d1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/runtime_debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ function isExportedByForceFilesystem(name) {
* their build, or no symbols that no longer exist.
*/
function hookGlobalSymbolAccess(sym, func) {
#if MODULARIZE && !EXPORT_ES6
// In MODULARIZE mode the generated code runs inside a function scope and not
// the global scope, and JavaScript does not provide access to function scopes
// so we cannot dynamically modify the scrope using `defineProperty` in this
// case.
//
// In this mode we simply ignore requests for `hookGlobalSymbolAccess`. Since
// this is a debug-only feature, skipping it is not major issue.
#else
if (typeof globalThis != 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
Object.defineProperty(globalThis, sym, {
configurable: true,
Expand All @@ -65,6 +74,7 @@ function hookGlobalSymbolAccess(sym, func) {
}
});
}
#endif
}

function missingGlobal(sym, msg) {
Expand Down

0 comments on commit a17e9d1

Please sign in to comment.