This guide walks through the three main ways to use core-js: polyfilling everything at once, polyfilling only the features you need, and using core-js without global namespace pollution.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/zloirock/core-js/llms.txt
Use this file to discover all available pages before exploring further.
Install core-js
Add core-js to your project. Pin to the full minor version to ensure all relevant polyfills are included.
Import at the top of your entry point
Add the core-js import as the very first statement in your application’s entry file — before any other imports or application code.
Usage patterns
Pattern 1: Polyfill everything at once
Import a single namespace entry point to polyfill a broad set of features in one line.| Import | Includes |
|---|---|
core-js/full | Everything, including early-stage proposals |
core-js/actual | Stable ES + Web standards + Stage 3 proposals |
core-js/stable | Stable ES + Web standards only |
core-js/es | Stable ECMAScript only |
Pattern 2: Polyfill specific features
Import individual feature modules to keep your bundle as small as possible. Each import targets exactly one constructor, method, or proposal.Pattern 3: Use core-js-pure (no global pollution)
If you are building a library or a component that must not modify the host environment’s globals, installcore-js-pure and import implementations directly.
With
core-js-pure, prototype methods like Array.prototype.flatMap cannot be called as methods on array instances. They are re-exported as static functions that accept the array as their first argument.Using with Babel
If you are using@babel/preset-env, set useBuiltIns to 'usage' or 'entry' and specify the exact minor version of core-js you have installed. Babel will automatically inject only the imports required for your configured target environments.
babel.config.json
useBuiltIns: 'usage', do not add core-js imports yourself — Babel inserts them automatically per file based on what you use.
With useBuiltIns: 'entry', place a single import 'core-js/actual' at the top of your entry point, and Babel will replace it with the precise set of module imports your targets need.
Using with swc
swc supports the sameentry and usage modes. Configure via .swcrc:
.swcrc
Next steps
- Installation — Full installation options for all packages
- core-js package reference — Complete entry point and namespace reference
- core-js-pure package reference — Pollution-free import patterns