Skip to content

Increased main.js bundle size but less lazy chunks, another case with Angular v9-rc.11 in a monorepo structure #16799

@dogmatico

Description

@dogmatico

🐞 Bug report

Command (mark with an x)

  • new
  • serve
  • 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 #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:

Captura de pantalla de 2020-01-30 09-41-47
Captura de pantalla de 2020-01-30 09-41-49

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:

Captura de pantalla de 2020-01-30 10-45-15
Captura de pantalla de 2020-01-30 10-51-58

🔬 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions