Skip to content

WARNING in budgets exceeded message showing wrong number #16871

Closed
@AdrienCulem

Description

@AdrienCulem

🐞 Bug report

Command (mark with an x)

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

Description

Warning is showing that the budget was not met by 0 bytes.
Shouldn't it show in the case of going over the maximum, "was exceeded by 0.77Mb".

Code is located at : angular-cli\packages\angular_devkit\build_angular\src\angular-cli-files\utilities\bundle-calculator.ts - Line 360

Previous code

const sizeDifference = formatSize(threshold.limit - size);
yield {
    severity: threshold.severity,
    message: `Exceeded maximum budget for ${label}. Budget ${
        formatSize(threshold.limit)} was not met by ${
        sizeDifference} with a total of ${formatSize(size)}.`,
};

Corrected code (imo)

const sizeDifference = formatSize(size - threshold.limit);
yield {
    severity: threshold.severity,
    message: `Exceeded maximum budget for ${label}. Budget ${
        formatSize(threshold.limit)} was exceeded by ${
        sizeDifference} with a total of ${formatSize(size)}.`,
};

🔬 Minimal Reproduction

ng build --prod

🔥 Exception or Error

WARNING in budgets: Exceeded maximum budget for initial. Budget 5 MB was not met by 0 bytes with a total of 5.77 MB.

🌍 Your Environment

Angular CLI: 9.0.1
Node: 10.16.3
OS: win32 x64

Angular: 9.0.0
... animations, common, compiler, compiler-cli, core, elements
... forms, language-service, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.14
@angular-devkit/build-angular     0.900.1
@angular-devkit/build-optimizer   0.900.1
@angular-devkit/build-webpack     0.900.1
@angular-devkit/core              8.3.14
@angular-devkit/schematics        8.3.14
@angular/cdk                      8.2.3
@angular/cli                      9.0.1
@ngtools/webpack                  9.0.1
@schematics/angular               8.3.14
@schematics/update                0.900.1
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions