Unexpected reserved word ‘arguments’ when running translations –localize

🐞 bug report

Is this a regression?

Yes, it worked in Angular 8


Running ng build --prod --localize causes the error Unexpected reserved word 'arguments' but running ng build --prod builds fine. I have tracked this down to superagent that is referenced by Auth0. What I don’t understand is why only –localize causes the build error. We are building and deploying the code using –prod builds, we are blocked on the –localize builds.

🔬 Minimal Reproduction

I have created a repo for reproduction

ng build --prod this builds fine
ng build --prod --localize causes Unexpected reserved word 'arguments'

🔥 Exception or Error

Localized bundle generation failed: angular9-issue1\main-es2015.acfa3bd7294e9b8980d0.js: Unexpected reserved word 'arguments' (1:481223)
An error occurred inlining file "main-es2015.acfa3bd7294e9b8980d0.js"

🌍 Your Environment

Angular Version:

Angular CLI: 9.1.1
Node: 12.16.1
OS: win32 x64

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

Package                           Version
@angular-devkit/architect         0.901.1
@angular-devkit/build-angular     0.901.1
@angular-devkit/build-optimizer   0.901.1
@angular-devkit/build-webpack     0.901.1
@angular-devkit/core              9.1.1
@angular-devkit/schematics        9.1.1
@ngtools/webpack                  9.1.1
@schematics/angular               9.1.1
@schematics/update                0.901.1
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0

Anything else relevant?

2 thoughts on “Unexpected reserved word ‘arguments’ when running translations –localize

  1. Looks like this is a problem with Babel. This construct is valid in native ES2015 environments:

    > function foo() {
    ... return {arguments};
    ... }
    > foo(1, 2,3)
    { arguments: [Arguments] { '0': 1, '1': 2, '2': 3 } }

    And there is already a bug reported in the Babel repo: babel/babel#10411