Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@babel/helper-define-polyfill-provider
Advanced tools
Babel helper to create your own polyfill provider
The @babel/helper-define-polyfill-provider package is part of the Babel ecosystem and is used to define a way to provide polyfills in your Babel configuration. It helps in specifying which polyfills to include based on the target environment and the features used in your code, ensuring that only necessary polyfills are added, thus optimizing the bundle size.
Define polyfill provider
This code sample demonstrates how to define a custom polyfill provider using the @babel/helper-define-polyfill-provider package. It specifies polyfills for 'Promise' and 'fetch' with their respective detection logic and paths to their polyfill modules.
import { createPolyfillProvider } from '@babel/helper-define-polyfill-provider';
const myPolyfillProvider = createPolyfillProvider({
name: 'myPolyfillProvider',
polyfills: {
'Promise': {
global: 'Promise',
detection: 'Promise in global',
path: 'core-js/modules/es.promise'
},
'fetch': {
global: 'fetch',
detection: 'fetch in global',
path: 'whatwg-fetch'
}
}
});
Similar to @babel/helper-define-polyfill-provider, @babel/preset-env is a Babel preset that allows you to specify a target environment and automatically determines the Babel plugins and polyfills you need. While @babel/preset-env is more comprehensive and widely used for setting up Babel configurations, @babel/helper-define-polyfill-provider offers more granular control over polyfill definitions.
Core-js is a modular standard library for JavaScript, including polyfills for ECMAScript up to 2021. It can be used directly or through @babel/preset-env. Unlike @babel/helper-define-polyfill-provider, which is a helper tool for defining polyfill providers, core-js provides actual implementations of polyfills and is often used as the underlying library for polyfilling in many environments.
Using npm:
npm install --save-dev @babel/helper-define-polyfill-provider
or using yarn:
yarn add @babel/helper-define-polyfill-provider --dev
FAQs
Babel helper to create your own polyfill provider
The npm package @babel/helper-define-polyfill-provider receives a total of 26,107,470 weekly downloads. As such, @babel/helper-define-polyfill-provider popularity was classified as popular.
We found that @babel/helper-define-polyfill-provider demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.