Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update terser to 5.27.0 #50

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ jobs:
fail-fast: true
matrix:
include:
- { ruby: 2.7, c-o-e: false }
- { ruby: '3.0', c-o-e: false }
- { ruby: 3.1, c-o-e: false }
- { ruby: 3.2, c-o-e: false }
- { ruby: 3.3, c-o-e: false }
- { ruby: jruby-9.4.5.0, c-o-e: false }
- { ruby: ruby-head, c-o-e: true }
- { ruby: jruby-head, c-o-e: true }
- { ruby: truffleruby, c-o-e: true }
- { ruby: truffleruby-head, c-o-e: true }
- { ruby: 3.2, gemfile: ./gemfiles/miniracer, c-o-e: false }
- { ruby: 3.3, gemfile: ./gemfiles/miniracer, c-o-e: false }
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
Expand Down
42 changes: 42 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,48 @@ Style/RedundantStringEscape: # new in 1.37
Enabled: true
Style/SelectByRegexp: # new in 1.22
Enabled: true
Lint/DuplicateMatchPattern: # new in 1.50
Enabled: true
Lint/ItWithoutArgumentsInBlock: # new in 1.59
Enabled: true
Lint/LiteralAssignmentInCondition: # new in 1.58
Enabled: true
Lint/MixedCaseRange: # new in 1.53
Enabled: true
Lint/RedundantRegexpQuantifiers: # new in 1.53
Enabled: true
Metrics/CollectionLiteralLength: # new in 1.47
Enabled: true
Style/DataInheritance: # new in 1.49
Enabled: true
Style/DirEmpty: # new in 1.48
Enabled: true
Style/ExactRegexpMatch: # new in 1.51
Enabled: true
Style/FileEmpty: # new in 1.48
Enabled: true
Style/RedundantArrayConstructor: # new in 1.52
Enabled: true
Style/RedundantCurrentDirectoryInPath: # new in 1.53
Enabled: true
Style/RedundantFilterChain: # new in 1.52
Enabled: true
Style/RedundantLineContinuation: # new in 1.49
Enabled: true
Style/RedundantRegexpArgument: # new in 1.53
Enabled: true
Style/RedundantRegexpConstructor: # new in 1.52
Enabled: true
Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
Enabled: true
Style/SingleLineDoEndBlock: # new in 1.57
Enabled: true
Style/SuperWithArgsParentheses: # new in 1.58
Enabled: true
Style/YAMLFileRead: # new in 1.53
Enabled: true
Performance/MapMethodChain: # new in 1.19
Enabled: true

Performance/AncestorsInclude:
Enabled: true
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
## Unreleased
## 1.2.0 (22 January 2024)
- update TerserJS to [5.27.0]
- remove sourcemap patches
- `pure_new` option added
- EOL rubies are no longer tested
- update rubocop

## 1.1.20 (27 November 2023)
- update TerserJS to [5.24.0]
- fix mangle properties, thanks @khaitu!
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ source "https://rubygems.org"

gemspec

unless RUBY_VERSION < '2.6'
unless RUBY_VERSION < '2.7'
group :development do
gem 'rubocop', '~> 1.46.0'
gem 'rubocop-performance', '~> 1.16.0', :require => false
gem 'rubocop', '~> 1.60.1'
gem 'rubocop-performance', '~> 1.20.2', :require => false
end
end
2 changes: 0 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ namespace :terser do

cd 'vendor/terser/' do
FileUtils.rm_rf("package-lock.json")
`patch -p1 -i ../../patches/terser-sync.patch`
`patch -p1 -i ../../patches/revert-source-maps.patch`
`npm install --no-package-lock --no-save`
end

Expand Down
2 changes: 1 addition & 1 deletion lib/terser.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/terser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class Error < StandardError; end
:negate_iife => true, # Negate immediately invoked function expressions to avoid extra parens
:pure_getters => false, # Assume that object property access does not have any side-effects
:pure_funcs => nil, # List of functions without side-effects. Can safely discard function calls when the result value is not used
:pure_new => false, # List of functions without side-effects. Can safely discard function calls when the result value is not used
:drop_console => false, # Drop calls to console.* functions
:keep_fargs => false, # Preserve unused function arguments
:keep_classnames => false, # Prevents discarding or mangling of class names. Pass a regular expression to only keep class names matching that regex.
Expand Down
2 changes: 1 addition & 1 deletion lib/terser/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

class Terser
# Current version of Terser.
VERSION = "1.1.20"
VERSION = "1.2.0"
end
2 changes: 1 addition & 1 deletion lib/terser_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function terser_wrapper(options) {
inputs[inputFilename] = source;

try {
return Terser.minifySync(inputs, options, null);
return Terser.minify_sync(inputs, options, null);
} catch (error) {
const { message, filename, line, col, pos } = error;
return {error: {message: message, filename: filename, line: line, col: col, pos: pos}}
Expand Down
205 changes: 0 additions & 205 deletions patches/revert-source-maps.patch

This file was deleted.

37 changes: 0 additions & 37 deletions patches/terser-sync.patch

This file was deleted.

21 changes: 21 additions & 0 deletions spec/terser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,27 @@
end
end

describe 'pure_new' do
let(:code) do
<<-JS
new function() {};
(new function() {
this.pass = () => console.log("PASS");
}).pass()
JS
end

it "when compress option is set" do
minified = Terser.compile(code, :compress => { :pure_new => true })
expect(minified).to match("(new function(){this.pass=()=>console.log(\"PASS\")}).pass();")
end

it "when compress option is false" do
minified = Terser.compile(code, :compress => { :pure_new => false })
expect(minified).to match("new function(){},(new function(){this.pass=()=>console.log(\"PASS\")}).pass();")
end
end

it "can be configured to output only ASCII" do
code = "function emoji() { return '\\ud83c\\ude01'; }"
minified = Terser.compile(code, :output => { :ascii_only => true })
Expand Down
Loading