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

ES6 support? #116

Closed
JRaspass opened this Issue Apr 6, 2017 · 8 comments

Comments

Projects
None yet
4 participants
@JRaspass
Contributor

JRaspass commented Apr 6, 2017

UglifyJS2 supports a subset of ES6 in their harmony branch, they make releases of both the regular version and the harmony version in sync - https://github.com/mishoo/UglifyJS2/releases

Would it be possible to either switch to this harmony release or perhaps import both and allow people to pass a flag? This grunt plugin did something very similar - gruntjs/grunt-contrib-uglify#393

@lautis

This comment has been minimized.

Owner

lautis commented Apr 6, 2017

As the UglifyJS releases seem to be now followed with a Harmony release, it could work to include both versions. I did few prerelease versions of Uglifier with the Harmony branch. Only very minor changes seemed to be necessary: 8744268.

lautis added a commit that referenced this issue Apr 6, 2017

Experimental ES6/Harmony mode
Include Harmony branch of UglifyJS. This can handle ES6 input, but
likely contains regressions. The released version of UglifyJS is still
the default unless Harmony mode is explicitly enabled.

Fixes #116.
@lautis

This comment has been minimized.

Owner

lautis commented Apr 6, 2017

@JRaspass I've implemented this in #117. Would you be interested to test?

@JRaspass

This comment has been minimized.

Contributor

JRaspass commented Apr 7, 2017

@lautis #117 worked beautifully for me, I replaced this line in my Gemfile:

-gem 'uglifier'
+gem 'uglifier', :git => 'https://github.com/lautis/uglifier.git', :ref => '9abd18da4f5eb2fb4b5aab8023f08470221743c1'

And then passed :harmony => true and it all worked, I used to get errors like this for arrow syntax:

JS_Parse_Error.get ((execjs):3538:621): SyntaxError: Unexpected token: operator (>) (ExecJS::RuntimeError)
@lautis

This comment has been minimized.

Owner

lautis commented Apr 7, 2017

Cool! I'll likely release that during the weekend.

@JRaspass

This comment has been minimized.

Contributor

JRaspass commented Apr 7, 2017

Thanks 👍

@lautis lautis closed this in #117 Apr 9, 2017

@lautis

This comment has been minimized.

Owner

lautis commented Apr 9, 2017

Released 3.2.0

@1c7

This comment has been minimized.

1c7 commented Nov 15, 2017

the ES6 problem waste my entire afternoon to get fix.

    setTimeout(() => {
      jQuery('#app').addClass('event_open');
    }, 1000);

change to

    setTimeout(function(){
      jQuery('#app').addClass('event_open');
    }, 1000);

problem solved.

the things is this code along with other thousands line of code,
that's why I didn't notice it for a long time.
then suddenly I saw the() => {) syntax there, I know that's ES6 syntax.
change it, and fixed!

Env

using Rails 5 and gem 'uglifier', '~> 3.2'

@nickrivadeneira

This comment has been minimized.

nickrivadeneira commented Nov 28, 2017

For anyone else who stumbles on this looking to make ES6 work for Rails 5.1 and Heroku deployments, this change worked for me in config/environments/production.rb:

config.assets.js_compressor = :uglifier

becomes

config.assets.js_compressor = Uglifier.new(harmony: true)

8398a7 added a commit to 8398a7/abilitysheet that referenced this issue Dec 3, 2017

Ewiseman referenced this issue in Ewiseman/profile Dec 7, 2017

davidwessman added a commit to pensionsupplysning/web that referenced this issue Jan 16, 2018

davidwessman added a commit to pensionsupplysning/web that referenced this issue Jan 16, 2018

davidwessman added a commit to pensionsupplysning/web that referenced this issue Jan 16, 2018

bragovo added a commit to luckypike/rain that referenced this issue Feb 28, 2018

bragovo added a commit to luckypike/rain that referenced this issue Feb 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment