aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Dylan Conway <dylan.conway567@gmail.com> 2023-05-08 23:39:02 -0700
committerGravatar Dylan Conway <dylan.conway567@gmail.com> 2023-05-08 23:39:02 -0700
commitc35518e6d674e81bf9374463aabdb0d1165cca71 (patch)
treecb83f2d7dfaf446aa1cbab2dbec564a0cc04a775
parent232a25b77f35e52277b9ecc2b276aa6bd66273f5 (diff)
downloadbun-c35518e6d674e81bf9374463aabdb0d1165cca71.tar.gz
bun-c35518e6d674e81bf9374463aabdb0d1165cca71.tar.zst
bun-c35518e6d674e81bf9374463aabdb0d1165cca71.zip
Fixes #2807
we will look at the minify tests for uglifyjs too
-rw-r--r--src/js_printer.zig3
-rw-r--r--test/bundler/bundler_minify.test.ts23
2 files changed, 26 insertions, 0 deletions
diff --git a/src/js_printer.zig b/src/js_printer.zig
index ade7c5594..9e2d0ad0c 100644
--- a/src/js_printer.zig
+++ b/src/js_printer.zig
@@ -983,6 +983,9 @@ fn NewPrinter(
p.printNewline();
p.options.indent += 1;
p.printStmt(stmt) catch unreachable;
+ if (stmt.data == .s_expr and stmt.data.s_expr.value.data == .e_missing) {
+ p.printSemicolonIfNeeded();
+ }
p.options.unindent();
},
}
diff --git a/test/bundler/bundler_minify.test.ts b/test/bundler/bundler_minify.test.ts
index 1bd255e46..8f0481905 100644
--- a/test/bundler/bundler_minify.test.ts
+++ b/test/bundler/bundler_minify.test.ts
@@ -134,4 +134,27 @@ describe("bundler", () => {
minifySyntax: true,
minifyWhitespace: true,
});
+ itBundled("minify/ForAndWhileLoopsWithMissingBlock", {
+ files: {
+ "/entry.js": /* js */ `
+ {
+ var n = 0;
+ for (let i = 0; i < 10; i++) i;
+ }
+ {
+ var j = 0;
+ for (let i in [1, 2, 3]) i;
+ }
+ {
+ var k = 0;
+ for (let i of [1, 2, 3]) i;
+ }
+ console.log("PASS");
+ `,
+ },
+ minifyWhitespace: true,
+ run: {
+ stdout: "PASS",
+ },
+ });
});