Skip to content
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

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

Closed
tx8821 opened this issue Jul 26, 2017 · 5 comments
Closed

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

tx8821 opened this issue Jul 26, 2017 · 5 comments

Comments

@tx8821
Copy link

tx8821 commented Jul 26, 2017

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?

@siemato
Copy link

siemato commented Jul 26, 2017

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.

@coryrylan
Copy link
Contributor

coryrylan commented Jul 26, 2017

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.

@filipesilva
Copy link
Contributor

Duplicate of #2907

@filipesilva filipesilva marked this as a duplicate of #2907 Jul 31, 2017
@hiepxanh
Copy link
Contributor

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

@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
None yet
Projects
None yet
Development

No branches or pull requests

5 participants