# Babel Performance Tuning — Babel & SWC

Source: https://www.geekswithgeeks.com/en/babel-swc/bs-babel-perf

> Speed up Babel builds with caching and exclusions.

## Babel is slow: the problem

Babel is written in JavaScript and parses every file into an AST, transforms it, and regenerates code. On large projects with thousands of files, this becomes a bottleneck.

## Exclude node_modules and unnecessary paths

Tell Babel to skip transpilation of `node_modules` and dist folders. Most npm packages are pre-transpiled.

```bash
npx babel src --ignore 'node_modules,**/*.test.js' -d dist
```

## Use caching: @babel/core caches results

Babel caches transformation results by default. On second runs, unchanged files skip re-transpilation. Webpack and bundlers enable this automatically.

## Benchmark your build times

Measure transpilation impact and identify bottlenecks. Use `time` command or build profiling tools.

```bash
# Measure build time
time npx babel src -d dist

# With SWC (usually much faster)
time npx swc src -d dist
```
