{"id":19124,"library":"babel-plugin-polyfill-custom","title":"babel-plugin-polyfill-custom","description":"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.","status":"active","version":"2.0.49","language":"javascript","source_language":"en","source_url":"https://github.com/3846masa/babel-plugin-polyfill-custom","tags":["javascript","babel","babel-plugin","polyfill"],"install":[{"cmd":"npm install babel-plugin-polyfill-custom","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-polyfill-custom","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-polyfill-custom","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for Babel plugin operation","package":"@babel/core","optional":false}],"imports":[{"note":"ESM default export; in CommonJS, require returns the plugin function directly (no .default).","wrong":"const babelPluginPolyfillCustom = require('babel-plugin-polyfill-custom').default","symbol":"default","correct":"import babelPluginPolyfillCustom from 'babel-plugin-polyfill-custom'"},{"note":"Named export available since v2.0.0; using require requires destructuring from main module.","wrong":"const customPolyfills = require('babel-plugin-polyfill-custom/customPolyfills')","symbol":"customPolyfills","correct":"import { customPolyfills } from 'babel-plugin-polyfill-custom'"},{"note":"TypeScript type import available; not a runtime value.","wrong":"","symbol":"PluginConfig","correct":"import type { PluginConfig } from 'babel-plugin-polyfill-custom'"}],"quickstart":{"code":"// babel.config.js\nimport babelPluginPolyfillCustom from 'babel-plugin-polyfill-custom';\n\nexport default {\n  presets: [\n    ['@babel/preset-env', { targets: 'last 2 versions' }]\n  ],\n  plugins: [\n    [\n      babelPluginPolyfillCustom,\n      {\n        polyfills: {\n          'Promise': 'core-js-pure/stable/promise',\n          'fetch': 'whatwg-fetch',\n          'Object.assign': '@babel/runtime/helpers/extends'\n        },\n        method: 'usage-pure',\n        browserlist: 'last 2 versions'\n      }\n    ]\n  ]\n};","lang":"javascript","description":"Configures babel-plugin-polyfill-custom with custom polyfill sources for Promise, fetch, and Object.assign, using usage-pure method."},"warnings":[{"fix":"Add @babel/preset-env to your Babel config alongside this plugin.","message":"babel-plugin-polyfill-custom cannot transpile ECMAScript syntax; must be used with @babel/preset-env for syntax transformation.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Configure your bundler to handle data URIs (see README for webpack/Rollup/Parcel examples).","message":"Polyfills are inserted via base64 data URIs; bundlers like webpack 5.38.0+ or Rollup with @rollup/plugin-data-uri are required.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use ESM import syntax or const plugin = require('babel-plugin-polyfill-custom') (no .default).","message":"v2.0.0 dropped support for CommonJS require() returning object with .default property; now ESM-only default export.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Rename the option to 'polyfills'.","message":"The 'polyfill' option (singular) was renamed to 'polyfills' (plural) in v1.5.0. Using singular still works but logs a warning.","severity":"deprecated","affected_versions":">=1.5.0 <2.0.0"},{"fix":"Avoid combining with @babel/plugin-transform-runtime; use 'usage-entry' or 'entry' method instead.","message":"Using 'method: 'usage-pure'' may result in duplicate polyfills if @babel/plugin-transform-runtime is also used.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save-dev babel-plugin-polyfill-custom","cause":"Package not installed or installed as devDependency without proper resolution.","error":"Error: Cannot find module 'babel-plugin-polyfill-custom'"},{"fix":"Use const babelPluginPolyfillCustom = require('babel-plugin-polyfill-custom'); (no .default)","cause":"Incorrect import (default import used with require() without destructuring).","error":"TypeError: babelPluginPolyfillCustom is not a function"},{"fix":"Ensure polyfill paths are absolute or correctly resolved from node_modules.","cause":"Missing or incorrect polyfill path in configuration.","error":"Error: [BABEL] ...: Cannot find module './polyfills' from 'babel-plugin-polyfill-custom'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}