idempotent-babel-polyfill
raw JSON → 7.4.4 verified Sat Apr 25 auth: no javascript maintenance
A tiny utility that allows importing babel-polyfill multiple times without causing duplicate initialization errors. Version 7.4.4 is the latest stable release; the package has seen no updates since 2018 and effectively acts as a polyfill wrapper for legacy Babel setups. It provides an idempotent import that checks if core-js or regenerator-runtime has already been loaded, preventing multiple polyfill application which can cause conflicts and performance issues. Unlike directly importing babel-polyfill, this package is safe to include in library code where consumers may also polyfill.
Common errors
error Error: Cannot find module 'babel-polyfill' ↓
cause babel-polyfill is not installed as a dependency.
fix
npm install babel-polyfill
error Attempted to load multiple Babel polyfills, which may cause issues. ↓
cause Multiple imports of babel-polyfill in the same application.
fix
Use idempotent-babel-polyfill to safely import only once.
error Requested path: babel-polyfill not found in module map ↓
cause Using idempotent-babel-polyfill in an environment where babel-polyfill is not available.
fix
Install babel-polyfill as a direct dependency.
Warnings
deprecated babel-polyfill is deprecated in favor of core-js/stable and regenerator-runtime/runtime. ↓
fix Replace with direct imports: import 'core-js/stable'; import 'regenerator-runtime/runtime';
breaking Package hasn't been updated since 2018; may be incompatible with modern Babel 7.4+. ↓
fix Use core-js directly or @babel/preset-env with useBuiltIns.
gotcha Importing idempotent-babel-polyfill multiple times still loads babel-polyfill once, but babel-polyfill itself may cause duplicate if already present. ↓
fix Ensure no other polyfill is loaded before this import.
gotcha The package does not guarantee idempotency if used in bundled environments with multiple copies. ↓
fix Use dedupe tools or better: use core-js directly with proper configuration.
Install
npm install idempotent-babel-polyfill yarn add idempotent-babel-polyfill pnpm add idempotent-babel-polyfill Imports
- default import (side-effect) wrong
import idempotentBabelPolyfill from 'idempotent-babel-polyfill'correctimport 'idempotent-babel-polyfill' - idempotentBabelPolyfill wrong
import idempotentBabelPolyfill from 'idempotent-babel-polyfill'correctimport { idempotentBabelPolyfill } from 'idempotent-babel-polyfill' - require
require('idempotent-babel-polyfill')
Quickstart
// Install: npm install idempotent-babel-polyfill
// Option 1: Import as side-effect (recommended)
import 'idempotent-babel-polyfill';
// Option 2: Use require
require('idempotent-babel-polyfill');
// Option 3: Call the exported function manually
import { idempotentBabelPolyfill } from 'idempotent-babel-polyfill';
idempotentBabelPolyfill();