Skip to content

[Bug]: babel/preset-env - document says esmodules is intersected, build warning says its ignored. #15371

Open
babel/website
#2714
@epreston

Description

@epreston

💻

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

console.log('hello world!');

Configuration file name

.babelrc.json

Configuration

{
  "presets": [
    [
      "@babel/preset-env",
      {
        "bugfixes": true,
        "targets": {
          "browsers": "Edge >= 108, Firefox >= 108, FirefoxAndroid  >= 107, Chrome >= 108, ChromeAndroid >= 108, Safari >= 16.1, iOS >= 16.1, not dead",
          "esmodules": true
        },
        "useBuiltIns": "usage",
        "corejs": "3.27.2"
      }
    ]
  ]
}

Current and expected behavior

Documentation for options "targets" says:

Please note: when specifying both browsers and the esmodules target, they will be intersected.

However, when building the following message is displayed.

@babel/preset-env: esmodules and browsers targets have been specified together.
browsers target, Edge >= 108, Firefox >= 108, FirefoxAndroid >= 107, Chrome >= 108, ChromeAndroid >= 108, Safari >= 16.1, iOS >= 16.1, not dead will be ignored.

Which is correct ? Is it intersected or ignored ?

Environment

Babel Versions:

  • "@babel/core": "^7.20.12",
  • "@babel/preset-env": "^7.20.2",
  • "babel-loader": "^9.1.2",

Node Versions:

  • npm 8.19.3
  • node 18.13.0

OS:

  • WIndows 10
  • OSX (latest)

Possible solution

Depending on which is correct, update documentation or warning message in babel/preset-env

Additional context

I would like rely on the intersection behaviour in the future, if possible.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions