@@ -79,9 +79,9 @@ import {
7979 normalizeSlashes ,
8080 PackageId ,
8181 packageIdToString ,
82+ ParsedPatterns ,
8283 Path ,
8384 pathIsRelative ,
84- Pattern ,
8585 patternText ,
8686 readJson ,
8787 removeExtension ,
@@ -1558,7 +1558,7 @@ function tryLoadModuleUsingOptionalResolutionSettings(extensions: Extensions, mo
15581558}
15591559
15601560function tryLoadModuleUsingPathsIfEligible ( extensions : Extensions , moduleName : string , loader : ResolutionKindSpecificLoader , state : ModuleResolutionState ) {
1561- const { baseUrl, paths, configFile } = state . compilerOptions ;
1561+ const { baseUrl, paths } = state . compilerOptions ;
15621562 if ( paths && ! pathIsRelative ( moduleName ) ) {
15631563 if ( state . traceEnabled ) {
15641564 if ( baseUrl ) {
@@ -1567,7 +1567,7 @@ function tryLoadModuleUsingPathsIfEligible(extensions: Extensions, moduleName: s
15671567 trace ( state . host , Diagnostics . paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0 , moduleName ) ;
15681568 }
15691569 const baseDirectory = getPathsBasePath ( state . compilerOptions , state . host ) ! ; // Always defined when 'paths' is defined
1570- const pathPatterns = configFile ?. configFileSpecs ? configFile . configFileSpecs . pathPatterns ||= tryParsePatterns ( paths ) : undefined ;
1570+ const pathPatterns = tryParsePatterns ( paths ) ;
15711571 return tryLoadModuleUsingPaths ( extensions , moduleName , baseDirectory , paths , pathPatterns , loader , /*onlyRecordFailures*/ false , state ) ;
15721572 }
15731573}
@@ -2518,7 +2518,8 @@ function loadNodeModuleFromDirectoryWorker(extensions: Extensions, candidate: st
25182518 if ( state . traceEnabled ) {
25192519 trace ( state . host , Diagnostics . package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2 , versionPaths . version , version , moduleName ) ;
25202520 }
2521- const result = tryLoadModuleUsingPaths ( extensions , moduleName , candidate , versionPaths . paths , /*pathPatterns*/ undefined , loader , onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex , state ) ;
2521+ const pathPatterns = tryParsePatterns ( versionPaths . paths ) ;
2522+ const result = tryLoadModuleUsingPaths ( extensions , moduleName , candidate , versionPaths . paths , pathPatterns , loader , onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex , state ) ;
25222523 if ( result ) {
25232524 return removeIgnoredPackageId ( result . value ) ;
25242525 }
@@ -3112,16 +3113,16 @@ function loadModuleFromSpecificNodeModulesDirectory(extensions: Extensions, modu
31123113 trace ( state . host , Diagnostics . package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2 , versionPaths . version , version , rest ) ;
31133114 }
31143115 const packageDirectoryExists = nodeModulesDirectoryExists && directoryProbablyExists ( packageDirectory , state . host ) ;
3115- const fromPaths = tryLoadModuleUsingPaths ( extensions , rest , packageDirectory , versionPaths . paths , /*pathPatterns*/ undefined , loader , ! packageDirectoryExists , state ) ;
3116+ const pathPatterns = tryParsePatterns ( versionPaths . paths ) ;
3117+ const fromPaths = tryLoadModuleUsingPaths ( extensions , rest , packageDirectory , versionPaths . paths , pathPatterns , loader , ! packageDirectoryExists , state ) ;
31163118 if ( fromPaths ) {
31173119 return fromPaths . value ;
31183120 }
31193121 }
31203122 return loader ( extensions , candidate , ! nodeModulesDirectoryExists , state ) ;
31213123}
31223124
3123- function tryLoadModuleUsingPaths ( extensions : Extensions , moduleName : string , baseDirectory : string , paths : MapLike < string [ ] > , pathPatterns : readonly ( string | Pattern ) [ ] | undefined , loader : ResolutionKindSpecificLoader , onlyRecordFailures : boolean , state : ModuleResolutionState ) : SearchResult < Resolved > {
3124- pathPatterns ||= tryParsePatterns ( paths ) ;
3125+ function tryLoadModuleUsingPaths ( extensions : Extensions , moduleName : string , baseDirectory : string , paths : MapLike < string [ ] > , pathPatterns : ParsedPatterns , loader : ResolutionKindSpecificLoader , onlyRecordFailures : boolean , state : ModuleResolutionState ) : SearchResult < Resolved > {
31253126 const matchedPattern = matchPatternOrExact ( pathPatterns , moduleName ) ;
31263127 if ( matchedPattern ) {
31273128 const matchedStar = isString ( matchedPattern ) ? undefined : matchedText ( matchedPattern , moduleName ) ;
0 commit comments