uglifier 4.2.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +45 -7
- data/.rubocop.yml +10 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/README.md +5 -25
- data/lib/uglifier/version.rb +1 -1
- data/lib/uglifier.rb +11 -10
- data/uglifier.gemspec +2 -2
- metadata +8 -9
- data/.travis.yml +0 -35
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d93953baa3d4cf3d30b44e0a0f90dc3b57162aa62283d53213e1647d3de236f3
|
|
4
|
+
data.tar.gz: 647b93d713f352702df61de8a4bcec00dc3a659d81f5a0ff5a6bac6ecfa39895
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e5a9c7445f6f385a4ed0117badd20011e75da0aaf2df4ca8102b2d5c33ad9c14651d2d33dc14b7b5bc9be9b4400623a851176ac993fa54663c0edb68a723f0e9
|
|
7
|
+
data.tar.gz: 5762685023380924279b268fab8c6e2de4c91c18ee45a613b344a937b3743e4b50cf73d8f259b73d99aaee71911e2e3be0608aa165e016b5a03061fa9f9ffd00
|
data/.github/workflows/ruby.yml
CHANGED
|
@@ -1,14 +1,52 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: CI
|
|
2
2
|
|
|
3
|
-
on: [push]
|
|
3
|
+
on: [push, pull_request]
|
|
4
4
|
|
|
5
5
|
jobs:
|
|
6
|
+
test:
|
|
7
|
+
name: >-
|
|
8
|
+
Test (${{ matrix.ruby }})
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
matrix:
|
|
13
|
+
gemfile: [Gemfile]
|
|
14
|
+
ruby:
|
|
15
|
+
- "2.4"
|
|
16
|
+
- "2.5"
|
|
17
|
+
- "2.6"
|
|
18
|
+
- "2.7"
|
|
19
|
+
- "3.0"
|
|
20
|
+
- "3.1"
|
|
21
|
+
- "3.2"
|
|
22
|
+
- "3.3"
|
|
23
|
+
- jruby
|
|
24
|
+
- truffleruby
|
|
25
|
+
include:
|
|
26
|
+
- ruby: 2.5
|
|
27
|
+
gemfile: gemfiles/rubyracer
|
|
28
|
+
- ruby: jruby
|
|
29
|
+
gemfile: gemfiles/rubyrhino
|
|
30
|
+
- ruby: 2.5
|
|
31
|
+
gemfile: gemfiles/alaska
|
|
32
|
+
alaska: 1
|
|
33
|
+
env:
|
|
34
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
|
35
|
+
ALASKA: ${{ matrix.alaska}}
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v2
|
|
38
|
+
- uses: ruby/setup-ruby@v1
|
|
39
|
+
with:
|
|
40
|
+
ruby-version: ${{ matrix.ruby }}
|
|
41
|
+
bundler-cache: true
|
|
42
|
+
- run: bundle exec rake spec
|
|
6
43
|
lint:
|
|
7
44
|
runs-on: ubuntu-latest
|
|
8
45
|
|
|
9
46
|
steps:
|
|
10
|
-
- uses: actions/checkout@
|
|
11
|
-
- uses:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
47
|
+
- uses: actions/checkout@v2
|
|
48
|
+
- uses: ruby/setup-ruby@v1
|
|
49
|
+
with:
|
|
50
|
+
ruby-version: "3.0"
|
|
51
|
+
bundler-cache: true
|
|
52
|
+
- run: bundle exec rubocop --format github
|
data/.rubocop.yml
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
AllCops:
|
|
2
2
|
DisplayCopNames: true
|
|
3
|
+
SuggestExtensions: false
|
|
4
|
+
NewCops: disable
|
|
5
|
+
TargetRubyVersion: 2.4
|
|
3
6
|
Exclude:
|
|
4
7
|
- uglifier.gemspec
|
|
5
8
|
- lib/uglifier/version.rb
|
|
@@ -17,7 +20,7 @@ Metrics/BlockLength:
|
|
|
17
20
|
Metrics/ClassLength:
|
|
18
21
|
Enabled: false
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
Layout/LineLength:
|
|
21
24
|
Max: 100
|
|
22
25
|
|
|
23
26
|
Metrics/MethodLength:
|
|
@@ -52,3 +55,9 @@ Style/MutableConstant:
|
|
|
52
55
|
|
|
53
56
|
Style/ExpandPathArguments:
|
|
54
57
|
Enabled: false
|
|
58
|
+
|
|
59
|
+
Style/FrozenStringLiteralComment:
|
|
60
|
+
Enabled: false
|
|
61
|
+
|
|
62
|
+
Style/StringConcatenation:
|
|
63
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -3,27 +3,7 @@
|
|
|
3
3
|
Ruby wrapper for [UglifyJS](https://github.com/mishoo/UglifyJS2) JavaScript
|
|
4
4
|
compressor.
|
|
5
5
|
|
|
6
|
-
UglifyJS
|
|
7
|
-
|
|
8
|
-
More stable alternatives for working with ES6 code is to first transpile to ES5 with e.g. [babel-transpiler](https://github.com/babel/ruby-babel-transpiler) or using [Closure Compiler](https://github.com/documentcloud/closure-compiler) to directly minify ES6 code.
|
|
9
|
-
|
|
10
|
-
[](https://travis-ci.org/lautis/uglifier)
|
|
11
|
-
|
|
12
|
-
## ES6 / ES2015+ / Harmony mode
|
|
13
|
-
|
|
14
|
-
When using Uglifier with ES6 syntax without any options, an error will be
|
|
15
|
-
thrown.
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
Uglifier::Error: Unexpected token: punc ((). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
The experimental ES6 syntax support can be enabled by passing `:harmony => true`
|
|
22
|
-
option to Uglifier.
|
|
23
|
-
|
|
24
|
-
```ruby
|
|
25
|
-
Uglifier.compile(js, harmony: true)
|
|
26
|
-
```
|
|
6
|
+
UglifyJS only works with ES5. If you need to compress ES6, [ruby-terser](https://github.com/ahorek/terser-ruby) is a better option.
|
|
27
7
|
|
|
28
8
|
### Rails
|
|
29
9
|
|
|
@@ -48,7 +28,7 @@ Uglifier is available as a ruby gem.
|
|
|
48
28
|
$ gem install uglifier
|
|
49
29
|
|
|
50
30
|
Ensure that your environment has a JavaScript interpreter supported by
|
|
51
|
-
[ExecJS](https://github.com/
|
|
31
|
+
[ExecJS](https://github.com/rails/execjs). Using `therubyracer` gem
|
|
52
32
|
is a safe choice if a runtime isn't already present. Note that while JScript built-in Windows 7 and older works, it is extremely slow.
|
|
53
33
|
|
|
54
34
|
## Usage
|
|
@@ -96,8 +76,8 @@ Available options and their defaults are
|
|
|
96
76
|
:indent_start => 0, # Starting indent level
|
|
97
77
|
:width => 80, # Specify line width when beautifier is used (only with beautifier)
|
|
98
78
|
:preamble => nil, # Preamble for the generated JS file. Can be used to insert any code or comment.
|
|
99
|
-
:wrap_iife => false
|
|
100
|
-
:shebang => true
|
|
79
|
+
:wrap_iife => false, # Wrap IIFEs in parenthesis. Note: this disables the negate_iife compression option.
|
|
80
|
+
:shebang => true, # Preserve shebang (#!) in preamble (shell scripts)
|
|
101
81
|
:quote_style => 0, # Quote style, possible values :auto (default), :single, :double, :original
|
|
102
82
|
:keep_quoted_props => false # Keep quotes property names
|
|
103
83
|
},
|
|
@@ -113,7 +93,7 @@ Available options and their defaults are
|
|
|
113
93
|
:regex => nil, # A regular expression to filter property names to be mangled
|
|
114
94
|
:ignore_quoted => false, # Only mangle unquoted property names
|
|
115
95
|
:debug => false, # Mangle names with the original name still present
|
|
116
|
-
}
|
|
96
|
+
}, # Mangle property names, disabled by default
|
|
117
97
|
:compress => {
|
|
118
98
|
:sequences => true, # Allow statements to be joined by commas
|
|
119
99
|
:properties => true, # Rewrite property access using the dot notation
|
data/lib/uglifier/version.rb
CHANGED
data/lib/uglifier.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
3
|
require "json"
|
|
4
|
-
require "base64"
|
|
5
4
|
require "execjs"
|
|
6
5
|
require "uglifier/version"
|
|
7
6
|
|
|
@@ -25,9 +24,9 @@ class Uglifier
|
|
|
25
24
|
|
|
26
25
|
# Default options for compilation
|
|
27
26
|
DEFAULTS = {
|
|
28
|
-
# rubocop:disable LineLength
|
|
27
|
+
# rubocop:disable Layout/LineLength
|
|
29
28
|
:output => {
|
|
30
|
-
:ascii_only => true, # Escape non-ASCII
|
|
29
|
+
:ascii_only => true, # Escape non-ASCII characters
|
|
31
30
|
:comments => :copyright, # Preserve comments (:all, :jsdoc, :copyright, :none)
|
|
32
31
|
:inline_script => false, # Escape occurrences of </script in strings
|
|
33
32
|
:quote_keys => false, # Quote keys in object literals
|
|
@@ -49,7 +48,7 @@ class Uglifier
|
|
|
49
48
|
:eval => false, # Mangle names when eval of when is used in scope
|
|
50
49
|
:reserved => ["$super"], # Argument names to be excluded from mangling
|
|
51
50
|
:properties => false, # Mangle property names
|
|
52
|
-
:toplevel => false
|
|
51
|
+
:toplevel => false # Mangle names declared in the toplevel scope
|
|
53
52
|
}, # Mangle variable and function names, set to false to skip mangling
|
|
54
53
|
:compress => {
|
|
55
54
|
:sequences => true, # Allow statements to be joined by commas
|
|
@@ -84,7 +83,7 @@ class Uglifier
|
|
|
84
83
|
:passes => 1, # Number of times to run compress. Raising the number of passes will increase compress time, but can produce slightly smaller code.
|
|
85
84
|
:keep_infinity => false, # Prevent compression of Infinity to 1/0
|
|
86
85
|
:side_effects => true, # Pass false to disable potentially dropping functions marked as "pure" using pure comment annotation. See UglifyJS documentation for details.
|
|
87
|
-
:switches => true
|
|
86
|
+
:switches => true # de-duplicate and remove unreachable switch branches
|
|
88
87
|
}, # Apply transformations to code, set to false to skip
|
|
89
88
|
:parse => {
|
|
90
89
|
:bare_returns => false, # Allow top-level return statements.
|
|
@@ -101,6 +100,7 @@ class Uglifier
|
|
|
101
100
|
:error_context_lines => 8, # How many lines surrounding the error line
|
|
102
101
|
:harmony => false # Enable ES6/Harmony mode (experimental). Disabling mangling and compressing is recommended with Harmony mode.
|
|
103
102
|
}
|
|
103
|
+
# rubocop:enable Layout/LineLength
|
|
104
104
|
|
|
105
105
|
EXTRA_OPTIONS = [:comments, :mangle_properties]
|
|
106
106
|
|
|
@@ -109,7 +109,7 @@ class Uglifier
|
|
|
109
109
|
:regex => nil, # A regular expression to filter property names to be mangled
|
|
110
110
|
:keep_quoted => false, # Keep quoted property names
|
|
111
111
|
:reserved => [], # List of properties that should not be mangled
|
|
112
|
-
:builtins => false
|
|
112
|
+
:builtins => false # Mangle properties that overlap with standard JS globals
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
SOURCE_MAP_DEFAULTS = {
|
|
@@ -122,8 +122,6 @@ class Uglifier
|
|
|
122
122
|
:input_source_map => nil # The contents of the source map describing the input
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
# rubocop:enable LineLength
|
|
126
|
-
|
|
127
125
|
# Minifies JavaScript code using implicit context.
|
|
128
126
|
#
|
|
129
127
|
# @param source [IO, String] valid JS source code.
|
|
@@ -146,9 +144,11 @@ class Uglifier
|
|
|
146
144
|
#
|
|
147
145
|
# @param options [Hash] optional overrides to +Uglifier::DEFAULTS+
|
|
148
146
|
def initialize(options = {})
|
|
147
|
+
# rubocop:disable Lint/UnreachableLoop
|
|
149
148
|
(options.keys - DEFAULTS.keys - EXTRA_OPTIONS)[0..1].each do |missing|
|
|
150
149
|
raise ArgumentError, "Invalid option: #{missing}"
|
|
151
150
|
end
|
|
151
|
+
# rubocop:enable Lint/UnreachableLoop
|
|
152
152
|
@options = options
|
|
153
153
|
end
|
|
154
154
|
|
|
@@ -159,7 +159,7 @@ class Uglifier
|
|
|
159
159
|
def compile(source)
|
|
160
160
|
if @options[:source_map]
|
|
161
161
|
compiled, source_map = run_uglifyjs(source, true)
|
|
162
|
-
source_map_uri =
|
|
162
|
+
source_map_uri = [source_map].pack('m0')
|
|
163
163
|
source_map_mime = "application/json;charset=utf-8;base64"
|
|
164
164
|
compiled + "\n//# sourceMappingURL=data:#{source_map_mime},#{source_map_uri}"
|
|
165
165
|
else
|
|
@@ -507,10 +507,11 @@ class Uglifier
|
|
|
507
507
|
|
|
508
508
|
def input_source_map(source, generate_map)
|
|
509
509
|
return nil unless generate_map
|
|
510
|
+
|
|
510
511
|
source_map_options = @options[:source_map].is_a?(Hash) ? @options[:source_map] : {}
|
|
511
512
|
sanitize_map_root(source_map_options.fetch(:input_source_map) do
|
|
512
513
|
url = extract_source_mapping_url(source)
|
|
513
|
-
|
|
514
|
+
url.split(",", 2)[-1].unpack1('m0') if url && url.start_with?("data:")
|
|
514
515
|
end)
|
|
515
516
|
rescue ArgumentError, JSON::ParserError
|
|
516
517
|
nil
|
data/uglifier.gemspec
CHANGED
|
@@ -8,12 +8,12 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.version = Uglifier::VERSION
|
|
9
9
|
spec.authors = ["Ville Lautanala"]
|
|
10
10
|
spec.email = ["lautis@gmail.com"]
|
|
11
|
-
spec.homepage = "
|
|
11
|
+
spec.homepage = "https://github.com/lautis/uglifier"
|
|
12
12
|
spec.summary = "Ruby wrapper for UglifyJS JavaScript compressor"
|
|
13
13
|
spec.description = "Uglifier minifies JavaScript files by wrapping UglifyJS to be accessible in Ruby"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
|
|
16
|
-
spec.required_ruby_version = '>=
|
|
16
|
+
spec.required_ruby_version = '>= 2.4.0'
|
|
17
17
|
|
|
18
18
|
spec.extra_rdoc_files = [
|
|
19
19
|
"LICENSE.txt",
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: uglifier
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.2.
|
|
4
|
+
version: 4.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ville Lautanala
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-09-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: execjs
|
|
@@ -104,7 +104,6 @@ files:
|
|
|
104
104
|
- ".gitmodules"
|
|
105
105
|
- ".rspec"
|
|
106
106
|
- ".rubocop.yml"
|
|
107
|
-
- ".travis.yml"
|
|
108
107
|
- ".yardopts"
|
|
109
108
|
- CHANGELOG.md
|
|
110
109
|
- CONTRIBUTING.md
|
|
@@ -121,11 +120,11 @@ files:
|
|
|
121
120
|
- lib/uglify-harmony.js
|
|
122
121
|
- lib/uglify.js
|
|
123
122
|
- uglifier.gemspec
|
|
124
|
-
homepage:
|
|
123
|
+
homepage: https://github.com/lautis/uglifier
|
|
125
124
|
licenses:
|
|
126
125
|
- MIT
|
|
127
126
|
metadata: {}
|
|
128
|
-
post_install_message:
|
|
127
|
+
post_install_message:
|
|
129
128
|
rdoc_options: []
|
|
130
129
|
require_paths:
|
|
131
130
|
- lib
|
|
@@ -133,15 +132,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
133
132
|
requirements:
|
|
134
133
|
- - ">="
|
|
135
134
|
- !ruby/object:Gem::Version
|
|
136
|
-
version:
|
|
135
|
+
version: 2.4.0
|
|
137
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
137
|
requirements:
|
|
139
138
|
- - ">="
|
|
140
139
|
- !ruby/object:Gem::Version
|
|
141
140
|
version: '0'
|
|
142
141
|
requirements: []
|
|
143
|
-
rubygems_version: 3.
|
|
144
|
-
signing_key:
|
|
142
|
+
rubygems_version: 3.2.22
|
|
143
|
+
signing_key:
|
|
145
144
|
specification_version: 4
|
|
146
145
|
summary: Ruby wrapper for UglifyJS JavaScript compressor
|
|
147
146
|
test_files: []
|
data/.travis.yml
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
sudo: false
|
|
2
|
-
language: ruby
|
|
3
|
-
cache: bundler
|
|
4
|
-
rvm:
|
|
5
|
-
- 1.9.3
|
|
6
|
-
- 2.0.0
|
|
7
|
-
- 2.1.10
|
|
8
|
-
- 2.2.10
|
|
9
|
-
- 2.3.8
|
|
10
|
-
- 2.4.5
|
|
11
|
-
- 2.5.3
|
|
12
|
-
- 2.6.0
|
|
13
|
-
- ruby-head
|
|
14
|
-
- jruby-9.2.5.0
|
|
15
|
-
before_install:
|
|
16
|
-
- gem install bundler -v 1.17.3
|
|
17
|
-
git:
|
|
18
|
-
submodules: false
|
|
19
|
-
gemfile:
|
|
20
|
-
- Gemfile
|
|
21
|
-
matrix:
|
|
22
|
-
include:
|
|
23
|
-
- rvm: 2.5.3
|
|
24
|
-
gemfile: gemfiles/rubyracer
|
|
25
|
-
- rvm: jruby-9.2.5.0
|
|
26
|
-
gemfile: gemfiles/rubyrhino
|
|
27
|
-
- rvm: 2.5.3
|
|
28
|
-
gemfile: gemfiles/alaska
|
|
29
|
-
env: ALASKA=1
|
|
30
|
-
allow_failures:
|
|
31
|
-
- rvm: 2.5.3
|
|
32
|
-
gemfile: gemfiles/alaska
|
|
33
|
-
env: ALASKA=1
|
|
34
|
-
- rvm: ruby-head
|
|
35
|
-
fast_finish: true
|