Registry / idempotent-babel-polyfill

idempotent-babel-polyfill

JSON →
library7.4.4jsnpmunverified

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.

npm install idempotent-babel-polyfill
INSTALL
IMPORT
SIG · IDEMPOTENT-BABEL-P
I
idempotent-babel-polyfill
javascriptv7.4.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default import (side-effect)
import 'idempotent-babel-polyfill'
import idempotentBabelPolyfill from 'idempotent-babel-polyfill'
The default import is a side-effect import that loads and executes the polyfill; named exports require object destructuring.
idempotentBabelPolyfill
import { idempotentBabelPolyfill } from 'idempotent-babel-polyfill'
import idempotentBabelPolyfill from 'idempotent-babel-polyfill'
The named export is a function that triggers the polyfill manually; it is not the default export.
require
require('idempotent-babel-polyfill')
CJS require works fine; no need for destructuring. The package supports both ESM and CJS.

Shows three ways to use the package: side-effect import, require, and calling the exported function.

// 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();
Debug
Known issues
deprecatedbabel-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';
affects: >=7.4.0
breakingPackage 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.
affects: >=7.4.0
gotchaImporting 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.
affects: all
gotchaThe 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.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'babel-polyfill'
babel-polyfill is not installed as a dependency.
fix
npm install babel-polyfill
Attempted to load multiple Babel polyfills, which may cause issues.
Multiple imports of babel-polyfill in the same application.
fix
Use idempotent-babel-polyfill to safely import only once.
Requested path: babel-polyfill not found in module map
Using idempotent-babel-polyfill in an environment where babel-polyfill is not available.
fix
Install babel-polyfill as a direct dependency.
Upgrade
Version history
7.4.4latest on npm
Audit
Dependencies
babel-polyfillrequiredRuntime peer dependency; the package wraps babel-polyfill.
Agent activity
4 hits · last 30 days
node
4
Resources
idempotent-babel-polyfill — npm install idempotent-babel-polyfill · libregistry