babel-es6-polyfill
raw JSON → 1.1.0 verified Sat Apr 25 auth: no javascript deprecated
A lightweight ES6/ES2015 polyfill specifically for Babel, version 1.1.0, designed for modern browsers that fully support ES5. Unlike Babel's default polyfill, it includes only standardized features from the ECMAScript specification, omitting proposals (e.g., setImmediate) and non-standard additions. This polyfill is intended for browser-only use, replacing babel-core's browser-polyfill.js. It has low release cadence with minimal updates. Key differentiators: pure standards track, no ES5 shims, and no proposals.
Common errors
error ReferenceError: Map is not defined ↓
cause babel-es6-polyfill not loaded before Babel-compiled code.
fix
Load the polyfill script before any compiled Babel output. Use <script src="...babel-es6-polyfill/dist/browser-polyfill.js"></script> at the top of your HTML.
error Cannot find module 'babel-es6-polyfill' ↓
cause Missing installation or incorrect path.
fix
Run npm install babel-es6-polyfill --save and ensure the path is correct: require('babel-es6-polyfill/dist/browser-polyfill.js').
error Uncaught TypeError: ... is not a function (e.g., Promise is undefined) ↓
cause Older browser lacks ES6 support and polyfill not loaded.
fix
Include the polyfill script as the very first script tag, before any other scripts.
Warnings
deprecated This package is deprecated in favor of @babel/polyfill (now @babel/polyfill-noop or core-js usage). ↓
fix Use @babel/polyfill or import core-js/stable and regenerator-runtime/runtime.
breaking Polyfill only works in browsers; it may fail in Node.js due to missing DOM APIs. ↓
fix Use core-js for Node.js polyfilling.
gotcha The polyfill does not include ES5 shims; it assumes target browsers support ES5 fully. ↓
fix Ensure browsers are ES5-compatible or include an ES5 polyfill first.
gotcha No proposals are included (e.g., Array.prototype.includes is ES2016, not ES6). Users may expect newer features. ↓
fix Use core-js-compat to include necessary features based on target browsers.
Install
npm install babel-es6-polyfill yarn add babel-es6-polyfill pnpm add babel-es6-polyfill Imports
- default wrong
import polyfill from 'babel-es6-polyfill';correctconst polyfill = require('babel-es6-polyfill/dist/browser-polyfill.js'); - browser-polyfill.js wrong
<script src="node_modules/babel-es6-polyfill/browser-polyfill.js"></script>correct<script src="node_modules/babel-es6-polyfill/dist/browser-polyfill.js"></script> - Polyfill wrong
const { Polyfill } = require('babel-es6-polyfill');correctconst polyfill = require('babel-es6-polyfill/dist/browser-polyfill.js');
Quickstart
// Include before compiled Babel code
const polyfill = require('babel-es6-polyfill/dist/browser-polyfill.js');
// Alternatively, in HTML:
// <script src="node_modules/babel-es6-polyfill/dist/browser-polyfill.js"></script>
// Then your compiled Babel code can use ES6 features like Promise, Map, Set, etc.
const map = new Map();
map.set('key', 'value');
console.log(map.get('key')); // 'value'