separate keep_classnames & keep_fnames (#2510)

fixes #2418
This commit is contained in:
Alex Lam S.L
2017-11-25 16:31:52 +08:00
committed by GitHub
parent bbf38dc9c0
commit f1e3ef5262
5 changed files with 113 additions and 2 deletions

View File

@@ -69,6 +69,7 @@ function Compressor(options, false_by_default) {
if_return : !false_by_default,
inline : !false_by_default,
join_vars : !false_by_default,
keep_classnames: false,
keep_fargs : true,
keep_fnames : false,
keep_infinity : false,
@@ -2610,8 +2611,9 @@ merge(Compressor.prototype, {
// pass 3: we should drop declarations not in_use
var tt = new TreeTransformer(
function before(node, descend, in_list) {
if (!compressor.option("keep_fnames")
&& node.name && (node instanceof AST_Function || node instanceof AST_ClassExpression)) {
if (node.name
&& (!compressor.option("keep_classnames") && node instanceof AST_ClassExpression
|| !compressor.option("keep_fnames") && node instanceof AST_Function)) {
var def = node.name.definition();
// any declarations with same name will overshadow
// name of this anonymous function and can therefore