@@ -76,6 +76,9 @@ function GetModuleDeclaration(
76
76
line = line . startsWith ( " " ) ? " //" + line . substring ( 3 ) : "// " + line ;
77
77
}
78
78
79
+ // replace type imports from directories with index (mixins are generating them)
80
+ line = line . replace ( / i m p o r t \( " ( [ . / ] + ) " \) / g, `import("$1/index")` ) ;
81
+
79
82
[
80
83
// Declaration
81
84
/ d e c l a r e m o d u l e [ ' " ] ( .* ) [ ' " ] / ,
@@ -85,15 +88,17 @@ function GetModuleDeclaration(
85
88
/ { 4 } m o d u l e [ ' " ] ( .* ) [ ' " ] / ,
86
89
/ ^ m o d u l e [ ' " ] ( \. .* ) [ ' " ] / ,
87
90
// Inlined Import
88
- / i m p o r t \( [ ' " ] ( . * ) [ ' " ] / ,
91
+ / i m p o r t \( [ ' " ] ( [ ^ ' " ] * ) [ ' " ] / ,
89
92
// Side Effect Import
90
93
/ i m p o r t [ ' " ] ( .* ) [ ' " ] / ,
91
94
] . forEach ( ( regex ) => {
92
95
const match = line . match ( regex ) ;
93
96
if ( match ) {
94
97
if ( match [ 1 ] [ 0 ] === "." ) {
95
98
const newLocation = path . join ( sourceDir , match [ 1 ] ) . replace ( / \\ / g, "/" ) ;
96
- line = line . replace ( match [ 1 ] , newLocation ) ;
99
+ // replaceAll only avaialable by modifying the typescript lib
100
+ // which we prefered to not change for now
101
+ line = ( line as any ) . replaceAll ( match [ 1 ] , newLocation ) ;
97
102
} else {
98
103
let found = false ;
99
104
Object . keys ( mapping ) . forEach ( ( devPackageName ) => {
@@ -319,8 +324,8 @@ function GetPackageDeclaration(
319
324
while ( i < lines . length ) {
320
325
let line = lines [ i ] ;
321
326
322
- if ( / i m p o r t \( " \. ( . * ) \) ./ g. test ( line ) && ! / ^ d e c l a r e t y p e ( .* ) i m p o r t / g. test ( line ) ) {
323
- line = line . replace ( / i m p o r t \( ( . * ) \) ./ , "" ) ;
327
+ if ( / i m p o r t \( " \. ( [ ^ ) ] * ) \) ./ g. test ( line ) && ! / ^ d e c l a r e t y p e ( .* ) i m p o r t / g. test ( line ) ) {
328
+ line = line . replace ( / i m p o r t \( ( [ ^ ) ] * ) \) ./ g , "" ) ;
324
329
}
325
330
326
331
if ( ! line . includes ( "const enum" ) && ! line . includes ( "=" ) ) {
0 commit comments