# Polyfills and Core-js — Babel & SWC

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

> Understand how polyfills fill gaps that transpilation can't cover.

## The polyfill vs transpile distinction

Transpilation converts syntax. Polyfills add missing functions: `Promise`, `Array.prototype.includes()`, `Object.assign()`, etc. Both are needed for legacy browser support.

## Core-js: the standard polyfill library

`core-js` is the most complete polyfill library. Babel can inject only the polyfills your code actually needs via `@babel/preset-env` with `useBuiltIns`.

## Configuring polyfill injection

Use `useBuiltIns: 'usage'` to automatically inject only needed polyfills. Reduces bundle size compared to including all of core-js.

```json
{
  "presets": [
    [
      "@babel/preset-env",
      {
        "useBuiltIns": "usage",
        "corejs": "3.32"
      }
    ]
  ]
}
```
