Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

rollup-plugin-corejs

susnux43.2kEUPL-1.21.0.1TypeScript support: included

⚡ include core-js polyfills when bundling with rollup

corejs, core-js, polyfill, polyfills, rollup, rollupplugin, rollup-plugin, browserslist

readme

NPM package version GitHub Workflow Status (main branch) license

rollup-plugin-corejs

A rollup plugin for injecting core-js polyfills based on your browserslist configuration.

This plugin is essentially a wrapper for core-js-builder for rollup.

One usecase is that you are not using babel, but esbuild for transpiling, e.g. using the rollup-plugin-esbuild with your supported browsers is much faster then using Babel, but it only transpiles the syntax and does not add any polyfills. So you would need to add e.g. core-js polyfills manually... or... use this plugin.

Compatibility

This version should work with rollup 3.

Getting started

🚀 Installation

npm i -D rollup-plugin-corejs

🔧 Configuration

If you are using CommonJS, then use this in your rollup.config.js:

const { corejsPlugin } = require('rollup-plugin-corejs')

module.exports = {
  //...
  plugins: [corejsPlugin({
    // options
  })]
  // ...
}

Or if you are using module JS (e.g. rollup.config.mjs):

import { corejsPlugin } from 'rollup-plugin-corejs'

export default {
  //...
  plugins: [
    corejsPlugin({
        // Options
    }),
    // ...
  ]
  // ...
}

🛠️ Options

All options are optionally, if no options are given the default is to use { modules: 'core-js/es' }.

You can omit setting targets in this case browserslist is used (package.json or .browserslistrc).

{
  /** CoreJS modules to use, defaults to 'core-js/es' */
  modules?: string | readonly string[] | readonly RegExp[],
  /** CoreJS modules to exclude */
  exclude?: string | readonly string[] | readonly RegExp[],
  /** Overide browserslist targets */
  targets?: string | readonly string[] | Record<string, string | readonly string[]>
  /** Only include polyfills for APIs used by your code (dependencies not included) */
  usage?: boolean
}

Changelog

See CHANGELOG

License

EUPL-1.2

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[1.0.1] - 2024-12-05

Changed

  • Updated dependencies

[1.0.0] - 2024-04-21

Added

  • New feature to add polyfills only for APIs that are used by your code. This is similar to Babels useBuiltIns: 'usage'. Please not that only your code is analyzed and not your third party dependencies.
  • usage option added, set to true to enable detecting usage polyfills

Changed

  • summary option was removed
  • Update dependencies

Fixed

0.3.0 - 2023-03-22

Changed

  • Update dependencies

Fixed

  • Fix loading extended browserslist config when no targets are given

0.2.0 - 2023-03-08

Changed

  • Update dependencies
  • Update core-js-builder to 3.29.0 which now provides its own types

Fixed

  • Provide plugin options types

0.1.0 - 2023-01-29

Added

  • Initial release for rollup 3.x