{"id":24965,"library":"babel-polyfill-safer","title":"babel-polyfill-safe","description":"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.","status":"deprecated","version":"6.6.1","language":"javascript","source_language":"en","source_url":"https://github.com/andrew-w-ross/babel-polyfill-safe","tags":["javascript","babel","polyfill","safe"],"install":[{"cmd":"npm install babel-polyfill-safer","lang":"bash","label":"npm"},{"cmd":"yarn add babel-polyfill-safer","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-polyfill-safer","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"core polyfill that gets wrapped; must be installed as a peer dependency","package":"babel-polyfill","optional":false}],"imports":[{"note":"Used as a side-effect import, no named exports. Usually placed at entry point.","wrong":"const polyfill = require('babel-polyfill-safe')","symbol":"babel-polyfill-safe","correct":"import 'babel-polyfill-safe'"},{"note":"CommonJS require works, but there is no default export.","wrong":"const { default } = require('babel-polyfill-safe')","symbol":"default","correct":"require('babel-polyfill-safe')"},{"note":"Internal mechanism; not meant for direct use.","wrong":"defining global._babelPolyfill manually before import","symbol":"global._babelPolyfill","correct":"if (global._babelPolyfill) { /* skip */ }"}],"quickstart":{"code":"// Ensure you have babel-polyfill installed\n// npm install babel-polyfill babel-polyfill-safe\n\n// At the very top of your entry file:\nimport 'babel-polyfill-safe';\n\n// Or with CommonJS:\nrequire('babel-polyfill-safe');\n\n// Now you can use modern features without worrying about multiple polyfill instances.\n// Example:\nconst fn = () => {};\nconst promise = Promise.resolve();","lang":"javascript","description":"Shows how to safely import the polyfill to avoid duplicate instance errors."},"warnings":[{"fix":"Migrate to @babel/polyfill or directly import core-js/stable and regenerator-runtime/runtime.","message":"babel-polyfill-safe is designed for Babel 6; Babel 7+ uses @babel/polyfill which has its own safety mechanisms.","severity":"deprecated","affected_versions":"<=6.6.1"},{"fix":"Ensure all dependencies use the same version of babel-polyfill; prefer deduplicating via npm/yarn.","message":"This 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.","severity":"gotcha","affected_versions":"*"},{"fix":"Avoid mixing multiple polyfill wrappers; stick to one official method.","message":"The package sets global._babelPolyfill = true after first require, which may conflict with other polyfill libraries that check the same global flag.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Replace all 'babel-polyfill' imports with 'babel-polyfill-safe' in your project and dependencies.","cause":"Multiple packages install and import babel-polyfill separately.","error":"Error: only one instance of babel-polyfill is allowed"},{"fix":"Ensure babel-polyfill (>=6.6.1) is installed; it includes regenerator-runtime.","cause":"Despite using babel-polyfill-safe, some async/transform require regenerator-runtime which might not be included.","error":"ReferenceError: regeneratorRuntime is not defined"},{"fix":"Run: npm install babel-polyfill@^6.6.1","cause":"babel-polyfill is a peer dependency but not installed.","error":"Cannot find module 'babel-polyfill'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}