File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,32 @@ type Resolver = NonNullable<ResolveOptions["resolver"]>;
4
4
5
5
const pluginName = "ResolveTypescriptPlugin" ;
6
6
7
+ export interface ResolveTypescriptPluginOptions {
8
+ includeNodeModules ?: boolean ;
9
+ }
10
+
7
11
export default class ResolveTypescriptPlugin {
12
+ private static defaultOptions : ResolveTypescriptPluginOptions = {
13
+ includeNodeModules : false
14
+ } ;
15
+
16
+ private options : ResolveTypescriptPluginOptions ;
17
+
18
+ public constructor ( options : ResolveTypescriptPluginOptions = { } ) {
19
+ this . options = { ...ResolveTypescriptPlugin . defaultOptions , ...options } ;
20
+ }
21
+
8
22
public apply ( resolver : Resolver ) : void {
9
23
const target = resolver . ensureHook ( "file" ) ;
10
24
for ( const extension of [ ".ts" , ".tsx" ] ) {
11
25
resolver
12
26
. getHook ( "raw-file" )
13
27
. tapAsync ( pluginName , ( request , resolveContext , callback ) => {
14
- if ( ! request . path || request . path . match ( / ( ^ | [ \\ / ] ) n o d e _ m o d u l e s ( $ | [ \\ / ] ) / ) ) {
28
+ if (
29
+ ! request . path ||
30
+ ( ! this . options . includeNodeModules &&
31
+ request . path . match ( / ( ^ | [ \\ / ] ) n o d e _ m o d u l e s ( $ | [ \\ / ] ) / ) )
32
+ ) {
15
33
return callback ( ) ;
16
34
}
17
35
You can’t perform that action at this time.
0 commit comments