Closed JRaspass closed 7 years ago
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: https://github.com/lautis/uglifier/commit/8744268a8c46fcef19eeace51e49d911339e4edf.
@JRaspass I've implemented this in https://github.com/lautis/uglifier/pull/117. Would you be interested to test?
@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)
Cool! I'll likely release that during the weekend.
Thanks :+1:
Released 3.2.0
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!
using Rails 5 and gem 'uglifier', '~> 3.2'
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)
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 - https://github.com/gruntjs/grunt-contrib-uglify/issues/393