diff options
author | 2022-02-07 23:34:19 -0800 | |
---|---|---|
committer | 2022-02-07 23:34:19 -0800 | |
commit | d43f7aa6aa7274bb717d1c1450357b1f62b8b5b2 (patch) | |
tree | 6a81367e5ad55a920efd5e7589b24ac00860fbcf | |
parent | 705325d6c5799afabe7e67ec661a0d6a63abc14b (diff) | |
download | bun-d43f7aa6aa7274bb717d1c1450357b1f62b8b5b2.tar.gz bun-d43f7aa6aa7274bb717d1c1450357b1f62b8b5b2.tar.zst bun-d43f7aa6aa7274bb717d1c1450357b1f62b8b5b2.zip |
Fix #117
Diffstat (limited to '')
-rw-r--r-- | src/js_printer.zig | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/js_printer.zig b/src/js_printer.zig index 3ab92be46..e48af9caa 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -2551,7 +2551,7 @@ pub fn NewPrinter( p.printIndent(); p.printSpaceBeforeIdentifier(); - if (!is_inside_bundle) { + if (!is_inside_bundle and !rewrite_esm_to_cjs) { p.print("export default"); } @@ -2560,7 +2560,7 @@ pub fn NewPrinter( switch (s.value) { .expr => |expr| { // this is still necessary for JSON - if (is_inside_bundle) { + if (is_inside_bundle or rewrite_esm_to_cjs) { p.printModuleExportSymbol(); p.print(" = "); } @@ -2576,7 +2576,7 @@ pub fn NewPrinter( switch (s2.data) { .s_function => |func| { p.printSpaceBeforeIdentifier(); - if (is_inside_bundle) { + if (is_inside_bundle or rewrite_esm_to_cjs) { if (func.func.name == null) { p.printModuleExportSymbol(); p.print(" = "); @@ -2601,22 +2601,24 @@ pub fn NewPrinter( p.printFunc(func.func); - if (is_inside_bundle) { + if (is_inside_bundle or rewrite_esm_to_cjs) { p.printSemicolonAfterStatement(); + } + if (is_inside_bundle) { if (func.func.name) |name| { p.printIndent(); p.printBundledExport("default", p.renamer.nameForSymbol(name.ref.?)); p.printSemicolonAfterStatement(); } - } else { + } else if (!rewrite_esm_to_cjs) { p.printNewline(); } }, .s_class => |class| { p.printSpaceBeforeIdentifier(); - if (is_inside_bundle) { + if (is_inside_bundle or rewrite_esm_to_cjs) { if (class.class.class_name == null) { p.printModuleExportSymbol(); p.print(" = "); @@ -2632,15 +2634,17 @@ pub fn NewPrinter( p.printClass(class.class); - if (is_inside_bundle) { + if (is_inside_bundle or rewrite_esm_to_cjs) { p.printSemicolonAfterStatement(); + } + if (is_inside_bundle) { if (class.class.class_name) |name| { p.printIndent(); p.printBundledExport("default", p.renamer.nameForSymbol(name.ref.?)); p.printSemicolonAfterStatement(); } - } else { + } else if (!rewrite_esm_to_cjs) { p.printNewline(); } }, |