uglifier 2.7.2 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +14 -0
- data/.gitmodules +6 -0
- data/.rubocop.yml +28 -1
- data/.travis.yml +16 -11
- data/.yardopts +4 -0
- data/CHANGELOG.md +228 -0
- data/CONTRIBUTING.md +9 -4
- data/Gemfile +1 -5
- data/README.md +88 -16
- data/Rakefile +112 -35
- data/lib/source-map.js +3055 -0
- data/lib/uglifier.js +49 -0
- data/lib/uglifier.rb +317 -120
- data/lib/uglifier/version.rb +1 -1
- data/lib/uglify-harmony.js +432 -0
- data/lib/uglify.js +21 -2104
- data/uglifier.gemspec +9 -9
- metadata +24 -51
- data/gemfiles/alaska +0 -4
- data/gemfiles/rubyracer +0 -4
- data/gemfiles/rubyrhino +0 -4
- data/spec/source_map_spec.rb +0 -110
- data/spec/spec_helper.rb +0 -23
- data/spec/uglifier_spec.rb +0 -280
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6eb829d19c603a2d3760e02f0235d9d654f640111734caa9317449378e40fa26
|
4
|
+
data.tar.gz: '0774580cb6353b90d72e5febfdc6777bc05c6d6d773b09e4aab3b82178fe8acd'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81f5c10b9dd4b9c84a6fe850dfb45b30bb25e0d9b04fa089ff745683028d1733e6b0b1c92846788af96197ee8774d8a7d105b424bc88f38b0c5abab5971bded0
|
7
|
+
data.tar.gz: 3120b0abc086792140a2cdb3a8ecae725327c8c8ea7b55c49d98be196e97de526087583c5bb2b6a0c169e86277474e8ae8a82d6a02cc23cd58cf0276defff03a
|
data/.gitmodules
CHANGED
@@ -4,3 +4,9 @@
|
|
4
4
|
[submodule "vendor/source-map"]
|
5
5
|
path = vendor/source-map
|
6
6
|
url = https://github.com/mozilla/source-map.git
|
7
|
+
[submodule "vendor/split"]
|
8
|
+
path = vendor/split
|
9
|
+
url = https://gist.github.com/2048056.git
|
10
|
+
[submodule "vendor/uglifyjs-harmony"]
|
11
|
+
path = vendor/uglifyjs-harmony
|
12
|
+
url = https://github.com/mishoo/UglifyJS2.git
|
data/.rubocop.yml
CHANGED
@@ -1,10 +1,19 @@
|
|
1
1
|
AllCops:
|
2
|
+
DisplayCopNames: true
|
2
3
|
Exclude:
|
3
4
|
- uglifier.gemspec
|
4
5
|
- lib/uglifier/version.rb
|
5
6
|
- "vendor/**/*"
|
6
7
|
- "gemfiles/vendor/**/*"
|
7
8
|
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Max: 20
|
11
|
+
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Enabled: true
|
14
|
+
Exclude:
|
15
|
+
- "spec/**/*_spec.rb"
|
16
|
+
|
8
17
|
Metrics/ClassLength:
|
9
18
|
Enabled: false
|
10
19
|
|
@@ -14,14 +23,32 @@ Metrics/LineLength:
|
|
14
23
|
Metrics/MethodLength:
|
15
24
|
Max: 20
|
16
25
|
|
17
|
-
Style/
|
26
|
+
Style/Encoding:
|
18
27
|
Enabled: false
|
19
28
|
|
20
29
|
Style/HashSyntax:
|
21
30
|
EnforcedStyle: hash_rockets
|
22
31
|
|
32
|
+
Style/PercentLiteralDelimiters:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Style/PreferredHashMethods:
|
36
|
+
Enabled: false
|
37
|
+
|
23
38
|
Style/SignalException:
|
24
39
|
Enabled: false
|
25
40
|
|
26
41
|
Style/StringLiterals:
|
27
42
|
Enabled: false
|
43
|
+
|
44
|
+
Style/SymbolArray:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
Style/Alias:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
Style/MutableConstant:
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
Style/ExpandPathArguments:
|
54
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -2,29 +2,34 @@ sudo: false
|
|
2
2
|
language: ruby
|
3
3
|
cache: bundler
|
4
4
|
rvm:
|
5
|
-
- 1.8.7
|
6
5
|
- 1.9.3
|
7
6
|
- 2.0.0
|
8
|
-
- 2.1.
|
9
|
-
- 2.2.
|
10
|
-
-
|
11
|
-
-
|
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
|
12
17
|
git:
|
13
18
|
submodules: false
|
14
19
|
gemfile:
|
15
20
|
- Gemfile
|
16
21
|
matrix:
|
17
22
|
include:
|
18
|
-
- rvm: 2.
|
23
|
+
- rvm: 2.5.3
|
19
24
|
gemfile: gemfiles/rubyracer
|
20
|
-
- rvm: 2.
|
21
|
-
gemfile: gemfiles/rubyracer
|
22
|
-
- rvm: jruby-19mode
|
25
|
+
- rvm: jruby-9.2.5.0
|
23
26
|
gemfile: gemfiles/rubyrhino
|
24
|
-
- rvm: 2.
|
27
|
+
- rvm: 2.5.3
|
25
28
|
gemfile: gemfiles/alaska
|
26
29
|
env: ALASKA=1
|
27
30
|
allow_failures:
|
28
|
-
- rvm: 2.
|
31
|
+
- rvm: 2.5.3
|
29
32
|
gemfile: gemfiles/alaska
|
30
33
|
env: ALASKA=1
|
34
|
+
- rvm: ruby-head
|
35
|
+
fast_finish: true
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,231 @@
|
|
1
|
+
## 4.2.0 (25 September 2019)
|
2
|
+
|
3
|
+
- show code context for error messages (#167)
|
4
|
+
- defer initialisation of ExecJS context to fix #165
|
5
|
+
|
6
|
+
## 4.1.20 (17 November 2018)
|
7
|
+
|
8
|
+
- update UglifyJS to [3.4.8](https://github.com/mishoo/UglifyJS2/compare/v3.4.9...v3.4.8)
|
9
|
+
|
10
|
+
## 4.1.19 (11 September 2018)
|
11
|
+
|
12
|
+
- update UglifyJS to [3.4.9](https://github.com/mishoo/UglifyJS2/compare/v3.4.7...v3.4.9)
|
13
|
+
|
14
|
+
## 4.1.18 (09 August 2018)
|
15
|
+
|
16
|
+
- update UglifyJS to [3.4.7](https://github.com/mishoo/UglifyJS2/compare/v3.4.6...v3.4.7)
|
17
|
+
|
18
|
+
## 4.1.17 (29 July 2018)
|
19
|
+
|
20
|
+
- update UglifyJS to [3.4.6](https://github.com/mishoo/UglifyJS2/compare/v3.4.5...v3.4.6)
|
21
|
+
|
22
|
+
## 4.1.16 (22 July 2018)
|
23
|
+
|
24
|
+
- update UglifyJS to [3.4.5](https://github.com/mishoo/UglifyJS2/compare/v3.4.4...v3.4.5)
|
25
|
+
|
26
|
+
## 4.1.15 (13 July 2018)
|
27
|
+
|
28
|
+
- update UglifyJS to [3.4.4](https://github.com/mishoo/UglifyJS2/compare/v3.4.3...v3.4.4)
|
29
|
+
|
30
|
+
## 4.1.14 (02 July 2018)
|
31
|
+
|
32
|
+
- update UglifyJS to [3.4.3](https://github.com/mishoo/UglifyJS2/compare/v3.4.2...v3.4.3)
|
33
|
+
|
34
|
+
## 4.1.13 (30 June 2018)
|
35
|
+
|
36
|
+
- update UglifyJS to [3.4.2](https://github.com/mishoo/UglifyJS2/compare/v3.4.1...v3.4.2)
|
37
|
+
|
38
|
+
## 4.1.12 (20 June 2018)
|
39
|
+
|
40
|
+
- update UglifyJS to [3.4.1](https://github.com/mishoo/UglifyJS2/compare/v3.4.0...v3.4.1)
|
41
|
+
|
42
|
+
## 4.1.11 (02 June 2018)
|
43
|
+
|
44
|
+
- update UglifyJS to [3.3.28](https://github.com/mishoo/UglifyJS2/compare/v3.3.22...v3.3.28)
|
45
|
+
|
46
|
+
## 4.1.10 (21 April 2018)
|
47
|
+
|
48
|
+
- update UglifyJS to [3.3.22](https://github.com/mishoo/UglifyJS2/compare/v3.3.20...v3.3.22)
|
49
|
+
|
50
|
+
## 4.1.9 (11 April 2018)
|
51
|
+
|
52
|
+
- update UglifyJS to [3.3.20](https://github.com/mishoo/UglifyJS2/compare/v3.3.16...v3.3.20)
|
53
|
+
|
54
|
+
## 4.1.8 (14 March 2018)
|
55
|
+
|
56
|
+
- update UglifyJS to [3.3.15](https://github.com/mishoo/UglifyJS2/compare/v3.3.14...v3.3.15)
|
57
|
+
|
58
|
+
## 4.1.7 (11 March 2018)
|
59
|
+
|
60
|
+
- update UglifyJS to [3.3.14](https://github.com/mishoo/UglifyJS2/compare/v3.3.10...v3.3.14)
|
61
|
+
|
62
|
+
## 4.1.6 (08 February 2018)
|
63
|
+
|
64
|
+
- update UglifyJS to [3.3.10](https://github.com/mishoo/UglifyJS2/compare/v3.3.9...v3.3.10)
|
65
|
+
- update uglify-es to [3.3.10](https://github.com/mishoo/UglifyJS2/compare/harmony-v3.3.9...harmony-v3.3.10)
|
66
|
+
|
67
|
+
## 4.1.5 (28 January 2018)
|
68
|
+
|
69
|
+
- update UglifyJS to [3.3.9](https://github.com/mishoo/UglifyJS2/compare/v3.3.8...v3.3.9)
|
70
|
+
- update uglify-es to [3.3.9](https://github.com/mishoo/UglifyJS2/compare/harmony-v3.3.8...harmony-v3.3.9)
|
71
|
+
|
72
|
+
## 4.1.4 (22 January 2018)
|
73
|
+
|
74
|
+
- update UglifyJS to [3.3.8](https://github.com/mishoo/UglifyJS2/compare/v3.3.5...v3.3.8)
|
75
|
+
- update uglify-es to [3.3.8](https://github.com/mishoo/UglifyJS2/compare/harmony-v3.3.5...harmony-v3.3.8)
|
76
|
+
|
77
|
+
## 4.1.3 (7 January 2018)
|
78
|
+
|
79
|
+
- update UglifyJS to 3.3.5
|
80
|
+
|
81
|
+
## 4.1.2 (30 December 2017)
|
82
|
+
|
83
|
+
- update UglifyJS to 3.3.4
|
84
|
+
|
85
|
+
## 4.1.1 (29 December 2017)
|
86
|
+
|
87
|
+
- update UglifyJS to 3.3.3
|
88
|
+
|
89
|
+
## 4.1.0 (28 December 2017)
|
90
|
+
|
91
|
+
- update UglifyJS to 3.3.2
|
92
|
+
- `cascade` compress option is merged into `collapse_vars`
|
93
|
+
|
94
|
+
## 4.0.2 (10 December 2017)
|
95
|
+
|
96
|
+
- update UglifyJS to 3.2.2
|
97
|
+
- show harmony suggestion when using for-of loops
|
98
|
+
|
99
|
+
## 4.0.1 (3 December 2017)
|
100
|
+
|
101
|
+
- update UglifyJS to 3.2.1
|
102
|
+
|
103
|
+
## 4.0.0 (2 December 2017)
|
104
|
+
|
105
|
+
- update UglifyJS to 3.2.0
|
106
|
+
- remove Angular ngInject processing
|
107
|
+
- add unsafe_math compress option
|
108
|
+
- add reduce_funcs compress option
|
109
|
+
- add parse options
|
110
|
+
- add shebang output option
|
111
|
+
- add keep_infinity compress option
|
112
|
+
- add quote_style output option
|
113
|
+
- add side_effects compress option
|
114
|
+
- add switches compress option
|
115
|
+
- more helpful error Message in Harmony mode
|
116
|
+
|
117
|
+
Dropped options:
|
118
|
+
|
119
|
+
- output: angular
|
120
|
+
- mangle: except => reserved
|
121
|
+
- mangle_properties: ignore_quoted => keep_quoted
|
122
|
+
- enclose
|
123
|
+
- squeeze, copyright and screw_ie8 options
|
124
|
+
|
125
|
+
|
126
|
+
## 3.2.0 (9 April 2017)
|
127
|
+
|
128
|
+
- experimental ES6/Harmony mode based on UglifyJS2 Harmony branch
|
129
|
+
- update UglifyJS to 2.8.22
|
130
|
+
|
131
|
+
## 3.1.13 (3 April 2017)
|
132
|
+
|
133
|
+
- update UglifyJS to 2.8.21
|
134
|
+
|
135
|
+
## 3.1.12 (31 March 2017)
|
136
|
+
|
137
|
+
- update UglifyJS to 2.8.20
|
138
|
+
|
139
|
+
## 3.1.11 (28 March 2017)
|
140
|
+
|
141
|
+
- update UglifyJS to 2.8.17
|
142
|
+
|
143
|
+
## 3.1.10 (25 March 2017)
|
144
|
+
|
145
|
+
- update UglifyJS to 2.8.16
|
146
|
+
|
147
|
+
## 3.1.9 (19 March 2017)
|
148
|
+
|
149
|
+
- update UglifyJS to 2.8.14
|
150
|
+
|
151
|
+
## 3.1.8 (17 March 2017)
|
152
|
+
|
153
|
+
- update UglifyJS to 2.8.13
|
154
|
+
|
155
|
+
## 3.1.7 (11 March 2017)
|
156
|
+
|
157
|
+
- fix NoMethodError on `Uglifier.compile(source, source_map: false)` (#114)
|
158
|
+
- update UglifyJS to 2.8.12
|
159
|
+
|
160
|
+
## 3.1.6 (9 March 2017)
|
161
|
+
|
162
|
+
- update UglifyJS to 2.8.11
|
163
|
+
|
164
|
+
## 3.1.5 (8 March 2017)
|
165
|
+
|
166
|
+
- update UglifyJS to 2.8.9
|
167
|
+
|
168
|
+
## 3.1.4 (5 March 2017)
|
169
|
+
|
170
|
+
- Update UglifyJS to 2.8.7
|
171
|
+
|
172
|
+
## 3.1.3 (2 March 2017)
|
173
|
+
|
174
|
+
- update UglifyJS to 2.8.5
|
175
|
+
- default passes to 1
|
176
|
+
- allow source_map option to be `true` instead of a hash
|
177
|
+
|
178
|
+
## 3.1.2 (1 March 2017)
|
179
|
+
|
180
|
+
- fix `reduce_vars` compressor option
|
181
|
+
- add `passes` compressor option
|
182
|
+
- update UglifyJS to 2.8.4
|
183
|
+
|
184
|
+
## 3.1.1 (27 February 2017)
|
185
|
+
|
186
|
+
- disable `reduce_vars` by default as it causes JS errors (#110)
|
187
|
+
|
188
|
+
## 3.1.0 (27 February 2017)
|
189
|
+
|
190
|
+
- update UglifyJS to 2.8.0
|
191
|
+
- add reduce_vars compress option
|
192
|
+
- enable `reduce_vars` and `collapse_vars` compress options by default
|
193
|
+
- unused top-level function and variable removal with `toplevel` compress option
|
194
|
+
- add `top_retain` compress option to specify list of top-level variables to always retain
|
195
|
+
- add `unsafe_comps` and `unsafe_proto` options
|
196
|
+
|
197
|
+
## 3.0.4 (30 November 2016)
|
198
|
+
|
199
|
+
- update UglifyJS to 2.7.5
|
200
|
+
- implement ignore_quoted and debug options for mangle_properties
|
201
|
+
|
202
|
+
## 3.0.3 (24 October 2016)
|
203
|
+
|
204
|
+
- update UglifyJS to 2.7.4
|
205
|
+
- add wrap_iife output option to wrap IIFEs in parenthesis
|
206
|
+
|
207
|
+
## 3.0.2 (20 August 2016)
|
208
|
+
|
209
|
+
- add top-level keep_fnames option that implies both compressor and mangler keep_fnames
|
210
|
+
- update UglifyJS to 2.7.3
|
211
|
+
|
212
|
+
## 3.0.1 (28 July 2016)
|
213
|
+
|
214
|
+
- update UglifyJS to 2.7.0
|
215
|
+
- split JS dependencies to separate files
|
216
|
+
|
217
|
+
## 3.0.0 (22 March 2016)
|
218
|
+
|
219
|
+
- drop support for Ruby 1.8
|
220
|
+
- remove json as dependency
|
221
|
+
- discard unused function arguments only in unsafe mode
|
222
|
+
- add `keep_fnames` option to preserve function names in compressed code
|
223
|
+
- add `collapse_vars` option to collapse single-use variables
|
224
|
+
- backwards incompatible changes to source map options
|
225
|
+
- support for inline base64 encoded source maps
|
226
|
+
- mangle property names option (disabled by default)
|
227
|
+
- update UglifyJS to 2.6.2
|
228
|
+
|
1
229
|
## 2.7.2 (26 August 2015)
|
2
230
|
|
3
231
|
- update UglifyJS to 2.4.24
|
data/CONTRIBUTING.md
CHANGED
@@ -28,14 +28,19 @@ Then run tests using rake:
|
|
28
28
|
|
29
29
|
git submodule update --init
|
30
30
|
|
31
|
-
After that, UglifyJS
|
31
|
+
After that, UglifyJS can be updated to a specific version with rake task.
|
32
32
|
|
33
|
-
|
33
|
+
rake uglifyjs:update VERSION=3.3.4
|
34
34
|
|
35
|
-
|
35
|
+
To compile JS with dependencies, run
|
36
36
|
|
37
|
-
|
37
|
+
rake uglifyjs:build
|
38
38
|
|
39
|
+
You can even write custom patches to UglifyJS in `vendor/uglifyjs` and `vendor/uglifyjs-harmony` directories and compile the bundles JS using the command above. However, for the changes to be releasable, they should be in UglifyJS repository.
|
40
|
+
|
41
|
+
To automatically update UglifyJS version and commit changes
|
42
|
+
|
43
|
+
rake uglifyjs VERSION=3.3.4
|
39
44
|
|
40
45
|
## Reporting issues
|
41
46
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,45 @@
|
|
1
|
-
# Uglifier
|
1
|
+
# Uglifier
|
2
2
|
|
3
|
-
Ruby wrapper for [UglifyJS](https://github.com/mishoo/UglifyJS2) JavaScript
|
3
|
+
Ruby wrapper for [UglifyJS](https://github.com/mishoo/UglifyJS2) JavaScript
|
4
|
+
compressor.
|
5
|
+
|
6
|
+
UglifyJS currently is extensively tested with ES5, but also includes experimental ES6/ES2015+/Harmony support.
|
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
|
+
[![Build Status](https://travis-ci.org/lautis/uglifier.svg?branch=master)](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
|
+
```
|
27
|
+
|
28
|
+
### Rails
|
29
|
+
|
30
|
+
When used in Rails, replace
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
config.assets.js_compressor = :uglifier
|
34
|
+
```
|
35
|
+
|
36
|
+
with
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
config.assets.js_compressor = Uglifier.new(harmony: true)
|
40
|
+
```
|
41
|
+
|
42
|
+
in `config/environments/production.rb`.
|
4
43
|
|
5
44
|
## Installation
|
6
45
|
|
@@ -55,49 +94,82 @@ Available options and their defaults are
|
|
55
94
|
:beautify => false, # Beautify output
|
56
95
|
:indent_level => 4, # Indent level in spaces
|
57
96
|
:indent_start => 0, # Starting indent level
|
58
|
-
:space_colon => false, # Insert space before colons (only with beautifier)
|
59
97
|
:width => 80, # Specify line width when beautifier is used (only with beautifier)
|
60
|
-
:preamble => nil
|
98
|
+
:preamble => nil, # Preamble for the generated JS file. Can be used to insert any code or comment.
|
99
|
+
:wrap_iife => false # Wrap IIFEs in parenthesis. Note: this disables the negate_iife compression option.
|
100
|
+
:shebang => true # Preserve shebang (#!) in preamble (shell scripts)
|
101
|
+
:quote_style => 0, # Quote style, possible values :auto (default), :single, :double, :original
|
102
|
+
:keep_quoted_props => false # Keep quotes property names
|
61
103
|
},
|
62
104
|
:mangle => {
|
63
105
|
:eval => false, # Mangle names when eval of when is used in scope
|
64
|
-
:
|
106
|
+
:reserved => ["$super"], # Argument names to be excluded from mangling
|
65
107
|
:sort => false, # Assign shorter names to most frequently used variables. Often results in bigger output after gzip.
|
66
|
-
:toplevel => false
|
108
|
+
:toplevel => false, # Mangle names declared in the toplevel scope
|
109
|
+
:properties => false, # Mangle property names
|
110
|
+
:keep_fnames => false # Do not modify function names
|
67
111
|
}, # Mangle variable and function names, set to false to skip mangling
|
112
|
+
:mangle_properties => {
|
113
|
+
:regex => nil, # A regular expression to filter property names to be mangled
|
114
|
+
:ignore_quoted => false, # Only mangle unquoted property names
|
115
|
+
:debug => false, # Mangle names with the original name still present
|
116
|
+
} # Mangle property names, disabled by default
|
68
117
|
:compress => {
|
69
118
|
:sequences => true, # Allow statements to be joined by commas
|
70
119
|
:properties => true, # Rewrite property access using the dot notation
|
71
120
|
:dead_code => true, # Remove unreachable code
|
72
121
|
:drop_debugger => true, # Remove debugger; statements
|
73
122
|
:unsafe => false, # Apply "unsafe" transformations
|
123
|
+
:unsafe_comps => false, # Reverse < and <= to > and >= to allow improved compression. This might be unsafe when an at least one of two operands is an object with computed values due the use of methods like get, or valueOf. This could cause change in execution order after operands in the comparison are switching. Compression only works if both comparisons and unsafe_comps are both set to true.
|
124
|
+
:unsafe_math => false, # Optimize numerical expressions like 2 * x * 3 into 6 * x, which may give imprecise floating point results.
|
125
|
+
:unsafe_proto => false, # Optimize expressions like Array.prototype.slice.call(a) into [].slice.call(a)
|
74
126
|
:conditionals => true, # Optimize for if-s and conditional expressions
|
75
127
|
:comparisons => true, # Apply binary node optimizations for comparisons
|
76
128
|
:evaluate => true, # Attempt to evaluate constant expressions
|
77
129
|
:booleans => true, # Various optimizations to boolean contexts
|
78
130
|
:loops => true, # Optimize loops when condition can be statically determined
|
79
131
|
:unused => true, # Drop unreferenced functions and variables
|
132
|
+
:toplevel => false, # Drop unreferenced top-level functions and variables
|
133
|
+
:top_retain => [], # prevent specific toplevel functions and variables from `unused` removal
|
80
134
|
:hoist_funs => true, # Hoist function declarations
|
81
135
|
:hoist_vars => false, # Hoist var declarations
|
82
136
|
:if_return => true, # Optimizations for if/return and if/continue
|
83
137
|
:join_vars => true, # Join consecutive var statements
|
84
|
-
:
|
138
|
+
:collapse_vars => false, # Collapse single-use var and const definitions when possible.
|
139
|
+
:reduce_funcs => false, # Inline single-use functions as function expressions. Depends on reduce_vars.
|
140
|
+
:reduce_vars => false, # Collapse variables assigned with and used as constant values.
|
85
141
|
:negate_iife => true, # Negate immediately invoked function expressions to avoid extra parens
|
86
142
|
:pure_getters => false, # Assume that object property access does not have any side-effects
|
87
143
|
:pure_funcs => nil, # List of functions without side-effects. Can safely discard function calls when the result value is not used
|
88
144
|
:drop_console => false, # Drop calls to console.* functions
|
89
|
-
:
|
90
|
-
:
|
145
|
+
:keep_fargs => false, # Preserve unused function arguments
|
146
|
+
:keep_fnames => false, # Do not drop names in function definitions
|
147
|
+
:passes => 1, # Number of times to run compress. Raising the number of passes will increase compress time, but can produce slightly smaller code.
|
148
|
+
:keep_infinity => false, # Prevent compression of Infinity to 1/0
|
149
|
+
:side_effects => true, # Pass false to disable potentially dropping functions marked as "pure" using pure comment annotation. See UglifyJS documentation for details.
|
150
|
+
:switches => true, # de-duplicate and remove unreachable switch branches
|
91
151
|
}, # Apply transformations to code, set to false to skip
|
152
|
+
:parse => {
|
153
|
+
:bare_returns => false, # Allow top-level return statements.
|
154
|
+
:expression => false, # Parse a single expression, rather than a program (for parsing JSON).
|
155
|
+
:html5_comments => true, # Ignore HTML5 comments in input
|
156
|
+
:shebang => true, # support #!command as the first line
|
157
|
+
:strict => false
|
158
|
+
},
|
92
159
|
:define => {}, # Define values for symbol replacement
|
93
160
|
:enclose => false, # Enclose in output function wrapper, define replacements as key-value pairs
|
94
|
-
:
|
95
|
-
:
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
161
|
+
: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.
|
162
|
+
:source_map => {
|
163
|
+
:map_url => false, # Url for source mapping to be appended in minified source
|
164
|
+
:url => false, # Url for original source to be appended in minified source
|
165
|
+
:sources_content => false, # Include original source content in map
|
166
|
+
:filename => nil, # The filename of the input file
|
167
|
+
:root => nil, # The URL of the directory which contains :filename
|
168
|
+
:output_filename => nil, # The filename or URL where the minified output can be found
|
169
|
+
:input_source_map => nil # The contents of the source map describing the input
|
170
|
+
},
|
171
|
+
:error_context_lines => 8, # How many context lines surrounding the error line. Env var ERROR_CONTEXT_LINES overrides this option
|
172
|
+
:harmony => false # Enable ES6/Harmony mode (experimental). Disabling mangling and compressing is recommended with Harmony mode.
|
101
173
|
}
|
102
174
|
```
|
103
175
|
|