aboutsummaryrefslogtreecommitdiff
path: root/node_modules/uglify-js/bin/uglifyjs
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/uglify-js/bin/uglifyjs
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
update packages
Diffstat (limited to 'node_modules/uglify-js/bin/uglifyjs')
-rwxr-xr-xnode_modules/uglify-js/bin/uglifyjs61
1 files changed, 37 insertions, 24 deletions
diff --git a/node_modules/uglify-js/bin/uglifyjs b/node_modules/uglify-js/bin/uglifyjs
index 718397c1e..62c7beb34 100755
--- a/node_modules/uglify-js/bin/uglifyjs
+++ b/node_modules/uglify-js/bin/uglifyjs
@@ -3,11 +3,7 @@
"use strict";
-// workaround for tty output truncation upon process.exit()
-[process.stdout, process.stderr].forEach(function(stream){
- if (stream._handle && stream._handle.setBlocking)
- stream._handle.setBlocking(true);
-});
+require("../tools/exit");
var fs = require("fs");
var info = require("../package.json");
@@ -15,7 +11,7 @@ var path = require("path");
var program = require("commander");
var UglifyJS = require("../tools/node");
-var skip_keys = [ "cname", "enclosed", "inlined", "parent_scope", "scope", "thedef", "uses_eval", "uses_with" ];
+var skip_keys = [ "cname", "inlined", "parent_scope", "scope", "uses_eval", "uses_with" ];
var files = {};
var options = {
compress: false,
@@ -44,13 +40,15 @@ program.option("-o, --output <file>", "Output file (default STDOUT).");
program.option("--comments [filter]", "Preserve copyright comments in the output.");
program.option("--config-file <file>", "Read minify() options from JSON file.");
program.option("-d, --define <expr>[=value]", "Global definitions.", parse_js("define"));
+program.option("-e, --enclose [arg[,...][:value[,...]]]", "Embed everything in a big function, with configurable argument(s) & value(s).");
program.option("--ie8", "Support non-standard Internet Explorer 8.");
program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
program.option("--name-cache <file>", "File to hold mangled name mappings.");
+program.option("--rename", "Force symbol expansion.");
program.option("--no-rename", "Disable symbol expansion.");
program.option("--self", "Build UglifyJS as a library (implies --wrap UglifyJS)");
-program.option("--source-map [options]", "Enable source map/specify source map options.", parse_source_map());
-program.option("--timings", "Display operations run time on STDERR.")
+program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js());
+program.option("--timings", "Display operations run time on STDERR.");
program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");
program.option("--verbose", "Print diagnostic messages.");
program.option("--warn", "Print warning messages.");
@@ -64,15 +62,14 @@ if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
}
[
"compress",
+ "enclose",
"ie8",
"mangle",
- "rename",
"sourceMap",
"toplevel",
"wrap"
].forEach(function(name) {
if (name in program) {
- if (name == "rename" && program[name]) return;
options[name] = program[name];
}
});
@@ -103,7 +100,7 @@ if (program.mangleProps) {
if (typeof program.mangleProps != "object") program.mangleProps = {};
if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
require("../tools/domprops").forEach(function(name) {
- UglifyJS._push_uniq(program.mangleProps.reserved, name);
+ UglifyJS.push_uniq(program.mangleProps.reserved, name);
});
}
if (typeof options.mangle != "object") options.mangle = {};
@@ -125,6 +122,11 @@ if (program.parse) {
fatal("ERROR: inline source map only works with built-in parser");
}
}
+if (~program.rawArgs.indexOf("--rename")) {
+ options.rename = true;
+} else if (!program.rename) {
+ options.rename = false;
+}
var convert_path = function(name) {
return name;
};
@@ -176,6 +178,11 @@ function run() {
UglifyJS.AST_Node.warn_function = function(msg) {
print_error("WARN: " + msg);
};
+ var content = program.sourceMap && program.sourceMap.content;
+ if (content && content != "inline") {
+ print_error("INFO: Using input source map: " + content);
+ options.sourceMap.content = read_file(content, content);
+ }
if (program.timings) options.timings = true;
try {
if (program.parse) {
@@ -227,7 +234,20 @@ function run() {
}
fatal(ex);
} else if (program.output == "ast") {
+ if (!options.compress && !options.mangle) {
+ result.ast.figure_out_scope({});
+ }
print(JSON.stringify(result.ast, function(key, value) {
+ if (value) switch (key) {
+ case "thedef":
+ return symdef(value);
+ case "enclosed":
+ return value.length ? value.map(symdef) : undefined;
+ case "variables":
+ case "functions":
+ case "globals":
+ return value.size() ? value.map(symdef) : undefined;
+ }
if (skip_key(key)) return;
if (value instanceof UglifyJS.AST_Token) return;
if (value instanceof UglifyJS.Dictionary) return;
@@ -364,23 +384,16 @@ function parse_js(flag) {
}
}
-function parse_source_map() {
- var parse = parse_js();
- return function(value, options) {
- var hasContent = options && "content" in options;
- var settings = parse(value, options);
- if (!hasContent && settings.content && settings.content != "inline") {
- print_error("INFO: Using input source map: " + settings.content);
- settings.content = read_file(settings.content, settings.content);
- }
- return settings;
- }
-}
-
function skip_key(key) {
return skip_keys.indexOf(key) >= 0;
}
+function symdef(def) {
+ var ret = (1e6 + def.id) + " " + def.name;
+ if (def.mangled_name) ret += " " + def.mangled_name;
+ return ret;
+}
+
function format_object(obj) {
var lines = [];
var padding = "";