output.polyfill

  • Type: 'entry' | 'usage' | 'off'
  • Default: 'off'

Control the injection mode of the polyfills.

Please refer to the Polyfill Mode for more details.

Optional value

usage

When output.polyfill is configured as 'usage', Rsbuild will inject the polyfills based on the APIs used in each file. This provides optimal bundle size as only needed polyfills are included.

rsbuild.config.ts
export default {
  output: {
    polyfill: 'usage',
  },
};

entry

When output.polyfill is configured as 'entry', Rsbuild will inject the polyfills in each entry file. This ensures all polyfills are available but may increase bundle size.

rsbuild.config.ts
export default {
  output: {
    polyfill: 'entry',
  },
};

off

When output.polyfill is configured as 'off', Rsbuild will not inject the polyfills, and developers need to ensure code compatibility themselves.

rsbuild.config.ts
export default {
  output: {
    polyfill: 'off',
  },
};