Skip to content

Ergonomic component-level code splitting and lazy loading #18093

@aalbericio

Description

@aalbericio

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[X] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Router Module is optional and, depending on the nature of the app, it does not naturally fit.

If we don't use the RouterModule, I can't see an easy way to take advantage of the "lazy loading" feature for modules.

I'd like to, somehow, identify an NgModule to be "lazy loaded" at definition time (just like you define its providers, etc).

Once the module has been marked as "lazy loaded", the build should generate an independent chunk for it and that module becomes eligible for being lazy-loaded at some execution time.

Of course, If I have the choice of marking a module "lazy", I also need a mechanism to manually load those "lazy loaded" modules and start using them.

In summary, the feature request is: make the "lazy loading" feature available to developers outside the RouterModule since this module is optional but the feature should still be available.

Of course this should output AOT compatible chunks, etc, just like the RouterModule internally does.

Expected behavior

In summary, the feature request is: make the "lazy loading" feature available to developers outside the RouterModule since this module is optional but the feature should still be available.

Of course this should output AOT compatible chunks, etc, just like the RouterModule internally does.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Our application and functionally can not be Router driven thus we need some way to make use of the "lazy loading" strategy that is internally used by the Router.

Environment


Angular version: X.Y.Z


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Metadata

Metadata

Labels

area: coreIssues related to the framework runtimefeatureIssue that requests a new featurefeature: under considerationFeature request for which voting has completed and the request is now under consideration

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions