@@ -19,7 +19,7 @@ const transformer = <T extends ts.Node>(_: ts.Program) => {
19
19
if ( match ) {
20
20
const out = path . resolve . replace ( / \* / g, match [ 1 ] ) ;
21
21
const file = slash ( relative ( fileDir , resolve ( baseUrl , out ) ) ) ;
22
- return file ;
22
+ return file [ 0 ] === "." ? file : `./ ${ file } ` ;
23
23
}
24
24
}
25
25
return null ;
@@ -30,36 +30,14 @@ const transformer = <T extends ts.Node>(_: ts.Program) => {
30
30
return ts . visitEachChild ( node , visit , context ) ;
31
31
}
32
32
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 ) ) &&
50
34
node . moduleSpecifier &&
51
35
ts . isStringLiteral ( node . moduleSpecifier )
52
36
) {
53
37
const file = findFileInPaths ( node . moduleSpecifier . text ) ;
54
38
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 ;
63
41
}
64
42
}
65
43
return ts . visitEachChild ( node , visit , context ) ;
0 commit comments