Support keep_fnames in compressor, and --keep-fnames. #552

Passing `--keep-fnames` will enable it both for compressor/mangler, so that
function names will not be dropped (when unused) nor mangled.
This commit is contained in:
Mihai Bazon
2015-01-05 11:03:13 +02:00
parent e37b67d013
commit e1f0747e4c
2 changed files with 8 additions and 1 deletions

View File

@@ -62,6 +62,7 @@ function Compressor(options, false_by_default) {
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,
@@ -1666,7 +1667,7 @@ merge(Compressor.prototype, {
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;
}