# Babel Performance Tuning — बेबल और SWC

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

> Caching और exclusions के साथ Babel builds को speed up करें।

## Babel धीमा है: समस्या

Babel JavaScript में लिखा गया है और हर फ़ाइल को AST में parse करता है, इसे transform करता है, और कोड को regenerate करता है। बड़े projects के साथ हजारों फ़ाइलों के साथ, यह एक bottleneck बन जाता है।

## node_modules और unnecessary paths को exclude करें

Babel को `node_modules` और dist folders के transpilation को skip करने के लिए बताएँ। अधिकांश npm packages पूर्व-transpiled हैं।

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

## Caching का उपयोग करें: @babel/core परिणामों को cache करता है

Babel डिफ़ॉल्ट रूप से transformation परिणामों को cache करता है। दूसरे runs पर, unchanged files re-transpilation को skip करते हैं। Webpack और bundlers इसे स्वचालित रूप से enable करते हैं।

## अपने build times को benchmark करें

Transpilation impact को measure करें और bottlenecks को identify करें। `time` command या build profiling tools का उपयोग करें।

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

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