From 740c0bb00a0bb9e0f4d808c9dc71e8087d416f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Tue, 16 Apr 2024 13:39:54 +0900 Subject: [PATCH] fix(es/minifier): Remove `raw` of strings after modification (#8865) **Related issue:** - Closes #8864 --- .../src/compress/pure/evaluate.rs | 3 ++- crates/swc_ecma_minifier/tests/exec.rs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/swc_ecma_minifier/src/compress/pure/evaluate.rs b/crates/swc_ecma_minifier/src/compress/pure/evaluate.rs index 1c29a585a298..ee3e60ba70e3 100644 --- a/crates/swc_ecma_minifier/src/compress/pure/evaluate.rs +++ b/crates/swc_ecma_minifier/src/compress/pure/evaluate.rs @@ -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 })); } diff --git a/crates/swc_ecma_minifier/tests/exec.rs b/crates/swc_ecma_minifier/tests/exec.rs index 59374233bafc..c7d625194b94 100644 --- a/crates/swc_ecma_minifier/tests/exec.rs +++ b/crates/swc_ecma_minifier/tests/exec.rs @@ -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')); + ", + ) +}