I was curious why bun build --compile would be faster. The docs say:
“Compiled executables reduce memory usage and improve Bun’s start time.
Normally, Bun reads and transpiles JavaScript and TypeScript files on import and require. This is part of what makes so much of Bun “just work”, but it’s not free. It costs time and memory to read files from disk, resolve file paths, parse, transpile, and print source code.
With compiled executables, you can move that cost from runtime to build-time.”
I use bun for everything except for monorepos with isolated deployment targets and shared packages. I use yarn or pnpm for monorepos. Maybe it's changed in the last six months but I could never get docker to properly resolve my dependencies when I only want to build the web app, for example, since the bun lock is deterministic based off of all the packages in the repo so isolating a single leaf makes it error.
Maybe I'm doing something wrong but I scoured docs and online and asked multiple AI agents to no avail.
>Next: the runtime itself. Bun has a bun build --compile flag that produces a single self-contained executable. No runtime, no node_modules, no source files needed in the container.
I didn't know that. So Bun is basically a whole runtime + framework all in one with little to no deployment headaches?
The bun build creates a large self-contained executable with no optimisations. Almost like a large electron build.
Deno also provides the same functionality, but with a smaller optimized binary.
Appreciate Bun helping creating healthy competition. I feel like Deno falls under most people's radar often. More security options, faster than Node, built on web standards.
I was curious why bun build --compile would be faster. The docs say:
“Compiled executables reduce memory usage and improve Bun’s start time.
Normally, Bun reads and transpiles JavaScript and TypeScript files on import and require. This is part of what makes so much of Bun “just work”, but it’s not free. It costs time and memory to read files from disk, resolve file paths, parse, transpile, and print source code.
With compiled executables, you can move that cost from runtime to build-time.”
https://bun.com/docs/bundler/executables#deploying-to-produc...
I use bun for everything except for monorepos with isolated deployment targets and shared packages. I use yarn or pnpm for monorepos. Maybe it's changed in the last six months but I could never get docker to properly resolve my dependencies when I only want to build the web app, for example, since the bun lock is deterministic based off of all the packages in the repo so isolating a single leaf makes it error.
Maybe I'm doing something wrong but I scoured docs and online and asked multiple AI agents to no avail.
>Next: the runtime itself. Bun has a bun build --compile flag that produces a single self-contained executable. No runtime, no node_modules, no source files needed in the container.
I didn't know that. So Bun is basically a whole runtime + framework all in one with little to no deployment headaches?
The bun build creates a large self-contained executable with no optimisations. Almost like a large electron build.
Deno also provides the same functionality, but with a smaller optimized binary.
Appreciate Bun helping creating healthy competition. I feel like Deno falls under most people's radar often. More security options, faster than Node, built on web standards.
This (single executable) is available in node.js now too as SEA mode.
But I think it still doesn't work with ESM, only CommonJS, so while not insurmountable, not as good as bun.
tl;dr replace SQLite with Map ~ 2x speed up, replace zod validation with ifs ~ 2x speed up. Bun had a memory leak on unresolved promises - now fixed