During a recent Rails 5 -> 6 upgrade we encountered an ES6 bug. Here’s the error message:
1 ActionView::Template::Error (Unexpected token: keyword (const). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true)
ES6 is the new standard, in Rails 6, and it doesn’t support Uglifier. However, it’s not a big problem because Webpacker is now the default Rails 6 asset compiler. Webpacker removes the need for Uglifier so we can safely remove it.
- Remove the
- gem 'uglifier'
- Remove the js_compressor step from
1 - config.assets.js_compressor = :uglifier