.describe("V", "Print version number and exit.")
.describe("noerr", "Don't throw an error for unknown options in -c, -b or -m.")
.describe("bare-returns", "Allow return outside of functions. Useful when minifying CommonJS modules.")
+ .describe("keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.")
.alias("p", "prefix")
.alias("o", "output")
OUTPUT_OPTIONS.screw_ie8 = true;
}
+if (ARGS.keep_fnames) {
+ if (COMPRESS) COMPRESS.keep_fnames = true;
+ if (MANGLE) MANGLE.keep_fnames = true;
+}
+
if (BEAUTIFY)
UglifyJS.merge(OUTPUT_OPTIONS, BEAUTIFY);
unused : !false_by_default,
hoist_funs : !false_by_default,
keep_fargs : false,
+ keep_fnames : false,
hoist_vars : false,
if_return : !false_by_default,
join_vars : !false_by_default,
OPT(AST_Function, function(self, compressor){
self = AST_Lambda.prototype.optimize.call(self, compressor);
- if (compressor.option("unused")) {
+ if (compressor.option("unused") && !compressor.option("keep_fnames")) {
if (self.name && self.name.unreferenced()) {
self.name = null;
}