Skip to content

Commit

Permalink
provide diagnostic details on --mangle-props
Browse files Browse the repository at this point in the history
closes #5618
  • Loading branch information
alexlamsl committed Aug 17, 2022
1 parent 8602d1b commit b79cf1f
Show file tree
Hide file tree
Showing 2 changed files with 16 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 {name}", { name: 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
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 b79cf1f

Please sign in to comment.