angular-cli: Unexpected reserved word 'arguments' when running translations --localize
🐞 bug report
Is this a regression?
Yes, it worked in Angular 8
Description
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 https://github.com/thduttonuk/angular9-issue1
Run
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? No
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 25
- Comments: 16 (12 by maintainers)
The upstream Babel issue is fixed in 7.11.0.
Looks like this is a problem with Babel. This construct is valid in native ES2015 environments:
And there is already a bug reported in the Babel repo: https://github.com/babel/babel/issues/10411
we have exactly the same issue but with the other auth0 library
auth0-js
. We currently use v9.13.2. Maybe something is broken in the Auth0 build process.Let’s invite @stevehobbsdev for conversation
Yes, the localization of the code uses Babel - and it is the Babel parser that is complaining. If you don’t localize then this is not called. We need to find out why this is a problem for Babel. Perhaps we can set an option when parsing…
I’ve tested this more and setting
"optimization": false,
in the angular.json config stops the error and it builds. Obviously we don’t want to do this as a work around due to the size of the bundles.