Registry / babel-polyfill-safer

babel-polyfill-safer

JSON →
library6.6.1jsnpmunverified

A wrapper around babel-polyfill (v6.6.1) that prevents errors when the polyfill is required multiple times. It checks a global flag to avoid re-applying polyfills, solving the 'only one instance of babel-polyfill is allowed' issue. The package is intended for legacy Babel 6 environments, is no longer actively developed, and users should migrate to @babel/polyfill or direct core-js/regenerator-runtime imports.

npm install babel-polyfill-safer
INSTALL
IMPORT
SIG · BABEL-POLYFILL-SAF
B
babel-polyfill-safer
javascriptv6.6.1
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.

babel-polyfill-safe
import 'babel-polyfill-safe'
const polyfill = require('babel-polyfill-safe')
Used as a side-effect import, no named exports. Usually placed at entry point.
default
require('babel-polyfill-safe')
const { default } = require('babel-polyfill-safe')
CommonJS require works, but there is no default export.
global._babelPolyfill
if (global._babelPolyfill) { /* skip */ }
defining global._babelPolyfill manually before import
Internal mechanism; not meant for direct use.

Shows how to safely import the polyfill to avoid duplicate instance errors.

// Ensure you have babel-polyfill installed // npm install babel-polyfill babel-polyfill-safe // At the very top of your entry file: import 'babel-polyfill-safe'; // Or with CommonJS: require('babel-polyfill-safe'); // Now you can use modern features without worrying about multiple polyfill instances. // Example: const fn = () => {}; const promise = Promise.resolve();
Debug
Known issues
deprecatedbabel-polyfill-safe is designed for Babel 6; Babel 7+ uses @babel/polyfill which has its own safety mechanisms.
fix
Migrate to @babel/polyfill or directly import core-js/stable and regenerator-runtime/runtime.
affects: <=6.6.1
gotchaThis package only prevents the 'only one instance' error; it does not version-check the polyfill content. If two different versions of babel-polyfill are required, behavior is undefined.
fix
Ensure all dependencies use the same version of babel-polyfill; prefer deduplicating via npm/yarn.
affects: *
gotchaThe package sets global._babelPolyfill = true after first require, which may conflict with other polyfill libraries that check the same global flag.
fix
Avoid mixing multiple polyfill wrappers; stick to one official method.
affects: *
Errors
Common errors & fixes
Error: only one instance of babel-polyfill is allowed
Multiple packages install and import babel-polyfill separately.
fix
Replace all 'babel-polyfill' imports with 'babel-polyfill-safe' in your project and dependencies.
ReferenceError: regeneratorRuntime is not defined
Despite using babel-polyfill-safe, some async/transform require regenerator-runtime which might not be included.
fix
Ensure babel-polyfill (>=6.6.1) is installed; it includes regenerator-runtime.
Cannot find module 'babel-polyfill'
babel-polyfill is a peer dependency but not installed.
fix
Run: npm install babel-polyfill@^6.6.1
Upgrade
Version history
6.6.1latest on npm
Audit
Dependencies
babel-polyfillrequiredcore polyfill that gets wrapped; must be installed as a peer dependency
Agent activity
3 hits · last 30 days
node
2
Resources
babel-polyfill-safer — npm install babel-polyfill-safer · libregistry