core-js is the global polyfill package. It patches native globals (Array, Promise, Set, etc.) directly so that all downstream code works without any changes. This is the right choice for application code.
Installation
Make sure
core-js is listed under dependencies, not devDependencies, since it is required at runtime.Entry namespaces
core-js ships several pre-composed entry points that let you control which features are polyfilled.
| Namespace | Path | What it includes |
|---|---|---|
full | core-js / core-js/full | Everything: stable ES, web standards, and all stage proposals including early-stage experiments |
actual | core-js/actual | Stable ES, web standards, and stage 3+ proposals — recommended |
stable | core-js/stable | Stable ES and web standards only (no proposals) |
es | core-js/es | Stable ECMAScript features only |
Usage
Import a full namespace
Feature-specific imports
Import a proposal by stage
Configurable polyfill aggressiveness
By default,core-js applies polyfills only when a feature is missing or broken. You can override this per-feature using the configurator:
Bundler configuration
SetsideEffects: true in your package.json (or the equivalent bundler flag) to prevent tree-shaking from removing polyfill imports:
core-js package:
Babel integration
@babel/preset-env
@babel/preset-env can automatically inject only the polyfills needed for your target environments.
Specify the full minor version (
"3.49" not "3") so that modules added in minor releases are included.useBuiltIns value | Behaviour |
|---|---|
"entry" | Replaces a single core-js import with only the modules needed for your targets |
"usage" | Adds per-file imports for features actually used in that file |
swc
When to use core-js
Use core-js when...
- Building an application (not a library)
- You control the full entry point
- You want native globals patched transparently
- You use Babel or swc with auto-injection
Use core-js-pure instead when...
- Authoring a reusable library or package
- You cannot afford to mutate globals
- You want explicit, named imports
- You need to avoid affecting other code on the page
Custom builds
To generate a trimmed bundle for specific targets or exclude features you don’t need, usecore-js-builder.