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