Skip to content

UglifyJs Unexpected token: name (Time) #6655

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

Closed
alkuzman opened this issue Jun 13, 2017 · 16 comments
Closed

UglifyJs Unexpected token: name (Time) #6655

alkuzman opened this issue Jun 13, 2017 · 16 comments
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity3: broken

Comments

@alkuzman
Copy link

alkuzman commented Jun 13, 2017

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

@sumitarora
Copy link
Contributor

@AKuzmanoski Are you getting any errors while running the dev build?

@alkuzman
Copy link
Author

No, it works fine on dev mode

@Brocco Brocco self-assigned this Jun 14, 2017
@Brocco Brocco added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity3: broken labels Jun 14, 2017
@jmls
Copy link

jmls commented Jun 16, 2017

I've started hitting this -

ERROR in main.1dae05ad85948e9171be.bundle.js from UglifyJs
Unexpected token: name (TaskTableComponent) [main.1dae05ad85948e9171be.bundle.js:53,6]
``

In my case, `TaskTableComponent` is a component defined in my app, loaded in the module

import { TaskTableComponent } from './task-table/task-table.component';


and I get no errors in dev mode (the component also works just fine)

@alkuzman
Copy link
Author

Can you share some details abot TaskTableComponent?

@jmls
Copy link

jmls commented Jun 16, 2017

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 ?

@marino-andriamialy
Copy link

marino-andriamialy commented Jul 11, 2017

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

@alexander-kovalev
Copy link

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

@kirillgroshkov
Copy link

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.

@daangeerdink
Copy link

I have the same issue, with a library required by AutobahnJS called cbor. There I get this error when trying to build with --prod:

ERROR in vendor.f46aa55cec82811ad623.bundle.js from UglifyJs
Unexpected token: name (Decoder) [[...]/node_modules/cbor/lib/decoder.js:48,0][vendor.f46aa55cec82811ad623.bundle.js:23235,6]

Anyone have a solution?

@toregua
Copy link

toregua commented Aug 22, 2017

Same problem for me with quilljs when i try to create a custom theme based on snow theme, when i run "ng build --prod" :

ERROR in main.b5edce071b49acaa29f7.bundle.js from UglifyJs
Unexpected token: name (MyCustomTheme) [main.b5edce071b49acaa29f7.bundle.js:30679,6]

ERROR in vendor.f179b6171896e95f4169.bundle.js from UglifyJs
Unexpected token: name (debug) [vendor.f179b6171896e95f4169.bundle.js:16561,4]

Please give us a solution/workaround

@wingsbob
Copy link

I think all these issues are supposed to be gathered in #2907

@FrancescoBorzi
Copy link

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

@anhmaker
Copy link

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

@hubert17
Copy link

I as well can confirm that you can't switch back the target to es5 if you have package like SignalR core which propably uses es6.

@wingsbob
Copy link

Upgrade to a newer version of angular-cli, this has been fixed for a little while now: #7610

@Brocco Brocco closed this as completed Dec 29, 2017
potocnikj pushed a commit to potocnikj/tarocco that referenced this issue Jun 17, 2018
@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 Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity3: broken
Projects
None yet
Development

No branches or pull requests