@@ -194,6 +194,10 @@ export class AotPlugin implements Tapable {
194
194
apply ( compiler : any ) {
195
195
this . _compiler = compiler ;
196
196
197
+ compiler . plugin ( 'invalid' , ( fileName : string , timestamp : number ) => {
198
+ this . _compilerHost . invalidate ( fileName ) ;
199
+ } ) ;
200
+
197
201
compiler . plugin ( 'context-module-factory' , ( cmf : any ) => {
198
202
cmf . plugin ( 'before-resolve' , ( request : any , callback : ( err ?: any , request ?: any ) => void ) => {
199
203
if ( ! request ) {
@@ -253,6 +257,7 @@ export class AotPlugin implements Tapable {
253
257
if ( this . _compilation . _ngToolsWebpackPluginInstance ) {
254
258
return cb ( new Error ( 'An @ngtools/webpack plugin already exist for this compilation.' ) ) ;
255
259
}
260
+
256
261
this . _compilation . _ngToolsWebpackPluginInstance = this ;
257
262
258
263
this . _resourceLoader = new WebpackResourceLoader ( compilation ) ;
@@ -286,18 +291,20 @@ export class AotPlugin implements Tapable {
286
291
this . _rootFilePath , this . _compilerOptions , this . _compilerHost , this . _program ) ;
287
292
} )
288
293
. then ( ( ) => {
289
- const diagnostics = this . _program . getGlobalDiagnostics ( ) ;
290
- if ( diagnostics . length > 0 ) {
291
- const message = diagnostics
292
- . map ( diagnostic => {
293
- const { line, character} = diagnostic . file . getLineAndCharacterOfPosition (
294
- diagnostic . start ) ;
295
- const message = ts . flattenDiagnosticMessageText ( diagnostic . messageText , '\n' ) ;
296
- return `${ diagnostic . file . fileName } (${ line + 1 } ,${ character + 1 } ): ${ message } )` ;
297
- } )
298
- . join ( '\n' ) ;
299
-
300
- throw new Error ( message ) ;
294
+ if ( this . _typeCheck ) {
295
+ const diagnostics = this . _program . getGlobalDiagnostics ( ) ;
296
+ if ( diagnostics . length > 0 ) {
297
+ const message = diagnostics
298
+ . map ( diagnostic => {
299
+ const { line, character} = diagnostic . file . getLineAndCharacterOfPosition (
300
+ diagnostic . start ) ;
301
+ const message = ts . flattenDiagnosticMessageText ( diagnostic . messageText , '\n' ) ;
302
+ return `${ diagnostic . file . fileName } (${ line + 1 } ,${ character + 1 } ): ${ message } )` ;
303
+ } )
304
+ . join ( '\n' ) ;
305
+
306
+ throw new Error ( message ) ;
307
+ }
301
308
}
302
309
} )
303
310
. then ( ( ) => {
0 commit comments