Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@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 23,312,579 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.