@@ -19,7 +19,7 @@ const transformer = <T extends ts.Node>(_: ts.Program) => {
1919 if ( match ) {
2020 const out = path . resolve . replace ( / \* / g, match [ 1 ] ) ;
2121 const file = slash ( relative ( fileDir , resolve ( baseUrl , out ) ) ) ;
22- return file ;
22+ return file [ 0 ] === "." ? file : `./ ${ file } ` ;
2323 }
2424 }
2525 return null ;
@@ -30,36 +30,14 @@ const transformer = <T extends ts.Node>(_: ts.Program) => {
3030 return ts . visitEachChild ( node , visit , context ) ;
3131 }
3232 if (
33- ts . isImportDeclaration ( node ) &&
34- ts . isStringLiteral ( node . moduleSpecifier )
35- ) {
36- const file = findFileInPaths ( node . moduleSpecifier . text ) ;
37- if ( file ) {
38- return ts . updateImportDeclaration (
39- node ,
40- node . decorators ,
41- node . modifiers ,
42- node . importClause ,
43- // If it's in the same level or below add the ./
44- ts . createLiteral ( file [ 0 ] === "." ? file : `./${ file } ` )
45- ) ;
46- }
47- }
48- if (
49- ts . isExportDeclaration ( node ) &&
33+ ( ts . isImportDeclaration ( node ) || ts . isExportDeclaration ( node ) ) &&
5034 node . moduleSpecifier &&
5135 ts . isStringLiteral ( node . moduleSpecifier )
5236 ) {
5337 const file = findFileInPaths ( node . moduleSpecifier . text ) ;
5438 if ( file ) {
55- return ts . updateExportDeclaration (
56- node ,
57- node . decorators ,
58- node . modifiers ,
59- node . exportClause ,
60- // If it's in the same level or below add the ./
61- ts . createLiteral ( file [ 0 ] === "." ? file : `./${ file } ` )
62- ) ;
39+ node . moduleSpecifier . text = file ;
40+ return node ;
6341 }
6442 }
6543 return ts . visitEachChild ( node , visit , context ) ;
0 commit comments