Bootstrap v5 Uglifier
aedryan opened this issue · 3 comments
aedryan commented
After updating to Bootstrap v5 we started seeing the following output when running bundle exec rake assets:precompile
:
rake aborted!
Uglifier::Error: Unexpected token: keyword (const). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
--
11619 * --------------------------------------------------------------------------
11620 */
11621
11622 /**
11623 * ------------------------------------------------------------------------
11624 * Constants
11625 * ------------------------------------------------------------------------
11626 */
=> const elementMap = new Map();
11628 var data = {
11629 set(element, key, instance) {
11630 if (!elementMap.has(element)) {
11631 elementMap.set(element, new Map());
11632 }
11633
11634 const instanceMap = elementMap.get(element); // make it clear we only want one instance per element
11635 // can be removed later when multiple key/instances are fine to be used
==
/cache/gems/gems/uglifier-4.2.0/lib/uglifier.rb:291:in `parse_result'
/cache/gems/gems/uglifier-4.2.0/lib/uglifier.rb:221:in `run_uglifyjs'
/cache/gems/gems/uglifier-4.2.0/lib/uglifier.rb:176:in `compile_with_map'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/uglifier_compressor.rb:58:in `call'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/uglifier_compressor.rb:30:in `call'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/bundle.rb:32:in `block in call'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/bundle.rb:31:in `call'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/base.rb:81:in `find_asset'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/base.rb:88:in `find_all_linked_assets'
/cache/gems/gems/sprockets-4.0.2/lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
/cache/gems/gems/concurrent-ruby-1.1.8/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
/cache/gems/gems/concurrent-ruby-1.1.8/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:41:in `block in synchronize'
/cache/gems/gems/concurrent-ruby-1.1.8/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:41:in `synchronize'
/cache/gems/gems/concurrent-ruby-1.1.8/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:41:in `synchronize'
/cache/gems/gems/concurrent-ruby-1.1.8/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:19:in `execute'
/cache/gems/gems/concurrent-ruby-1.1.8/lib/concurrent-ruby/concurrent/promise.rb:563:in `block in realize'
/cache/gems/gems/concurrent-ruby-1.1.8/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:363:in `run_task'
/cache/gems/gems/concurrent-ruby-1.1.8/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `block (3 levels) in create_worker'
/cache/gems/gems/concurrent-ruby-1.1.8/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:335:in `loop'
/cache/gems/gems/concurrent-ruby-1.1.8/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:335:in `block (2 levels) in create_worker'
/cache/gems/gems/concurrent-ruby-1.1.8/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `catch'
/cache/gems/gems/concurrent-ruby-1.1.8/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block in create_worker'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
I was able to fix this by changing our environment configuration like so:
config.assets.js_compressor = Uglifier.new(harmony: true)
Which was formerly:
config.assets.js_compressor = :uglifier
But I just thought it worth mentioning if anyone else happens upon this and/or someone decides it's worth including in the changelog or release notes.
luccasmaso commented
Hi, you should use config.assets.js_compressor = :terser
for compression with ES6 (https://github.com/lautis/uglifier#readme)
Try replacing with gem 'terser', '~> 1.1.3'
in your Gemfile.
aedryan commented
That worked for us, thanks for the recommendation.
itsalongstory commented
config.assets.js_compressor = Uglifier.new(harmony: true)
harmony
no longer supports bootstrap 5.2