Skip to content

Commit a747d50

Browse files
alan-agius4kyliau
authored andcommitted
refactor: add time logs in _listLazyRoutesFromProgram
Add these time logs as at the moment we are not logging anything for the discovery lazy loaded modules
1 parent ffec4fb commit a747d50

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

packages/ngtools/webpack/src/angular_compiler_plugin.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
DEFAULT_ERROR_CODE,
2222
Diagnostic,
2323
EmitFlags,
24-
LazyRoute,
2524
Program,
2625
SOURCE,
2726
UNKNOWN_ERROR_CODE,
@@ -422,25 +421,33 @@ export class AngularCompilerPlugin {
422421
}
423422

424423
private _listLazyRoutesFromProgram(): LazyRouteMap {
425-
let lazyRoutes: LazyRoute[];
424+
let entryRoute: string | undefined;
425+
let ngProgram: Program;
426+
426427
if (this._JitMode) {
427428
if (!this.entryModule) {
428429
return {};
429430
}
430431

431-
const ngProgram = createProgram({
432+
time('AngularCompilerPlugin._listLazyRoutesFromProgram.createProgram');
433+
ngProgram = createProgram({
432434
rootNames: this._rootNames,
433435
options: { ...this._compilerOptions, genDir: '', collectAllErrors: true },
434436
host: this._compilerHost,
435437
});
438+
timeEnd('AngularCompilerPlugin._listLazyRoutesFromProgram.createProgram');
436439

437-
lazyRoutes = ngProgram.listLazyRoutes(
438-
this.entryModule.path + '#' + this.entryModule.className,
439-
);
440+
entryRoute = this.entryModule.path + '#' + this.entryModule.className;
440441
} else {
441-
lazyRoutes = (this._program as Program).listLazyRoutes();
442+
ngProgram = this._program as Program;
442443
}
443444

445+
time('AngularCompilerPlugin._listLazyRoutesFromProgram.listLazyRoutes');
446+
// entryRoute will only be defined in JIT.
447+
// In AOT all routes within the program are returned.
448+
const lazyRoutes = ngProgram.listLazyRoutes(entryRoute);
449+
timeEnd('AngularCompilerPlugin._listLazyRoutesFromProgram.listLazyRoutes');
450+
444451
return lazyRoutes.reduce(
445452
(acc, curr) => {
446453
const ref = curr.route;

0 commit comments

Comments
 (0)