aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/js_ast.zig15
-rw-r--r--test/bundler/transpiler.test.js2
2 files changed, 10 insertions, 7 deletions
diff --git a/src/js_ast.zig b/src/js_ast.zig
index 451d01a1b..2f0d8ddd6 100644
--- a/src/js_ast.zig
+++ b/src/js_ast.zig
@@ -2325,12 +2325,16 @@ pub const E = struct {
} else {
var prev_part = &parts.items[parts.items.len - 1];
- if (part.value.data.e_string.len() > 0) {
- prev_part.tail.push(part.value.data.e_string);
- }
+ if (prev_part.tail.isUTF8()) {
+ if (part.value.data.e_string.len() > 0) {
+ prev_part.tail.push(part.value.data.e_string);
+ }
- if (part.tail.len() > 0) {
- prev_part.tail.push(Expr.init(E.String, part.tail, part.tail_loc).data.e_string);
+ if (part.tail.len() > 0) {
+ prev_part.tail.push(Expr.init(E.String, part.tail, part.tail_loc).data.e_string);
+ }
+ } else {
+ parts.appendAssumeCapacity(part);
}
}
} else {
@@ -9825,4 +9829,3 @@ pub const UseDirective = enum {
// Stmt | 192
// STry | 384
// -- ESBuild bit sizes
-
diff --git a/test/bundler/transpiler.test.js b/test/bundler/transpiler.test.js
index cde968f80..407aaf197 100644
--- a/test/bundler/transpiler.test.js
+++ b/test/bundler/transpiler.test.js
@@ -2152,7 +2152,7 @@ class Foo {
describe("simplification", () => {
it("unary operator", () => {
- expectPrinted("a = !(b, c)", "a = (b , !c)");
+ expectPrinted("a = !(b, c)", "a = (b, !c)");
});
it("const inlining", () => {