terser 1.1.10 → 1.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9954e828ecb22b20755ceebcf4d3c2e4070740fcbe7dd8bf54a5b66c500050a
4
- data.tar.gz: 63716a756c0c24d25c45307b044e2365d6065a957c99bd4283be495015fb5384
3
+ metadata.gz: 22265ec2111f27b275743c52fc9753948dadc4d5e0a9f2c843039ac0948c5b78
4
+ data.tar.gz: 2550c195b6450da8cfdbbbae53ebb85ef0b7cd6f573d06c9ada25f740e0d7b6b
5
5
  SHA512:
6
- metadata.gz: c81c947cd4f86fb24cbae03faf6d5487bb31d1a6963953c62644c5482b8e588135bfcf9082a89b262104e0a9f3fce439ee60bb58162c7ae099ae45cd8aa38f4a
7
- data.tar.gz: f4182cb022920b32254d1979369b39609a15d1d49933a6a2ca2e127699e78af43557f09e4bcea43c65248ed6dc03f7085972546c532f60058744045d9339bc68
6
+ metadata.gz: c82469000fbaaa5a55c1fa5eac9c19f4dbabff716dae52dc44f3fca0b6452e1b995827e8dcbece8aa9bfb11c2aff0c0c1f4d1e9cdcc8d71c4125c2db4e4d95c2
7
+ data.tar.gz: 86ccd5509a758ee06b453ac3a02bd707304e5e2507ab62195dabee0de2095911eaa23359f11505cb0d073482c0568c96bfc9b314fdf5a06e9ca40c61ab2cc7ea
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
1
  ## Unreleased
2
+
3
+ ## 1.1.11 (28 June 2022)
4
+ - add keep_classnames and keep_numbers available in terser (default is false)
5
+
2
6
  ## 1.1.10 (13 June 2022)
3
7
  - update TerserJS to [5.14.1]
4
8
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  class Terser
4
4
  # Current version of Terser.
5
- VERSION = "1.1.10"
5
+ VERSION = "1.1.11"
6
6
  end
data/lib/terser.rb CHANGED
@@ -32,6 +32,7 @@ class Terser
32
32
  :ascii_only => true, # Escape non-ASCII characterss
33
33
  :comments => :copyright, # Preserve comments (:all, :jsdoc, :copyright, :none)
34
34
  :inline_script => false, # Escape occurrences of </script in strings
35
+ :keep_numbers => false, # Disables optimizations like converting 1000000 into 1e6
35
36
  :quote_keys => false, # Quote keys in object literals
36
37
  :max_line_len => 32 * 1024, # Maximum line length in minified code
37
38
  :semicolons => true, # Separate statements with semicolons
@@ -80,6 +81,7 @@ class Terser
80
81
  :pure_funcs => nil, # List of functions without side-effects. Can safely discard function calls when the result value is not used
81
82
  :drop_console => false, # Drop calls to console.* functions
82
83
  :keep_fargs => false, # Preserve unused function arguments
84
+ :keep_classnames => false, # Prevents discarding or mangling of class names. Pass a regular expression to only keep class names matching that regex.
83
85
  :keep_fnames => false, # Do not drop names in function definitions
84
86
  :passes => 1, # Number of times to run compress. Raising the number of passes will increase compress time, but can produce slightly smaller code.
85
87
  :keep_infinity => false, # Prevent compression of Infinity to 1/0
@@ -94,7 +96,8 @@ class Terser
94
96
  :strict => false
95
97
  },
96
98
  :define => {}, # Define values for symbol replacement
97
- :keep_fnames => false, # Generate code safe for the poor souls relying on Function.prototype.name at run-time. Sets both compress and mangle keep_fanems to true.
99
+ :keep_fnames => false, # Generate code safe for the poor souls relying on Function.prototype.name at run-time. Sets both compress and mangle keep_fnames to true.
100
+ :keep_classnames => false, # Prevents discarding or mangling of class names. Sets both compress and mangle keep_classnames to true.
98
101
  :toplevel => false,
99
102
  :source_map => false, # Generate source map
100
103
  :error_context_lines => 8 # How many lines surrounding the error line
@@ -297,7 +300,8 @@ class Terser
297
300
  def mangle_options
298
301
  defaults = conditional_option(
299
302
  DEFAULTS[:mangle],
300
- :keep_fnames => keep_fnames?(:mangle)
303
+ :keep_fnames => keep_fnames?(:mangle),
304
+ :keep_classnames => keep_classnames?(:mangle)
301
305
  )
302
306
 
303
307
  conditional_option(
@@ -335,7 +339,10 @@ class Terser
335
339
  conditional_option(
336
340
  @options[:compress],
337
341
  defaults,
338
- { :keep_fnames => keep_fnames?(:compress) }.merge(negate_iife_block)
342
+ {
343
+ :keep_fnames => keep_fnames?(:compress),
344
+ :keep_classnames => keep_classnames?(:compress)
345
+ }.merge(negate_iife_block)
339
346
  )
340
347
  end
341
348
 
@@ -403,6 +410,15 @@ class Terser
403
410
  end
404
411
  end
405
412
 
413
+ def keep_classnames?(type)
414
+ if @options[:keep_classnames] || DEFAULTS[:keep_classnames]
415
+ true
416
+ else
417
+ @options[type].respond_to?(:[]) && @options[type][:keep_classnames] ||
418
+ DEFAULTS[type].respond_to?(:[]) && DEFAULTS[type][:keep_classnames]
419
+ end
420
+ end
421
+
406
422
  def source_map_options(input_map, source_map_options)
407
423
  options = conditional_option(source_map_options[:source_map], SOURCE_MAP_DEFAULTS) || SOURCE_MAP_DEFAULTS
408
424
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.10
4
+ version: 1.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Rosicky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-13 00:00:00.000000000 Z
11
+ date: 2022-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs