terser 1.0.2 → 1.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +205 -1
- data/CHANGELOG.md +58 -0
- data/Gemfile +6 -1
- data/README.md +8 -3
- data/Rakefile +6 -1
- data/lib/terser/compressor.rb +1 -1
- data/lib/terser/railtie.rb +16 -0
- data/lib/terser/version.rb +1 -1
- data/lib/terser.js +1 -2
- data/lib/terser.rb +24 -6
- data/lib/terser_wrapper.js +7 -3
- data/terser.gemspec +2 -2
- metadata +9 -9
- data/.travis.yml +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da43fa919f823977e14273029f62095aa3ba543bd8ea0704999d699fb1e50d7b
|
4
|
+
data.tar.gz: 211b0f09002e37478f5866f8394a5aba2f9c984235d0ccf5d2d8b2079ecf99cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c0f070a8b4eab6183c92b5dd2ef60b04e45f9eced0b2a8701bf218ce2b7101f46ab93676299d7546fdc09903606303f93f5e3b913987e141f7193d013c4faae
|
7
|
+
data.tar.gz: e187bf407f3f98be8e473014b03e68799ecf589b1c0e6a1877327ca6731eaf701efee1bbb7cdd6684eb31afbc48d5dbb9cf098ff7a09f2cb0d5e9bca088eba86
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require: rubocop-performance
|
2
|
+
|
1
3
|
AllCops:
|
2
4
|
DisplayCopNames: true
|
3
5
|
TargetRubyVersion: 2.5
|
@@ -136,6 +138,8 @@ Style/RedundantRegexpEscape:
|
|
136
138
|
Enabled: true
|
137
139
|
Style/RedundantSelfAssignment:
|
138
140
|
Enabled: true
|
141
|
+
Style/RedundantBegin:
|
142
|
+
Enabled: false
|
139
143
|
Style/SingleArgumentDig:
|
140
144
|
Enabled: true
|
141
145
|
Style/SlicingWithRange:
|
@@ -144,4 +148,204 @@ Style/SoleNestedConditional:
|
|
144
148
|
Enabled: true
|
145
149
|
Style/StringConcatenation:
|
146
150
|
Enabled: true
|
147
|
-
|
151
|
+
Lint/DuplicateRegexpCharacterClassElement:
|
152
|
+
Enabled: true
|
153
|
+
Lint/EmptyBlock:
|
154
|
+
Enabled: true
|
155
|
+
Lint/NoReturnInBeginEndBlocks:
|
156
|
+
Enabled: true
|
157
|
+
Lint/ToEnumArguments:
|
158
|
+
Enabled: true
|
159
|
+
Lint/UnmodifiedReduceAccumulator:
|
160
|
+
Enabled: true
|
161
|
+
Style/ArgumentsForwarding:
|
162
|
+
Enabled: true
|
163
|
+
Style/CollectionCompact:
|
164
|
+
Enabled: true
|
165
|
+
Style/DocumentDynamicEvalDefinition:
|
166
|
+
Enabled: true
|
167
|
+
Style/NegatedIfElseCondition:
|
168
|
+
Enabled: true
|
169
|
+
Style/SwapValues:
|
170
|
+
Enabled: true
|
171
|
+
Lint/DuplicateBranch:
|
172
|
+
Enabled: true
|
173
|
+
Lint/EmptyClass:
|
174
|
+
Enabled: true
|
175
|
+
Style/NilLambda:
|
176
|
+
Enabled: true
|
177
|
+
Layout/LineEndStringConcatenationIndentation: # (new in 1.18)
|
178
|
+
Enabled: true
|
179
|
+
Layout/SpaceBeforeBrackets: # (new in 1.7)
|
180
|
+
Enabled: true
|
181
|
+
Lint/AmbiguousAssignment: # (new in 1.7)
|
182
|
+
Enabled: true
|
183
|
+
Lint/DeprecatedConstants: # (new in 1.8)
|
184
|
+
Enabled: true
|
185
|
+
Lint/EmptyInPattern: # (new in 1.16)
|
186
|
+
Enabled: true
|
187
|
+
Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
|
188
|
+
Enabled: true
|
189
|
+
Lint/NumberedParameterAssignment: # (new in 1.9)
|
190
|
+
Enabled: true
|
191
|
+
Lint/OrAssignmentToConstant: # (new in 1.9)
|
192
|
+
Enabled: true
|
193
|
+
Lint/RedundantDirGlobSort: # (new in 1.8)
|
194
|
+
Enabled: true
|
195
|
+
Lint/SymbolConversion: # (new in 1.9)
|
196
|
+
Enabled: true
|
197
|
+
Lint/TripleQuotes: # (new in 1.9)
|
198
|
+
Enabled: true
|
199
|
+
Lint/UnexpectedBlockArity: # (new in 1.5)
|
200
|
+
Enabled: true
|
201
|
+
Naming/InclusiveLanguage: # (new in 1.18)
|
202
|
+
Enabled: true
|
203
|
+
Style/EndlessMethod: # (new in 1.8)
|
204
|
+
Enabled: true
|
205
|
+
Style/HashConversion: # (new in 1.10)
|
206
|
+
Enabled: true
|
207
|
+
Style/HashExcept: # (new in 1.7)
|
208
|
+
Enabled: true
|
209
|
+
Style/IfWithBooleanLiteralBranches: # (new in 1.9)
|
210
|
+
Enabled: true
|
211
|
+
Style/InPatternThen: # (new in 1.16)
|
212
|
+
Enabled: true
|
213
|
+
Style/MultilineInPatternThen: # (new in 1.16)
|
214
|
+
Enabled: true
|
215
|
+
Style/QuotedSymbols: # (new in 1.16)
|
216
|
+
Enabled: true
|
217
|
+
Style/RedundantArgument: # (new in 1.4)
|
218
|
+
Enabled: true
|
219
|
+
Style/StringChars: # (new in 1.12)
|
220
|
+
Enabled: true
|
221
|
+
Gemspec/DeprecatedAttributeAssignment: # new in 1.30
|
222
|
+
Enabled: true
|
223
|
+
Gemspec/DevelopmentDependencies: # new in 1.44
|
224
|
+
Enabled: true
|
225
|
+
Gemspec/RequireMFA: # new in 1.23
|
226
|
+
Enabled: true
|
227
|
+
Layout/LineContinuationLeadingSpace: # new in 1.31
|
228
|
+
Enabled: true
|
229
|
+
Layout/LineContinuationSpacing: # new in 1.31
|
230
|
+
Enabled: true
|
231
|
+
Lint/AmbiguousOperatorPrecedence: # new in 1.21
|
232
|
+
Enabled: true
|
233
|
+
Lint/AmbiguousRange: # new in 1.19
|
234
|
+
Enabled: true
|
235
|
+
Lint/ConstantOverwrittenInRescue: # new in 1.31
|
236
|
+
Enabled: true
|
237
|
+
Lint/DuplicateMagicComment: # new in 1.37
|
238
|
+
Enabled: true
|
239
|
+
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
|
240
|
+
Enabled: true
|
241
|
+
Lint/NonAtomicFileOperation: # new in 1.31
|
242
|
+
Enabled: true
|
243
|
+
Lint/RefinementImportMethods: # new in 1.27
|
244
|
+
Enabled: true
|
245
|
+
Lint/RequireRangeParentheses: # new in 1.32
|
246
|
+
Enabled: true
|
247
|
+
Lint/RequireRelativeSelfPath: # new in 1.22
|
248
|
+
Enabled: true
|
249
|
+
Lint/UselessRescue: # new in 1.43
|
250
|
+
Enabled: true
|
251
|
+
Lint/UselessRuby2Keywords: # new in 1.23
|
252
|
+
Enabled: true
|
253
|
+
Naming/BlockForwarding: # new in 1.24
|
254
|
+
Enabled: true
|
255
|
+
Security/CompoundHash: # new in 1.28
|
256
|
+
Enabled: true
|
257
|
+
Security/IoMethods: # new in 1.22
|
258
|
+
Enabled: true
|
259
|
+
Style/ArrayIntersect: # new in 1.40
|
260
|
+
Enabled: true
|
261
|
+
Style/ComparableClamp: # new in 1.44
|
262
|
+
Enabled: true
|
263
|
+
Style/ConcatArrayLiterals: # new in 1.41
|
264
|
+
Enabled: true
|
265
|
+
Style/EmptyHeredoc: # new in 1.32
|
266
|
+
Enabled: true
|
267
|
+
Style/EnvHome: # new in 1.29
|
268
|
+
Enabled: true
|
269
|
+
Style/FetchEnvVar: # new in 1.28
|
270
|
+
Enabled: true
|
271
|
+
Style/FileRead: # new in 1.24
|
272
|
+
Enabled: true
|
273
|
+
Style/FileWrite: # new in 1.24
|
274
|
+
Enabled: true
|
275
|
+
Style/MagicCommentFormat: # new in 1.35
|
276
|
+
Enabled: true
|
277
|
+
Style/MapCompactWithConditionalBlock: # new in 1.30
|
278
|
+
Enabled: true
|
279
|
+
Style/MapToHash: # new in 1.24
|
280
|
+
Enabled: true
|
281
|
+
Style/MapToSet: # new in 1.42
|
282
|
+
Enabled: true
|
283
|
+
Style/MinMaxComparison: # new in 1.42
|
284
|
+
Enabled: true
|
285
|
+
Style/NestedFileDirname: # new in 1.26
|
286
|
+
Enabled: true
|
287
|
+
Style/NumberedParameters: # new in 1.22
|
288
|
+
Enabled: true
|
289
|
+
Style/NumberedParametersLimit: # new in 1.22
|
290
|
+
Enabled: true
|
291
|
+
Style/ObjectThen: # new in 1.28
|
292
|
+
Enabled: true
|
293
|
+
Style/OpenStructUse: # new in 1.23
|
294
|
+
Enabled: true
|
295
|
+
Style/OperatorMethodCall: # new in 1.37
|
296
|
+
Enabled: true
|
297
|
+
Style/RedundantConstantBase: # new in 1.40
|
298
|
+
Enabled: true
|
299
|
+
Style/RedundantDoubleSplatHashBraces: # new in 1.41
|
300
|
+
Enabled: true
|
301
|
+
Style/RedundantEach: # new in 1.38
|
302
|
+
Enabled: true
|
303
|
+
Style/RedundantHeredocDelimiterQuotes: # new in 1.45
|
304
|
+
Enabled: true
|
305
|
+
Style/RedundantInitialize: # new in 1.27
|
306
|
+
Enabled: true
|
307
|
+
Style/RedundantSelfAssignmentBranch: # new in 1.19
|
308
|
+
Enabled: true
|
309
|
+
Style/RedundantStringEscape: # new in 1.37
|
310
|
+
Enabled: true
|
311
|
+
Style/SelectByRegexp: # new in 1.22
|
312
|
+
Enabled: true
|
313
|
+
|
314
|
+
Performance/AncestorsInclude:
|
315
|
+
Enabled: true
|
316
|
+
Performance/ArraySemiInfiniteRangeSlice:
|
317
|
+
Enabled: true
|
318
|
+
Performance/BigDecimalWithNumericArgument:
|
319
|
+
Enabled: true
|
320
|
+
Performance/BlockGivenWithExplicitBlock:
|
321
|
+
Enabled: true
|
322
|
+
Performance/CollectionLiteralInLoop:
|
323
|
+
Enabled: true
|
324
|
+
Performance/ConstantRegexp:
|
325
|
+
Enabled: true
|
326
|
+
Performance/MethodObjectAsBlock:
|
327
|
+
Enabled: true
|
328
|
+
Performance/RedundantSortBlock:
|
329
|
+
Enabled: true
|
330
|
+
Performance/RedundantStringChars:
|
331
|
+
Enabled: true
|
332
|
+
Performance/ReverseFirst:
|
333
|
+
Enabled: true
|
334
|
+
Performance/SortReverse:
|
335
|
+
Enabled: true
|
336
|
+
Performance/Squeeze:
|
337
|
+
Enabled: true
|
338
|
+
Performance/StringInclude:
|
339
|
+
Enabled: true
|
340
|
+
Performance/Sum:
|
341
|
+
Enabled: true
|
342
|
+
Performance/MapCompact: # (new in 1.11)
|
343
|
+
Enabled: true
|
344
|
+
Performance/RedundantEqualityComparisonBlock: # (new in 1.10)
|
345
|
+
Enabled: true
|
346
|
+
Performance/RedundantSplitRegexpArgument: # (new in 1.10)
|
347
|
+
Enabled: true
|
348
|
+
Performance/ConcurrentMonotonicTime: # new in 1.12
|
349
|
+
Enabled: true
|
350
|
+
Performance/StringIdentifierArgument: # new in 1.13
|
351
|
+
Enabled: true
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,62 @@
|
|
1
1
|
## Unreleased
|
2
|
+
## 1.1.17 (14 July 2023)
|
3
|
+
- update TerserJS to [5.19.0]
|
4
|
+
|
5
|
+
## 1.1.16 (01 June 2023)
|
6
|
+
- update TerserJS to [5.17.7]
|
7
|
+
|
8
|
+
## 1.1.15 (09 May 2023)
|
9
|
+
- update TerserJS to [5.17.3]
|
10
|
+
- add lhs_constants (default is true)
|
11
|
+
|
12
|
+
## 1.1.14 (24 February 2023)
|
13
|
+
- update TerserJS to [5.16.5]
|
14
|
+
- update Rubocop
|
15
|
+
|
16
|
+
## 1.1.13 (03 December 2022)
|
17
|
+
- update TerserJS to [5.16.1]
|
18
|
+
|
19
|
+
## 1.1.12 (15 July 2022)
|
20
|
+
- update TerserJS to [5.14.2]
|
21
|
+
|
22
|
+
## 1.1.11 (28 June 2022)
|
23
|
+
- add keep_classnames and keep_numbers available in terser (default is false)
|
24
|
+
|
25
|
+
## 1.1.10 (13 June 2022)
|
26
|
+
- update TerserJS to [5.14.1]
|
27
|
+
|
28
|
+
## 1.1.9 (04 May 2022)
|
29
|
+
- update TerserJS to [5.13.1]
|
30
|
+
|
31
|
+
## 1.1.8 (25 November 2021)
|
32
|
+
- update TerserJS to [5.10.0]
|
33
|
+
|
34
|
+
## 1.1.7 (23 September 2021)
|
35
|
+
- update TerserJS to [5.9.0]
|
36
|
+
|
37
|
+
## 1.1.6 (15 September 2021)
|
38
|
+
- update TerserJS to [5.8.0]
|
39
|
+
|
40
|
+
## 1.1.5 (29 June 2021)
|
41
|
+
- update TerserJS to [5.7.1]
|
42
|
+
|
43
|
+
## 1.1.4 (27 June 2021)
|
44
|
+
- update TerserJS to [5.7.0]
|
45
|
+
- use railtie to register compressor on Rails initialization
|
46
|
+
|
47
|
+
## 1.1.3 (23 March 2021)
|
48
|
+
- update TerserJS to [5.6.1]
|
49
|
+
|
50
|
+
## 1.1.2 (03 March 2021)
|
51
|
+
- update TerserJS to [5.6.0]
|
52
|
+
|
53
|
+
## 1.1.1 (19 November 2020)
|
54
|
+
- update TerserJS to [5.5.0]
|
55
|
+
- (bugfix) error messages
|
56
|
+
- update rubocop to 1.3.1
|
57
|
+
|
58
|
+
## 1.1.0 (17 November 2020)
|
59
|
+
- update TerserJS to [5.4.0]
|
2
60
|
|
3
61
|
## 1.0.2 (13 October 2020)
|
4
62
|
- LICENSE.txt encoding fix
|
data/Gemfile
CHANGED
@@ -4,4 +4,9 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
|
7
|
+
unless RUBY_VERSION < '2.6'
|
8
|
+
group :development do
|
9
|
+
gem 'rubocop', '~> 1.46.0'
|
10
|
+
gem 'rubocop-performance', '~> 1.16.0', :require => false
|
11
|
+
end
|
12
|
+
end
|
data/README.md
CHANGED
@@ -7,14 +7,13 @@ a fork based on https://github.com/lautis/uglifier and https://github.com/mishoo
|
|
7
7
|
|
8
8
|
ES6 support
|
9
9
|
|
10
|
-
[![
|
10
|
+
[![Ruby](https://github.com/ahorek/terser-ruby/actions/workflows/ruby.yml/badge.svg)](https://github.com/ahorek/terser-ruby/actions/workflows/ruby.yml)
|
11
11
|
|
12
12
|
### Rails
|
13
13
|
|
14
|
-
When used in Rails, replace
|
14
|
+
When used in Rails, add or replace
|
15
15
|
|
16
16
|
```ruby
|
17
|
-
Sprockets.register_compressor 'application/javascript', :terser, Terser::Compressor
|
18
17
|
Rails.application.configure do
|
19
18
|
config.assets.js_compressor = :terser
|
20
19
|
end
|
@@ -26,6 +25,11 @@ in `config/environments/production.rb`.
|
|
26
25
|
Terser is available as a ruby gem.
|
27
26
|
|
28
27
|
$ gem install terser
|
28
|
+
|
29
|
+
Or add to your Gemfile:
|
30
|
+
|
31
|
+
$ bundle add terser
|
32
|
+
$ bundle install
|
29
33
|
|
30
34
|
Ensure that your environment has a JavaScript interpreter supported by
|
31
35
|
[ExecJS](https://github.com/sstephenson/execjs). Using `miniracer` gem or NodeJS
|
@@ -126,6 +130,7 @@ Available options and their defaults are
|
|
126
130
|
:keep_fnames => false, # Do not drop names in function definitions
|
127
131
|
:passes => 1, # Number of times to run compress. Raising the number of passes will increase compress time, but can produce slightly smaller code.
|
128
132
|
:keep_infinity => false, # Prevent compression of Infinity to 1/0
|
133
|
+
:lhs_constants => true, # Moves constant values to the left-hand side of binary nodes. `foo == 42 → 42 == foo`
|
129
134
|
:side_effects => true, # Pass false to disable potentially dropping functions marked as "pure" using pure comment annotation. See UglifyJS documentation for details.
|
130
135
|
:switches => true, # de-duplicate and remove unreachable switch branches
|
131
136
|
}, # Apply transformations to code, set to false to skip
|
data/Rakefile
CHANGED
@@ -54,11 +54,16 @@ namespace :terser do
|
|
54
54
|
|
55
55
|
cd 'vendor/terser/' do
|
56
56
|
FileUtils.rm_rf("package-lock.json")
|
57
|
+
`patch -p1 -i ../../patches/terser-sync.patch`
|
58
|
+
`patch -p1 -i ../../patches/revert-source-maps.patch`
|
57
59
|
`npm install --no-package-lock --no-save`
|
58
60
|
end
|
59
61
|
|
60
62
|
FileUtils.cp("vendor/source-map/dist/source-map.min.js", "lib/source-map.js")
|
61
|
-
|
63
|
+
|
64
|
+
# FileUtils.cp("vendor/terser/dist/bundle.min.js", "lib/terser.js")
|
65
|
+
minified_source = `node ./vendor/terser/bin/terser vendor/terser/dist/bundle.min.js`
|
66
|
+
File.write("lib/terser.js", minified_source)
|
62
67
|
|
63
68
|
FileUtils.cp("vendor/split/split.js", "lib/split.js")
|
64
69
|
`patch -p1 -i patches/es5-string-split.patch`
|
data/lib/terser/compressor.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'sprockets/digest_utils'
|
4
|
-
require 'sprockets/source_map_utils' if Gem::Version.new(
|
4
|
+
require 'sprockets/source_map_utils' if Gem::Version.new(Sprockets::VERSION) >= Gem::Version.new('4.x')
|
5
5
|
|
6
6
|
class Terser
|
7
7
|
# A wrapper for Sprockets
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/railtie'
|
4
|
+
|
5
|
+
class Terser
|
6
|
+
# Railtie for Rails
|
7
|
+
class Railtie < ::Rails::Railtie
|
8
|
+
initializer :terser, :group => :all do |_|
|
9
|
+
if config.respond_to?(:assets) # to make sure the sprockets pipeline is active
|
10
|
+
config.assets.configure do |env|
|
11
|
+
env.register_compressor 'application/javascript', :terser, Terser::Compressor
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/terser/version.rb
CHANGED