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

Add opera mobile compat data #15727

Merged
merged 9 commits into from Jul 4, 2023

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jun 27, 2023

Q                       A
Fixed Issues? Fixes #15711
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This PR contains commits from #15726, please review that one first.

In browserslist/browserslist#768, browserslist no longer returns op_mob version as if it were the one of Opera Desktop, it does return the correct opera mobile versions. However, @babel/helper-compilation-targets still maps op_mob as Opera. This significantly lowered the support matrix of queries like last 2 versions or defaults because although Opera Mobile 73 is modern, Opera Desktop 73 (Chrome 87) is 2 years old.

In this PR we maps op_mob as opera_mobile and add compat data for opera_mobile. While it is technically a new feature for @babel/compat-data, this PR fixes the regression that the defaults browserslist query is misintepreted by @babel/preset-env when using browserslist@4.21.9. Therefore I mark it as a bug fix.

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: compat-data labels Jun 27, 2023
package.json Outdated
"glob-watcher/chokidar": "npm:^3.4.0",
"@types/babel__core": "link:./nope",
"@types/babel__traverse": "link:./nope",
"@babel/helper-define-polyfill-provider/@babel/helper-compilation-targets": "workspace:*",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is kind of deadlock: If we don't map compilation targets to the workspace one, the one used by @babel/helper-define-polyfill-provider will throw on unrecognized targets opera_mobile on tests. If we map the library, the build dependency @babel/preset-env@npm will be affected.

One solution is to move babel-polyfills to the monorepo. I am investigating how to specify the resolutions so that the build deps are not affected.

@JLHwung JLHwung force-pushed the add-opera_mobile-compat-data branch from c4be578 to 90e94a1 Compare June 27, 2023 18:03
@babel-bot
Copy link
Collaborator

babel-bot commented Jun 27, 2023

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

@JLHwung JLHwung force-pushed the add-opera_mobile-compat-data branch from eae3bec to 19ddaf6 Compare June 27, 2023 18:59
@@ -37,6 +37,7 @@ Object {
"ios": "10.3.0",
"node": "13.2.0",
"opera": "48.0.0",
"opera_mobile": "73.0.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although op_mob is set to 45, op_mob 45 is still an unknown browser for browserslist, so it is resolved to opera_mobile 73.0.0. This probably won't affect end users unless they use esmodules: "intersect" with opera_mobile only queries.

Copy link
Member

Choose a reason for hiding this comment

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

It's unfortunate, but it's probably the best we can do.

Copy link

Choose a reason for hiding this comment

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

This probably won't affect end users unless they use esmodules:

This statement is a bit concerning to me, but I don't really understand the restriction. Could you explain further? Is there a tweak to browserslist that could alleviate it?

Copy link
Contributor Author

@JLHwung JLHwung Jul 3, 2023

Choose a reason for hiding this comment

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

If you are using esmodules: true, the "opera_mobile": "73.0.0" here is no op because Opera mobile 73 should cover every features implemented by other old browsers listed here such as Firefox 60 and Chrome 61.

If you want to fix this in browerslist, the upstream library https://github.com/browserslist/caniuse-lite should contain every opera mobile versions, so browserslist can actually resolve op_mob 45 to opera mobile 45. Currently it throws unknown version.

Copy link
Member

Choose a reason for hiding this comment

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

Is my understanding that this is not a regression introduced by this PR correct? And the old babel behavior was to just map opera mobile to opera desktop, which also had wrong results since the mapping was wrong.

Copy link

Choose a reason for hiding this comment

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

It's a bug fix with no regression IMO:

  • With current Babel and browserslist < 4.20.9, Babel and browserslist essentially had the same incorrect assumption of equating the two. The net effect was sort of just ignoring Opera Mobile as an independent target.
  • With current Babel and 4.20.9, Babel is doing some extra transpiling for any target that includes op_mob from browserslist
  • With this PR and 4.20.9, the extra transpiling goes away

I cannot think of a query at the moment that would result in any sort of regression or breakage.

@JLHwung JLHwung force-pushed the add-opera_mobile-compat-data branch from b958bb3 to b4a87a9 Compare June 29, 2023 13:08
@@ -0,0 +1,27 @@
diff --git a/lib/options.js b/lib/options.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.

We can remove this patch once @babel/helper-compilation-targets is published and @babel/helper-define-polyfill-provider updates its dependency.

@JLHwung JLHwung force-pushed the add-opera_mobile-compat-data branch from b4a87a9 to 72ecd77 Compare July 3, 2023 15:15
@@ -37,6 +37,7 @@ Object {
"ios": "10.3.0",
"node": "13.2.0",
"opera": "48.0.0",
"opera_mobile": "73.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

It's unfortunate, but it's probably the best we can do.

@JLHwung JLHwung force-pushed the add-opera_mobile-compat-data branch from e211122 to f0622bf Compare July 3, 2023 20:54
@nicolo-ribaudo nicolo-ribaudo merged commit e8c596c into babel:main Jul 4, 2023
54 of 55 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the add-opera_mobile-compat-data branch July 4, 2023 05:10
@ZeeshanTamboli ZeeshanTamboli mentioned this pull request Jul 12, 2023
1 task
@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 Oct 4, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 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 pkg: compat-data PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Opera mobile equated to Opera desktop in preset-env
5 participants