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
Usage
Basic example
Example output
Options
targets
Specifies the minimum environment versions to support. Accepts a browserslist query string or a targets object:
modules
Optional. Restricts the result to a subset of core-js modules. Accepts a string, regex, or array of either:
exclude
Optional. Works the same as modules but removes matching entries from the result.
version
The core-js version to evaluate data against. Defaults to the latest version shipped with the package.
inverse
When true, returns modules that are not required for the target environments — useful for auditing or generating an exclusion list.
Additional exports
core-js-compat exposes several lower-level exports for advanced use:
| Export | Type | Description |
|---|---|---|
compat (default) | Function | The main query function — same as the default import |
data | Object | Full compatibility data: { [ModuleName]: { [EngineName]: EngineVersion } } |
entries | Object | Map of entry points to module lists: { [EntryPoint]: Array<ModuleName> } |
modules | Array | Complete list of all core-js module names |
getModulesListForTargetVersion | Function | Returns the modules available in a specific core-js version |
getModulesListForTargetVersion
Direct sub-path requires
Each export is also available as a standalone require: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.