Project

General

Profile

Refactor #26790

Recognize ES6 syntax in asset pipeline when compressing for production

Added by Ondřej Pražák about 4 years ago. Updated about 4 years ago.

Status:
Rejected
Priority:
Normal
Category:
JavaScript stack
Target version:
-
Fixed in Releases:
Found in Releases:
Red Hat JIRA:

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)

Related issues

Related to Foreman - Bug #26606: Support gridster for pluginsClosed
Related to Foreman - Bug #26800: Running db migrations on nightlies fails with "LoadError: cannot load such file -- uglifier"Resolved

Associated revisions

Revision 940c0e02 (diff)
Added by Ondřej Pražák about 4 years ago

Fixes #26790 - Support ES6 in Uglifier

History

#1 Updated by Ondřej Pražák about 4 years ago

  • Related to Bug #26606: Support gridster for plugins added

#2 Updated by The Foreman Bot about 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/6755 added

#3 Updated by Ohad Levy about 4 years ago

  • Target version set to 1.23.0
  • Fixed in Releases 1.23.0 added

#4 Updated by Ondřej Pražák about 4 years ago

  • Status changed from Ready For Testing to Closed

#5 Updated by The Foreman Bot about 4 years ago

  • Pull request https://github.com/theforeman/foreman/pull/6759 added

#6 Updated by Anonymous about 4 years ago

  • Target version changed from 1.23.0 to 1.22.0
  • Fixed in Releases 1.22.0 added

#7 Updated by Adam Ruzicka about 4 years ago

  • Related to Bug #26800: Running db migrations on nightlies fails with "LoadError: cannot load such file -- uglifier" added

#8 Updated by Tomer Brisker about 4 years ago

  • Status changed from Closed to Rejected
  • Fixed in Releases deleted (1.22.0, 1.23.0)

The fix for this caused other issues and was reverted.

#9 Updated by Tomer Brisker about 4 years ago

  • Target version deleted (1.22.0)

Also available in: Atom PDF