Skip to content

babel-preset-env does not use package.json browserslist #762

Closed
@sudo-suhas

Description

@sudo-suhas

babel-preset-env does not yet consume the browserslist config in package.json. There is a PR open for adding this support.

We can see this in action by adding "debug": true to babel-preset-env options in .babelrc

babel-preset-env DEBUG output - Current
babel-preset-env: `DEBUG` option

Using targets:
{}

Modules transform: false

Using plugins:
  check-es2015-constants {}
  transform-es2015-arrow-functions {}
  transform-es2015-block-scoped-functions {}
  transform-es2015-block-scoping {}
  transform-es2015-classes {}
  transform-es2015-computed-properties {}
  transform-es2015-destructuring {}
  transform-es2015-duplicate-keys {}
  transform-es2015-for-of {}
  transform-es2015-function-name {}
  transform-es2015-literals {}
  transform-es2015-object-super {}
  transform-es2015-parameters {}
  transform-es2015-shorthand-properties {}
  transform-es2015-spread {}
  transform-es2015-sticky-regex {}
  transform-es2015-template-literals {}
  transform-es2015-typeof-symbol {}
  transform-es2015-unicode-regex {}
  transform-regenerator {}
  transform-exponentiation-operator {}
  transform-async-to-generator {}
  syntax-trailing-function-commas {}

From babel-preset-env readme:

The default behavior without options runs all transforms (behaves the same as babel-preset-latest).

This can be fixed if we change the babel-preset-env to the following:

{
  "presets": [
    ["env", {
      "modules": false,
      "targets": {
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
      }
    }],
    "stage-2"
  ],
  "plugins": ["transform-runtime"],
  "env": {
    "test": {
      "presets": ["env", "stage-2"],
      "plugins": ["istanbul"]
    }
  }
}
babel-preset-env DEBUG output - Proposed
babel-preset-env: `DEBUG` option

Using targets:
{
  "android": "4.4",
  "chrome": "49",
  "edge": "14",
  "firefox": "53",
  "ie": "10",
  "ios": "10",
  "safari": "10"
}

Modules transform: false

Using plugins:
  check-es2015-constants {"android":"4.4","ie":"10"}
  transform-es2015-arrow-functions {"android":"4.4","ie":"10"}
  transform-es2015-block-scoped-functions {"android":"4.4","ie":"10"}
  transform-es2015-block-scoping {"android":"4.4","ie":"10"}
  transform-es2015-classes {"android":"4.4","ie":"10"}
  transform-es2015-computed-properties {"android":"4.4","ie":"10"}
  transform-es2015-destructuring {"android":"4.4","chrome":"49","edge":"14","ie":"10"}
  transform-es2015-duplicate-keys {"android":"4.4","ie":"10"}
  transform-es2015-for-of {"android":"4.4","chrome":"49","edge":"14","ie":"10"}
  transform-es2015-function-name {"android":"4.4","chrome":"49","edge":"14","ie":"10"}
  transform-es2015-literals {"android":"4.4","ie":"10"}
  transform-es2015-object-super {"android":"4.4","ie":"10"}
  transform-es2015-parameters {"android":"4.4","ie":"10"}
  transform-es2015-shorthand-properties {"android":"4.4","ie":"10"}
  transform-es2015-spread {"android":"4.4","ie":"10"}
  transform-es2015-sticky-regex {"android":"4.4","ie":"10"}
  transform-es2015-template-literals {"android":"4.4","ie":"10"}
  transform-es2015-typeof-symbol {"android":"4.4","ie":"10"}
  transform-es2015-unicode-regex {"android":"4.4","chrome":"49","ie":"10"}
  transform-regenerator {"android":"4.4","chrome":"49","ie":"10"}
  transform-exponentiation-operator {"android":"4.4","chrome":"49","ie":"10","ios":"10","safari":"10"}
  transform-async-to-generator {"android":"4.4","chrome":"49","edge":"14","ie":"10","ios":"10","safari":"10"}
  syntax-trailing-function-commas {"android":"4.4","chrome":"49","ie":"10"

Should I make a pull request with this or do we want the babel-preset-env pull request to go in and then update the dependency?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions