I’m using hotwire-rails with assets pipeline, it works fine when js_compressor
is off but raised an Uglifier::Error Unexpected token: keyword (extends) Error
if js_compressor
is on. I knew I can’t do concatenation or transpiling, but I should be able to do compression?
I knew this should be a Uglifier issue, but all Uglifier solution is suggested pass harmony: true
, I already did it, event tried terser
, still got the same error, I can’t figure it out.
# config/environments/development.rb
config.assets.js_compressor = Uglifier.new(harmony: true)
bundle exec assets:precompile Exception backtrace
Uglifier::Error: Unexpected token: keyword (extends)
--
1 import { Controller } from "stimulus"
2
=> export default class extends Controller {
4 connect() {
5 this.element.textContent = "Hello World!"
6 }
7 };
/Users/fangxing/.rvm/gems/ruby-2.6.6/gems/uglifier-4.2.0/lib/uglifier.rb:291:in `parse_result'
/Users/fangxing/.rvm/gems/ruby-2.6.6/gems/uglifier-4.2.0/lib/uglifier.rb:221:in `run_uglifyjs'
/Users/fangxing/.rvm/gems/ruby-2.6.6/gems/uglifier-4.2.0/lib/uglifier.rb:166:in `compile'
/Users/fangxing/.rvm/gems/ruby-2.6.6/gems/sprockets-4.0.2/lib/sprockets/compressing.rb:84:in `block in js_compressor='