File tree 2 files changed +10
-6
lines changed
packages/compiler-cli/src/ngtsc/routing/src
2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import {ModuleResolver} from '../../imports';
12
12
import { PartialEvaluator } from '../../partial_evaluator' ;
13
13
14
14
import { scanForRouteEntryPoints } from './lazy' ;
15
- import { RouterEntryPointManager } from './route' ;
15
+ import { RouterEntryPointManager , entryPointKeyFor } from './route' ;
16
16
17
17
export interface NgModuleRawRouteData {
18
18
sourceFile : ts . SourceFile ;
@@ -38,9 +38,9 @@ export class NgModuleRouteAnalyzer {
38
38
39
39
add ( sourceFile : ts . SourceFile , moduleName : string , imports : ts . Expression | null ,
40
40
exports : ts . Expression | null , providers : ts . Expression | null ) : void {
41
- const key = ` ${ sourceFile . fileName } # ${ moduleName } ` ;
41
+ const key = entryPointKeyFor ( sourceFile . fileName , moduleName ) ;
42
42
if ( this . modules . has ( key ) ) {
43
- throw new Error ( `Double route analyzing ${ key } ` ) ;
43
+ throw new Error ( `Double route analyzing for ' ${ key } '. ` ) ;
44
44
}
45
45
this . modules . set (
46
46
key , {
Original file line number Diff line number Diff line change @@ -44,11 +44,15 @@ export class RouterEntryPointManager {
44
44
}
45
45
46
46
fromNgModule ( sf : ts . SourceFile , moduleName : string ) : RouterEntryPoint {
47
- const absoluteFile = sf . fileName ;
48
- const key = `${ absoluteFile } #${ moduleName } ` ;
47
+ const key = entryPointKeyFor ( sf . fileName , moduleName ) ;
49
48
if ( ! this . map . has ( key ) ) {
50
- this . map . set ( key , new RouterEntryPointImpl ( absoluteFile , moduleName ) ) ;
49
+ this . map . set ( key , new RouterEntryPointImpl ( sf . fileName , moduleName ) ) ;
51
50
}
52
51
return this . map . get ( key ) ! ;
53
52
}
54
53
}
54
+
55
+ export function entryPointKeyFor ( filePath : string , moduleName : string ) : string {
56
+ // Drop the extension to be compatible with how cli calls `listLazyRoutes(entryRoute)`.
57
+ return `${ filePath . replace ( / \. t s x ? $ / i, '' ) } #${ moduleName } ` ;
58
+ }
You can’t perform that action at this time.
0 commit comments