@@ -79,9 +79,9 @@ import {
79
79
normalizeSlashes ,
80
80
PackageId ,
81
81
packageIdToString ,
82
+ ParsedPatterns ,
82
83
Path ,
83
84
pathIsRelative ,
84
- Pattern ,
85
85
patternText ,
86
86
readJson ,
87
87
removeExtension ,
@@ -1558,7 +1558,7 @@ function tryLoadModuleUsingOptionalResolutionSettings(extensions: Extensions, mo
1558
1558
}
1559
1559
1560
1560
function tryLoadModuleUsingPathsIfEligible ( extensions : Extensions , moduleName : string , loader : ResolutionKindSpecificLoader , state : ModuleResolutionState ) {
1561
- const { baseUrl, paths, configFile } = state . compilerOptions ;
1561
+ const { baseUrl, paths } = state . compilerOptions ;
1562
1562
if ( paths && ! pathIsRelative ( moduleName ) ) {
1563
1563
if ( state . traceEnabled ) {
1564
1564
if ( baseUrl ) {
@@ -1567,7 +1567,7 @@ function tryLoadModuleUsingPathsIfEligible(extensions: Extensions, moduleName: s
1567
1567
trace ( state . host , Diagnostics . paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0 , moduleName ) ;
1568
1568
}
1569
1569
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 ) ;
1571
1571
return tryLoadModuleUsingPaths ( extensions , moduleName , baseDirectory , paths , pathPatterns , loader , /*onlyRecordFailures*/ false , state ) ;
1572
1572
}
1573
1573
}
@@ -2518,7 +2518,8 @@ function loadNodeModuleFromDirectoryWorker(extensions: Extensions, candidate: st
2518
2518
if ( state . traceEnabled ) {
2519
2519
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 ) ;
2520
2520
}
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 ) ;
2522
2523
if ( result ) {
2523
2524
return removeIgnoredPackageId ( result . value ) ;
2524
2525
}
@@ -3112,16 +3113,16 @@ function loadModuleFromSpecificNodeModulesDirectory(extensions: Extensions, modu
3112
3113
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 ) ;
3113
3114
}
3114
3115
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 ) ;
3116
3118
if ( fromPaths ) {
3117
3119
return fromPaths . value ;
3118
3120
}
3119
3121
}
3120
3122
return loader ( extensions , candidate , ! nodeModulesDirectoryExists , state ) ;
3121
3123
}
3122
3124
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 > {
3125
3126
const matchedPattern = matchPatternOrExact ( pathPatterns , moduleName ) ;
3126
3127
if ( matchedPattern ) {
3127
3128
const matchedStar = isString ( matchedPattern ) ? undefined : matchedText ( matchedPattern , moduleName ) ;
0 commit comments