diff options
author | 2021-10-07 21:30:28 -0700 | |
---|---|---|
committer | 2021-10-07 21:30:28 -0700 | |
commit | 3b28af17dba6b6225c079dbf3f6c2a3903ee3981 (patch) | |
tree | 20d448028fb30d7fd1d75d6ce1e2b85b1e3ea6e8 | |
parent | 5a03dfb9a4f00adb811988a4522221ee065ea180 (diff) | |
download | bun-3b28af17dba6b6225c079dbf3f6c2a3903ee3981.tar.gz bun-3b28af17dba6b6225c079dbf3f6c2a3903ee3981.tar.zst bun-3b28af17dba6b6225c079dbf3f6c2a3903ee3981.zip |
Fix edgecase when bundling JavaScript that references ESM exported functions before they're defined
-rw-r--r-- | src/js_printer.zig | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/js_printer.zig b/src/js_printer.zig index 0a62df78b..95e8ea22c 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -2221,12 +2221,6 @@ pub fn NewPrinter( if (s.func.flags.is_export) { if (!rewrite_esm_to_cjs) { p.print("export "); - } else { - if (rewrite_esm_to_cjs) { - p.print("var "); - p.printSymbol(nameRef); - p.print(" = "); - } } } if (s.func.flags.is_async) { @@ -2244,6 +2238,11 @@ pub fn NewPrinter( if (rewrite_esm_to_cjs and s.func.flags.is_export) { p.printSemicolonAfterStatement(); + p.print("var "); + p.printSymbol(nameRef); + p.print(" = "); + p.printSymbol(nameRef); + p.printSemicolonAfterStatement(); } else { p.printNewline(); } @@ -2267,12 +2266,6 @@ pub fn NewPrinter( if (!rewrite_esm_to_cjs) { p.print("export "); } - - if (rewrite_esm_to_cjs) { - p.print("var "); - p.printSymbol(nameRef); - p.print(" = "); - } } p.print("class "); |