Skip to content

ng build -prod FAILS with UglifyJs error when targeting ES2015!! #7149

Closed

Description

@tx8821

Bug Report or Feature Request (mark with an x)

- [X] bug report
- [ ] feature request

Versions.

Project 1: @angular/cli: 1.1.3
Project 2: @angular/cli: 1.3.0-rc.1

node: 7.10.0
os: win32 x64

In tsconfig.json: "target": "es2015"

Repro steps.

Create new app. Target tsconfig to ES2015. Build with -prod flag. Get the errors.

The log given by the failure.

ERROR in main.d3a567e3e4474c9592a2.bundle.js from UglifyJs
Unexpected token: name (AppModule) [main.d3a567e3e4474c9592a2.bundle.js:23,6]

Mention any other details that might be useful.

When I set ES2015 as target in my tsconfig, I can't use -prod flag anymore! Getting UglifyJs errors!
My limited research concludes that Uglify cannot parse ES6, link here: webpack/webpack#2972 (comment)

I need -prod flag, and I need to target ES2015. Am I missing something?

Activity

  1. siemato commented on Jul 26, 2017

    @siemato

    As far as I know UglifyJS does not support es2015.

    This is a statement from the UglifyJS Readme:

    Those wishing to minify ES2015+ (ES6+) should use the npm package uglify-es.

  2. coryrylan commented on Jul 26, 2017

    @coryrylan
    Contributor

    What @siedentm said is correct. Currently the CLI does not support ES2015 as an option when compiling modules I believe. The CLI would have to adjust the uglify plugin dependent on the module type set in the TSConfig.

  3. filipesilva commented on Jul 31, 2017

    @filipesilva
    Contributor

    Duplicate of #2907

  4. hiepxanh commented on Oct 12, 2017

    @hiepxanh
    Contributor

    hello, I upgrade to angular 5 beta 4 and still get errror Unexpected token: name (AppModule), what should i do ?

  5. 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.

  6. 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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions