653d0f009e
* chore: bump node in DEPS to v20.13.0 * crypto: enable NODE_EXTRA_CA_CERTS with BoringSSL https://github.com/nodejs/node/pull/52217 * test: skip test for dynamically linked OpenSSL https://github.com/nodejs/node/pull/52542 * lib, url: add a `windows` option to path parsing https://github.com/nodejs/node/pull/52509 * src: use dedicated routine to compile function for builtin CJS loader https://github.com/nodejs/node/pull/52016 * test: mark test as flaky https://github.com/nodejs/node/pull/52671 * build,tools: add test-ubsan ci https://github.com/nodejs/node/pull/46297 * src: preload function for Environment https://github.com/nodejs/node/pull/51539 * chore: fixup patch indices * deps: update c-ares to 1.28.1 https://github.com/nodejs/node/pull/52285 * chore: handle updated filenames - https://github.com/nodejs/node/pull/51999 - https://github.com/nodejs/node/pull/51927 * chore: bump node in DEPS to v20.13.1 * events: extract addAbortListener for safe internal use https://github.com/nodejs/node/pull/52081 * module: print location of unsettled top-level await in entry points https://github.com/nodejs/node/pull/51999 * fs: add stacktrace to fs/promises https://github.com/nodejs/node/pull/49849 * chore: update patches --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.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 7bbd59e16330b59f6c71aa8e6ff59659e42f6cee..276ab42c22b796ee07ce66744187adca6a8b8da4 100644
|
|
--- a/lib/internal/modules/cjs/loader.js
|
|
+++ b/lib/internal/modules/cjs/loader.js
|
|
@@ -148,6 +148,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');
|
|
@@ -1353,10 +1360,12 @@ Module.prototype._compile = function(content, filename) {
|
|
setHasStartedUserCJSExecution();
|
|
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]);
|
|
}
|
|
if (requireDepth === 0) { statCache = null; }
|
|
return result;
|