improve ease of use for --mangle except
This commit is contained in:
parent
2af73232c7
commit
e03c194beb
|
|
@ -142,7 +142,6 @@ The available options are:
|
|||
```
|
||||
TODOs:
|
||||
```
|
||||
-r, --reserved Reserved names to exclude from mangling.
|
||||
--lint Display some scope warnings
|
||||
--reserved-file File containing reserved names
|
||||
--reserve-domprops Make (most?) DOM properties reserved for
|
||||
|
|
@ -206,10 +205,10 @@ To enable the mangler you need to pass `--mangle` (`-m`). The following
|
|||
(disabled by default).
|
||||
|
||||
When mangling is enabled but you want to prevent certain names from being
|
||||
mangled, you can declare those names with `--reserved` (`-r`) — pass a
|
||||
mangled, you can declare those names with `--mangle except` — pass a
|
||||
comma-separated list of names. For example:
|
||||
|
||||
uglifyjs ... -m -r '$,require,exports'
|
||||
uglifyjs ... -m except=[$,require,exports]
|
||||
|
||||
to prevent the `require`, `exports` and `$` names from being changed.
|
||||
|
||||
|
|
|
|||
10
bin/uglifyjs
10
bin/uglifyjs
|
|
@ -246,10 +246,10 @@ function parseJS(flag, constants) {
|
|||
var value = node.right;
|
||||
if (!constants) {
|
||||
options[name] = value;
|
||||
} else if (value instanceof UglifyJS.AST_Constant) {
|
||||
options[name] = value.getValue();
|
||||
} else if (value instanceof UglifyJS.AST_Array) {
|
||||
options[name] = value.elements.map(to_string);
|
||||
} else {
|
||||
options[name] = value.print_to_string();
|
||||
options[name] = to_string(value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -259,6 +259,10 @@ function parseJS(flag, constants) {
|
|||
return true;
|
||||
}
|
||||
if (!(node instanceof UglifyJS.AST_Sequence)) throw node;
|
||||
|
||||
function to_string(value) {
|
||||
return value instanceof UglifyJS.AST_Constant ? value.getValue() : value.print_to_string();
|
||||
}
|
||||
}));
|
||||
} catch(ex) {
|
||||
fatal("Error parsing arguments for '" + flag + "': " + value);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user