File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,12 +41,17 @@ const generateTransformer = (sourceFile) => {
4141 // Node is the relative path of an import or export
4242 if ( parentNodeIsExportOrImport && isStringLiteral ( node ) ) {
4343 const relativePathWithQuotes = node . getFullText ( sourceFile ) . trimStart ( )
44- const relativePathWithoutQuotes = relativePathWithQuotes . substring ( 1 , relativePathWithQuotes . length - 1 )
44+ let relativePathWithoutQuotes = relativePathWithQuotes . substring ( 1 , relativePathWithQuotes . length - 1 )
4545
4646 if ( relativePathWithoutQuotes . includes ( ".js" ) ) {
4747 return node
4848 }
4949
50+ // "./" -> "."
51+ if ( relativePathWithoutQuotes . endsWith ( `/` ) ) {
52+ relativePathWithoutQuotes = relativePathWithoutQuotes . substring ( 0 , relativePathWithoutQuotes . length - 1 )
53+ }
54+
5055 const fullImportPath = join ( pathWithoutFileName , relativePathWithoutQuotes ) ;
5156
5257 // Append .js or index.js to all imports
@@ -55,10 +60,17 @@ const generateTransformer = (sourceFile) => {
5560 }
5661 else if ( existsDtsOrJs ( fullImportPath , "index" ) ) {
5762 node = context . factory . createStringLiteral ( `${ relativePathWithoutQuotes } /index.js` )
63+
5864 }
5965 else {
6066 throw new Error ( `Can't fix TypeScript paths: ${ node . getFullText ( sourceFile ) } ` )
6167 }
68+
69+ const text = /** @type {ts.StringLiteral } */ ( node ) . text
70+ if ( text . includes ( `//` ) ) {
71+ throw new Error ( `Error "${ text } "` )
72+ }
73+
6274 }
6375
6476 return node
You can’t perform that action at this time.
0 commit comments