Skip to content

UglifyJs Unexpected token: name (Time)  #6655

Closed

Description

@alkuzman

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

Activity

  1. sumitarora commented on Jun 13, 2017

    @sumitarora
    Contributor

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

  2. alkuzman commented on Jun 13, 2017

    @alkuzman
    Author

    No, it works fine on dev mode

  3. self-assigned this
    on Jun 14, 2017
  4. added
    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
    on Jun 14, 2017
  5. jmls commented on Jun 16, 2017

    @jmls

    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)
    
  6. alkuzman commented on Jun 16, 2017

    @alkuzman
    Author

    Can you share some details abot TaskTableComponent?

  7. jmls commented on Jun 16, 2017

    @jmls

    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 ?

  8. marino-andriamialy commented on Jul 11, 2017

    @marino-andriamialy

    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

  9. alexander-kovalev commented on Jul 27, 2017

    @alexander-kovalev

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

  10. kirillgroshkov commented on Aug 10, 2017

    @kirillgroshkov

    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.

  11. daangeerdink commented on Aug 18, 2017

    @daangeerdink

    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?

  12. toregua commented on Aug 22, 2017

    @toregua

    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

  13. wingsbob commented on Sep 12, 2017

    @wingsbob

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

  14. FrancescoBorzi commented on Nov 13, 2017

    @FrancescoBorzi

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

  15. anhmaker commented on Dec 22, 2017

    @anhmaker

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

  16. hubert17 commented on Dec 29, 2017

    @hubert17

    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.

  17. wingsbob commented on Dec 29, 2017

    @wingsbob

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

  18. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    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.

  19. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentseverity3: broken

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions