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
Fix destructuring assignments being transpiled for edge 15 #9902
Conversation
Can you add a test for this code?
It's the code for which compat-table reports edge 15 as unsupported. MDN isn't really reliable, I suggest using https://kangax.github.io/compat-table/es6/ instead. |
For sure. But the outcome was the same. preset-env behavior didn't match what I would expect from the compat table.
I would expect only ((a, _ref) => {
let { b = 0, c = 3 } = _ref;
return a === 1 && b === 2 && c === 3;
})(1, {
b: 2
}); which is edge 15 compatible. Didn't quite click for me where to put the test but I got it now. Reworking the PR. |
Yeah, the parameters transform is enough |
a3ab9c5
to
e9b27ae
Compare
24a0e71 should make my intentions clearer. Hope this is the right place for the test. Got one test failing locally but this happened before any changes. Maybe a rebase will fix it. |
Yeah, it's fixed on master. If the only failing test is that one, it's ok. |
e9b27ae
to
24a0e71
Compare
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10741/ |
preset-env transpiles object destructuring in edge 17.
Current behavior: 2254f7c#diff-0d3abae52af132aba0fb19ce6f915ccf
Expected behavior: 24a0e71#diff-0d3abae52af132aba0fb19ce6f915ccf
The destructuring assignment is implemented as early as edge 15 (loosely in 14) though. Was this required for some transform dependencies when function parameters are transpiled? Specifically destructuring in the function parameters is only properly implemented in later browsers.
Will need to check if those are still transpiled properly in the deploy preview in this PR.
On another note: preset-env is really nice but I wish the documentation would be more clear that there are legitimate use cases for specifiyng each transform instead of using the preset.
transform-destructuring
is currently used up to firefox 53 just because the return in custom iterator implementations is not called. I don't think this has any impact on basic object destructuring which would allow me to drop the transform for firefox 49. Maybe this is more of an issue with the mdn page which lists object destructuring as being implemented in firefox 49 but then babel transpiles it anyway. Pretty confusing but I guess this is what browser support still requires.