There comes a time in every developer's life when they come to realize their thoughtleaders misled them.
Oh, we've really done it now.
So remember how we told you all to use babel-preset-env
?
{
"presets": [
["env", {
"targets": {
"browsers": [
"last 2 versions"
]
}
}]
]
}
We told you to use it because it would only compile the things that the browsers you support actually needed to be compiled. So if all the browsers you cared about supported arrow functions, Babel would stop compiling away arrow functions.
Except, if you use babel-preset-env
the way I did above.
Arrow functions will never stop being compiled... no, like never ever. It
could be the year 2418 and Babel will still be compiling away arrow
functions.
This is because of that one little "last 2 versions"
bit.
When you say "We support the last 2 versions of every browser", you probably don't mean browsers like:
But guess what? "last 2 versions" will always match those... forever.
Take Internet Explorer for example. It's been replaced by Edge and will never have any new versions after Internet Explorer 11. Microsoft gave us that gift.
But if you say that you support the "last 2 versions" of every browser, that means you support the last 2 versions of Edge AND the last 2 versions of Internet Explorer.
And since there's never going to be another version of Internet Explorer, you will be supporting Internet Explorer 10 & 11... forever.
This would be my personal recommendation:
"browsers": [
">0.25%",
"not ie 11",
"not op_mini all"
]
Then you can adjust it as needed with specific browsers. You can read about how it works in the browserlist documentation.
Using market share percentages as your baseline is much better than some arbitrary number of previous versions. If a browser is used by 0 people, then market percentages will reflect that.
I would make this adjustment in your apps immediately, it will likely lead to a fairly big drop in your app's size (depending on the features that you are using and how often).