summaryrefslogtreecommitdiff
path: root/lib/internal/main/run_main_module.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/main/run_main_module.js')
-rw-r--r--lib/internal/main/run_main_module.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/internal/main/run_main_module.js b/lib/internal/main/run_main_module.js
index eae9042041..ca5d1122c5 100644
--- a/lib/internal/main/run_main_module.js
+++ b/lib/internal/main/run_main_module.js
@@ -6,10 +6,12 @@ const {
prepareMainThreadExecution(true);
-const CJSModule = require('internal/modules/cjs/loader').Module;
-
markBootstrapComplete();
// Note: this loads the module through the ESM loader if the module is
-// determined to be an ES module
-CJSModule.runMain(process.argv[1]);
+// determined to be an ES module. This hangs from the CJS module loader
+// because we currently allow monkey-patching of the module loaders
+// in the preloaded scripts through require('module').
+// runMain here might be monkey-patched by users in --require.
+// XXX: the monkey-patchability here should probably be deprecated.
+require('internal/modules/cjs/loader').Module.runMain(process.argv[1]);