File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 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"]>;
44
55const pluginName = "ResolveTypescriptPlugin" ;
66
7+ export interface ResolveTypescriptPluginOptions {
8+ includeNodeModules ?: boolean ;
9+ }
10+
711export 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+
822 public apply ( resolver : Resolver ) : void {
923 const target = resolver . ensureHook ( "file" ) ;
1024 for ( const extension of [ ".ts" , ".tsx" ] ) {
1125 resolver
1226 . getHook ( "raw-file" )
1327 . 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+ ) {
1533 return callback ( ) ;
1634 }
1735
You can’t perform that action at this time.
0 commit comments