@@ -704,34 +704,27 @@ export class AngularCompilerPlugin implements Tapable {
704
704
705
705
return Promise . resolve ( )
706
706
. then ( ( ) => {
707
- if ( this . _ngCompilerSupportsNewApi ) {
708
- return ;
707
+ // Make a new program and load the Angular structure if there are changes.
708
+ if ( changedFiles . length > 0 ) {
709
+ return this . _createOrUpdateProgram ( ) ;
709
710
}
710
-
711
+ } )
712
+ . then ( ( ) => {
711
713
// Try to find lazy routes.
712
714
// We need to run the `listLazyRoutes` the first time because it also navigates libraries
713
715
// and other things that we might miss using the (faster) findLazyRoutesInAst.
714
716
// Lazy routes modules will be read with compilerHost and added to the changed files.
715
717
const changedTsFiles = this . _compilerHost . getChangedFilePaths ( )
716
718
. filter ( k => k . endsWith ( '.ts' ) ) ;
717
- if ( this . _firstRun ) {
719
+ if ( this . _ngCompilerSupportsNewApi ) {
720
+ this . _processLazyRoutes ( this . _listLazyRoutesFromProgram ( ) ) ;
721
+ return this . _createOrUpdateProgram ( ) ;
722
+ } else if ( this . _firstRun ) {
718
723
this . _processLazyRoutes ( this . _getLazyRoutesFromNgtools ( ) ) ;
719
724
} else if ( changedTsFiles . length > 0 ) {
720
725
this . _processLazyRoutes ( this . _findLazyRoutesInAst ( changedTsFiles ) ) ;
721
726
}
722
727
} )
723
- . then ( ( ) => {
724
- // Make a new program and load the Angular structure if there are changes.
725
- if ( changedFiles . length > 0 ) {
726
- return this . _createOrUpdateProgram ( ) ;
727
- }
728
- } )
729
- . then ( ( ) => {
730
- if ( this . _ngCompilerSupportsNewApi ) {
731
- // TODO: keep this when the new ngCompiler supports the new lazy routes API.
732
- this . _lazyRoutes = this . _listLazyRoutesFromProgram ( ) ;
733
- }
734
- } )
735
728
. then ( ( ) => {
736
729
// Build transforms, emit and report errors if there are changes or it's the first run.
737
730
if ( changedFiles . length > 0 || this . _firstRun ) {
0 commit comments