Skip to content

Commit

Permalink
provide diagnostic details on --mangle-props (#5621)
Browse files Browse the repository at this point in the history
closes #5618
  • Loading branch information
alexlamsl authored Aug 17, 2022
1 parent d6d2f5c commit 9eea3a6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/propmangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ function mangle_properties(ast, options) {
}

function mangle(name) {
if (!should_mangle(name)) return name;
if (!should_mangle(name)) {
AST_Node.info("Preserving property {this}", name);
return name;
}
var mangled = cache.get(name);
if (!mangled) {
if (debug) {
Expand All @@ -286,6 +289,10 @@ function mangle_properties(ast, options) {
if (/^#/.test(name)) mangled = "#" + mangled;
cache.set(name, mangled);
}
AST_Node.info("Mapping property {name} to {mangled}", {
mangled: mangled,
name: name,
});
return mangled;
}

Expand Down
1 change: 1 addition & 0 deletions test/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ function to_toplevel(input, mangle_options, expression) {
var tokens = [];
input.walk(new U.TreeWalker(function(node) {
if (U.push_uniq(tokens, node.start)) node.start.line -= offset;
if (U.push_uniq(tokens, node.end)) node.end.line -= offset;
}));
var toplevel;
if (!expression) {
Expand Down
8 changes: 8 additions & 0 deletions test/compress/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,14 @@ mangle_properties: {
console.log(A.s, new A().e);
}
expect_stdout: "PASS 42"
expect_warnings: [
"INFO: Mapping property #P to #t",
"INFO: Mapping property Q to s",
"INFO: Mapping property #p to #i",
"INFO: Mapping property r to e",
"INFO: Preserving property q",
"INFO: Preserving property log",
]
node_version: ">=14.6"
}

Expand Down

0 comments on commit 9eea3a6

Please sign in to comment.