@@ -162,6 +162,7 @@ function stat(filename) {
162
162
}
163
163
return result ;
164
164
}
165
+ Module . _stat = stat ;
165
166
166
167
function updateChildren ( parent , child , scan ) {
167
168
const children = parent ?. children ;
@@ -334,6 +335,7 @@ function readPackage(requestPath) {
334
335
throw e ;
335
336
}
336
337
}
338
+ Module . _readPackage = readPackage ;
337
339
338
340
function readPackageScope ( checkPath ) {
339
341
const rootSeparatorIndex = StringPrototypeIndexOf ( checkPath , sep ) ;
@@ -343,7 +345,7 @@ function readPackageScope(checkPath) {
343
345
checkPath = StringPrototypeSlice ( checkPath , 0 , separatorIndex ) ;
344
346
if ( StringPrototypeEndsWith ( checkPath , sep + 'node_modules' ) )
345
347
return false ;
346
- const pjson = readPackage ( checkPath + sep ) ;
348
+ const pjson = Module . _readPackage ( checkPath + sep ) ;
347
349
if ( pjson ) return {
348
350
data : pjson ,
349
351
path : checkPath ,
@@ -353,7 +355,7 @@ function readPackageScope(checkPath) {
353
355
}
354
356
355
357
function tryPackage ( requestPath , exts , isMain , originalPath ) {
356
- const pkg = readPackage ( requestPath ) ?. main ;
358
+ const pkg = Module . _readPackage ( requestPath ) ?. main ;
357
359
358
360
if ( ! pkg ) {
359
361
return tryExtensions ( path . resolve ( requestPath , 'index' ) , exts , isMain ) ;
@@ -399,7 +401,7 @@ const realpathCache = new SafeMap();
399
401
// keep symlinks intact, otherwise resolve to the
400
402
// absolute realpath.
401
403
function tryFile ( requestPath , isMain ) {
402
- const rc = stat ( requestPath ) ;
404
+ const rc = Module . _stat ( requestPath ) ;
403
405
if ( rc !== 0 ) return ;
404
406
if ( preserveSymlinks && ! isMain ) {
405
407
return path . resolve ( requestPath ) ;
@@ -493,7 +495,7 @@ function resolveExports(nmPath, request) {
493
495
if ( ! name )
494
496
return ;
495
497
const pkgPath = path . resolve ( nmPath , name ) ;
496
- const pkg = readPackage ( pkgPath ) ;
498
+ const pkg = Module . _readPackage ( pkgPath ) ;
497
499
if ( pkg ?. exports != null ) {
498
500
try {
499
501
return finalizeEsmResolution ( packageExportsResolve (
@@ -533,7 +535,7 @@ Module._findPath = function(request, paths, isMain) {
533
535
for ( let i = 0 ; i < paths . length ; i ++ ) {
534
536
// Don't search further if path doesn't exist
535
537
const curPath = paths [ i ] ;
536
- if ( curPath && stat ( curPath ) < 1 ) continue ;
538
+ if ( curPath && Module . _stat ( curPath ) < 1 ) continue ;
537
539
538
540
if ( ! absoluteRequest ) {
539
541
const exportsResolved = resolveExports ( curPath , request ) ;
@@ -544,7 +546,7 @@ Module._findPath = function(request, paths, isMain) {
544
546
const basePath = path . resolve ( curPath , request ) ;
545
547
let filename ;
546
548
547
- const rc = stat ( basePath ) ;
549
+ const rc = Module . _stat ( basePath ) ;
548
550
if ( ! trailingSlash ) {
549
551
if ( rc === 0 ) { // File.
550
552
if ( ! isMain ) {
0 commit comments