summaryrefslogtreecommitdiff
path: root/ext/node/01_node.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/01_node.js')
-rw-r--r--ext/node/01_node.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/node/01_node.js b/ext/node/01_node.js
index 883932c5d..d33a7c43c 100644
--- a/ext/node/01_node.js
+++ b/ext/node/01_node.js
@@ -10,6 +10,7 @@
ArrayPrototypeFilter,
ObjectEntries,
ObjectCreate,
+ ObjectDefineProperty,
} = window.__bootstrap.primordials;
function assert(cond) {
@@ -82,7 +83,7 @@
const nativeModuleExports = ObjectCreate(null);
const builtinModules = [];
- function initialize(nodeModules) {
+ function initialize(nodeModules, nodeGlobalThisName) {
assert(!initialized);
initialized = true;
for (const [name, exports] of ObjectEntries(nodeModules)) {
@@ -98,6 +99,14 @@
nodeGlobals.setImmediate = nativeModuleExports["timers"].setImmediate;
nodeGlobals.setInterval = nativeModuleExports["timers"].setInterval;
nodeGlobals.setTimeout = nativeModuleExports["timers"].setTimeout;
+
+ // add a hidden global for the esm code to use in order to reliably
+ // get node's globalThis
+ ObjectDefineProperty(globalThis, nodeGlobalThisName, {
+ enumerable: false,
+ writable: false,
+ value: nodeGlobalThis,
+ });
}
window.__bootstrap.internals = {