improve diagnostics on top_retain & mangle.properties (#5622)

closes #5618
This commit is contained in:
Alex Lam S.L
2022-08-18 19:32:21 +01:00
committed by GitHub
parent ac002b6338
commit 4653e8aec0
7 changed files with 100 additions and 8 deletions

View File

@@ -6841,6 +6841,7 @@ Compressor.prototype.compress = function(node) {
if (self instanceof AST_Toplevel && compressor.top_retain) {
self.variables.each(function(def) {
if (compressor.top_retain(def) && !(def.id in in_use_ids)) {
AST_Node.info("Retaining variable {name}", def);
in_use_ids[def.id] = true;
in_use.push(def);
}

View File

@@ -260,8 +260,14 @@ function mangle_properties(ast, options) {
}
function should_mangle(name) {
if (reserved.has(name)) return false;
if (regex && !regex.test(name)) return false;
if (reserved.has(name)) {
AST_Node.info("Preserving reserved property {this}", name);
return false;
}
if (regex && !regex.test(name)) {
AST_Node.info("Preserving excluded property {this}", name);
return false;
}
return cache.has(name) || names_to_mangle.has(name);
}
@@ -271,10 +277,7 @@ function mangle_properties(ast, options) {
}
function mangle(name) {
if (!should_mangle(name)) {
AST_Node.info("Preserving property {this}", name);
return name;
}
if (!should_mangle(name)) return name;
var mangled = cache.get(name);
if (!mangled) {
if (debug) {