angular-cli: UglifyJs Unexpected token: name (Time)

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Building production using ng build --prod results with the following error: ERROR in vendor.6524f61fda4d53a6f933.bundle.js from UglifyJs Unexpected token: name (Time) [vendor.6524f61fda4d53a6f933.bundle.js:18068,6]

I can’t find Time in my project path, i think it is from some of the libraries i use.

Before i updated Angular, and Angular CLI I used Angular 4.1.3 and Angular CLI 1.0.6 and I was getting similar error but insted of Time, unexpected token was PolicyMappings which was from pkijs

I also found Time class in pkijs

Versions.

@angular/cli: 1.1.1 node: 7.5.0 os: win32 x64 @angular/animations: 4.2.1 @angular/common: 4.2.1 @angular/compiler: 4.2.1 @angular/core: 4.2.1 @angular/flex-layout: 2.0.0-beta.8 @angular/forms: 4.2.1 @angular/http: 4.2.1 @angular/material: 2.0.0-beta.6-88089a7 @angular/platform-browser: 4.2.1 @angular/platform-browser-dynamic: 4.2.1 @angular/router: 4.2.1 @angular/cli: 1.1.1 @angular/compiler-cli: 4.2.1 @ngtools/webpack: 1.4.1

Repro steps.

npm install pkijs npm install @types/pkijs ng build --prod

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 16 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I have compilerOptions.target of es5 and still have ERROR from UglifyJS. I figured it’s because I’m using pify package that’s ES6. Still haven’t found a solution yet.

I changed compilerOptions.target from es6 to es5 and this error disappeared.

I’ve resolved this using UglifyJS2#harmony-v2.8.22 --dev for ES6:

yarn add git://github.com/mishoo/UglifyJS2#harmony-v2.8.22 --dev

documented at: https://www.npmjs.com/package/uglifyjs-webpack-plugin

I may have found the problem - I had a target of es6, because es5 was causing me problems with this.allowedFields = [ ...new Set(this.allowedFields) ].sort((a,b) => { return a.toLowerCase() > b.toLowerCase() ? 1 : -1});

I think that es6 does not compile properly with uglify.js , which may be throwing out the errors

Any idea on how I can get uglify to work with es6 ?

Upgrade to a newer version of angular-cli, this has been fixed for a little while now: https://github.com/angular/angular-cli/pull/7610

I changed compilerOptions.target from es6 to es5 and OK too.

I can confirm this issue. Only happens when I set the target to es6. Using es5 the issue is not there.