Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@babel/preset-env incorrectly add too many plugins with Node.js target #9047

Closed
ehmicky opened this issue Nov 20, 2018 · 5 comments · Fixed by #9048
Closed

@babel/preset-env incorrectly add too many plugins with Node.js target #9047

ehmicky opened this issue Nov 20, 2018 · 5 comments · Fixed by #9048
Labels
Has PR outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: preset-env

Comments

@ehmicky
Copy link

ehmicky commented Nov 20, 2018

Bug Report

Current Behavior
When targeting the latest Node.js version (11.2.0), @babel/preset-env adds the following plugins:

@babel/preset-env: `DEBUG` option

Using targets:
{
  "node": "11"
}

Using modules transform: auto

Using plugins:
  proposal-async-generator-functions { "node":"11" }
  syntax-object-rest-spread { "node":"11" }
  proposal-unicode-property-regex { "node":"11" }
  proposal-json-strings { "node":"11" }
  proposal-optional-catch-binding { "node":"11" }

Using polyfills with `usage` option:

[myfile.js] Based on your code and targets, none were added.
"use strict";

Input Code

// empty file

Expected behavior/code
All those plugins are not needed with Node.js 11.2.0 which already supports those.

Babel Configuration (.babelrc, package.json, cli command)

module.exports = {
  plugins: [
    "@babel/plugin-transform-runtime",
  ],
  presets: [
    ["@babel/preset-env", {
      targets: {
        node: "11"
      },
      useBuiltIns: 'usage',
      debug: true,
    }]
  ]
}

Environment

  • Babel version(s): 6.23.0
  • Node/npm version: Node 11.2.0, npm 6.4.1
  • OS: Ubuntu 18.10
  • Monorepo: no
  • How you are using Babel: cli

Possible Solution
This seems to be an issue with compat-table data. I've opened an issue here

@babel-bot
Copy link
Collaborator

Hey @ehmicky! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@ehmicky
Copy link
Author

ehmicky commented Nov 20, 2018

After looking more into the issue, it seems like the problem is not compat-table but the build script.

Example for proposal-unicode-property-regex:

  • compat-table/data-es2016plus indicates chrome64 is supported.
  • compat-table/environments indicates that node10_13 equals chrome68
  • But output plugins.json from preset-env does not contain any node property, which indicates lack of support
  • As a result, when targeting Node.js 11, proposal-unicode-property-regex is added even though compat-table indicates it should not.

@existentialism
Copy link
Member

@ehmicky published #9048 for this (we've been waiting for compat-table to get node10+ support so that we could update our mappings)

@ehmicky
Copy link
Author

ehmicky commented Nov 20, 2018

Great, thanks for this very fast PR!

I note the following:

  • proposal-json-strings should be the only transform needed for Node.js 11
  • syntax-object-rest-spread is not needed in Node.js 11. I am not sure how it actually gets added there, but hopefully this PR will fix it as well. I am mentioning it because I cannot see it in the PR, but I'm guessing it got added as a side-effect from another transform.

@existentialism
Copy link
Member

@ehmicky syntax-object-rest-spread is needed to enable parsing in babel, not for transforming.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Feb 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Has PR outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: preset-env
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants