Skip to content

Commit

Permalink
[branch 4.x] Minify JS: migrate from Uglifier to Terser gem to suppor…
Browse files Browse the repository at this point in the history
…t ES6 (#2531)

* Minify JS: migrate from Uglifier to Terser gem to support ES6

* [SPECS] features/minify_javascript: match Terser defaults for IIFE

Co-authored-by: Thomas Reynolds <me@tdreyno.com>
  • Loading branch information
markets and tdreyno committed Feb 10, 2022
1 parent 8ae4e0a commit 718df1f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ PATH
rack (>= 1.4.5, < 3)
sassc (~> 2.0)
servolux
terser (~> 1.1)
tilt (~> 2.0.9)
toml
uglifier (~> 3.0)
webrick

GEM
Expand Down Expand Up @@ -207,6 +207,8 @@ GEM
temple (0.8.2)
term-ansicolor (1.7.1)
tins (~> 1.0)
terser (1.1.8)
execjs (>= 0.3.0, < 3)
thor (0.19.4)
tilt (2.0.10)
timers (4.0.4)
Expand All @@ -217,8 +219,6 @@ GEM
parslet (>= 1.8.0, < 3.0.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (2.0.0)
webrick (1.7.0)
xpath (2.1.0)
Expand Down
10 changes: 5 additions & 5 deletions middleman-core/features/minify_javascript.feature
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ Feature: Minify Javascript
Then I should see:
"""
<script>
!function(){should(),all.be(),on={one:line}}();
should(),all.be(),on={one:line};
</script>
<script>
!function(){should(),too()}();
should(),too();
</script>
<script type='text/javascript'>
//<!--
!function(){one,line(),here()}();
one,line(),here();
//-->
</script>
<script type='text/html'>
Expand All @@ -159,11 +159,11 @@ Feature: Minify Javascript
<?='Hello'?>
<script>
!function(){should(),all.be(),on={one:line}}();
should(),all.be(),on={one:line};
</script>
<script type='text/javascript'>
//<!--
!function(){one,line(),here()}();
one,line(),here();
//-->
</script>
<script type='text/html'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,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'
Expand Down
2 changes: 1 addition & 1 deletion middleman-core/middleman-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Gem::Specification.new do |s|
s.add_dependency('sassc', ['~> 2.0'])

# Minify JS
s.add_dependency('uglifier', ['~> 3.0'])
s.add_dependency('terser', ['~> 1.1'])
s.add_dependency('execjs', ['~> 2.0'])

# Testing
Expand Down

0 comments on commit 718df1f

Please sign in to comment.