Skip to main content
core-js-compat contains machine-readable data describing which core-js modules are needed for which environments. It is the data layer used by tools like @babel/preset-env and swc to generate optimised polyfill lists automatically. You can also use it directly to answer the question: “Which core-js modules do I need to support these browsers?”

Installation

npm install --save-dev core-js-compat

Usage

Basic example

import compat from 'core-js-compat';

const {
  list,    // array of required module names
  targets, // object mapping each module to the engines that need it
} = compat({
  targets: '> 1%',           // browserslist query or min-version object
  modules: [                 // optional: filter to these entry points / modules
    'core-js/actual',        //   - an entry point
    'esnext.array.unique-by', //   - a module name or prefix
    /^web\./,                //   - a regex matched against the module name
  ],
  exclude: [                 // optional: exclude specific modules
    'web.atob',
  ],
  version: '3.49',           // core-js version to evaluate against (default: latest)
  inverse: false,            // when true: return modules NOT needed for these targets
});

console.log(targets);

Example output

// targets output (truncated to show structure)
{
  'es.error.cause':                { ios: '14.5-14.8' },
  'es.aggregate-error.cause':      { ios: '14.5-14.8' },
  'es.array.at':                   { ios: '14.5-14.8' },
  'es.array.find-last':            { firefox: '100', ios: '14.5-14.8' },
  'es.array.find-last-index':      { firefox: '100', ios: '14.5-14.8' },
  'es.array.includes':             { firefox: '100' },
  'es.array.push':                 { chrome: '100', edge: '101', ios: '14.5-14.8', safari: '15.4' },
  'es.array.unshift':              { ios: '14.5-14.8', safari: '15.4' },
  'es.object.has-own':             { ios: '14.5-14.8' },
  'es.regexp.flags':               { chrome: '100', edge: '101' },
  'es.string.at-alternative':      { ios: '14.5-14.8' },
  'es.typed-array.at':             { ios: '14.5-14.8' },
  'es.typed-array.find-last':      { firefox: '100', ios: '14.5-14.8' },
  'es.typed-array.find-last-index':{ firefox: '100', ios: '14.5-14.8' },
  'esnext.array.group':            { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
  'esnext.array.to-reversed':      { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
  'esnext.array.unique-by':        { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
  'web.dom-exception.stack':       { chrome: '100', edge: '101', ios: '14.5-14.8', safari: '15.4' },
  'web.immediate':                 { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
  'web.structured-clone':          { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
  // ...
}

Options

targets

Specifies the minimum environment versions to support. Accepts a browserslist query string or a targets object:
const { list } = compat({
  targets: 'defaults, not IE 11, maintained node versions',
});

modules

Optional. Restricts the result to a subset of core-js modules. Accepts a string, regex, or array of either:
modules: [
  'core-js/actual',         // entry point — expands to all modules under that namespace
  'esnext.array.unique-by', // exact module name or name prefix
  /^web\./,                 // regex matched against module names
]

exclude

Optional. Works the same as modules but removes matching entries from the result.
exclude: ['web.atob', /^esnext\.reflect\./]

version

The core-js version to evaluate data against. Defaults to the latest version shipped with the package.
version: '3.49'

inverse

When true, returns modules that are not required for the target environments — useful for auditing or generating an exclusion list.
inverse: true

Additional exports

core-js-compat exposes several lower-level exports for advanced use:
import compat, {
  data,
  entries,
  modules,
  getModulesListForTargetVersion,
} from 'core-js-compat';
ExportTypeDescription
compat (default)FunctionThe main query function — same as the default import
dataObjectFull compatibility data: { [ModuleName]: { [EngineName]: EngineVersion } }
entriesObjectMap of entry points to module lists: { [EntryPoint]: Array<ModuleName> }
modulesArrayComplete list of all core-js module names
getModulesListForTargetVersionFunctionReturns the modules available in a specific core-js version

getModulesListForTargetVersion

import { getModulesListForTargetVersion } from 'core-js-compat';

const modules = getModulesListForTargetVersion('3.49');
// => ['es.array.at', 'es.array.find-last', ...]

Direct sub-path requires

Each export is also available as a standalone require:
require('core-js-compat/compat')({ targets, modules, version });
require('core-js-compat/data');
require('core-js-compat/entries');
require('core-js-compat/modules');
require('core-js-compat/get-modules-list-for-target-version')('3.49');

Use cases

Build tool integration

Used internally by @babel/preset-env and swc to determine which core-js modules to inject for a given browser target.

Custom bundle generation

Feed the output list directly into core-js-builder to produce a trimmed bundle containing only what your targets need.

Compatibility auditing

Use the targets output to understand exactly which browsers or environments require each polyfill — useful for prioritising support decisions.

Version migration

Use getModulesListForTargetVersion to compare module availability across core-js versions before upgrading.

Build docs developers (and LLMs) love