Skip to content

Commit

Permalink
refactor: add time logs in _listLazyRoutesFromProgram
Browse files Browse the repository at this point in the history
Add these time logs as at the moment we are not logging anything for the discovery lazy loaded modules
  • Loading branch information
alan-agius4 authored and kyliau committed Dec 11, 2018
1 parent f2ae4fe commit 603e6f4
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/ngtools/webpack/src/angular_compiler_plugin.ts
Expand Up @@ -21,7 +21,6 @@ import {
DEFAULT_ERROR_CODE,
Diagnostic,
EmitFlags,
LazyRoute,
Program,
SOURCE,
UNKNOWN_ERROR_CODE,
Expand Down Expand Up @@ -423,25 +422,33 @@ export class AngularCompilerPlugin {
}

private _listLazyRoutesFromProgram(): LazyRouteMap {
let lazyRoutes: LazyRoute[];
let entryRoute: string | undefined;
let ngProgram: Program;

if (this._JitMode) {
if (!this.entryModule) {
return {};
}

const ngProgram = createProgram({
time('AngularCompilerPlugin._listLazyRoutesFromProgram.createProgram');
ngProgram = createProgram({
rootNames: this._rootNames,
options: { ...this._compilerOptions, genDir: '', collectAllErrors: true },
host: this._compilerHost,
});
timeEnd('AngularCompilerPlugin._listLazyRoutesFromProgram.createProgram');

lazyRoutes = ngProgram.listLazyRoutes(
this.entryModule.path + '#' + this.entryModule.className,
);
entryRoute = this.entryModule.path + '#' + this.entryModule.className;
} else {
lazyRoutes = (this._program as Program).listLazyRoutes();
ngProgram = this._program as Program;
}

time('AngularCompilerPlugin._listLazyRoutesFromProgram.listLazyRoutes');
// entryRoute will only be defined in JIT.
// In AOT all routes within the program are returned.
const lazyRoutes = ngProgram.listLazyRoutes(entryRoute);
timeEnd('AngularCompilerPlugin._listLazyRoutesFromProgram.listLazyRoutes');

return lazyRoutes.reduce(
(acc, curr) => {
const ref = curr.route;
Expand Down

0 comments on commit 603e6f4

Please sign in to comment.