Skip to content

Commit 15cf37e

Browse files
committed
fix(@ngtools/webpack): always process lazy routes
With support for the new API, we stopped processing lazy routes paths, which was a mistake
1 parent cde0219 commit 15cf37e

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

packages/@ngtools/webpack/src/angular_compiler_plugin.ts

+9-16
Original file line numberDiff line numberDiff line change
@@ -704,34 +704,27 @@ export class AngularCompilerPlugin implements Tapable {
704704

705705
return Promise.resolve()
706706
.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();
709710
}
710-
711+
})
712+
.then(() => {
711713
// Try to find lazy routes.
712714
// We need to run the `listLazyRoutes` the first time because it also navigates libraries
713715
// and other things that we might miss using the (faster) findLazyRoutesInAst.
714716
// Lazy routes modules will be read with compilerHost and added to the changed files.
715717
const changedTsFiles = this._compilerHost.getChangedFilePaths()
716718
.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) {
718723
this._processLazyRoutes(this._getLazyRoutesFromNgtools());
719724
} else if (changedTsFiles.length > 0) {
720725
this._processLazyRoutes(this._findLazyRoutesInAst(changedTsFiles));
721726
}
722727
})
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-
})
735728
.then(() => {
736729
// Build transforms, emit and report errors if there are changes or it's the first run.
737730
if (changedFiles.length > 0 || this._firstRun) {

0 commit comments

Comments
 (0)