Skip to content

Commit 313683f

Browse files
Meligymatsko
authored andcommitted
fix(compiler-cli): avoid handling functions in loadChildren as lazy load routes paths
The change avoids the compiler CLI internal API from mismatching the following case as lazy loading ``` import { NonLazyLoadedModule } from './non-lazy-loaded/non-lazy-loaded.module'; export function getNonLazyLoadedModule() { return NonLazyLoadedModule; } export const routes = [ { path: '/some-path', loadChildren: getNonLazyLoadedModule } ]; ``` The output of the check is later passed to `RouteDef.fromString()`, so, it makes sense to be only a string. Fixes angular/angular-cli#3204
1 parent 338be6d commit 313683f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/@angular/compiler-cli/src/ngtools_impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function _collectRoutes(
198198
*/
199199
function _collectLoadChildren(routes: Route[]): string[] {
200200
return routes.reduce((m, r) => {
201-
if (r.loadChildren) {
201+
if (r.loadChildren && typeof r.loadChildren === 'string') {
202202
return m.concat(r.loadChildren);
203203
} else if (Array.isArray(r)) {
204204
return m.concat(_collectLoadChildren(r));

0 commit comments

Comments
 (0)