Skip to content

Confusing project budgets #27580

Closed
Closed
@Ghostbird

Description

@Ghostbird

Command

build

Is this a regression?

I don't think so.

Description

When generating a new project, budgets are automatically assigned, however the generated values are really confusing. I accidentally ran into some of these limits. I had to grab a calculator, the build output, make some assumptions, run some calculations, before I could actually understand what these options meant.

It would be nice if these were unambiguous.

The generated project limits rules-as-written are:

  • Initial maximum warning: 500 kilobits
  • Initial maximum error: 1millibit
  • Any component style maximum warning: 2 kilobits
  • Any component style maximum error: 6 kilobits

First of all, let's assume that the the m in mb should be M, that's a factor 10⁹ difference, but ¹/₁₀₀₀ bits makes no sense here, since we're talking about real storage here. I've only ever used millibits in calculations on pure information.

I analysed this output:

Budget 500.00 kB was not met by 589.00 kB with a total of 1.06 MB

This quickly points in the direction that the b should be a B, it's bytes, not bits.
Finally if I run some calculations on this, it clears up another thing (but the output is faulty here too).

(500 + 589)×10³ ≠ 1.06 × 10⁶ (rules-as-written ISO prefixes)
(500 + 589)×2¹⁰ ≠ 1.06 × 10³ × 2¹⁰ (floppy disk megabytes)
(500 + 589)×2¹⁰ = 1.06 × 10²⁰ (actually intended ISO/IEC 80000-13 binary prefix standard)

From this I can conclude that the numbers used in calculations are actually using the binary measures according to ISO/IEC 80000 (which is the most common for modern systems AFAIK), and the k should be ki and the m should ultimately be Mi.

As you can see, it's no trivial matter to understand what the configuration file actually means with these values:

  • Initial maximum warning: 500 kiB (kibibytes) or 500 × 10¹⁰ bytes = 512000 bytes
  • Initial maximum error: 1 MiB (mebibyte) or 1 × 10²⁰ bytes = 1048576 bytes
  • Any component style maximum warning: 2 kiB or 2 × 10¹⁰ bytes = 2048 bytes
  • Any component style maximum error: 6 kiB or 6 × 10¹⁰ bytes = 6144 bytes

Note that you now suddenly can see that the initial maximum warning is not half of the initial maximum error but is approximately 48.8% of the maximum error.

While not a big priority, as it is unlikely to cause problems whose solution isn't obvious (increase the limits), it is annoying as it can unexpectedly cause errors whose exact cause is hard to understand.

Minimal Reproduction

ng g new app
Check angular.json » project » app » architect » build » configuration » production » budgets

Exception or Error

No response

Your Environment

$ ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 17.3.6
Node: 22.0.0 (Unsupported)
Package Manager: npm 10.5.1
OS: linux x64

Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1703.6 (cli-only)
@angular-devkit/core         17.3.6 (cli-only)
@angular-devkit/schematics   17.3.6 (cli-only)
@schematics/angular          17.3.6 (cli-only)
    
Warning: The current version of Node (22.0.0) is not supported by Angular.

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions