Socket
Socket
Sign inDemoInstall

babel-plugin-polyfill-corejs3

Package Overview
Dependencies
72
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-polyfill-corejs3

A Babel plugin to inject imports to core-js@3 polyfills


Version published
Weekly downloads
26M
increased by2.69%
Maintainers
1
Install size
3.91 MB
Created
Weekly downloads
 

Package description

What is babel-plugin-polyfill-corejs3?

The babel-plugin-polyfill-corejs3 package is a plugin for Babel that automatically includes the necessary core-js polyfills based on the code being transpiled and the target environments specified in the Babel configuration. It helps developers to use modern JavaScript features without worrying about the support in older environments, as it takes care of loading the necessary shims and polyfills.

What are babel-plugin-polyfill-corejs3's main functionalities?

Automatic Polyfilling

Automatically includes necessary polyfills for features used in the code that are not supported in the target environments.

require('core-js');

Modular Polyfills

Allows for modular inclusion of polyfills, adding only the polyfills needed for specific features used in the code.

require('core-js/modules/es.array.iterator');

Configurable Target Environments

Enables configuration of target environments to determine which polyfills are needed based on browser or node version support.

presets: [['@babel/preset-env', { targets: '> 0.25%, not dead' }]]

Other packages similar to babel-plugin-polyfill-corejs3

Readme

Source

babel-plugin-polyfill-corejs3

Install

Using npm:

npm install --save-dev babel-plugin-polyfill-corejs3

or using yarn:

yarn add babel-plugin-polyfill-corejs3 --dev

Usage

Add this plugin to your Babel configuration:

{
  "plugins": [["polyfill-corejs3", { "method": "usage-global", "version": "3.20" }]]
}

This package supports the usage-pure, usage-global, and entry-global methods. When entry-global is used, it replaces imports to core-js.

Options

See here for a list of options supported by every polyfill provider.

version

string, defaults to "3.0".

This option only has an effect when used alongside "method": "usage-global" or "method": "usage-pure". It is recommended to specify the minor version you are using as core-js@3.0 may not include polyfills for the latest features. If you are bundling an app, you can provide the version directly from your node modules:

{
  plugins: [
    ["polyfill-corejs3", {
      "method": "usage-pure",
      // use `core-js/package.json` if you are using `usage-global`
      "version": require("core-js-pure/package.json").version
    }]
  ]
}

If you are a library author, specify a reasonably modern core-js version in your package.json and provide the plugin the minimal supported version.

{
  "dependencies": {
    "core-js": "^3.20.0"
  }
}
{
  plugins: [
    ["polyfill-corejs3", {
      "method": "usage-global",
      // improvise if you have more complicated version spec, e.g. > 3.1.4
      "version": require("./package.json").dependencies["core-js"]
    }]
  ]
}

proposals

boolean, defaults to false.

This option only has an effect when used alongside "method": "usage-global" or "method": "usage-pure". When proposals are true, any ES proposal supported by core-js will be polyfilled as well.

Keywords

FAQs

Last updated on 20 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc