Uglifier error in production mode on RoR 7.0.3.1 with Bootstrap 5.2
See original GitHub issueRuby 3.1.2 Ruby on Rails 7.0.3.1 gem Uglifier 4.2.0 Third party library: Bootstrap 5.2 ( new version 5.2 released )
With bootstrap 5.1.3 (previous version) all works fine!
app/assets/config/manifest.js
:
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
//= link lib/bootstrap/5.2.0/js/bootstrap.bundle.min.js
//= link lib/bootstrap/5.2.0/js/bootstrap.min.js
//= link lib/bootstrap/5.2.0/css/bootstrap.min.css
in view stylesheets and javascripts are attached via stylesheet_link_tag
and javascript_include_tag
config/environments/production.rb
:
config.assets.compile = true
config.assets.js_compressor = Uglifier.new(harmony: true)
log/production.log
:
I, [2022-08-04T20:29:16.542499 #11922] INFO -- : [425e1b3d-5d27-4e00-afdf-d698f79e50ab] Started GET "/" for 127.0.0.1 at 2022-08-04 20:29:16 +0500
I, [2022-08-04T20:29:16.545698 #11922] INFO -- : [425e1b3d-5d27-4e00-afdf-d698f79e50ab] Processing by ApplicationBaseController#index as HTML
I, [2022-08-04T20:29:16.554844 #11922] INFO -- : [425e1b3d-5d27-4e00-afdf-d698f79e50ab] Rendered application_base/index.html.erb within layouts/application (Duration: 0.9ms | Allocations: 314)
I, [2022-08-04T20:29:33.586606 #11922] INFO -- : [425e1b3d-5d27-4e00-afdf-d698f79e50ab] Rendered layout layouts/application.html.erb (Duration: 17032.8ms | Allocations: 628213)
I, [2022-08-04T20:29:33.586988 #11922] INFO -- : [425e1b3d-5d27-4e00-afdf-d698f79e50ab] Completed 500 Internal Server Error in 17041ms (ActiveRecord: 0.7ms | Allocations: 630135)
F, [2022-08-04T20:29:33.587842 #11922] FATAL -- : [425e1b3d-5d27-4e00-afdf-d698f79e50ab]
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] ActionView::Template::Error (
):
[425e1b3d-5d27-4e00-afdf-d698f79e50ab]
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] uglifier (4.2.0) lib/uglifier.rb:291:in `parse_result'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] uglifier (4.2.0) lib/uglifier.rb:221:in `run_uglifyjs'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] uglifier (4.2.0) lib/uglifier.rb:166:in `compile'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/compressing.rb:84:in `block in js_compressor='
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/processor_utils.rb:84:in `call_processor'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/processor_utils.rb:66:in `block in call_processors'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/processor_utils.rb:65:in `reverse_each'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/processor_utils.rb:65:in `call_processors'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/loader.rb:182:in `load_from_unloaded'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/loader.rb:59:in `block in load'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/loader.rb:43:in `load'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/cached_environment.rb:44:in `block in load'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/cached_environment.rb:44:in `fetch'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/cached_environment.rb:44:in `load'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/bundle.rb:32:in `block in call'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] /home/ruby/.rbenv/versions/3.1.2/lib/ruby/3.1.0/set.rb:511:in `each_key'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] /home/ruby/.rbenv/versions/3.1.2/lib/ruby/3.1.0/set.rb:511:in `each'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/bundle.rb:31:in `call'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/processor_utils.rb:84:in `call_processor'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/processor_utils.rb:66:in `block in call_processors'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/processor_utils.rb:65:in `reverse_each'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/processor_utils.rb:65:in `call_processors'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/loader.rb:182:in `load_from_unloaded'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/loader.rb:59:in `block in load'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/loader.rb:43:in `load'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/cached_environment.rb:44:in `block in load'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/cached_environment.rb:44:in `fetch'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/cached_environment.rb:44:in `load'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/bundle.rb:32:in `block in call'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] /home/ruby/.rbenv/versions/3.1.2/lib/ruby/3.1.0/set.rb:511:in `each_key'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] /home/ruby/.rbenv/versions/3.1.2/lib/ruby/3.1.0/set.rb:511:in `each'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/bundle.rb:31:in `call'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/processor_utils.rb:84:in `call_processor'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/processor_utils.rb:66:in `block in call_processors'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/processor_utils.rb:65:in `reverse_each'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/processor_utils.rb:65:in `call_processors'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/loader.rb:182:in `load_from_unloaded'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/loader.rb:59:in `block in load'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/loader.rb:43:in `load'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/cached_environment.rb:44:in `block in load'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/cached_environment.rb:44:in `fetch'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/cached_environment.rb:44:in `load'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/base.rb:81:in `find_asset'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/base.rb:88:in `find_all_linked_assets'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/manifest.rb:125:in `each'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/manifest.rb:125:in `to_a'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] sprockets (4.1.1) lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] concurrent-ruby (1.1.10) lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] concurrent-ruby (1.1.10) lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `block in synchronize'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] concurrent-ruby (1.1.10) lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] concurrent-ruby (1.1.10) lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] concurrent-ruby (1.1.10) lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:22:in `execute'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] concurrent-ruby (1.1.10) lib/concurrent-ruby/concurrent/promise.rb:564:in `block in realize'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] concurrent-ruby (1.1.10) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `run_task'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] concurrent-ruby (1.1.10) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:343:in `block (3 levels) in create_worker'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] concurrent-ruby (1.1.10) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `loop'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] concurrent-ruby (1.1.10) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block (2 levels) in create_worker'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] concurrent-ruby (1.1.10) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `catch'
[425e1b3d-5d27-4e00-afdf-d698f79e50ab] concurrent-ruby (1.1.10) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `block in create_worker'
All other compressors are works with errors in this case
Issue Analytics
- State:
- Created a year ago
- Comments:14
Top Results From Across the Web
Some problems with attach Bootstrap 5.2 to Ruby on Rails
I have some problems with attach Bootstrap v5.2 , but v5.1.3 was work fine. Error in production mode on RoR 7.0.3.1 with Bootstrap...
Read more >ES6 syntax, harmony mode must be enabled with Uglifier. ...
Uglifier ::Error: Unexpected token: keyword (const). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true). while ...
Read more >Upgrading Ruby on Rails
Upgrading Ruby on RailsThis guide provides steps to be followed when you upgrade your applications to a newer version of Ruby on Rails....
Read more >Rails 7, Bootstrap 5 tutorial : fear and relief
Rails 7 has a very opinionated way to handle the front-end assets. Let's see how it works for Bootstrap 5.
Read more >the asset "application.js" is not present in the asset pipeline
I set it up with bootstrap preinstalled using Ruby 3.1.2 and Rails 7.0.3 and when I try to render a page on my...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@itsalongstory Ah, ok - that explains it.
The README does say
UglifyJS only works with ES5. If you need to compress ES6, [ruby-terser](https://github.com/ahorek/terser-ruby) is a better option.
I switched to terser and that solved my problem, so I think that’s the resolution for this issue. If terser doesn’t work for you I would suggest opening an issue against the terser repo.
I think the problem is uglifier doesn’t full support ES6, and Bootstrap 5.2 has some new ES6 code.