Skip to content

[babel 8] Enforce specifying proper core-js version #16042

Description

@zloirock

In most cases of core-js usage with preset-env, I see something like corejs: 3 in the config. With installed [email protected].

The first core-js@3 release was in March 2019 and since then the number of core-js features has almost doubled.

corejs: 3 in the preset-env config is interpreted [email protected] which limits the subset of used core-js features only to features that were in [email protected] and, in most cases, is not that the user expect.

I propose to limit potentially incorrect corejs option values.

  • Disallow SemVer strings without a minor component, instead of corejs: "3" it should be at least corejs: "3.0"
  • Disallow numbers: even if someone writes corejs: 3.30 it will be interpreted as corejs: 3.3

From @JLHwung:

What about we also offer two magic options in Babel 8?

  • corejs: "node_modules": use whatever version in ./node_modules/core-js/package.json
    This is for the people who bundle core-js with their website
  • corejs: "package.json": use the minimum version specified in packageJson.dependencies["core-js"]
    This is for library authors that specified core-js as a dependency

For more sophisticated usage, please specify your own core-js version.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions