← Back to list

ESBuild, SWC, and TSC — Which Compiler Should You Use in 2026?

I tested all three on a 100k+ line Next.js codebase. The results surprised me and will probably change your build pipeline.

Kevin - MERN Stack Developer · 2026-02-05 08:38 · 65 claps · 3.3 min read paywalled
#web-development #front-end-development #typescript #swc #ecmascript
Open on Medium ↗
Wiki topics: 🌐 · Web Development

ESBuild, SWC, and TSC — Which Compiler Should You Use in 2026?

I tested all three on a 100k+ line Next.js codebase. The results surprised me and will probably change your build pipeline.

Lost productivity from long build times. TypeScript compilation makes every developer at your team wait for 15–20 minutes each day. Through A/B testing ESBuild, SWC, and TSC across our production Next. over the span of three months. Having gathered some data to share, it happens to prove wrong what the Twitter hype around js apps would lead you to believe.

It’s not just about pure compiler speed anymore — that makes up three (inherently) subjective aspects of the best compiler, the “right” compiler. This is a matter of what measures you can live with.

Common Assumptions About Performance That Are Wrong

Yes, ESBuild is fast. Ridiculously fast. 45x faster compilation over TSC for cold builds during our first tests. SWC clocked in at 20x faster. Case closed, right?

Not quite.

What the benchmarks won’t show you: Speed may not matter AT ALL if your production build breaks with·no noise. Well, that’s precisely what happened in the beginning when we migrated to ESBuild for 2,300+ TypeScript files in our React dashboard.

TSC: The Sleepiest Of The Giants You Must Not Forget

However, TS’s current compiler is glacier slow, but it’s the sole compiler that understands TS.

When to stick with TSC:

  • Your composition of generic types is complex, and other compilers get it wrong
  • Type safety (With critical information & services (fintech, health care, critical infrastructure) it is non-negotiable)
  • Your team depends on --strict mode and more advanced type system features
  • You are writing component libraries in which type definitions really count

Real-world scenario:

We make heavy use of conditional types and mapped types in the authentication module. ESBuild built it fine but quietly dropped type violations that TSC complained about immediately. This would have been a incident in production.

// TSC catches this, ESBuild doesn't
type UserPermissions<T extends Role> = T extends 'admin' 
  ? AdminPermissions 
  : T extends 'user' 
  ? UserPermissions 
  : never;

// This type error only surfaces with TSC
const permissions: UserPermissions<'guest'> = getPermissions();

SWC: The Sweet Spot for Next js

Next. This is why SWC is included by default with js 12+. It’s the pragmatic compromise between TSC’s completeness and the speed of ESBuild.

So why does SWC win for full stack JavaScript apps?

  • Rust native performance (of the order of 15–20x) speed time TSC
  • Better support for TypeScript than ESBuild (moves decorators, const enums)
  • Cool JSX transformation and React refresh, first class
  • Production-tested across millions of Next. js deployments

Our setup:

// next.config.js
module.exports = {
  swcMinify: true,
  compiler: {
    styledComponents: true,
    removeConsole: process.env.NODE_ENV === 'production',
  },
}

Build time improvements:

Development rebuild: 890ms → 120ms

Production build: 4m 20s → 35s

That’s not incremental improvement. That’s developer experience transformation.

When All You Care About Is Speed (faster than Swiss folk) — ESBuild

ESBuild performs its best when type-checking is independent of bundling.

Ideal use cases:

  • JavaScript Bundlers(no Typescript fuzzy)
  • Development servers that you are already running tsc — watch on their own
  • Turborepo orchestrating between different monorepo tooling
  • Basic TypeScript projects that don’t use fancy types

Our Vite + React setup:

// vite.config.ts
export default defineConfig({
  plugins: [react()],
  build: {
    target: 'esnext',
    minify: 'esbuild', // Lightning fast minification
  },
  optimizeDeps: {
    esbuildOptions: {
      target: 'esnext',
    },
  },
})

ESBuild for bundling and TSC for type-checking in CI/CD (Pro Tip) Best of both worlds.

The Decision Framework

I’ve run all three in production and here’s what I would recommend:

Choose TSC if:

  • Type safety > build speed
  • You are responsible for a library of components
  • Your codebase is additionally using some advanced TypeScript features

Choose SWC if:

  • You’re building with Next. js or React
  • You want fast builds WITHOUT compromising on type coverage
  • You are expecting no configuration changes

Choose ESBuild if:

  • You’re bundling pure JavaScript
  • There is also no type information available in CI, if: You run type-checking separately in CI
  • Your Number 1 Delay Is Build Speed

What We Actually Ship

Our production stack (Next. js 14, TypeScript 5.3, Tailwind CSS:

  • Development: SWC (built into Next. js)
  • Type-checking : TSC in watch mode + pre-commit hooks
  • IN CI/CD for production builds: SWC with — strict
  • Library bundling: ESBuild for our internal component packages

This mix-and-match hybrid approach provided us with build speeds up to 8x faster without the cost of losing type safety.

It isn’t choose your compiler war a winner. Trust me, this is all about knowing the tradeoffs and architecting your build pipeline around it. Speed counts, but that doesn’t mean faster broken code is a victory.

What’s your build setup? Feel free to drop your stack in the comments — we want to know what other teams will be using in 2026!


메타데이터
post_id
a2df3c783ad2
slug
esbuild-swc-and-tsc-which-compiler-should-you-use-in-2026-a2df3c783ad2
url
https://medium.com/@mernstackdevbykevin/esbuild-swc-and-tsc-which-compiler-should-you-use-in-2026-a2df3c783ad2
canonical_url
https://medium.com/@mernstackdevbykevin/esbuild-swc-and-tsc-which-compiler-should-you-use-in-2026-a2df3c783ad2
author_url
https://medium.com/@mernstackdevbykevin
status
ok
fetched_at
2026-07-10 23:21:07