Actions
Refactor #26790
closedRecognize ES6 syntax in asset pipeline when compressing for production
Difficulty:
Triaged:
No
Description
As more legacy js code is moved into webpack, often elements of ES6 syntax are used. However, there are plugins that rely on some parts of the moved js files and are not not webpacked. The problem is that Uglifier is not able to recognize ES6 syntax when compiling assets in production for a non-webpacked plugin and the plugin relies on webpacked assets from core.
Steps to reproduce:
1) foreman 1.22 or later, foreman_openscap 1.0.0
2) rake plugin:assets:precompile['foreman_openscap'] RAILS_ENV='production'
rake aborted! Uglifier::Error: Unexpected token: punc ()). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true). /home/vagrant/.rvm/gems/ruby-2.4.1/gems/uglifier-4.1.20/lib/uglifier.rb:234:in `parse_result' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/uglifier-4.1.20/lib/uglifier.rb:216:in `run_uglifyjs' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/uglifier-4.1.20/lib/uglifier.rb:168:in `compile' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:53:in `call' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:28:in `call' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `reverse_each' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/base.rb:73:in `find_all_linked_assets' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:134:in `block in find' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:133:in `each' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:133:in `find' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:186:in `compile' /home/vagrant/projects/foreman/lib/tasks/plugin_assets.rake:24:in `block in compile' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/rake/sprocketstask.rb:147:in `with_logger' /home/vagrant/projects/foreman/lib/tasks/plugin_assets.rake:23:in `compile' /home/vagrant/projects/foreman/lib/tasks/plugin_assets.rake:63:in `block in <top (required)>' /home/vagrant/.rvm/gems/ruby-2.4.1/gems/rake-12.3.2/exe/rake:27:in `<top (required)>' /home/vagrant/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `eval' /home/vagrant/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `<main>' Tasks: TOP => plugin:assets:precompile (See full trace by running task with --trace)
Actions