diff options
author | 2022-02-16 20:15:35 -0800 | |
---|---|---|
committer | 2022-02-16 20:15:35 -0800 | |
commit | 4ba0e7b7d88ed84b13dcdcb8f14d523fd34b070f (patch) | |
tree | 9ab8e23e5121ffee71948866b10b4732a44f0545 | |
parent | 7637cfb0a6a31c0da5c6489c5679a313691f3f55 (diff) | |
download | bun-4ba0e7b7d88ed84b13dcdcb8f14d523fd34b070f.tar.gz bun-4ba0e7b7d88ed84b13dcdcb8f14d523fd34b070f.tar.zst bun-4ba0e7b7d88ed84b13dcdcb8f14d523fd34b070f.zip |
[JS Printer] Fix missing space at end of object bindings
See also https://github.com/evanw/esbuild/pull/2025
-rw-r--r-- | src/js_printer.zig | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/js_printer.zig b/src/js_printer.zig index c093dbcdd..ec165a355 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -2158,12 +2158,7 @@ pub fn NewPrinter( if (item.value) |val| { switch (val.data) { .e_identifier => |e| { - - // TODO: is needing to check item.flags.was_shorthand a bug? - // esbuild doesn't have to do that... - // maybe it's a symptom of some other underlying issue - // or maybe, it's because i'm not lowering the same way that esbuild does. - if (strings.eql(key.utf8, p.renamer.nameForSymbol(e.ref))) { + if (key.eql(string, p.renamer.nameForSymbol(e.ref))) { if (item.initializer) |initial| { p.printInitializer(initial); } @@ -2171,7 +2166,6 @@ pub fn NewPrinter( return; } } - // if (strings) {} }, .e_import_identifier => |e| { const ref = p.symbols.follow(e.ref); @@ -2311,13 +2305,8 @@ pub fn NewPrinter( p.maybePrintDefaultBindingValue(item); // Make sure there's a comma after trailing missing items - if (is_last) { - switch (item.binding.data) { - .b_missing => { - p.print(","); - }, - else => {}, - } + if (is_last and item.binding.data == .b_missing) { + p.print(","); } } @@ -2325,6 +2314,8 @@ pub fn NewPrinter( p.options.unindent(); p.printNewline(); p.printIndent(); + } else { + p.printSpace(); } } @@ -2425,7 +2416,7 @@ pub fn NewPrinter( p.options.unindent(); p.printNewline(); p.printIndent(); - } else if (b.properties.len > 0) { + } else { p.printSpace(); } } |