Skip to content

Commit 603e6f4

Browse files
alan-agius4Keen Yee Liau
authored and
Keen Yee Liau
committed
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 f2ae4fe commit 603e6f4

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Diff for: packages/ngtools/webpack/src/angular_compiler_plugin.ts

+14-7
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,
@@ -423,25 +422,33 @@ export class AngularCompilerPlugin {
423422
}
424423

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

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

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

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

0 commit comments

Comments
 (0)