Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions packages/@ngtools/webpack/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class AotPlugin implements Tapable {
private _compilerHost: WebpackCompilerHost;
private _resourceLoader: WebpackResourceLoader;
private _lazyRoutes: LazyRouteMap = Object.create(null);
private _discoveredLazyRoutes: LazyRouteMap;
private _tsConfigPath: string;
private _entryModule: string;

Expand Down Expand Up @@ -485,25 +486,28 @@ export class AotPlugin implements Tapable {
}
})
.then(() => {
if (!this.firstRun) {
this._discoveredLazyRoutes = this._findLazyRoutesInAst();
}
// Populate the file system cache with the virtual module.
this._compilerHost.populateWebpackResolver(this._compiler.resolvers.normal);
})
.then(() => {
// We need to run the `listLazyRoutes` the first time because it also navigates libraries
// and other things that we might miss using the findLazyRoutesInAst.
let discoveredLazyRoutes: LazyRouteMap = this.firstRun ?
__NGTOOLS_PRIVATE_API_2.listLazyRoutes({
if (this.firstRun) {
this._discoveredLazyRoutes = __NGTOOLS_PRIVATE_API_2.listLazyRoutes({
program: this._program,
host: this._compilerHost,
angularCompilerOptions: this._angularCompilerOptions,
entryModule: this._entryModule
})
: this._findLazyRoutesInAst();
});
}

// Process the lazy routes discovered.
Object.keys(discoveredLazyRoutes)
Object.keys(this._discoveredLazyRoutes)
.forEach(k => {
const lazyRoute = discoveredLazyRoutes[k];
const lazyRoute = this._discoveredLazyRoutes[k];
k = k.split('#')[0];
if (lazyRoute === null) {
return;
Expand Down