File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -41,12 +41,17 @@ const generateTransformer = (sourceFile) => {
41
41
// Node is the relative path of an import or export
42
42
if ( parentNodeIsExportOrImport && isStringLiteral ( node ) ) {
43
43
const relativePathWithQuotes = node . getFullText ( sourceFile ) . trimStart ( )
44
- const relativePathWithoutQuotes = relativePathWithQuotes . substring ( 1 , relativePathWithQuotes . length - 1 )
44
+ let relativePathWithoutQuotes = relativePathWithQuotes . substring ( 1 , relativePathWithQuotes . length - 1 )
45
45
46
46
if ( relativePathWithoutQuotes . includes ( ".js" ) ) {
47
47
return node
48
48
}
49
49
50
+ // "./" -> "."
51
+ if ( relativePathWithoutQuotes . endsWith ( `/` ) ) {
52
+ relativePathWithoutQuotes = relativePathWithoutQuotes . substring ( 0 , relativePathWithoutQuotes . length - 1 )
53
+ }
54
+
50
55
const fullImportPath = join ( pathWithoutFileName , relativePathWithoutQuotes ) ;
51
56
52
57
// Append .js or index.js to all imports
@@ -55,10 +60,17 @@ const generateTransformer = (sourceFile) => {
55
60
}
56
61
else if ( existsDtsOrJs ( fullImportPath , "index" ) ) {
57
62
node = context . factory . createStringLiteral ( `${ relativePathWithoutQuotes } /index.js` )
63
+
58
64
}
59
65
else {
60
66
throw new Error ( `Can't fix TypeScript paths: ${ node . getFullText ( sourceFile ) } ` )
61
67
}
68
+
69
+ const text = /** @type {ts.StringLiteral } */ ( node ) . text
70
+ if ( text . includes ( `//` ) ) {
71
+ throw new Error ( `Error "${ text } "` )
72
+ }
73
+
62
74
}
63
75
64
76
return node
You can’t perform that action at this time.
0 commit comments