Last active
September 11, 2023 12:40
-
-
Save BOTKooper/c777e56cfd2d4760b66dcc6a3d74ede3 to your computer and use it in GitHub Desktop.
Weird `bun build` behaviour while giving it different targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/Documents/bun-env ⬢ 18.17.1 03:40:10 PM | |
❯ batcat index.ts | |
───────┬─────────────────────────────────────────────────────────────────────────────────────────── | |
│ File: index.ts | |
───────┼─────────────────────────────────────────────────────────────────────────────────────────── | |
1 │ console.log("Hello via Bun!"); | |
2 │ | |
3 │ | |
4 │ if(process.env.SECRET_FEATURE_ENABLED === 'true') { | |
5 │ console.log("Development mode"); | |
6 │ } | |
7 │ | |
8 │ if(process.env.SECRET_FEATURE_ENABLED === 'false') { | |
9 │ console.log("Production mode"); | |
10 │ } | |
───────┴─────────────────────────────────────────────────────────────────────────────────────────── | |
~/Documents/bun-env ⬢ 18.17.1 03:40:13 PM | |
❯ batcat .env | |
───────┬─────────────────────────────────────────────────────────────────────────────────────────── | |
│ File: .env | |
───────┼─────────────────────────────────────────────────────────────────────────────────────────── | |
1 │ SECRET_FEATURE_ENABLED=true | |
───────┴─────────────────────────────────────────────────────────────────────────────────────────── | |
~/Documents/bun-env ⬢ 18.17.1 03:40:18 PM | |
❯ bun build ./index.ts --target=node --outdir=dist | |
./index.js 0.22 KB | |
[2ms] bundle 1 modules | |
~/Documents/bun-env ⬢ 18.17.1 03:40:24 PM | |
❯ batcat dist/index.js | |
───────┬─────────────────────────────────────────────────────────────────────────────────────────── | |
│ File: dist/index.js | |
───────┼─────────────────────────────────────────────────────────────────────────────────────────── | |
1 │ // index.ts | |
2 │ console.log("Hello via Bun!"); | |
3 │ if (process.env.SECRET_FEATURE_ENABLED === "true") { | |
4 │ console.log("Development mode"); | |
5 │ } | |
6 │ if (process.env.SECRET_FEATURE_ENABLED === "false") { | |
7 │ console.log("Production mode"); | |
8 │ } | |
───────┴─────────────────────────────────────────────────────────────────────────────────────────── | |
~/Documents/bun-env ⬢ 18.17.1 03:40:30 PM | |
❯ bun build ./index.ts --target=bun --outdir=dist | |
[0.02ms] ".env" | |
./index.js 0.12 KB | |
[3ms] bundle 1 modules | |
~/Documents/bun-env ⬢ 18.17.1 03:40:33 PM | |
❯ batcat dist/index.js | |
───────┬─────────────────────────────────────────────────────────────────────────────────────────── | |
│ File: dist/index.js | |
───────┼─────────────────────────────────────────────────────────────────────────────────────────── | |
1 │ // @bun | |
2 │ // index.ts | |
3 │ console.log("Hello via Bun!"); | |
4 │ if (true) { | |
5 │ console.log("Development mode"); | |
6 │ } | |
7 │ if (false) { | |
8 │ } | |
───────┴─────────────────────────────────────────────────────────────────────────────────────────── | |
~/Documents/bun-env ⬢ 18.17.1 03:40:36 PM | |
❯ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment