File tree Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -8,26 +8,29 @@ export default class ResolveTypescriptPlugin {
8
8
public apply ( resolver : Resolver ) : void {
9
9
const target = resolver . ensureHook ( "file" ) ;
10
10
resolver . getHook ( "raw-file" ) . tapAsync ( pluginName , ( request , resolveContext , callback ) => {
11
- if ( ! request . path || request . path . split ( / [ \\ / ] / ) . indexOf ( " node_modules" ) >= 0 ) {
11
+ if ( ! request . path || request . path . match ( / ( ^ | [ \\ / ] ) n o d e _ m o d u l e s ( $ | [ \\ / ] ) / ) ) {
12
12
return callback ( ) ;
13
13
}
14
14
15
- const path = request . path . replace ( / \. j s $ / , ".ts " ) ;
15
+ const path = request . path . replace ( / \. j s $ / , "" ) ;
16
16
if ( path === request . path ) {
17
17
callback ( ) ;
18
18
} else {
19
- resolver . doResolve (
20
- target ,
21
- {
22
- ...request ,
23
- path,
24
- relativePath :
25
- request . relativePath && request . relativePath . replace ( / \. j s $ / , ".ts" )
26
- } ,
27
- `using path: ${ path } ` ,
28
- resolveContext ,
29
- callback
30
- ) ;
19
+ for ( const extension of [ ".ts" , ".tsx" ] ) {
20
+ resolver . doResolve (
21
+ target ,
22
+ {
23
+ ...request ,
24
+ path : `${ path } ${ extension } ` ,
25
+ relativePath :
26
+ request . relativePath &&
27
+ request . relativePath . replace ( / \. j s $ / , extension )
28
+ } ,
29
+ `using path: ${ path } ` ,
30
+ resolveContext ,
31
+ callback
32
+ ) ;
33
+ }
31
34
}
32
35
} ) ;
33
36
}
You can’t perform that action at this time.
0 commit comments