66fa1f4665
* chore: bump node in DEPS to v20.17.0 * module: disallow CJS <-> ESM edges in a cycle from require(esm) https://github.com/nodejs/node/pull/52264 * src: expose LookupAndCompile with parameters https://github.com/nodejs/node/pull/53886 * src: fix -Wshadow warning https://github.com/nodejs/node/pull/53885 * lib: convert WeakMaps in cjs loader with symbol properties https://github.com/nodejs/node/pull/52095 * src: reduce unnecessary serialization of CLI options in C++ https://github.com/nodejs/node/pull/52451 * build: ensure v8_pointer_compression_sandbox is enabled on 64bit https://github.com/nodejs/node/pull/53884 * lib: improve error message when index not found on cjs https://github.com/nodejs/node/pull/53859 * src,lib: expose getCategoryEnabledBuffer to use on node.http https://github.com/nodejs/node/pull/53602 * deps: update c-ares to v1.32.2 https://github.com/nodejs/node/pull/53865 * chore: update patch indices * deps: update V8 to 12.2 https://github.com/nodejs/node/pull/51362 * stream: Expose DuplexPair API https://github.com/nodejs/node/pull/34111 --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
40 lines
1.8 KiB
Diff
40 lines
1.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Cheng Zhao <zcbenz@gmail.com>
|
|
Date: Sun, 27 Mar 2016 14:42:26 +0900
|
|
Subject: Pass all globals through "require"
|
|
|
|
(cherry picked from commit 7d015419cb7a0ecfe6728431a4ed2056cd411d62)
|
|
|
|
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
|
|
index c284b39b1ac13eaea8776b7b4f457c084dce5fb8..c794751ecd4448119ce33d661e694f83b3323f03 100644
|
|
--- a/lib/internal/modules/cjs/loader.js
|
|
+++ b/lib/internal/modules/cjs/loader.js
|
|
@@ -185,6 +185,13 @@ const {
|
|
CHAR_FORWARD_SLASH,
|
|
} = require('internal/constants');
|
|
|
|
+// Store the "global" variable from global scope into a local scope, so we can
|
|
+// still reference it from this file even after we deleted the "global" variable
|
|
+// from the global scope.
|
|
+const localGlobal = (typeof global !== 'undefined') ? global : undefined;
|
|
+// Do the same for "Buffer".
|
|
+const localBuffer = (typeof Buffer !== 'undefined') ? Buffer : undefined;
|
|
+
|
|
const {
|
|
isProxy,
|
|
} = require('internal/util/types');
|
|
@@ -1464,10 +1471,12 @@ Module.prototype._compile = function(content, filename, loadAsESM = false) {
|
|
this[kIsExecuting] = true;
|
|
if (inspectorWrapper) {
|
|
result = inspectorWrapper(compiledWrapper, thisValue, exports,
|
|
- require, module, filename, dirname);
|
|
+ require, module, filename, dirname,
|
|
+ process, localGlobal, localBuffer);
|
|
} else {
|
|
result = ReflectApply(compiledWrapper, thisValue,
|
|
- [exports, require, module, filename, dirname]);
|
|
+ [exports, require, module, filename,
|
|
+ dirname, process, localGlobal, localBuffer]);
|
|
}
|
|
this[kIsExecuting] = false;
|
|
if (requireDepth === 0) { statCache = null; }
|