Skip to content

Commit 740c0bb

Browse files
authored
fix(es/minifier): Remove raw of strings after modification (#8865)
**Related issue:** - Closes #8864
1 parent af19385 commit 740c0bb

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -742,9 +742,10 @@ impl Pure<'_> {
742742
};
743743

744744
self.changed = true;
745-
report_change!("evaluate: Evaluated `{}` of a string literal", method);
745+
report_change!("evaluate: Evaluated `{method}` of a string literal");
746746
*e = Expr::Lit(Lit::Str(Str {
747747
value: new_val.into(),
748+
raw: None,
748749
..s
749750
}));
750751
}

crates/swc_ecma_minifier/tests/exec.rs

+19
Original file line numberDiff line numberDiff line change
@@ -11193,3 +11193,22 @@ fn issue_8246_1() {
1119311193
false,
1119411194
);
1119511195
}
11196+
11197+
#[test]
11198+
fn issue_8864_1() {
11199+
run_default_exec_test(
11200+
"
11201+
class Renderer {
11202+
renderStaticFrame(string1, string2) {
11203+
const line1Text = `${string1} and ${string2}`.toUpperCase();
11204+
const line2Text = 'line 2 text'.toUpperCase();
11205+
11206+
const text = `${line1Text}\n${line2Text}`;
11207+
return text;
11208+
}
11209+
}
11210+
11211+
console.log(new Renderer().renderStaticFrame('a', 'b'));
11212+
",
11213+
)
11214+
}

0 commit comments

Comments
 (0)