> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# output.polyfill

- **Type:** `'entry' | 'usage' | 'off'`
- **Default:** `'off'`

Controls the polyfill injection mode.

> See [Polyfill Mode](/guide/advanced/browser-compatibility.md#polyfills) for more details.

## Install core-js

When you enable polyfill injection, make sure [core-js](https://github.com/zloirock/core-js) v3 is installed in your project, which is a popular polyfill library for JavaScript.


```sh [npm]
npm add core-js
```

```sh [yarn]
yarn add core-js
```

```sh [pnpm]
pnpm add core-js
```

```sh [bun]
bun add core-js
```

```sh [deno]
deno add npm:core-js
```

## Optional value

### usage

With `output.polyfill` set to `'usage'`, Rsbuild injects polyfills based on the APIs used in each file. This provides optimal bundle size by including only needed polyfills.

```ts title="rsbuild.config.ts"
export default {
  output: {
    polyfill: 'usage',
  },
};
```

### entry

With `output.polyfill` set to `'entry'`, Rsbuild injects polyfills in each entry file. This ensures all polyfills are available but may increase bundle size.

```ts title="rsbuild.config.ts"
export default {
  output: {
    polyfill: 'entry',
  },
};
```

:::tip
It should be noted that when you bundle page with [Web Workers](/guide/basic/web-workers.md), the `entry` mode is not applicable to Web Workers because the Web Workers thread is isolated from the main thread (page), and the `usage` mode can be used at this time.
:::

### off

With `output.polyfill` set to `'off'`, Rsbuild doesn't inject polyfills. You need to handle code compatibility yourself.

```ts title="rsbuild.config.ts"
export default {
  output: {
    polyfill: 'off',
  },
};
```

## Version history

| Version | Changes                                           |
| ------- | ------------------------------------------------- |
| v2.0.0  | Rsbuild no longer depends on `core-js` by default |
