terser 1.1.10 → 1.1.11
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/CHANGELOG.md +4 -0
- data/lib/terser/version.rb +1 -1
- data/lib/terser.rb +19 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22265ec2111f27b275743c52fc9753948dadc4d5e0a9f2c843039ac0948c5b78
|
4
|
+
data.tar.gz: 2550c195b6450da8cfdbbbae53ebb85ef0b7cd6f573d06c9ada25f740e0d7b6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c82469000fbaaa5a55c1fa5eac9c19f4dbabff716dae52dc44f3fca0b6452e1b995827e8dcbece8aa9bfb11c2aff0c0c1f4d1e9cdcc8d71c4125c2db4e4d95c2
|
7
|
+
data.tar.gz: 86ccd5509a758ee06b453ac3a02bd707304e5e2507ab62195dabee0de2095911eaa23359f11505cb0d073482c0568c96bfc9b314fdf5a06e9ca40c61ab2cc7ea
|
data/CHANGELOG.md
CHANGED
data/lib/terser/version.rb
CHANGED
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
|
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
|
-
{
|
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.
|
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-
|
11
|
+
date: 2022-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|