Skip to content

preset-env not removing all consts when using browserslist - works fine when directly supplied with target (v7.12.7 works fine) #12953

@neil-morrison44

Description

@neil-morrison44

Bug Report

Current behavior

I have a browserslist property in my package.json, if this is set to ie 11 then my output file will contain ~43 consts, if I do not ie 11 then there's ~293 consts.

I'm using webpack & babel-loader and my presets look like:

                presets: [
                  [
                    "@babel/env",
                    {
                      modules: false,
                      useBuiltIns: "usage",
                      corejs: { version: 3, proposals: true },
                    },
                  ],
                  "@babel/preset-react",
                ],

(I've tried swapping the order and it didn't change much)

As far as I can tell there's nothing special about the consts that're being forgotten about, aside from them coming from a node_module (which is correctly being parsed since it's being run through @babel/preset-react just fine)

@babel/preset-env v7.12.7 gets every const with exactly the same config, both the current version (v7.13.9) and v7.13.0 seem to leave some consts.

The strange thing is if I tell @babel/env to target IE 11 explicitly by doing

                    {
                      modules: false,
                      useBuiltIns: "usage",
                      corejs: { version: 3, proposals: true },
                     target: {
                       ie: 11
                     },
                    },

then v7.13.7 works as well as v7.12.7 does when reading from the browserslist

Expected behavior

It builds an output without any consts when targetting IE 11 via browserslist

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
{
  "your": { "config": "here" }
}

Environment

  System:
    OS: Linux 5.4 Debian GNU/Linux 8 (jessie) 8 (jessie)
  Binaries:
    Node: 12.16.1 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
  npmPackages:
    @babel/preset-env: 7.13.7 => 7.13.7
  • Babel version(s): latest as of issue
  • Monorepo: no
  • How you are using Babel: webpack

Repo isn't publicly accessible & I'm not sure how easy it'd be to get a contained reproducible example of it happening (might be something to do with volume, I've really got no idea)

Metadata

Metadata

Labels

i: regressionoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions