File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -484,9 +484,14 @@ export class ClassLoader {
484484 ) : { packageName : string ; fileName : string ; fileNameReferenced : string } | undefined {
485485 // Handle import paths within the current package
486486 if ( importPath . startsWith ( '.' ) ) {
487+ const fileName = joinFilePath ( filePathDirName ( currentFilePath ) , importPath ) ;
488+ const indexOfExtension = fileName . indexOf ( '.' , fileName . lastIndexOf ( '/' ) ) ;
489+ const fileNameWithoutExtension = indexOfExtension === - 1 ?
490+ fileName :
491+ fileName . slice ( 0 , indexOfExtension ) ;
487492 return {
488493 packageName : currentPackageName ,
489- fileName : joinFilePath ( filePathDirName ( currentFilePath ) , importPath ) ,
494+ fileName : fileNameWithoutExtension ,
490495 fileNameReferenced : currentFilePath ,
491496 } ;
492497 }
Original file line number Diff line number Diff line change @@ -2368,6 +2368,15 @@ export = NS`,
23682368 } ) ;
23692369 } ) ;
23702370
2371+ it ( 'for a local file imported with an extension' , ( ) => {
2372+ expect ( loader . importTargetToAbsolutePath ( 'package' , 'dir/lib/fileA' , './subdir/fileB.js' ) )
2373+ . toEqual ( {
2374+ packageName : 'package' ,
2375+ fileName : normalizeFilePath ( 'dir/lib/subdir/fileB' ) ,
2376+ fileNameReferenced : 'dir/lib/fileA' ,
2377+ } ) ;
2378+ } ) ;
2379+
23712380 it ( 'for a package' , ( ) => {
23722381 resolutionContext . packageNameIndexOverrides [ 'other-package' ] = '/some-dir/index.js' ;
23732382 expect ( loader . importTargetToAbsolutePath ( 'package' , 'dir/lib/fileA' , 'other-package' ) )
You can’t perform that action at this time.
0 commit comments