Course contentsShow
← React
Lesson 79 of 2,3963. JSX FundamentalsFree lesson

The Role of Babel and Modern Transpilers

How tools like Babel, esbuild, and SWC transform JSX into JavaScript function calls.

The Role of Babel and Modern Transpilers

What you'll learn: How tools like Babel, esbuild, and SWC transform your JSX code into plain JavaScript that browsers can execute.

The Translation Layer

Remember how JSX compiles to React.createElement() calls? Browsers don't understand JSX natively—they only understand standard JavaScript. This is where transpilers come in.

A transpiler is a tool that reads code written in one syntax and translates it into another. Think of it like a translator converting English to Spanish—the meaning stays the same, but the language changes.

The Main Players

Babel was the original standard. It's a highly configurable transpiler that transforms modern JavaScript (including JSX) into browser-compatible code. When you write <div>Hello</div>, Babel converts it to React.createElement('div', null, 'Hello').

esbuild is a newer transpiler written in Go, making it 10-100x faster than Babel. It performs the same JSX transformation but prioritizes speed.

SWC (Speedy Web Compiler) is written in Rust and offers similar performance to esbuild while maintaining more Babel-like features.

Why This Matters to You

Modern tools like Vite use esbuild during development (for speed) and can switch to other transpilers for production builds. You write JSX once, and the transpiler handles converting it to those function calls you learned about.

The transpiler runs automatically when you save your file—you never see the transformed code in your editor, but it's happening behind the scenes every time.

Key Takeaway: Transpilers like Babel, esbuild, and SWC are invisible translators that convert your readable JSX syntax into the React.createElement() function calls browsers can execute.