mishoo/UglifyJS

It seems like uglify-js does not support es6?

Closed this issue · 11 comments

when I use generator, I got this error, will you support es6? Thank you.

Unexpected token operator «*»
avdg commented

It's still not in, but you can follow #448 if you want

As @avdg indicated, you can follow #448 for es6 support. Thanks!

kzc commented

This is the official uglify package for ES6/ES2015:

https://www.npmjs.com/package/uglify-es

Can anybody(@phoenixeliot) tell why there is a downvote for @Piusha, the answer worked for me?
Is there any issue with the package, its mentioned in the webpack site itself !

I was facing issue with webpack.optimize.UglifyJsPlugin for a simple code 10 ** 5.

I got it working with uglifyjs-webpack-plugin .

kzc commented

Anyone can downvote anything on github. It doesn't mean their opinion is necessarily correct.

uglifyjs-webpack-plugin@1.x is an uglify-es wrapper library supported the webpack project. It appears to works fine for ES6+. Any questions for that plugin should be directed to https://github.com/webpack-contrib/uglifyjs-webpack-plugin

Simple to me: UglifyJS does not support ES6 anymore from 2.0 as per the release notes.
https://github.com/webpack-contrib/uglifyjs-webpack-plugin/releases/tag/v2.0.0

avdg commented

UglifyJS never supported es6 feature from master, all work on es6 and later was done on a separate branch or on separate projects.

In case anybody else is as confused as I was an hour ago:

  • uglify-js has never supported ES6
  • uglify-es supports ES6 but was abandoned
  • tercer is a fork of uglify-es that is under active development
  • uglifyjs-webpack-plugin went from using uglify-js (no ES6) under the hood, to uglify-es (yes ES6), back to uglify-js (no ES6), and now uses tercer (yes ES6).

If you, like me, ever manually made an instance of uglifyjs-webpack-plugin in your config (probably to specify non-default options), you briefly had ES6 support but it went away again through no fault of your own. Switch to tercer-webpack-plugin, rename uglifyOptions to tercerOptions, and everything will probably be fine.

@thw0rted For anyone else reading, it's terser. Thanks for the clarification @thw0rted

Well, hell. I must have been pretty burned out by the time I wrote that because I had it right in my notes, and of course "terser" is a clever play on words while "tercer" means nothing. I'm really impressed I managed to get it wrong like 5 times, consistently, in that one post. 🤷‍♂️