output.polyfill

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

Controls the polyfill injection mode.

See Polyfill Mode for more details.

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.

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.

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

off

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

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