Skip to content

Commit 46a118e

Browse files
committed
module: disallow CJS <-> ESM edges in a cycle from require(esm)
nodejs/node#52264
1 parent adbe94f commit 46a118e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

patches/node/pass_all_globals_through_require.patch

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Subject: Pass all globals through "require"
66
(cherry picked from commit 7d015419cb7a0ecfe6728431a4ed2056cd411d62)
77

88
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
9-
index 7bbd59e16330b59f6c71aa8e6ff59659e42f6cee..276ab42c22b796ee07ce66744187adca6a8b8da4 100644
9+
index c284b39b1ac13eaea8776b7b4f457c084dce5fb8..e385702c708048593b51f75db0e00803383b2b42 100644
1010
--- a/lib/internal/modules/cjs/loader.js
1111
+++ b/lib/internal/modules/cjs/loader.js
12-
@@ -148,6 +148,13 @@ const {
12+
@@ -185,6 +185,13 @@ const {
1313
CHAR_FORWARD_SLASH,
1414
} = require('internal/constants');
1515

@@ -23,8 +23,8 @@ index 7bbd59e16330b59f6c71aa8e6ff59659e42f6cee..276ab42c22b796ee07ce66744187adca
2323
const {
2424
isProxy,
2525
} = require('internal/util/types');
26-
@@ -1353,10 +1360,12 @@ Module.prototype._compile = function(content, filename) {
27-
setHasStartedUserCJSExecution();
26+
@@ -1464,10 +1471,12 @@ Module.prototype._compile = function(content, filename, loadAsESM = false) {
27+
this[kIsExecuting] = true;
2828
if (inspectorWrapper) {
2929
result = inspectorWrapper(compiledWrapper, thisValue, exports,
3030
- require, module, filename, dirname);
@@ -36,5 +36,6 @@ index 7bbd59e16330b59f6c71aa8e6ff59659e42f6cee..276ab42c22b796ee07ce66744187adca
3636
+ [exports, require, module, filename,
3737
+ dirname, process, localGlobal, localBuffer]);
3838
}
39+
this[kIsExecuting] = false;
3940
if (requireDepth === 0) { statCache = null; }
40-
return result;
41+

0 commit comments

Comments
 (0)