@@ -196,9 +196,11 @@ export class AotPlugin implements Tapable {
196
196
} ) ;
197
197
198
198
// Virtual file system.
199
- compiler . resolvers . normal . plugin ( 'resolve' , ( request : any , cb ?: ( ) => void ) => {
199
+ compiler . resolvers . normal . plugin ( 'resolve' , ( request : any , cb ?: ( err ?: any ) => void ) => {
200
200
if ( request . request . match ( / \. t s $ / ) ) {
201
- this . done . then ( ( ) => cb ( ) ) ;
201
+ this . done
202
+ . then ( ( ) => cb ( ) )
203
+ . catch ( ( err ) => cb ( err ) ) ;
202
204
} else {
203
205
cb ( ) ;
204
206
}
@@ -212,9 +214,8 @@ export class AotPlugin implements Tapable {
212
214
213
215
private _make ( compilation : any , cb : ( err ?: any , request ?: any ) => void ) {
214
216
this . _compilation = compilation ;
215
-
216
217
if ( this . _compilation . _ngToolsWebpackPluginInstance ) {
217
- cb ( new Error ( 'An @ngtools/webpack plugin already exist for this compilation.' ) ) ;
218
+ return cb ( new Error ( 'An @ngtools/webpack plugin already exist for this compilation.' ) ) ;
218
219
}
219
220
this . _compilation . _ngToolsWebpackPluginInstance = this ;
220
221
@@ -227,28 +228,28 @@ export class AotPlugin implements Tapable {
227
228
basePath : this . basePath
228
229
} ;
229
230
230
- let promise = Promise . resolve ( ) ;
231
- if ( ! this . _skipCodeGeneration ) {
232
- // Create the Code Generator.
233
- const codeGenerator = ngCompiler . CodeGenerator . create (
234
- this . _angularCompilerOptions ,
235
- i18nOptions ,
236
- this . _program ,
237
- this . _compilerHost ,
238
- new ngCompiler . NodeReflectorHostContext ( this . _compilerHost ) ,
239
- this . _resourceLoader
240
- ) ;
241
-
242
- // We need to temporarily patch the CodeGenerator until either it's patched or allows us
243
- // to pass in our own ReflectorHost.
244
- // TODO: remove this.
245
- patchReflectorHost ( codeGenerator ) ;
246
- promise = promise . then ( ( ) => codeGenerator . codegen ( {
247
- transitiveModules : true
248
- } ) ) ;
249
- }
231
+ this . _donePromise = Promise . resolve ( )
232
+ . then ( ( ) => {
233
+ if ( this . _skipCodeGeneration ) {
234
+ return ;
235
+ }
250
236
251
- this . _donePromise = promise
237
+ // Create the Code Generator.
238
+ const codeGenerator = ngCompiler . CodeGenerator . create (
239
+ this . _angularCompilerOptions ,
240
+ i18nOptions ,
241
+ this . _program ,
242
+ this . _compilerHost ,
243
+ new ngCompiler . NodeReflectorHostContext ( this . _compilerHost ) ,
244
+ this . _resourceLoader
245
+ ) ;
246
+
247
+ // We need to temporarily patch the CodeGenerator until either it's patched or allows us
248
+ // to pass in our own ReflectorHost.
249
+ // TODO: remove this.
250
+ patchReflectorHost ( codeGenerator ) ;
251
+ return codeGenerator . codegen ( { transitiveModules : true } ) ;
252
+ } )
252
253
. then ( ( ) => {
253
254
// Create a new Program, based on the old one. This will trigger a resolution of all
254
255
// transitive modules, which include files that might just have been generated.
0 commit comments