Registry / devops / babel-plugin-polyfill-custom

babel-plugin-polyfill-custom

JSON →
library2.0.49jsnpmunverified

A Babel plugin that allows developers to freely customize polyfills, enabling the selection of any polyfill implementation (e.g., whatwg-fetch, unfetch, Zousan) instead of being limited to core-js or es-shims. Current stable version is 2.0.49, released on 2026-04-21, with weekly updates and frequent dependency bumps. Key differentiators: supports any polyfill, not just ECMAScript; uses browserslist to determine required polyfills; inserts polyfills via base64 data URIs for differential bundle serving. Alternative to @babel/preset-env's core-js-based polyfilling.

npm install babel-plugin-polyfill-custom
INSTALL
IMPORT
SIG · BABEL-PLUGIN-POLYF
B
babel-plugin-polyfill-custom
devopsjavascriptv2.0.49
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import babelPluginPolyfillCustom from 'babel-plugin-polyfill-custom'
const babelPluginPolyfillCustom = require('babel-plugin-polyfill-custom').default
ESM default export; in CommonJS, require returns the plugin function directly (no .default).
customPolyfills
import { customPolyfills } from 'babel-plugin-polyfill-custom'
const customPolyfills = require('babel-plugin-polyfill-custom/customPolyfills')
Named export available since v2.0.0; using require requires destructuring from main module.
PluginConfig
import type { PluginConfig } from 'babel-plugin-polyfill-custom'
TypeScript type import available; not a runtime value.

Configures babel-plugin-polyfill-custom with custom polyfill sources for Promise, fetch, and Object.assign, using usage-pure method.

// babel.config.js import babelPluginPolyfillCustom from 'babel-plugin-polyfill-custom'; export default { presets: [ ['@babel/preset-env', { targets: 'last 2 versions' }] ], plugins: [ [ babelPluginPolyfillCustom, { polyfills: { 'Promise': 'core-js-pure/stable/promise', 'fetch': 'whatwg-fetch', 'Object.assign': '@babel/runtime/helpers/extends' }, method: 'usage-pure', browserlist: 'last 2 versions' } ] ] };
Debug
Known issues
gotchababel-plugin-polyfill-custom cannot transpile ECMAScript syntax; must be used with @babel/preset-env for syntax transformation.
fix
Add @babel/preset-env to your Babel config alongside this plugin.
affects: >=0.0.0
gotchaPolyfills are inserted via base64 data URIs; bundlers like webpack 5.38.0+ or Rollup with @rollup/plugin-data-uri are required.
fix
Configure your bundler to handle data URIs (see README for webpack/Rollup/Parcel examples).
affects: >=0.0.0
breakingv2.0.0 dropped support for CommonJS require() returning object with .default property; now ESM-only default export.
fix
Use ESM import syntax or const plugin = require('babel-plugin-polyfill-custom') (no .default).
affects: >=2.0.0
deprecatedThe 'polyfill' option (singular) was renamed to 'polyfills' (plural) in v1.5.0. Using singular still works but logs a warning.
fix
Rename the option to 'polyfills'.
affects: >=1.5.0 <2.0.0
gotchaUsing 'method: 'usage-pure'' may result in duplicate polyfills if @babel/plugin-transform-runtime is also used.
fix
Avoid combining with @babel/plugin-transform-runtime; use 'usage-entry' or 'entry' method instead.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-polyfill-custom'
Package not installed or installed as devDependency without proper resolution.
fix
npm install --save-dev babel-plugin-polyfill-custom
TypeError: babelPluginPolyfillCustom is not a function
Incorrect import (default import used with require() without destructuring).
fix
Use const babelPluginPolyfillCustom = require('babel-plugin-polyfill-custom'); (no .default)
Error: [BABEL] ...: Cannot find module './polyfills' from 'babel-plugin-polyfill-custom'
Missing or incorrect polyfill path in configuration.
fix
Ensure polyfill paths are absolute or correctly resolved from node_modules.
Upgrade
Version history
2.0.49latest on npm
Audit
Dependencies
@babel/corerequiredPeer dependency required for Babel plugin operation
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
babel-plugin-polyfill-custom — npm install babel-plugin-polyfill-custom · libregistry