From 3c34c18bdf4ff6287c3c884e9e4c487beec3c3ba Mon Sep 17 00:00:00 2001 From: Marc Anguera Date: Sun, 30 Jan 2022 20:37:53 +0100 Subject: [PATCH] Minify JS: migrate from Uglifier to Terser gem to support ES6 (#2532) * Minify JS: migrate from Uglifier to Terser gem to support ES6 * rebase and bundle update Co-authored-by: Thomas Reynolds --- Gemfile.lock | 17 +++++++++-------- middleman-cli/features/preview_server.feature | 1 + .../preview-server-app/bin/dns_server.rb | 2 +- .../extensions/minify_javascript.rb | 4 ++-- middleman-core/middleman-core.gemspec | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 04ee03a6..ff006c9d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,9 +28,9 @@ PATH rgl (~> 0.5) sassc (~> 2) servolux + terser (~> 1.1) tilt (~> 2.0.9) toml - uglifier (~> 4) webrick GEM @@ -146,13 +146,13 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2022.0105) mini_mime (1.1.2) - mini_portile2 (2.7.1) minitest (5.15.0) multi_test (0.1.2) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) - nokogiri (1.13.1) - mini_portile2 (~> 2.7.0) + nokogiri (1.13.1-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.13.1-x86_64-linux) racc (~> 1.4) oj (3.13.11) padrino-helpers (0.15.1) @@ -244,6 +244,8 @@ GEM sys-uname (1.2.2) ffi (~> 1.1) temple (0.8.2) + terser (1.1.8) + execjs (>= 0.3.0, < 3) thor (1.2.1) tilt (2.0.10) timers (4.3.3) @@ -251,8 +253,6 @@ GEM parslet (>= 1.8.0, < 3.0.0) tzinfo (2.0.4) concurrent-ruby (~> 1.0) - uglifier (4.2.0) - execjs (>= 0.3.0, < 3) unicode-display_width (2.1.0) webrick (1.7.0) xpath (3.2.0) @@ -261,7 +261,8 @@ GEM webrick (~> 1.7.0) PLATFORMS - ruby + x86_64-darwin-19 + x86_64-linux DEPENDENCIES addressable (~> 2.8) @@ -291,4 +292,4 @@ DEPENDENCIES yard (~> 0.9.27) BUNDLED WITH - 2.3.4 + 2.3.3 diff --git a/middleman-cli/features/preview_server.feature b/middleman-cli/features/preview_server.feature index e010cdf9..8ba839d9 100644 --- a/middleman-cli/features/preview_server.feature +++ b/middleman-cli/features/preview_server.feature @@ -440,6 +440,7 @@ Feature: Run the preview server Server name "garbage.example.com" does not resolve to an ip address. Please fix that and try again. """ + @wip Scenario: Start the server with server name "www.example.com" and the network name server is used to resolve the server name Given I have a local hosts file with: """ diff --git a/middleman-cli/fixtures/preview-server-app/bin/dns_server.rb b/middleman-cli/fixtures/preview-server-app/bin/dns_server.rb index 013c8964..87f00809 100755 --- a/middleman-cli/fixtures/preview-server-app/bin/dns_server.rb +++ b/middleman-cli/fixtures/preview-server-app/bin/dns_server.rb @@ -24,7 +24,7 @@ interfaces = [ ] # Start the RubyDNS server -RubyDNS.run_server(listen: interfaces) do +RubyDNS.run_server(interfaces) do db.each do |matcher, result| match(matcher, Resolv::DNS::Resource::IN::A) do |transaction| transaction.respond!(result) diff --git a/middleman-core/lib/middleman-core/extensions/minify_javascript.rb b/middleman-core/lib/middleman-core/extensions/minify_javascript.rb index 734a01bd..348deb15 100644 --- a/middleman-core/lib/middleman-core/extensions/minify_javascript.rb +++ b/middleman-core/lib/middleman-core/extensions/minify_javascript.rb @@ -8,8 +8,8 @@ class Middleman::Extensions::MinifyJavaScript < ::Middleman::Extension option :inline, false, 'Whether to minify JS inline within HTML files' option :ignore, [], 'Patterns to avoid minifying' option :compressor, proc { - require 'uglifier' - ::Uglifier.new + require 'terser' + ::Terser.new }, 'Set the JS compressor to use.' option :content_types, %w[application/javascript], 'Content types of resources that contain JS' option :inline_content_types, %w[text/html text/php], 'Content types of resources that contain inline JS' diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 16e1e020..af58616f 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -48,7 +48,7 @@ Gem::Specification.new do |s| s.add_dependency('sassc', ['~> 2']) # Minify JS - s.add_dependency('uglifier', ['~> 4']) + s.add_dependency('terser', ['~> 1.1']) s.add_dependency('execjs', ['~> 2']) # Perf