@@ -21,7 +21,6 @@ import {
21
21
DEFAULT_ERROR_CODE ,
22
22
Diagnostic ,
23
23
EmitFlags ,
24
- LazyRoute ,
25
24
Program ,
26
25
SOURCE ,
27
26
UNKNOWN_ERROR_CODE ,
@@ -423,25 +422,33 @@ export class AngularCompilerPlugin {
423
422
}
424
423
425
424
private _listLazyRoutesFromProgram ( ) : LazyRouteMap {
426
- let lazyRoutes : LazyRoute [ ] ;
425
+ let entryRoute : string | undefined ;
426
+ let ngProgram : Program ;
427
+
427
428
if ( this . _JitMode ) {
428
429
if ( ! this . entryModule ) {
429
430
return { } ;
430
431
}
431
432
432
- const ngProgram = createProgram ( {
433
+ time ( 'AngularCompilerPlugin._listLazyRoutesFromProgram.createProgram' ) ;
434
+ ngProgram = createProgram ( {
433
435
rootNames : this . _rootNames ,
434
436
options : { ...this . _compilerOptions , genDir : '' , collectAllErrors : true } ,
435
437
host : this . _compilerHost ,
436
438
} ) ;
439
+ timeEnd ( 'AngularCompilerPlugin._listLazyRoutesFromProgram.createProgram' ) ;
437
440
438
- lazyRoutes = ngProgram . listLazyRoutes (
439
- this . entryModule . path + '#' + this . entryModule . className ,
440
- ) ;
441
+ entryRoute = this . entryModule . path + '#' + this . entryModule . className ;
441
442
} else {
442
- lazyRoutes = ( this . _program as Program ) . listLazyRoutes ( ) ;
443
+ ngProgram = this . _program as Program ;
443
444
}
444
445
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
+
445
452
return lazyRoutes . reduce (
446
453
( acc , curr ) => {
447
454
const ref = curr . route ;
0 commit comments