Add option keep_fargs.
By default it's `false`. Pass `true` if you need to keep unused function arguments. Close #188.
This commit is contained in:
@@ -61,6 +61,7 @@ function Compressor(options, false_by_default) {
|
|||||||
loops : !false_by_default,
|
loops : !false_by_default,
|
||||||
unused : !false_by_default,
|
unused : !false_by_default,
|
||||||
hoist_funs : !false_by_default,
|
hoist_funs : !false_by_default,
|
||||||
|
keep_fargs : 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,
|
||||||
@@ -1044,18 +1045,20 @@ merge(Compressor.prototype, {
|
|||||||
var tt = new TreeTransformer(
|
var tt = new TreeTransformer(
|
||||||
function before(node, descend, in_list) {
|
function before(node, descend, in_list) {
|
||||||
if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
|
if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
|
||||||
for (var a = node.argnames, i = a.length; --i >= 0;) {
|
if (!compressor.option("keep_fargs")) {
|
||||||
var sym = a[i];
|
for (var a = node.argnames, i = a.length; --i >= 0;) {
|
||||||
if (sym.unreferenced()) {
|
var sym = a[i];
|
||||||
a.pop();
|
if (sym.unreferenced()) {
|
||||||
compressor.warn("Dropping unused function argument {name} [{file}:{line},{col}]", {
|
a.pop();
|
||||||
name : sym.name,
|
compressor.warn("Dropping unused function argument {name} [{file}:{line},{col}]", {
|
||||||
file : sym.start.file,
|
name : sym.name,
|
||||||
line : sym.start.line,
|
file : sym.start.file,
|
||||||
col : sym.start.col
|
line : sym.start.line,
|
||||||
});
|
col : sym.start.col
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else break;
|
||||||
}
|
}
|
||||||
else break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node instanceof AST_Defun && node !== self) {
|
if (node instanceof AST_Defun && node !== self) {
|
||||||
|
|||||||
Reference in New Issue
Block a user