Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle calculator assumes bundle size configs otherwise reduce fails on empty array #17215

Closed
11 tasks
marvec opened this issue Mar 13, 2020 · 1 comment · Fixed by #17216
Closed
11 tasks

Bundle calculator assumes bundle size configs otherwise reduce fails on empty array #17215

marvec opened this issue Mar 13, 2020 · 1 comment · Fixed by #17216
Labels
area: devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Milestone

Comments

@marvec
Copy link

marvec commented Mar 13, 2020

🐞 Bug report

Command (mark with an x)

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

Is this a regression?

The bug was introduced by this commit:
770de94#diff-86d5f24a73f7db8e65c3e66c4dab5205

Description

Our project does not have budgets set for all configurations. After upgrading to Angular 9, it cannot be built because of the following exception during the build process.

Calls to Array.reduce functions are missing default values here https://github.com/angular/angular-cli/blob/9.0.x/packages/angular_devkit/build_angular/src/angular-cli-files/utilities/bundle-calculator.ts

🔬 Minimal Reproduction

We do not any simple reproducer, however the bug is obvious from the code directly.

🔥 Exception or Error

[error] TypeError: Reduce of empty array with no initial value
    at Array.reduce (<anonymous>)
    at Object.values.map (/project/node_modules/@angular-devkit/build-angular/src/angular-cli-files/utilities/bundle-calculator.js:151:18)
    at Array.map (<anonymous>)
    at BundleCalculator.calculate (/project/node_modules/@angular-devkit/build-angular/src/angular-cli-files/utilities/bundle-calculator.js:147:65)
    at calculateSizes (/project/node_modules/@angular-devkit/build-angular/src/angular-cli-files/utilities/bundle-calculator.js:101:23)
    at Object.checkBudgets (/project/node_modules/@angular-devkit/build-angular/src/angular-cli-files/utilities/bundle-calculator.js:271:23)
    at checkBudgets.next (<anonymous>)
    at BundleBudgetPlugin.runChecks (/project/node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/bundle-budget.js:22:40)
    at compiler.hooks.afterEmit.tap (/project/node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/bundle-budget.js:14:18)
    at _next0 (eval at create (/project/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:19:1)
    at _err0 (eval at create (/project/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:44:1)
    at compiler.hooks.afterEmit.tapAsync (/project/node_modules/copy-webpack-plugin/dist/index.js:115:7)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/project/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:40:1)
    at AsyncSeriesHook.lazyCompileHook (/project/node_modules/tapable/lib/Hook.js:154:20)
    at asyncLib.forEachLimit.err (/project/node_modules/webpack/lib/Compiler.js:482:27)
    at /project/node_modules/neo-async/async.js:2818:7


🌍 Your Environment

Even after adding the default budgets config, it still fails.

"budgets": [
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb"
                }
              ]

@alan-agius4 alan-agius4 added area: devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity5: regression labels Mar 13, 2020
@ngbot ngbot bot added this to the needsTriage milestone Mar 13, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Mar 13, 2020
mgechev pushed a commit that referenced this issue Mar 13, 2020
mgechev pushed a commit that referenced this issue Mar 13, 2020
This was referenced Mar 19, 2020
This was referenced Mar 23, 2020
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants