@@ -613,7 +613,7 @@ function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOpt
613613 prefersTsExtension ( allowedEndings ) ,
614614 ) ;
615615
616- const fromPaths = pathsOnly || fromPackageJsonImports === undefined ? paths && tryGetModuleNameFromPaths ( relativeToBaseUrl , paths , allowedEndings , host , compilerOptions ) : undefined ;
616+ const fromPaths = pathsOnly || fromPackageJsonImports === undefined ? paths && tryGetModuleNameFromPaths ( relativeToBaseUrl , paths , allowedEndings , baseDirectory , getCanonicalFileName , host , compilerOptions ) : undefined ;
617617 if ( pathsOnly ) {
618618 return fromPaths ;
619619 }
@@ -925,10 +925,11 @@ function tryGetModuleNameFromAmbientModule(moduleSymbol: Symbol, checker: TypeCh
925925 }
926926}
927927
928- function tryGetModuleNameFromPaths ( relativeToBaseUrl : string , paths : MapLike < readonly string [ ] > , allowedEndings : ModuleSpecifierEnding [ ] , host : ModuleSpecifierResolutionHost , compilerOptions : CompilerOptions ) : string | undefined {
928+ function tryGetModuleNameFromPaths ( relativeToBaseUrl : string , paths : MapLike < readonly string [ ] > , allowedEndings : ModuleSpecifierEnding [ ] , baseDirectory : string , getCanonicalFileName : GetCanonicalFileName , host : ModuleSpecifierResolutionHost , compilerOptions : CompilerOptions ) : string | undefined {
929929 for ( const key in paths ) {
930930 for ( const patternText of paths [ key ] ) {
931- const pattern = normalizePath ( patternText ) ;
931+ const normalized = normalizePath ( patternText ) ;
932+ const pattern = getRelativePathIfInSameVolume ( normalized , baseDirectory , getCanonicalFileName ) ?? normalized ;
932933 const indexOfStar = pattern . indexOf ( "*" ) ;
933934 // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
934935 // meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution
@@ -1290,6 +1291,8 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCan
12901291 subModuleName ,
12911292 versionPaths . paths ,
12921293 allowedEndings ,
1294+ packageRootPath ,
1295+ getCanonicalFileName ,
12931296 host ,
12941297 options ,
12951298 ) ;
0 commit comments