From 533e323dee8991b28747c6580167cccecb40e36e Mon Sep 17 00:00:00 2001
From: Pirate Praveen <praveen@debian.org>
Date: Thu, 1 Oct 2020 15:21:54 +0000
Subject: [PATCH] Switch to terser gem to replace uglifier

---
 Gemfile                           | 2 +-
 Gemfile.lock                      | 9 ++++-----
 config/environments/production.rb | 2 +-
 config/initializers/sprockets.rb  | 1 +
 4 files changed, 7 insertions(+), 7 deletions(-)
 create mode 100644 config/initializers/sprockets.rb

diff --git a/Gemfile b/Gemfile
index 56e55b52ab1c3..7c4c0939553e4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -290,7 +290,7 @@ gem 'gitlab_chronic_duration', '~> 0.10.6.2'
 gem 'rack-proxy', '~> 0.6.0'
 
 gem 'sassc-rails', '~> 2.1.0'
-gem 'uglifier', '~> 2.7.2'
+gem 'terser', '~> 1.0'
 
 gem 'addressable', '~> 2.7'
 gem 'font-awesome-rails', '~> 4.7'
diff --git a/Gemfile.lock b/Gemfile.lock
index 13a5c5832ac66..1e96934e34a13 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -312,7 +312,7 @@ GEM
       tzinfo
     eventmachine (1.2.7)
     excon (0.71.1)
-    execjs (2.6.0)
+    execjs (2.7.0)
     expression_parser (0.9.0)
     extended-markdown-filter (0.6.0)
       html-pipeline (~> 2.0)
@@ -1130,6 +1130,8 @@ GEM
     temple (0.8.2)
     terminal-table (1.8.0)
       unicode-display_width (~> 1.1, >= 1.1.1)
+    terser (1.0.1)
+      execjs (>= 0.3.0, < 3)
     test-prof (0.12.0)
     text (1.3.1)
     thin (1.7.2)
@@ -1157,9 +1159,6 @@ GEM
       thread_safe (~> 0.1)
     u2f (0.2.1)
     uber (0.1.0)
-    uglifier (2.7.2)
-      execjs (>= 0.3.0)
-      json (>= 1.8.0)
     unf (0.1.4)
       unf_ext
     unf_ext (0.0.7.5)
@@ -1483,13 +1482,13 @@ DEPENDENCIES
   stackprof (~> 0.2.15)
   state_machines-activerecord (~> 0.6.0)
   sys-filesystem (~> 1.1.6)
+  terser (~> 1.0)
   test-prof (~> 0.12.0)
   thin (~> 1.7.0)
   timecop (~> 0.9.1)
   toml-rb (~> 1.0.0)
   truncato (~> 0.7.11)
   u2f (~> 0.2.1)
-  uglifier (~> 2.7.2)
   unf (~> 0.1.4)
   unicorn (~> 5.5)
   unicorn-worker-killer (~> 0.4.4)
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 393a274606eae..d9b3ee354b0b3 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -12,7 +12,7 @@
   config.public_file_server.enabled = false
 
   # Compress JavaScripts and CSS.
-  config.assets.js_compressor = :uglifier
+  config.assets.js_compressor = :terser
   # config.assets.css_compressor = :sass
 
   # Don't fallback to assets pipeline if a precompiled asset is missed
diff --git a/config/initializers/sprockets.rb b/config/initializers/sprockets.rb
new file mode 100644
index 0000000000000..a20b7dc75e98a
--- /dev/null
+++ b/config/initializers/sprockets.rb
@@ -0,0 +1 @@
+Sprockets.register_compressor 'application/javascript', :terser, Terser::Compressor
-- 
GitLab