@@ -111,21 +111,23 @@ export class AotPlugin implements Tapable {
111
111
? [ options . exclude as string ] : ( options . exclude as string [ ] ) ;
112
112
113
113
exclude . forEach ( ( pattern : string ) => {
114
- pattern = pattern
115
- // Replace windows path separators to forward slashes.
116
- . replace ( / \\ / g, '/' )
117
- // Escape characters that are used normally in regexes, except stars.
118
- . replace ( / [ \- \[ \] { } ( ) + ? . \\ ^ $ | ] / g, '\\$&' )
119
- // Two stars replacement.
120
- . replace ( / \* \* / g, '(?:.*)' )
121
- // One star replacement.
122
- . replace ( / \* / g, '(?:[^/]*)' )
123
- // Escape characters from the basePath and make sure it's forward slashes.
124
- . replace ( / ^ / , `(${ basePath . replace ( / \\ / g, '/' ) . replace ( / [ \- \[ \] \/ { } ( ) + ? . \\ ^ $ | * ] / g, '\\$&' ) } )?` ) ;
125
-
126
- const re = new RegExp ( '^' + pattern + '$' ) ;
127
- fileNames = fileNames . filter ( x => ! x . replace ( / \\ / g, '/' ) . match ( re ) ) ;
128
- } ) ;
114
+ const basePathPattern = '(' + basePath . replace ( / \\ / g, '/' )
115
+ . replace ( / [ \- \[ \] \/ { } ( ) + ? . \\ ^ $ | * ] / g, '\\$&' ) + ')?' ;
116
+ pattern = pattern
117
+ // Replace windows path separators to forward slashes.
118
+ . replace ( / \\ / g, '/' )
119
+ // Escape characters that are used normally in regexes, except stars.
120
+ . replace ( / [ \- \[ \] { } ( ) + ? . \\ ^ $ | ] / g, '\\$&' )
121
+ // Two stars replacement.
122
+ . replace ( / \* \* / g, '(?:.*)' )
123
+ // One star replacement.
124
+ . replace ( / \* / g, '(?:[^/]*)' )
125
+ // Escape characters from the basePath and make sure it's forward slashes.
126
+ . replace ( / ^ / , basePathPattern ) ;
127
+
128
+ const re = new RegExp ( '^' + pattern + '$' ) ;
129
+ fileNames = fileNames . filter ( x => ! x . replace ( / \\ / g, '/' ) . match ( re ) ) ;
130
+ } ) ;
129
131
} else {
130
132
fileNames = fileNames . filter ( fileName => ! / \. s p e c \. t s $ / . test ( fileName ) ) ;
131
133
}
0 commit comments