Skip to content

Commit be86fad

Browse files
authored
fix(es/minifier): Fix debug cargo feature (#11325)
**Description:** These compilation errors are related to Wtf8, which doesn't impl `Display`
1 parent b0ab736 commit be86fad

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

.changeset/rude-cats-flow.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
swc_ecma_minifier: patch
3+
swc_core: patch
4+
---
5+
6+
fix(es/minifier): Fix debug feature

crates/swc_ecma_minifier/src/compress/optimize/evaluate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl Optimizer<'_> {
262262
self.changed = true;
263263
report_change!(
264264
"evaluate: Converting RegExpr call into a regexp literal `/{}/`",
265-
exp.value
265+
value
266266
);
267267

268268
*e = Lit::Regex(Regex {
@@ -287,8 +287,8 @@ impl Optimizer<'_> {
287287
self.changed = true;
288288
report_change!(
289289
"evaluate: Converting RegExpr call into a regexp literal `/{}/{}`",
290-
exp.value,
291-
flags.value
290+
value,
291+
flags
292292
);
293293

294294
*e = Lit::Regex(Regex {

crates/swc_ecma_minifier/src/compress/optimize/props.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl Optimizer<'_> {
225225
.get(&(obj.to_id(), sym.clone()))
226226
.cloned()
227227
{
228-
report_change!("hoist_props: Inlining `{}.{}`", obj.sym, sym);
228+
report_change!("hoist_props: Inlining `{}.{:?}`", obj.sym, sym);
229229
self.changed = true;
230230
*e = value.into();
231231
}

crates/swc_ecma_minifier/src/compress/pure/evaluate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl Pure<'_> {
594594

595595
self.changed = true;
596596
report_change!(
597-
"evaluate: Evaluating `{}.toPrecision()` as `{}`",
597+
"evaluate: Evaluating `{}.toPrecision()` as `{:?}`",
598598
num,
599599
value
600600
);
@@ -642,7 +642,7 @@ impl Pure<'_> {
642642

643643
self.changed = true;
644644
report_change!(
645-
"evaluate: Evaluating `{}.toExponential()` as `{}`",
645+
"evaluate: Evaluating `{}.toExponential()` as `{:?}`",
646646
num,
647647
value
648648
);
@@ -668,7 +668,7 @@ impl Pure<'_> {
668668

669669
self.changed = true;
670670
report_change!(
671-
"evaluate: Evaluating `{}.toPrecision({})` as `{}`",
671+
"evaluate: Evaluating `{}.toPrecision({})` as `{:?}`",
672672
num,
673673
precision,
674674
value

crates/swc_ecma_minifier/src/compress/pure/strings.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ impl Pure<'_> {
391391
self.changed = true;
392392

393393
report_change!(
394-
"template: Concatted a string (`{}`) on rhs of `+` to a template literal",
394+
"template: Concatted a string (`{:?}`) on rhs of `+` to a template literal",
395395
rs.value
396396
);
397397

@@ -427,7 +427,7 @@ impl Pure<'_> {
427427
self.changed = true;
428428

429429
report_change!(
430-
"template: Prepended a string (`{}`) on lhs of `+` to a template literal",
430+
"template: Prepended a string (`{:?}`) on lhs of `+` to a template literal",
431431
ls.value
432432
);
433433

@@ -500,13 +500,16 @@ impl Pure<'_> {
500500
if let Value::Known(Type::Str) = type_of_third {
501501
if let Value::Known(second_str) = left.right.as_pure_wtf8(self.expr_ctx) {
502502
if let Value::Known(third_str) = bin.right.as_pure_wtf8(self.expr_ctx) {
503+
#[cfg(feature = "debug")]
504+
let debug_second_str = second_str.clone();
505+
503506
let new_str = second_str.into_owned() + &*third_str;
504507
let left_span = left.span;
505508

506509
self.changed = true;
507510
report_change!(
508-
"strings: Concatting `{} + {}` to `{}`",
509-
second_str,
511+
"strings: Concatting `{:?} + {:?}` to `{:?}`",
512+
debug_second_str,
510513
third_str,
511514
new_str
512515
);

0 commit comments

Comments
 (0)