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

v7 Regression: Different behavior of babel-preset-env around whether Edge 15 needs destructuring to be transpiled #9255

Open
rmacklin opened this Issue Dec 28, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@rmacklin
Copy link
Contributor

rmacklin commented Dec 28, 2018

v7 Regression

Describe the regression
I’ve noticed that while upgrading a project to babel 7, which includes replacing the old babel-preset-env@1.7.0 package with the newer @babel/preset-env@7.2.3, the set of transforms applied for the edge 15 browser target changed.

Before the upgrade, destructuring was not being transpiled, but after the upgrade it is being transpiled (unexpectedly).

Input Code

function foo({ a, b }) {
  return a + b;
}

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

This is the configuration passed to babel-preset-env / @babel/preset-env:

targets: {
  browsers: ['edge 15']
}

Output

Output using babel 6.2.6 and babel-preset-env 1.6.2 (REPL):

"use strict";

function foo({ a, b }) {
  return a + b;
}

Output using babel 7.2.2 and preset-env 7.2.3 (REPL):

"use strict";

function foo(_ref) {
  let a = _ref.a,
      b = _ref.b;
  return a + b;
}

Expected behavior/code

I expected the output code using babel 7 to be the same as when using babel 6. That is, I didn't expect that upgrading to babel 7 would start transpiling destructuring for Edge 15.

Environment

  • Babel version(s): See REPL links
  • Node/npm version: N/A see REPL links
  • OS: N/A see REPL links
  • Monorepo: N/A see REPL links
  • How you are using Babel: N/A see REPL links
@babel-bot

This comment has been minimized.

Copy link
Collaborator

babel-bot commented Dec 28, 2018

Hey @rmacklin! 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.

@rmacklin

This comment has been minimized.

Copy link
Contributor

rmacklin commented Dec 29, 2018

I came across https://github.com/babel/babel/pull/9140/files which adds "edge: 18" to the transform-destructuring configuration in babel-preset-env/data/plugins.json, and if I change the configured browser target to edge 18, it goes back to not transpiling destructuring. However, I’d like to understand why it wasn’t being transpiled originally when using babel 6 and babel-preset-env 1.6.x or 1.7.0.

How does babel-preset-env use caniuse data, and in particular, how that has changed since babel-preset-env was its own package outside the monorepo (i.e. version <= 1.7.0)?

Ideally, I’d like to be able to upgrade the project I'm working on to babel 7 without changing the transpiled output and without changing the browsers list, but running into this issue makes that impossible. Thus, I’d like to understand what’s different in the newer versions of the env preset so that I can make the right decision about whether to accept different transpilation output or modify the browsers configuration.

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

nicolo-ribaudo commented Dec 29, 2018

We had to enable that transpilation because of #8349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment