New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(router): Allow loadChildren to return a Route array #45700
Conversation
5a0cf43
to
37dd312
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
8005af8
to
ea2aef2
Compare
ea2aef2
to
b6ada11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed-for: public-api
b6ada11
to
d826217
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-for: public-api, fw-core, fw-router
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-for: public-api
This commit expands the `LoadChildrenCallback` to accept returning `Routes` in addition to the existing `NgModule` type. In addition, it adds a check to ensure these loaded routes all use standalone components. The components must be standalone because if they were not, we would not have the required `NgModule` which the component is declared in. Existing API: ``` {path: 'lazy/route', loadChildren: import('./lazy').then(m => m.LazyModule)} @NgModule({ imports: [ ExtraCmpModule, RouterModule.forChild([ {path: 'extra/route', component: ExtraCmp}, ]), ], }) export class LazyModule {} ``` The new API for lazy loading route configs with standalone components (no NgModule) is to expand `loadChildren` to allow returning simply a `Routes` array. ``` // parent.ts { path: 'parent', loadChildren: () => import('./children').then(m => m.ROUTES), } // children.ts export const ROUTES: Route[] = [ {path: 'child', component: ChildCmp}, ]; ``` Note that this includes minimal documentation updates. We need to include a holistic update to the documentation for standalone components in the future that includes this feature.
d826217
to
374852c
Compare
merge assistance: requires an update to the g3 patch: http://cl/443671599 |
This PR was merged into the repository by commit 4962a4a. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This commit expands the
LoadChildrenCallback
to accept returningRoutes
in addition to the existing
NgModule
type. In addition, it adds acheck to ensure these loaded routes all use standalone components.
The components must be standalone because if they were not,
we would not have the required
NgModule
which the component is declared in.Existing API:
The new API for lazy loading route configs with standalone components
(no NgModule) is to expand
loadChildren
to allow returning simply aRoutes
array.Note that this includes minimal documentation updates. We need to
include a holistic update to the documentation for standalone components
in the future that includes this feature.