@@ -784,6 +784,7 @@ function installModuleLoaderOverrides() {
784784 const {
785785 legacyMainResolveExtensions,
786786 legacyMainResolveExtensionsIndexes,
787+ kLoaderOverrideNoResult,
787788 setLoaderOverrides,
788789 } = require ( 'internal/modules/helpers' ) ;
789790 const { kResolvedByMainIndexNode } = legacyMainResolveExtensionsIndexes ;
@@ -854,12 +855,12 @@ function installModuleLoaderOverrides() {
854855 const r = findVFS ( jsonPath ) ;
855856 if ( r === null ) return undefined ;
856857 const { vfs } = r ;
857- if ( vfsStat ( vfs , jsonPath ) !== 0 ) return undefined ;
858+ if ( vfsStat ( vfs , jsonPath ) !== 0 ) return kLoaderOverrideNoResult ;
858859 let content ;
859860 try {
860861 content = vfs . readFileSync ( jsonPath ) ;
861862 } catch {
862- return undefined ;
863+ return kLoaderOverrideNoResult ;
863864 }
864865 // Both CJS and ESM raise ERR_INVALID_PACKAGE_CONFIG since
865866 // nodejs/node#48606.
@@ -870,7 +871,7 @@ function installModuleLoaderOverrides() {
870871 const r = findVFS ( checkPath ) ;
871872 if ( r === null ) return undefined ;
872873 const found = findVFSPackageJSON ( r . vfs , checkPath , r . normalized ) ;
873- return found . tuple ;
874+ return found . tuple ?? kLoaderOverrideNoResult ;
874875 } ,
875876 getPackageScopeConfig ( resolved ) {
876877 let filePath ;
@@ -908,7 +909,7 @@ function installModuleLoaderOverrides() {
908909 const type = found . tuple [ 2 ] ;
909910 if ( type === 'module' || type === 'commonjs' ) return type ;
910911 }
911- return undefined ;
912+ return kLoaderOverrideNoResult ;
912913 } ,
913914 } ) ;
914915}
0 commit comments