extend keep_fnames to classes (#4793)

This commit is contained in:
Alex Lam S.L
2021-03-17 01:28:27 +00:00
committed by GitHub
parent b244b4ec21
commit 997d09bb33
3 changed files with 27 additions and 4 deletions

View File

@@ -96,8 +96,10 @@ SymbolDef.prototype = {
|| this.undeclared || this.undeclared
|| !options.eval && this.scope.pinned() || !options.eval && this.scope.pinned()
|| options.keep_fnames || options.keep_fnames
&& (this.orig[0] instanceof AST_SymbolLambda && (this.orig[0] instanceof AST_SymbolClass
|| this.orig[0] instanceof AST_SymbolDefun); || this.orig[0] instanceof AST_SymbolDefClass
|| this.orig[0] instanceof AST_SymbolDefun
|| this.orig[0] instanceof AST_SymbolLambda);
}, },
}; };

View File

@@ -779,6 +779,27 @@ computed_key_generator: {
node_version: ">=4" node_version: ">=4"
} }
keep_fnames: {
options = {
keep_fnames: true,
toplevel: true,
}
mangle = {
keep_fnames: true,
toplevel: true,
}
input: {
"use strict";
class Foo {}
console.log(Foo.name, class Bar {}.name);
}
expect: {
"use strict";
class Foo {}
console.log(Foo.name, class Bar {}.name);
}
}
issue_805_1: { issue_805_1: {
options = { options = {
inline: true, inline: true,

View File

@@ -4,7 +4,7 @@ mangle_keep_fnames_false: {
keep_fnames: true, keep_fnames: true,
} }
mangle = { mangle = {
keep_fnames : false, keep_fnames: false,
} }
input: { input: {
"use strict"; "use strict";
@@ -30,7 +30,7 @@ mangle_keep_fnames_true: {
keep_fnames: true, keep_fnames: true,
} }
mangle = { mangle = {
keep_fnames : true, keep_fnames: true,
} }
input: { input: {
"use strict"; "use strict";