Skip to content

susnux/rollup-plugin-corejs

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date
Dec 5, 2024
Jan 29, 2023
Apr 21, 2024
Jun 6, 2023
Jan 29, 2023
Dec 5, 2024
Apr 8, 2023
Dec 5, 2024
Mar 7, 2023
Dec 11, 2024
Dec 11, 2024
Mar 7, 2023
Dec 5, 2024

Repository files navigation

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