Created
March 11, 2019 01:58
-
-
Save phenomnomnominal/d37142697a8b91bc5d8fdba536877bfa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function listLazyRoutes( | |
moduleMeta: CompileNgModuleMetadata, reflector: StaticReflector): LazyRoute[] { | |
const allLazyRoutes: LazyRoute[] = []; | |
for (const {provider, module} of moduleMeta.transitiveModule.providers) { | |
if (tokenReference(provider.token) === reflector.ROUTES) { | |
const loadChildren = _collectLoadChildren(provider.useValue); | |
for (const route of loadChildren) { | |
allLazyRoutes.push(parseLazyRoute(route, reflector, module.reference)); | |
} | |
} | |
} | |
return allLazyRoutes; | |
} | |
export function parseLazyRoute( | |
route: string, reflector: StaticReflector, module?: StaticSymbol): LazyRoute { | |
const [routePath, routeName] = route.split('#'); | |
const referencedModule = reflector.resolveExternalReference( | |
{ | |
moduleName: routePath, | |
name: routeName, | |
}, | |
module ? module.filePath : undefined); | |
return {route: route, module: module || referencedModule, referencedModule}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment