@@ -27,7 +27,7 @@ interface ResolutionResult {
2727}
2828
2929class ResolutionContext {
30- private noResolvePaths : picomatch . Matcher [ ] ;
30+ private noResolvePaths : picomatch . Glob [ ] ;
3131
3232 public diagnostics : ts . Diagnostic [ ] = [ ] ;
3333 public resolvedFiles = new Map < string , ProcessedFile > ( ) ;
@@ -38,9 +38,7 @@ class ResolutionContext {
3838 private readonly emitHost : EmitHost ,
3939 private readonly plugins : Plugin [ ]
4040 ) {
41- const unique = [ ...new Set ( options . noResolvePaths ) ] ;
42- const matchers = unique . map ( x => picomatch ( x ) ) ;
43- this . noResolvePaths = matchers ;
41+ this . noResolvePaths = [ ...new Set ( options . noResolvePaths ) ] ;
4442 }
4543
4644 public addAndResolveDependencies ( file : ProcessedFile ) : void {
@@ -73,7 +71,7 @@ class ResolutionContext {
7371 return ;
7472 }
7573
76- if ( this . noResolvePaths . find ( isMatch => isMatch ( required . requirePath ) ) ) {
74+ if ( this . noResolvePaths . find ( glob => picomatch . isMatch ( required . requirePath , glob ) ) ) {
7775 if ( this . options . tstlVerbose ) {
7876 console . log (
7977 `Skipping module resolution of ${ required . requirePath } as it is in the tsconfig noResolvePaths.`
@@ -215,14 +213,16 @@ class ResolutionContext {
215213 const fileFromPath = this . getFileFromPath ( resolvedPath ) ;
216214 if ( fileFromPath ) return fileFromPath ;
217215
218- if ( this . options . paths && this . options . baseUrl ) {
216+ if ( this . options . paths ) {
219217 // If no file found yet and paths are present, try to find project file via paths mappings
220- const fileFromPaths = this . tryGetModuleNameFromPaths (
221- dependencyPath ,
222- this . options . paths ,
223- this . options . baseUrl
224- ) ;
225- if ( fileFromPaths ) return fileFromPaths ;
218+ // When baseUrl is not set, resolve paths relative to the tsconfig directory (TS 6.0+ behavior)
219+ const pathsBase =
220+ this . options . baseUrl ??
221+ ( this . options . configFilePath ? path . dirname ( this . options . configFilePath ) : undefined ) ;
222+ if ( pathsBase ) {
223+ const fileFromPaths = this . tryGetModuleNameFromPaths ( dependencyPath , this . options . paths , pathsBase ) ;
224+ if ( fileFromPaths ) return fileFromPaths ;
225+ }
226226 }
227227
228228 // Not a TS file in our project sources, use resolver to check if we can find dependency
0 commit comments