Skip to content

Commit

Permalink
Fix Uglifier parse error
Browse files Browse the repository at this point in the history
Before:

```
$ RAILS_ENV=production SECRET_KEY_BASE=lkajsdflkajsdflkajsdlfkjasdlkfj be rake assets:precompile
rake aborted!
Uglifier::Error: Unexpected token: punc ((). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
--
 11011   factory(global.ActionCable = {}));
 11012 })(this, (function(exports) {
 11013   "use strict";
 11014   var adapters = {
 11015     logger: self.console,
 11016     WebSocket: self.WebSocket
 11017   };
 11018   var logger = {
    =>     log(...messages) {
 11020       if (this.enabled) {
 11021         messages.push(Date.now());
 11022         adapters.logger.log("[ActionCable]", ...messages);
 11023       }
 11024     }
 11025   };
 11026   const now = () => (new Date).getTime();
 11027   const secondsSince = time => (now() - time) / 1e3;
==
/Users/rschneeman/.gem/ruby/3.1.2/gems/uglifier-4.2.0/lib/uglifier.rb:291:in `parse_result'
/Users/rschneeman/.gem/ruby/3.1.2/gems/uglifier-4.2.0/lib/uglifier.rb:221:in `run_uglifyjs'
/Users/rschneeman/.gem/ruby/3.1.2/gems/uglifier-4.2.0/lib/uglifier.rb:176:in `compile_with_map'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/uglifier_compressor.rb:58:in `call'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/uglifier_compressor.rb:30:in `call'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:84:in `call_processor'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:65:in `reverse_each'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:65:in `call_processors'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/loader.rb:182:in `load_from_unloaded'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/loader.rb:59:in `block in load'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/loader.rb:43:in `load'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/cached_environment.rb:44:in `block in load'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/cached_environment.rb:44:in `fetch'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/cached_environment.rb:44:in `load'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/base.rb:81:in `find_asset'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/base.rb:88:in `find_all_linked_assets'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/manifest.rb:125:in `each'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/manifest.rb:125:in `to_a'
/Users/rschneeman/.gem/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
/Users/rschneeman/.gem/ruby/3.1.2/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
/Users/rschneeman/.gem/ruby/3.1.2/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `block in synchronize'
/Users/rschneeman/.gem/ruby/3.1.2/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
/Users/rschneeman/.gem/ruby/3.1.2/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
/Users/rschneeman/.gem/ruby/3.1.2/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:22:in `execute'
/Users/rschneeman/.gem/ruby/3.1.2/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/promise.rb:564:in `block in realize'
/Users/rschneeman/.gem/ruby/3.1.2/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `run_task'
/Users/rschneeman/.gem/ruby/3.1.2/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:343:in `block (3 levels) in create_worker'
/Users/rschneeman/.gem/ruby/3.1.2/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `loop'
/Users/rschneeman/.gem/ruby/3.1.2/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block (2 levels) in create_worker'
/Users/rschneeman/.gem/ruby/3.1.2/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `catch'
/Users/rschneeman/.gem/ruby/3.1.2/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `block in create_worker'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
```

After:

```
$ RAILS_ENV=production SECRET_KEY_BASE=lkajsdflkajsdflkajsdlfkjasdlkfj be rake assets:precompile
I, [2022-07-25T15:42:50.648241 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/tabs-802b0bd70d12f0493270a5048112a756fe63affbe3e36963195fd6eb1425c572.js
I, [2022-07-25T15:42:50.648610 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/tabs-802b0bd70d12f0493270a5048112a756fe63affbe3e36963195fd6eb1425c572.js.gz
I, [2022-07-25T15:42:50.648916 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/dashboard-52cc0a6f738f77e24d3f013a2174dec68837e664eab4a773f21ebab84b01420a.js
I, [2022-07-25T15:42:50.649156 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/dashboard-52cc0a6f738f77e24d3f013a2174dec68837e664eab4a773f21ebab84b01420a.js.gz
I, [2022-07-25T15:42:50.650432 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/application-6c1f44e72ef041282b5b7c93afdab24345af0e4a8c386c25eb884b2e2c4e2d8c.js
I, [2022-07-25T15:42:50.650703 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/application-6c1f44e72ef041282b5b7c93afdab24345af0e4a8c386c25eb884b2e2c4e2d8c.js.gz
I, [2022-07-25T15:42:50.651415 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/actiontext-81e286cd6b71a0827990aec2867dcfab7c94caaa3feeaf55466a7741c30b7d40.js
I, [2022-07-25T15:42:50.651617 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/actiontext-81e286cd6b71a0827990aec2867dcfab7c94caaa3feeaf55466a7741c30b7d40.js.gz
I, [2022-07-25T15:42:50.651785 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/trix-0739f876ba5e18ebd2717232387e6752c6328d7d97ce143d8866f6e9f3d279e7.js
I, [2022-07-25T15:42:50.652401 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/trix-0739f876ba5e18ebd2717232387e6752c6328d7d97ce143d8866f6e9f3d279e7.js.gz
I, [2022-07-25T15:42:50.653206 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/activestorage-997aaa7ee7cd1f853586f1abbcf8a4fa59a8f80270c9033c09ad406150f80e3a.js
I, [2022-07-25T15:42:50.653665 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/activestorage-997aaa7ee7cd1f853586f1abbcf8a4fa59a8f80270c9033c09ad406150f80e3a.js.gz
I, [2022-07-25T15:42:50.654071 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/activestorage.esm-aaa35775410d4c9038d69046036657c2fea6d5e47bd681dc92f11b306087ed6a.js
I, [2022-07-25T15:42:50.654387 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/activestorage.esm-aaa35775410d4c9038d69046036657c2fea6d5e47bd681dc92f11b306087ed6a.js.gz
I, [2022-07-25T15:42:50.654743 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/actioncable-92f6c9e9908a7b2c224e5a6689d938937329ad215f2aacdb7781f28795cf6809.js
I, [2022-07-25T15:42:50.656641 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/actioncable-92f6c9e9908a7b2c224e5a6689d938937329ad215f2aacdb7781f28795cf6809.js.gz
I, [2022-07-25T15:42:50.657066 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/actioncable.esm-6ff4c875f7c74aded61b68b042ce24650c7caa1003f6c99a64a37b40dc13ec8d.js
I, [2022-07-25T15:42:50.657394 #52075]  INFO -- : Writing /Users/rschneeman/Documents/projects/work/tmp/webhooks-demo/public/assets/actioncable.esm-6ff4c875f7c74aded61b68b042ce24650c7caa1003f6c99a64a37b40dc13ec8d.js.gz
```

Additional details in this issue: lautis/uglifier#127 (comment)
  • Loading branch information
schneems committed Jul 25, 2022
1 parent f652b47 commit 8109622
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false

# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# Compress JavaScripts and CSS.
config.assets.js_compressor = Uglifier.new(harmony: true)
# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
Expand Down

0 comments on commit 8109622

Please sign in to comment.