summaryrefslogtreecommitdiff
path: root/ext/node/01_node.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-09-08 22:01:48 +0200
committerGitHub <noreply@github.com>2022-09-08 22:01:48 +0200
commit6c179daff07fe60d478142ea86231a34dc9ee1fd (patch)
tree39ff8701af61eec0674827b4ef62de1d4087e407 /ext/node/01_node.js
parent93cbac69e8a53fbb393fc7a2f12654b223cf01ad (diff)
fix(npm): recursive translation of reexports, remove window global in node code (#15806)
Co-authored-by: David Sherret <dsherret@gmail.com>
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 = {