-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
🐞 Bug report
Command (mark with an x)
- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Is this a regression?
Not that I know of
Description
When lazy loading bundles via a library project as described here: #6373 (comment) the bundling of the routes is incorrect. There does not seem to be a way to correctly lazy-load mutliple routes from the same library and have the code chunked correctly. See the repo below
🔬 Minimal Reproduction
Clone and run the following repo and you will notice that while the "wrapper modules" are correctly lazy loaded, the actual modules and components from the library are all bundled into the common.js bundle which completely defeats the purpose of lazy loading. It seems that when lazy loading routes from a library, each route would need to be its own library or secondary entry point in order for the bundling to work correctly which doesn't make sense when using the libraries for feature development as a feature could consist of multiple lazy-routes.
Minimal repro: https://github.com/RobM-ADP/lazy-load-bug
🌍 Your Environment
$ ng version
Angular CLI: 8.0.3
Node: 10.15.3
OS: darwin x64
Angular: 8.0.1
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.800.3
@angular-devkit/build-angular 0.800.3
@angular-devkit/build-ng-packagr 0.800.3
@angular-devkit/build-optimizer 0.800.3
@angular-devkit/build-webpack 0.800.3
@angular-devkit/core 8.0.3
@angular-devkit/schematics 8.0.3
@angular/cli 8.0.3
@ngtools/json-schema 1.1.0
@ngtools/webpack 8.0.3
@schematics/angular 8.0.3
@schematics/update 0.800.3
ng-packagr 5.3.0
rxjs 6.5.2
typescript 3.4.5
webpack 4.30.0
common.js bundle
Notice that components from both Module AAA and Module BBB are in here.
aaa-wrapper-module.js bundle
Notice that the only thing in here is the wrapper itself. So lazy-loading has really added no benefit.

