Skip to content

Commit

Permalink
fix(es/minifier): Remove raw of strings after modification (#8865)
Browse files Browse the repository at this point in the history
**Related issue:**

 - Closes #8864
  • Loading branch information
kdy1 committed Apr 16, 2024
1 parent af19385 commit 740c0bb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/swc_ecma_minifier/src/compress/pure/evaluate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,9 +742,10 @@ impl Pure<'_> {
};

self.changed = true;
report_change!("evaluate: Evaluated `{}` of a string literal", method);
report_change!("evaluate: Evaluated `{method}` of a string literal");
*e = Expr::Lit(Lit::Str(Str {
value: new_val.into(),
raw: None,
..s
}));
}
Expand Down
19 changes: 19 additions & 0 deletions crates/swc_ecma_minifier/tests/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11193,3 +11193,22 @@ fn issue_8246_1() {
false,
);
}

#[test]
fn issue_8864_1() {
run_default_exec_test(
"
class Renderer {
renderStaticFrame(string1, string2) {
const line1Text = `${string1} and ${string2}`.toUpperCase();
const line2Text = 'line 2 text'.toUpperCase();
const text = `${line1Text}\n${line2Text}`;
return text;
}
}
console.log(new Renderer().renderStaticFrame('a', 'b'));
",
)
}

0 comments on commit 740c0bb

Please sign in to comment.