iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

Build Tools (esbuild, swc, tsc)

Four TypeScript compilers ship in 2026 — pick by the trade-off between speed, completeness, and what you actually need.

The choices

ToolLanguageStrengthsLimits
tscTypeScriptOfficial, complete, type-checks.Slowest on big projects.
esbuildGoLightning fast.Doesn't type-check; some edge cases.
swcRustFast, powers Next.js + Vitest.Doesn't type-check.
Viteesbuild + RollupBest dev DX for apps.App-shaped projects.

The split

The modern pattern is to separate compile from type-check:

  • Use esbuild / swc / Vite for fast development & production builds.
  • Use tsc --noEmit in CI for type checking.
  • Use tsc for emitting .d.ts files in libraries (esbuild/swc don't do this perfectly).

tsc — official

SHELL
tsc                       # builds based on tsconfig.json
tsc -p tsconfig.build.json
tsc --noEmit              # type-check only
tsc -w                    # watch mode
tsc -b                    # build mode for project references

esbuild

SHELL
pnpm add -D esbuild
esbuild src/index.ts --bundle --platform=node --outfile=dist/index.js

swc

SHELL
pnpm add -D @swc/cli @swc/core
swc src -d dist

Vite (apps)

SHELL
npm create vite@latest my-app -- --template react-ts
cd my-app
npm install
npm run dev      # dev server
npm run build    # production build

For libraries — tsup

tsup wraps esbuild + tsc to produce ESM + CJS + .d.ts in one command:

SHELL
pnpm add -D tsup
tsup src/index.ts --format esm,cjs --dts
Tip: Don't worry about picking the "fastest" tool until you measure. A clean monorepo with tsc -b can be plenty fast; a sloppy esbuild config still won't catch bugs.

Example

Example
// 'tsc'      — official, strict, slow for big projects
// 'esbuild'  — Go-based bundler, lightning fast
// 'swc'      — Rust-based; powers Next.js & Vitest
// 'Vite'     — esbuild for dev + Rollup for prod
//
// All of them transpile TS without type-checking — keep 'tsc --noEmit' in CI.
console.log('Compile fast at dev time, type-check separately');
Try it Yourself »

Exercise

Rust-based TS transpiler used by Next.js and Vitest.

Test yourself

Q1. Type-check tool is…
Q2. For dev speed try…
Q3. For library builds (ESM + CJS + .d.ts) try…

Discussion

Loading…