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

breaking: fallback targets to "defaults, not ie 11" #12989

Merged
merged 13 commits into from Mar 23, 2021

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Mar 10, 2021

Q                       A
Fixed Issues? Closes #12616
Patch: Bug Fix?
Major: Breaking Change? Y, behind the BABEL_8_BREAKING flag
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link babel/website#2765
Any Dependency Changes?
License MIT

This PR is an alternative to #12616. When no browsers targets are set and ignoreBrowserslistConfig is false (default value), @babel/compilation-targets will return the browserlists query "defaults, not ie 11", thus @babel/preset-env will skip most transforms given their native support on these targets (as of Mar 2021):

npx browserslist --mobile-to-desktop "defaults, not ie 11"
and_chr 86
and_chr 85
and_ff 82
and_ff 81
and_qq 10.4
and_uc 12.12
android 86
android 85
baidu 7.12
chrome 86
chrome 85
chrome 84
edge 86
edge 85
firefox 82
firefox 81
firefox 78
ios_saf 14
ios_saf 13.4-13.7
ios_saf 13.3
ios_saf 12.2-12.4
kaios 2.5
op_mini all
op_mob 72
op_mob 71
opera 72
opera 71
safari 14
safari 13.1
samsung 12.0
samsung 11.1-11.2

Related plugins behaviour changes:

  • @babel/plugin-proposal-object-rest-spread will use Object.assign by default

@babel/helper-compilation-targets behaviour changes:

  • { esmodules: "intersect" } without a target will become no op because defaults, not ie 11 have native esmodules support.

This PR includes commits from #12996.

import "core-js/modules/es6.typed.float32-array.js";
import "core-js/modules/es6.typed.float64-array.js";
import "core-js/modules/es6.weak-map.js";
import "core-js/modules/es6.weak-set.js";
import "core-js/modules/web.timers.js";
import "core-js/modules/web.immediate.js";
import "core-js/modules/web.dom.iterable.js";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most core-js 2 polyfills are not used because defaults, not ie 11 already have native support.

@babel-bot
Copy link
Collaborator

babel-bot commented Mar 10, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/44286/

@nicolo-ribaudo
Copy link
Member

cc @developit

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 10, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9399e44:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@developit
Copy link
Member

@nicolo-ribaudo @JLHwung this will be fantastic with bugfixes defaulting to true.

@nicolo-ribaudo
Copy link
Member

@developit Note that bugfixes: true almost doesn't change the behavior of defaults, not ie 11, since the all bugfixes we currently have except for bugfix/transform-tagged-template-caching target older browsers.

Copy link
Member

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 🎊 💯

@developit
Copy link
Member

@nicolo-ribaudo ah sorry, I had misread - that makes sense given Safari 11 and prior are not included due to the % cutoff.

Just to clarify - op_mini all will still be excluded due to the data issues, right?

@nicolo-ribaudo
Copy link
Member

Yes, we don't have data for op_mini all. If we'll ever have it, we'll make sure not to change the actual default behavior.

@JLHwung JLHwung force-pushed the exclude-ie-in-default-targets branch from ab5f225 to 32a2d00 Compare March 11, 2021 21:31
@@ -1,3 +1,4 @@
{
"externalHelpers": false
"externalHelpers": false,
"targets": { "browsers": "ie 6, ios 4" }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added ios 4 here because IE 5.5 has Array.map but not ios 4. Note that browserslist does not support IE 5.

};

var buildTest = function buildTest(name) {
const buildTest = name => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have issue-10879-babel-7 for this test, so good to overwrite the test output.

@nicolo-ribaudo
Copy link
Member

Can/should 32a2d00 be extracted to a separate smaller PR?

@@ -1,5 +1,5 @@
{
"presets": ["env"],
"presets": [["env", { "targets": { "browsers": "ie 6" } }]],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really a nit and only if you can do it with a regexp, but I find the top-level targets slightly more readable (less [ and {).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still want to make this change? Guess it could be a separate PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could track this in a separate PR but if we use top level targets, the output fixtures may need to be updated since plugins can be aware of that. This PR aims for minimizing fixtures update so we can move forward.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok yeah that sounds like a different issue entirely given that chance.

Really want to work on making these diffs easier to look through! Would be interesting to run our tests through a combination of retainLines/recast

@JLHwung JLHwung force-pushed the exclude-ie-in-default-targets branch from d1b36e2 to 9399e44 Compare March 12, 2021 22:15
Copy link
Member

@hzoo hzoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably one of the more helpful breaking changes that we do

  • default to es6+
  • makes users have to be aware of targets
  • we can do the ideas we were talking about with applying preset-modules/bugfixes to further syntax since current bugfixes wouldn't be applied like @nicolo-ribaudo mentioned?

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exciting 🎉

@nicolo-ribaudo nicolo-ribaudo merged commit 6ee87ee into babel:main Mar 23, 2021
@nicolo-ribaudo nicolo-ribaudo deleted the exclude-ie-in-default-targets branch March 23, 2021 19:17
@JLHwung JLHwung mentioned this pull request Mar 25, 2021
34 tasks
sodatea added a commit to vuejs/vue-cli that referenced this pull request Apr 15, 2021
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 23, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 23, 2021
@nicolo-ribaudo nicolo-ribaudo added this to the v8.0.0 milestone Aug 8, 2023
@JLHwung JLHwung added PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release and removed babel 8 labels Aug 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants