镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Increased main.js bundle size but less lazy chunks after updating to angular 9.0.0-rc.1 #16146

Closed

Description

@wambowams

🐞 Bug report

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

After updating from Angular 8.2.3 to 9.0.0-rc.1 the bundle size was increased for main module and some of the feature modules:
Before it was:
bundle_before9

After updating to Angular 9.0.0-rc.1 it is
image

🔬 Minimal Reproduction

running ng build --prod --namedChunks with following configuration:

            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "commonChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "1mb",
                  "maximumError": "2mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb"
                }
              ],
              "serviceWorker": true,
              "ngswConfigPath": "ngsw-config.json"
            }
          }

🌍 Your Environment


Angular CLI: 9.0.0-rc.1
Node: 10.15.3
OS: win32 x64
Angular: 9.0.0-rc.1
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.0-rc.1
@angular-devkit/build-angular     0.900.0-rc.1
@angular-devkit/build-optimizer   0.900.0-rc.1
@angular-devkit/build-webpack     0.900.0-rc.1
@angular-devkit/core              9.0.0-rc.1
@angular-devkit/schematics        9.0.0-rc.1
@angular/cdk                      8.2.3
@angular/material                 8.2.3
@ngtools/webpack                  9.0.0-rc.1
@schematics/angular               9.0.0-rc.1
@schematics/update                0.900.0-rc.1
rxjs                              6.5.3
typescript                        3.6.4
webpack                           4.41.2

Activity

  1. alan-agius4 commented on Nov 11, 2019

    @alan-agius4
    Collaborator

    Any chance of reproduction please?

  2. wambowams commented on Nov 11, 2019

    @wambowams
    Author

    I will try this afternoon, but its little bit hard as its a customer's project

  3. filipesilva commented on Nov 12, 2019

    @filipesilva
    Contributor

    @wambowams just to be really sure, can you show the sizes on disk for the dist folder? Sometime in 8 we had a bug where the ng build reported sizes weren't correct.

  4. parys commented on Nov 12, 2019

    @parys

    I hope this comment can help.
    Faced with increasing main module size(in es2015) from 1.06 to 1.15 MB (and es5 size increased too), but all other modules decreased. Full application size decreased from 3.44 to 2.67 MB.
    webpack-bundle-analyzer shows that it caused by angular/material. it increased from 127 to 200 kB and increase main module.
    core and cli is 9 RC1,
    material and cdk is 9 RC0

    p.s. File sizes at disk are increased, checked this.

  5. filipesilva commented on Nov 13, 2019

    @filipesilva
    Contributor

    @parys can you check if you have the same number of files? I wouldn't be surprised if only of the lazy modules had been merged with the main module.

  6. added this to the v9-blockers milestone on Nov 13, 2019
  7. removed this from the v9-blockers milestone on Nov 13, 2019
  8. added this to the Backlog milestone on Nov 13, 2019
  9. 44 remaining items

  10. filipesilva commented on Mar 2, 2020

    @filipesilva
    Contributor

    @santhony7 can you check if your total app size, with the size of the lazy bundles included, went down?

  11. izmaylovdev commented on Mar 2, 2020

    @izmaylovdev

    @filipesilva got same problem, here is bundle-analyzer results
    Before:
    image
    After:
    image

  12. izmaylovdev commented on Mar 2, 2020

    @izmaylovdev

    I think this may be due to ngcc processing @angular/* packages, should ngcc do this?

  13. filipesilva commented on Mar 2, 2020

    @filipesilva
    Contributor

    Yes, ngcc should process those packages.

    Webpack Bundle analyzer won't give the correct numbers in a lot of cases though. Using source-map-explorer will give you a more accurate picture of the code in your bundles, as described in https://angular.io/guide/deployment#inspect-the-bundles.

  14. santhony7 commented on Mar 2, 2020

    @santhony7

    @filipesilva Yeah, I do know that the total size has been reduced but I also think it is important to be very specific about that when claiming file size reduction. As you know, the browser's time-to-interactive or the page-speed-index is pretty much the only metric that matters to leadership. Selling them the upgrade on the promise of faster (initial) download only to find out you made it worse can be a bit disheartening.

  15. filipesilva commented on Mar 2, 2020

    @filipesilva
    Contributor

    To the best of my knowledge, we only have one situation currently where the main bundle gets bigger: https://github.com/angular/angular-cli/issues/16866. Still trying to figure out what we can do in that case. Do you also use material in your app?

  16. izmaylovdev commented on Mar 2, 2020

    @izmaylovdev

    Yes. I use material, but it is not big part of my app. Thanks for your help.

  17. santhony7 commented on Mar 2, 2020

    @santhony7

    @filipesilva Yes sir we do. "@angular/material": "^9.1.0",

  18. yamidvo commented on Mar 26, 2020

    @yamidvo

    Hi everyone! my main.js is considerably bigger with ivy. Any idea what it could be?

    Before:
    Captura de Pantalla 2020-03-26 a la(s) 12 32 09 p  m
    After:
    Captura de Pantalla 2020-03-26 a la(s) 12 31 55 p  m

  19. filipesilva commented on Mar 26, 2020

    @filipesilva
    Contributor

    @yamidvo the tool you are using (webpack-bundle-analyzer) will not provide very precise numbers with Angular CLI 9, because we process bundles after they leave webpack. A better tool to get that data would be source-map-explorer as described in https://angular.io/guide/deployment#inspect-the-bundles. That will give you very precise measurements.

  20. parys commented on Mar 26, 2020

    @parys

    2020-03-26_21-17-31
    @filipesilva
    Full bundle: 2.88 MB
    Main bundle: 972, 9 KB (size in webpack-bundle-analyzer 973.6 KB (less than 1KB)
    Angular modules: 704.45 KB + rxjs 48.26 + zone.js 35.7 = 788 KB is only for angular stuff. ( and I've already moved to lazy modules almost all material modules that not used at the index page. As I remember angular 9 decrease full size from 3.4 to 2.9 MB but increased main bundle a lot( and almost all is taken by angular(

  21. yamidvo commented on Mar 26, 2020

    @yamidvo

    Similarly, the difference is large

    before:
    Captura de Pantalla 2020-03-26 a la(s) 1 54 14 p  m

    after:
    Captura de Pantalla 2020-03-26 a la(s) 1 54 21 p  m

  22. filipesilva commented on Mar 30, 2020

    @filipesilva
    Contributor

    @parys I can't say much regarding that screenshot as I don't have anything to compare it to. Could you include a screenshot of the source map explorer output from before 9 please?

    @yamidvo I noticed you have a large shared module, which can be a problem as described in #16146 (comment). Have you tried what I mention in the "What you can do right now" section of that comment? You might have static imports to your shared code from your main entry point, causing it to not be loaded lazily at all. I don't think this is a problem we can fix on our side.

    Either way, something else you two can do is to opt out of Ivy, as described in https://angular.io/guide/ivy#opting-out-of-ivy-in-version-9. This should get back to the setup used in Angular version 8.

  23. angular-automatic-lock-bot commented on Apr 30, 2020

    @angular-automatic-lock-bot

    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.

  24. locked and limited conversation to collaborators on Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions