summaryrefslogtreecommitdiff
path: root/lib/internal/bootstrap/pre_execution.js
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-04-17 23:21:25 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2019-04-22 17:30:09 +0800
commit7c816b7588f0e2910bcef5db48f71296cd3b67c2 (patch)
tree3790a650c6b582fb6be11946e1c63d538351b1ff /lib/internal/bootstrap/pre_execution.js
parent528d100394ab45dd62141e010e53722accd5826d (diff)
downloadandroid-node-v8-7c816b7588f0e2910bcef5db48f71296cd3b67c2.tar.gz
android-node-v8-7c816b7588f0e2910bcef5db48f71296cd3b67c2.tar.bz2
android-node-v8-7c816b7588f0e2910bcef5db48f71296cd3b67c2.zip
module: explicitly initialize CJS loader
Explicitly initialize the CJS loader with `module._initPaths()` instead of making it a side-effect of requiring `internal/modules/cjs/loader` - that makes it harder to reason about when it's safe to load `internal/modules/cjs/loader`. PR-URL: https://github.com/nodejs/node/pull/27313 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/internal/bootstrap/pre_execution.js')
-rw-r--r--lib/internal/bootstrap/pre_execution.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index 6b1e3fb213..93ede41419 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -48,6 +48,7 @@ function prepareMainThreadExecution(expandArgv1 = false) {
initializeDeprecations();
initializeFrozenIntrinsics();
+ initializeCJSLoader();
initializeESMLoader();
loadPreloadModules();
}
@@ -336,6 +337,10 @@ function initializePolicy() {
}
}
+function initializeCJSLoader() {
+ require('internal/modules/cjs/loader')._initPaths();
+}
+
function initializeESMLoader() {
const experimentalModules = getOptionValue('--experimental-modules');
const experimentalVMModules = getOptionValue('--experimental-vm-modules');
@@ -397,5 +402,6 @@ module.exports = {
loadPreloadModules,
setupTraceCategoryState,
setupInspectorHooks,
- initializeReport
+ initializeReport,
+ initializeCJSLoader
};