@@ -24,8 +24,8 @@ export function replaceTscAliasPaths(
24
24
outDir ?: string ;
25
25
watch ?: boolean ;
26
26
} = {
27
- watch : false ,
28
- }
27
+ watch : false
28
+ }
29
29
) {
30
30
Output . info ( '=== tsc-alias starting ===' ) ;
31
31
if ( ! options . configFile ) {
@@ -120,7 +120,7 @@ export function replaceTscAliasPaths(
120
120
basePath,
121
121
path,
122
122
paths : _paths ,
123
- isExtra,
123
+ isExtra
124
124
} ;
125
125
} )
126
126
. filter ( ( { prefix } ) => prefix ) ;
@@ -130,9 +130,10 @@ export function replaceTscAliasPaths(
130
130
if ( normalize ( alias . path ) . includes ( '..' ) ) {
131
131
const tempBasePath = normalizePath (
132
132
normalize (
133
- `${ configDir } /${ outDir } /${ hasExtraModule && relConfDirPathInOutPath
134
- ? relConfDirPathInOutPath
135
- : ''
133
+ `${ configDir } /${ outDir } /${
134
+ hasExtraModule && relConfDirPathInOutPath
135
+ ? relConfDirPathInOutPath
136
+ : ''
136
137
} /${ baseUrl } `
137
138
)
138
139
) ;
@@ -166,15 +167,17 @@ export function replaceTscAliasPaths(
166
167
const replaceImportStatement = ( {
167
168
orig,
168
169
file,
169
- alias,
170
+ alias
170
171
} : {
171
172
orig : string ;
172
173
file : string ;
173
174
alias : typeof aliases [ 0 ] ;
174
175
} ) : string => {
175
176
const requiredModule = orig . split ( / " | ' / ) [ 1 ] ;
176
177
const index = orig . indexOf ( alias . prefix ) ;
177
- const isAlias = requiredModule . startsWith ( alias . prefix ) ;
178
+ const isAlias = requiredModule . includes ( '/' )
179
+ ? requiredModule . startsWith ( alias . prefix + '/' )
180
+ : requiredModule . startsWith ( alias . prefix ) ;
178
181
if ( index > - 1 && isAlias ) {
179
182
let absoluteAliasPath = getAbsoluteAliasPath ( alias . basePath , alias . path ) ;
180
183
let relativeAliasPath : string = normalizePath (
@@ -201,19 +204,19 @@ export function replaceTscAliasPaths(
201
204
for ( const alias of aliases ) {
202
205
const replacementParams = {
203
206
file,
204
- alias,
207
+ alias
205
208
} ;
206
209
tempCode = tempCode
207
210
. replace ( requireRegex , ( orig ) =>
208
211
replaceImportStatement ( {
209
212
orig,
210
- ...replacementParams ,
213
+ ...replacementParams
211
214
} )
212
215
)
213
216
. replace ( importRegex , ( orig ) =>
214
217
replaceImportStatement ( {
215
218
orig,
216
- ...replacementParams ,
219
+ ...replacementParams
217
220
} )
218
221
) ;
219
222
}
@@ -227,11 +230,11 @@ export function replaceTscAliasPaths(
227
230
// Finding files and changing alias paths
228
231
const globPattern = [
229
232
`${ outPath } /**/*.{js,jsx,ts,tsx}` ,
230
- `!${ outPath } /**/node_modules` ,
233
+ `!${ outPath } /**/node_modules`
231
234
] ;
232
235
const files = sync ( globPattern , {
233
236
dot : true ,
234
- onlyFiles : true ,
237
+ onlyFiles : true
235
238
} ) ;
236
239
237
240
const flen = files . length ;
0 commit comments