Add a "keep_fnames" option to the compressor to retain function expression names
See #552. This is useful for stack traces.
This commit is contained in:
@@ -62,6 +62,7 @@ function Compressor(options, false_by_default) {
|
|||||||
unused : !false_by_default,
|
unused : !false_by_default,
|
||||||
hoist_funs : !false_by_default,
|
hoist_funs : !false_by_default,
|
||||||
keep_fargs : false,
|
keep_fargs : false,
|
||||||
|
keep_fnames : false,
|
||||||
hoist_vars : false,
|
hoist_vars : false,
|
||||||
if_return : !false_by_default,
|
if_return : !false_by_default,
|
||||||
join_vars : !false_by_default,
|
join_vars : !false_by_default,
|
||||||
@@ -1666,7 +1667,7 @@ merge(Compressor.prototype, {
|
|||||||
|
|
||||||
OPT(AST_Function, function(self, compressor){
|
OPT(AST_Function, function(self, compressor){
|
||||||
self = AST_Lambda.prototype.optimize.call(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()) {
|
if (self.name && self.name.unreferenced()) {
|
||||||
self.name = null;
|
self.name = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,3 +163,17 @@ used_var_in_catch: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keep_fnames: {
|
||||||
|
options = { unused: true, keep_fnames: true };
|
||||||
|
input: {
|
||||||
|
function foo() {
|
||||||
|
return function bar(baz) {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function foo() {
|
||||||
|
return function bar() {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user