lautis / uglifier

Ruby wrapper for UglifyJS JavaScript compressor.
http://www.rubydoc.info/gems/uglifier
MIT License
613 stars 82 forks source link

Error when using Javascript back-ticks for template literal #133

Closed javinto closed 4 years ago

javinto commented 6 years ago

When I use Javascript template literals for interpolation I get an Uglifier::Error. Example

console.log(`This should match ${times} times`);

I get the following error on deployment of my Rails application:

Uglifier::Error: Unexpected character '`'

.../bundle/ruby/2.4.0/gems/uglifier-4.1.8/lib/uglifier.rb:234:in `parse_result'

opensourceame commented 6 years ago

You need to change the parsing engine. Edit your config/environment/production.rb and look for the Uglifier line. Change it to:

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

see:

https://github.com/lautis/uglifier#rails

juansecaro commented 4 years ago

You need to change the parsing engine. Edit your config/environment/production.rb and look for the Uglifier line. Change it to:

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

see:

https://github.com/lautis/uglifier#rails

Thanks! That did the work

tylerbeckert commented 4 years ago

You need to change the parsing engine. Edit your config/environment/production.rb and look for the Uglifier line. Change it to:

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

see:

https://github.com/lautis/uglifier#rails

This resolved the issue for me too 👍🏻

javinto commented 4 years ago

Thank you, just tested with config.assets.js_compressor = Uglifier.new(harmony: true) and that solved the problem.