parent
66cebbf336
commit
9812cba843
10
README.md
10
README.md
|
|
@ -76,7 +76,11 @@ The available options are:
|
||||||
not used.
|
not used.
|
||||||
-m, --mangle [options] Mangle names/specify mangler options.
|
-m, --mangle [options] Mangle names/specify mangler options.
|
||||||
--mangle-props [options] Mangle properties/specify mangler options:
|
--mangle-props [options] Mangle properties/specify mangler options:
|
||||||
|
`builtins` Mangle property names that overlaps
|
||||||
|
with standard JavaScript globals.
|
||||||
`debug` Add debug prefix and suffix.
|
`debug` Add debug prefix and suffix.
|
||||||
|
`domprops` Mangle property names that overlaps
|
||||||
|
with DOM properties.
|
||||||
`ignore_quoted` Only mangle unquoted properies.
|
`ignore_quoted` Only mangle unquoted properies.
|
||||||
`regex` Only mangle matched property names.
|
`regex` Only mangle matched property names.
|
||||||
-b, --beautify [options] Beautify output/specify output options:
|
-b, --beautify [options] Beautify output/specify output options:
|
||||||
|
|
@ -142,12 +146,6 @@ The available options are:
|
||||||
specify the name that your module will take
|
specify the name that your module will take
|
||||||
when included in, say, a browser.
|
when included in, say, a browser.
|
||||||
```
|
```
|
||||||
TODOs:
|
|
||||||
```
|
|
||||||
--reserved-file File containing reserved names
|
|
||||||
--reserve-domprops Make (most?) DOM properties reserved for
|
|
||||||
--mangle-props
|
|
||||||
```
|
|
||||||
|
|
||||||
Specify `--output` (`-o`) to declare the output file. Otherwise the output
|
Specify `--output` (`-o`) to declare the output file. Otherwise the output
|
||||||
goes to STDOUT.
|
goes to STDOUT.
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,14 @@ if (program.keepFnames) {
|
||||||
options.keep_fnames = true;
|
options.keep_fnames = true;
|
||||||
}
|
}
|
||||||
if (program.mangleProps) {
|
if (program.mangleProps) {
|
||||||
|
if (program.mangleProps.domprops) {
|
||||||
|
delete program.mangleProps.domprops;
|
||||||
|
} else {
|
||||||
|
if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
|
||||||
|
require("../tools/domprops").forEach(function(name) {
|
||||||
|
UglifyJS.push_uniq(program.mangleProps.reserved, name);
|
||||||
|
});
|
||||||
|
}
|
||||||
if (typeof options.mangle != "object") options.mangle = {};
|
if (typeof options.mangle != "object") options.mangle = {};
|
||||||
options.mangle.properties = program.mangleProps;
|
options.mangle.properties = program.mangleProps;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,16 +43,16 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function find_builtins() {
|
function find_builtins(reserved) {
|
||||||
// NaN will be included due to Number.NaN
|
// NaN will be included due to Number.NaN
|
||||||
var a = [
|
[
|
||||||
"null",
|
"null",
|
||||||
"true",
|
"true",
|
||||||
"false",
|
"false",
|
||||||
"Infinity",
|
"Infinity",
|
||||||
"-Infinity",
|
"-Infinity",
|
||||||
"undefined",
|
"undefined",
|
||||||
];
|
].forEach(add);
|
||||||
[ Object, Array, Function, Number,
|
[ Object, Array, Function, Number,
|
||||||
String, Boolean, Error, Math,
|
String, Boolean, Error, Math,
|
||||||
Date, RegExp
|
Date, RegExp
|
||||||
|
|
@ -63,13 +63,13 @@ function find_builtins() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
function add(name) {
|
function add(name) {
|
||||||
push_uniq(a, name);
|
push_uniq(reserved, name);
|
||||||
}
|
}
|
||||||
return a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mangle_properties(ast, options) {
|
function mangle_properties(ast, options) {
|
||||||
options = defaults(options, {
|
options = defaults(options, {
|
||||||
|
builtins: false,
|
||||||
cache: null,
|
cache: null,
|
||||||
debug: false,
|
debug: false,
|
||||||
ignore_quoted: false,
|
ignore_quoted: false,
|
||||||
|
|
@ -78,9 +78,8 @@ function mangle_properties(ast, options) {
|
||||||
reserved: null,
|
reserved: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
var reserved = options.reserved;
|
var reserved = options.reserved || [];
|
||||||
if (reserved == null)
|
if (!options.builtins) find_builtins(reserved);
|
||||||
reserved = find_builtins();
|
|
||||||
|
|
||||||
var cache = options.cache;
|
var cache = options.cache;
|
||||||
if (cache == null) {
|
if (cache == null) {
|
||||||
|
|
|
||||||
11204
tools/domprops.json
11204
tools/domprops.json
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user