Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.

Commit 990de2a

Browse files
evilebottnawimichael-ciniawsky
authored andcommitted
feat(uglify): add missing toplevel, nameCache, keep_classnames, keep_fnames and safari10 options (uglifyOptions) (#229)
1 parent 88cde68 commit 990de2a

File tree

4 files changed

+696
-14
lines changed

4 files changed

+696
-14
lines changed

Diff for: README.md

+16-6
Original file line numberDiff line numberDiff line change
@@ -160,22 +160,28 @@ Number of concurrent runs.
160160

161161
|Name|Type|Default|Description|
162162
|:--:|:--:|:-----:|:----------|
163-
|**`ie8`**|`{Boolean}`|`false`|Enable IE8 Support|
164163
|**`ecma`**|`{Number}`|`undefined`|Supported ECMAScript Version (`5`, `6`, `7` or `8`). Affects `parse`, `compress` && `output` options|
164+
|**`warnings`**|`{Boolean}`|`false`|Display Warnings|
165165
|**[`parse`](https://github.com/mishoo/UglifyJS2/tree/harmony#parse-options)**|`{Object}`|`{}`|Additional Parse Options|
166+
|**[`compress`](https://github.com/mishoo/UglifyJS2/tree/harmony#compress-options)**|`{Boolean\|Object}`|`true`|Additional Compress Options|
166167
|**[`mangle`](https://github.com/mishoo/UglifyJS2/tree/harmony#mangle-options)**|`{Boolean\|Object}`|`true`|Enable Name Mangling (See [Mangle Properties](https://github.com/mishoo/UglifyJS2/tree/harmony#mangle-properties-options) for advanced setups, use with ⚠️)|
167168
|**[`output`](https://github.com/mishoo/UglifyJS2/tree/harmony#output-options)**|`{Object}`|`{}`|Additional Output Options (The defaults are optimized for best compression)|
168-
|**[`compress`](https://github.com/mishoo/UglifyJS2/tree/harmony#compress-options)**|`{Boolean\|Object}`|`true`|Additional Compress Options|
169-
|**`warnings`**|`{Boolean}`|`false`|Display Warnings|
169+
|**`toplevel`**|`{Boolean}`|`false`|Enable top level variable and function name mangling and to drop unused variables and functions|
170+
|**`nameCache`**|`{Object}`|`null`|Enable cache of mangled variable and property names across multiple invocations|
171+
|**`ie8`**|`{Boolean}`|`false`|Enable IE8 Support|
172+
|**`keep_classnames`**|`{Boolean}`|`undefined`|Enable prevent discarding or mangling of class names|
173+
|**`keep_fnames`**|`{Boolean}`|`false`| Enable prevent discarding or mangling of function names. Useful for code relying on `Function.prototype.name`. If the top level minify option `keep_classnames` is `undefined` it will be overriden with the value of the top level minify option `keep_fnames`|
174+
|**`safari10`**|`{Boolean}`|`false`|Enable work around Safari 10/11 bugs in loop scoping and `await`|
170175

171176
**webpack.config.js**
172177
```js
173178
[
174179
new UglifyJsPlugin({
175180
uglifyOptions: {
176-
ie8: false,
177181
ecma: 8,
182+
warnings: false,
178183
parse: {...options},
184+
compress: {...options},
179185
mangle: {
180186
...options,
181187
properties: {
@@ -187,8 +193,12 @@ Number of concurrent runs.
187193
beautify: false,
188194
...options
189195
},
190-
compress: {...options},
191-
warnings: false
196+
toplevel: false,
197+
nameCache: null,
198+
ie8: false,
199+
keep_classnames: undefined,
200+
keep_fnames: false,
201+
safari10: false,
192202
}
193203
})
194204
]

Diff for: src/uglify/minify.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,25 @@
44
import uglify from 'uglify-es';
55

66
const buildUglifyOptions = ({
7-
ie8,
87
ecma,
8+
warnings,
99
parse = {},
10+
compress = {},
1011
mangle,
1112
output,
12-
compress = {},
13-
warnings,
1413
toplevel,
1514
nameCache,
16-
} = {}) => ({
1715
ie8,
16+
/* eslint-disable camelcase */
17+
keep_classnames,
18+
keep_fnames,
19+
/* eslint-enable camelcase */
20+
safari10,
21+
} = {}) => ({
1822
ecma,
23+
warnings,
1924
parse,
25+
compress,
2026
mangle: mangle == null ? true : mangle,
2127
output: {
2228
shebang: true,
@@ -25,12 +31,14 @@ const buildUglifyOptions = ({
2531
semicolons: true,
2632
...output,
2733
},
28-
compress,
29-
warnings,
30-
toplevel,
31-
nameCache,
3234
// Ignoring sourcemap from options
3335
sourceMap: null,
36+
toplevel,
37+
nameCache,
38+
ie8,
39+
keep_classnames,
40+
keep_fnames,
41+
safari10,
3442
});
3543

3644
const buildComments = (options, uglifyOptions, extractedComments) => {

0 commit comments

Comments
 (0)