Skip to content

Commit 9eea3a6

Browse files
authored
provide diagnostic details on --mangle-props (#5621)
closes #5618
1 parent d6d2f5c commit 9eea3a6

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

Diff for: lib/propmangle.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,10 @@ function mangle_properties(ast, options) {
271271
}
272272

273273
function mangle(name) {
274-
if (!should_mangle(name)) return name;
274+
if (!should_mangle(name)) {
275+
AST_Node.info("Preserving property {this}", name);
276+
return name;
277+
}
275278
var mangled = cache.get(name);
276279
if (!mangled) {
277280
if (debug) {
@@ -286,6 +289,10 @@ function mangle_properties(ast, options) {
286289
if (/^#/.test(name)) mangled = "#" + mangled;
287290
cache.set(name, mangled);
288291
}
292+
AST_Node.info("Mapping property {name} to {mangled}", {
293+
mangled: mangled,
294+
name: name,
295+
});
289296
return mangled;
290297
}
291298

Diff for: test/compress.js

+1
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ function to_toplevel(input, mangle_options, expression) {
459459
var tokens = [];
460460
input.walk(new U.TreeWalker(function(node) {
461461
if (U.push_uniq(tokens, node.start)) node.start.line -= offset;
462+
if (U.push_uniq(tokens, node.end)) node.end.line -= offset;
462463
}));
463464
var toplevel;
464465
if (!expression) {

Diff for: test/compress/classes.js

+8
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,14 @@ mangle_properties: {
22002200
console.log(A.s, new A().e);
22012201
}
22022202
expect_stdout: "PASS 42"
2203+
expect_warnings: [
2204+
"INFO: Mapping property #P to #t",
2205+
"INFO: Mapping property Q to s",
2206+
"INFO: Mapping property #p to #i",
2207+
"INFO: Mapping property r to e",
2208+
"INFO: Preserving property q",
2209+
"INFO: Preserving property log",
2210+
]
22032211
node_version: ">=14.6"
22042212
}
22052213

0 commit comments

Comments
 (0)