Course contentsShow
← TypeScript
Lesson 35 of 1,7961. Why TypeScriptFree lesson

Build Tools and TypeScript

How bundlers like Vite, esbuild, and swc handle TypeScript compilation.

Build Tools and TypeScript

What you'll learn: How modern bundlers seamlessly compile TypeScript without you needing to run tsc separately.

The Traditional Approach

When TypeScript first became popular, developers had to manually compile their .ts files to .js using the TypeScript compiler (tsc) before bundling them for the browser. This meant running two separate tools: one for compilation, one for bundling.

Modern Bundlers to the Rescue

Today's build tools like Vite, esbuild, and swc have TypeScript compilation built directly into their bundling process. Think of them as all-in-one kitchen appliances instead of separate gadgets cluttering your counter.

How They Work

  • Vite uses esbuild under the hood to transpile TypeScript files blazingly fast during development. It strips away the type annotations (turning TypeScript into JavaScript) without doing full type checking.

  • esbuild is a super-fast bundler written in Go that handles TypeScript natively. It focuses purely on transpilation—removing types—not validating them.

  • swc (Speedy Web Compiler) is a Rust-based tool that also transpiles TypeScript at incredible speeds by skipping type checking.

The Trade-off

These tools prioritize speed over safety. They'll convert your TypeScript to JavaScript almost instantly, but they won't tell you if you have type errors. For that, you still run tsc --noEmit separately (usually in your editor or CI pipeline) to verify types without generating files.

Key Takeaway: Modern bundlers like Vite, esbuild, and swc handle TypeScript compilation automatically by stripping types during the build process, though you'll want to run type-checking separately to catch errors.