workaround for compress of export default anonymous functions

This commit is contained in:
kzc 2017-12-17 01:38:58 -05:00
parent 34f765d48b
commit e5c4ae0fe0

View File

@ -409,6 +409,7 @@ merge(Compressor.prototype, {
}
}
if (node instanceof AST_DefClass || node instanceof AST_Defun) {
if (!node.name) return;
node.inlined = false;
var d = node.name.definition();
if (compressor.exposed(d) || safe_to_read(d)) {
@ -2581,6 +2582,7 @@ merge(Compressor.prototype, {
if (node instanceof AST_Defun || node instanceof AST_DefClass) {
var in_export = tw.parent() instanceof AST_Export;
if (in_export || !drop_funcs && scope === self) {
if (!node.name) return;
var node_def = node.name.definition();
if (node_def.global && !(node_def.id in in_use_ids)) {
in_use_ids[node_def.id] = true;
@ -2666,6 +2668,7 @@ merge(Compressor.prototype, {
if (node.name
&& (!compressor.option("keep_classnames") && node instanceof AST_ClassExpression
|| !compressor.option("keep_fnames") && node instanceof AST_Function)) {
if (!node.name) return;
var def = node.name.definition();
// any declarations with same name will overshadow
// name of this anonymous function and can therefore
@ -2701,6 +2704,7 @@ merge(Compressor.prototype, {
}
}
if ((node instanceof AST_Defun || node instanceof AST_DefClass) && node !== self) {
if (!node.name) return;
var def = node.name.definition();
var keep = (def.id in in_use_ids) || !drop_funcs && def.global;
if (!keep) {