Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@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 22,735,373 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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.