oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.26k stars 2.69k forks source link

Bun build incorrect bundle on objects-to-csv #13008

Open rubenfiszel opened 1 month ago

rubenfiszel commented 1 month ago

What version of Bun is running?

1.1.21+70ca2b76c

What platform is your computer?

Linux 6.9.7-arch1-1 x86_64 unknown

What steps can reproduce the bug?

write script:

import ObjectsToCsv from "objects-to-csv";

export async function main(): any {
  const data = [];
  const csv = new ObjectsToCsv(data);
  console.log(await csv.toString());
}

main();

bun build script.ts > out.js, then bun run out.js

What is the expected behavior?

same behavior as running the script , no error

What do you see instead?

▶ bun run t2.js

4904 |         }
4905 |       });
4906 |     }
4907 |     return generator;
4908 |   };
4909 |   Generator = function(options = {}) {
         ^
ReferenceError: Can't find variable: Generator
      at /tmp/t2/t2.js:4909:3
      at /tmp/t2/t2.js:32:45
      at /tmp/t2/t2.js:7111:15
      at /tmp/t2/t2.js:32:45
      at /tmp/t2/t2.js:7120:13
      at /tmp/t2/t2.js:32:45
      at /tmp/t2/t2.js:7171:13
      at /tmp/t2/t2.js:32:45
      at /tmp/t2/t2.js:7230:37

Bun v1.1.21 (Linux x64

Additional information

No response

Jarred-Sumner commented 1 month ago

Confirming this issue still reproduces as of Bun v1.1.22