@@ -10,7 +10,7 @@ import { couldNotReadDependency, couldNotResolveRequire } from "./diagnostics";
1010import { BuildMode , CompilerOptions } from "../CompilerOptions" ;
1111import { findLuaRequires , LuaRequire } from "./find-lua-requires" ;
1212import { Plugin } from "./plugins" ;
13- import * as picomatch from "picomatch" ;
13+ import picomatch from "picomatch" ;
1414
1515const resolver = resolve . ResolverFactory . createResolver ( {
1616 extensions : [ ".lua" ] ,
@@ -39,8 +39,7 @@ class ResolutionContext {
3939 private readonly plugins : Plugin [ ]
4040 ) {
4141 const unique = [ ...new Set ( options . noResolvePaths ) ] ;
42- const matchers = unique . map ( x => picomatch ( x ) ) ;
43- this . noResolvePaths = matchers ;
42+ this . noResolvePaths = unique . map ( x => picomatch ( x ) ) ;
4443 }
4544
4645 public addAndResolveDependencies ( file : ProcessedFile ) : void {
@@ -215,14 +214,16 @@ class ResolutionContext {
215214 const fileFromPath = this . getFileFromPath ( resolvedPath ) ;
216215 if ( fileFromPath ) return fileFromPath ;
217216
218- if ( this . options . paths && this . options . baseUrl ) {
217+ if ( this . options . paths ) {
219218 // 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 ;
219+ // When baseUrl is not set, resolve paths relative to the tsconfig directory (TS 6.0+ behavior)
220+ const pathsBase =
221+ this . options . baseUrl ??
222+ ( this . options . configFilePath ? path . dirname ( this . options . configFilePath ) : undefined ) ;
223+ if ( pathsBase ) {
224+ const fileFromPaths = this . tryGetModuleNameFromPaths ( dependencyPath , this . options . paths , pathsBase ) ;
225+ if ( fileFromPaths ) return fileFromPaths ;
226+ }
226227 }
227228
228229 // Not a TS file in our project sources, use resolver to check if we can find dependency
0 commit comments