[Pkg-javascript-commits] [uglifyjs] 98/190: Added a mangle properties option
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Aug 7 23:17:16 UTC 2016
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.
commit 799509e145e56a9a6ccbaad6d32e1c404e0469eb
Author: Jeremy Marzka <jeremy.marzka at techthrive.com>
Date: Sun Jan 17 21:54:09 2016 -0500
Added a mangle properties option
---
README.md | 3 +++
tools/node.js | 31 ++++++++++++++++++++-----------
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index 6dea439..9cde9ee 100644
--- a/README.md
+++ b/README.md
@@ -626,6 +626,9 @@ Other options:
- `mangle` — pass `false` to skip mangling names.
+- `mangleProperties` (default `false`) — pass an object to specify custom
+ mangle property options.
+
- `output` (default `null`) — pass an object if you wish to specify
additional [output options][codegen]. The defaults are optimized
for best compression.
diff --git a/tools/node.js b/tools/node.js
index f604866..5764286 100644
--- a/tools/node.js
+++ b/tools/node.js
@@ -32,15 +32,17 @@ UglifyJS.AST_Node.warn_function = function(txt) {
exports.minify = function(files, options) {
options = UglifyJS.defaults(options, {
- spidermonkey : false,
- outSourceMap : null,
- sourceRoot : null,
- inSourceMap : null,
- fromString : false,
- warnings : false,
- mangle : {},
- output : null,
- compress : {}
+ spidermonkey : false,
+ outSourceMap : null,
+ sourceRoot : null,
+ inSourceMap : null,
+ fromString : false,
+ warnings : false,
+ mangle : {},
+ mangleProperties : false,
+ nameCache : null,
+ output : null,
+ compress : {}
});
UglifyJS.base54.reset();
@@ -77,14 +79,21 @@ exports.minify = function(files, options) {
toplevel = toplevel.transform(sq);
}
- // 3. mangle
+ // 3. mangle properties
+ if (options.mangleProperties || options.nameCache) {
+ options.mangleProperties.cache = UglifyJS.readNameCache(options.nameCache, "props");
+ toplevel = UglifyJS.mangle_properties(toplevel, options.mangleProperties);
+ UglifyJS.writeNameCache(options.nameCache, "props", options.mangleProperties.cache);
+ }
+
+ // 4. mangle
if (options.mangle) {
toplevel.figure_out_scope(options.mangle);
toplevel.compute_char_frequency(options.mangle);
toplevel.mangle_names(options.mangle);
}
- // 4. output
+ // 5. output
var inMap = options.inSourceMap;
var output = {};
if (typeof options.inSourceMap == "string") {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list