@@ -4,15 +4,15 @@ const {
4
4
ObjectCreate,
5
5
StringPrototypeEndsWith,
6
6
} = primordials ;
7
- const CJSLoader = require ( 'internal/modules/cjs/loader' ) ;
8
- const { Module, toRealPath, readPackageScope } = CJSLoader ;
7
+
9
8
const { getOptionValue } = require ( 'internal/options' ) ;
10
9
const path = require ( 'path' ) ;
11
10
12
11
function resolveMainPath ( main ) {
13
12
// Note extension resolution for the main entry point can be deprecated in a
14
13
// future major.
15
14
// Module._findPath is monkey-patchable here.
15
+ const { Module, toRealPath } = require ( 'internal/modules/cjs/loader' ) ;
16
16
let mainPath = Module . _findPath ( path . resolve ( main ) , null , true ) ;
17
17
if ( ! mainPath )
18
18
return ;
@@ -37,6 +37,7 @@ function shouldUseESMLoader(mainPath) {
37
37
const userImports = getOptionValue ( '--import' ) ;
38
38
if ( userLoaders . length > 0 || userImports . length > 0 )
39
39
return true ;
40
+ const { readPackageScope } = require ( 'internal/modules/cjs/loader' ) ;
40
41
// Determine the module format of the main
41
42
if ( mainPath && StringPrototypeEndsWith ( mainPath , '.mjs' ) )
42
43
return true ;
@@ -79,6 +80,7 @@ function executeUserEntryPoint(main = process.argv[1]) {
79
80
runMainESM ( resolvedMain || main ) ;
80
81
} else {
81
82
// Module._load is the monkey-patchable CJS module loader.
83
+ const { Module } = require ( 'internal/modules/cjs/loader' ) ;
82
84
Module . _load ( main , null , true ) ;
83
85
}
84
86
}
0 commit comments