@@ -4,15 +4,15 @@ const {
44 ObjectCreate,
55 StringPrototypeEndsWith,
66} = primordials ;
7- const CJSLoader = require ( 'internal/modules/cjs/loader' ) ;
8- const { Module, toRealPath, readPackageScope } = CJSLoader ;
7+
98const { getOptionValue } = require ( 'internal/options' ) ;
109const path = require ( 'path' ) ;
1110
1211function resolveMainPath ( main ) {
1312 // Note extension resolution for the main entry point can be deprecated in a
1413 // future major.
1514 // Module._findPath is monkey-patchable here.
15+ const { Module, toRealPath } = require ( 'internal/modules/cjs/loader' ) ;
1616 let mainPath = Module . _findPath ( path . resolve ( main ) , null , true ) ;
1717 if ( ! mainPath )
1818 return ;
@@ -41,6 +41,7 @@ function shouldUseESMLoader(mainPath) {
4141 getOptionValue ( '--experimental-specifier-resolution' ) ;
4242 if ( esModuleSpecifierResolution === 'node' )
4343 return true ;
44+ const { readPackageScope } = require ( 'internal/modules/cjs/loader' ) ;
4445 // Determine the module format of the main
4546 if ( mainPath && StringPrototypeEndsWith ( mainPath , '.mjs' ) )
4647 return true ;
@@ -83,6 +84,7 @@ function executeUserEntryPoint(main = process.argv[1]) {
8384 runMainESM ( resolvedMain || main ) ;
8485 } else {
8586 // Module._load is the monkey-patchable CJS module loader.
87+ const { Module } = require ( 'internal/modules/cjs/loader' ) ;
8688 Module . _load ( main , null , true ) ;
8789 }
8890}
0 commit comments