Increased main.js bundle size but less lazy chunks, another case with Angular v9-rc.11 in a monorepo structure
π Bug report
Command (mark with an x)
- [ ] new
- [ ] serve
- [x] build
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Is this a regression?
Yes, with Angular v8, or Ivy disabled, the main bundle size issue did not happen
Description
Like in issue https://github.com/angular/angular-cli/issues/16146, Ivy enabled builds result in bigger main bundles.
We use an app-shell plus lazy load of components- with Angular Elements like in aio, and routes. With View Engine (VE), both in Angular 8 and 9, the main bundle effectively only included what was required to render the shell:
- Core framework,
- Auth back-end,
- Angular Material sidenav and toolbar,
- Shell components.
Once Ivy is enabled, it includes additional code. E.g., in one application, we get those two source-map-explorer results:

In other app, the result is also bigger main bundles. In particular, it adds all the @Injectable({providedIn: 'root}) services that are provided in a data-access internal library:

π¬ Minimal Reproduction
The issue is in a proprietary mono-repo of front-ends. We can provide access in Bitbucket or Github private repositories if necessary. To generate the bundles, we used
ng build <project-name> --prod --source-map --localize=false
And only changed the tsconfig.json to set angularCompilerOptions.enableIvy = false
π Your Environment
Angular CLI: 9.0.0-rc.11
Node: 12.14.1
OS: linux x64
Angular: 9.0.0-rc.11
... animations, cli, common, compiler, compiler-cli, core
... elements, forms, language-service, localize
... platform-browser, platform-browser-dynamic, platform-server
... router, service-worker
Ivy Workspace: No
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.900.0-rc.11
@angular-devkit/build-angular 0.900.0-rc.11
@angular-devkit/build-ng-packagr 0.900.0-rc.11
@angular-devkit/build-optimizer 0.900.0-rc.11
@angular-devkit/build-webpack 0.900.0-rc.11
@angular-devkit/core 9.0.0-rc.11
@angular-devkit/schematics 9.0.0-rc.11
@angular/cdk 9.0.0-rc.8
@angular/material 9.0.0-rc.8
@angular/pwa 0.803.23
@ngtools/webpack 9.0.0-rc.11
@schematics/angular 8.3.23
@schematics/update 0.900.0-rc.11
rxjs 6.5.4
typescript 3.7.5
webpack 4.41.2
The @angular/forms package is currently marked as side effect free. All the client-side @angular packages are marked with the exception of the @angular/compiler package which is not used in a production (AOT compiled) application.
We've added documentation about this class of problem in https://github.com/angular/angular/pull/35178. It should be available https://next.angular.io/guide/ivy-compatibility#payload-size-debugging now, and shortly in https://angular.io/guide/ivy-compatibility#payload-size-debugging
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.