bundling vs. transpiling
If you work with modern JavaScript or TypeScript, you deal with two core concepts every day: bundling and transpiling. They are often used together, but they do different things in the build process.

1. transpiling: the language translator
Section titled “1. transpiling: the language translator”Transpiling converts code written in one language version into another. It transforms modern syntax (ES6+ or TypeScript) into JavaScript that a specific runtime can understand.
- Goal: keep code compatible with the target runtime (for example, converting TypeScript to JavaScript that matches the Node.js version you run).
- Mechanism: tools like Babel, or the transpilers inside Bun, do the conversion.
- Performance note: the transpilation step itself does not change runtime speed, since the output is always JavaScript, but running transpilation at runtime (for example, using
ts-nodein production without pre-compiling) slows startup and uses more memory. Skipping pre-compilation in production is a mistake.
2. bundling: the efficiency packer
Section titled “2. bundling: the efficiency packer”Bundling takes multiple source files and dependencies and combines them into a single output file, or a few smaller ones.
- Goal: optimize loading and simplify deployment.
- Use cases:
- Browser environments: bundling reduces the number of HTTP requests the browser makes for JavaScript and CSS, which speeds up loading.
- Serverless and edge functions (like AWS Lambda): bundling packages dependencies from
node_modulesinto the deployment artifact, since you may not have file system access or the ability to runnpm installat execution time.
- Optimization techniques: bundling often includes minification (removing human-readable formatting for the interpreter) and tree-shaking (removing unused code).
| Feature | Bundling | Transpiling |
|---|---|---|
| Action | Combines many files into one (or few). | Converts newer language syntax to older syntax. |
| Primary Goal | Optimize loading, minimize I/O, simplify deployment. | Ensure language compatibility. |
| Example Tool | Browserify, Webpack, esbuild, Rollup. | Babel, Bun’s internal transpiler, tsc. |
see also
Section titled “see also”This post is a transcription of a video I made a while ago: