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

Provide mapping to Chromium versions for Chromium-based browsers #290

Closed
ylemkimon opened this issue Aug 26, 2018 · 6 comments
Closed

Provide mapping to Chromium versions for Chromium-based browsers #290

ylemkimon opened this issue Aug 26, 2018 · 6 comments

Comments

@ylemkimon
Copy link

ylemkimon commented Aug 26, 2018

Most tools use only major browsers version to detect features. For instance, Babel (babel-preset-env) only uses Android, Chrome, Edge, Firefox, IE, iOS, Safari, Node versions for detecting which transforms to include. (babel/babel/packages/babel-preset-env/src/targets-parser.js#L32-L42).

However, there are local-popular or manufacturer-specific browsers (see #250 for their importance) such as QQ browser, Baidu browser, UC browser, Samsung Internet, which are based on rather old Chromium and rarely update its version:

  • QQ: I'm not sure which version caniuse refers to, but latest version 8.7 is based on 57
  • Baidu: 7.12 based on 48, but its user-agent string suggests it may be a WebView wrapper
  • UC: 11.8 based on 57
  • Samsung: 7 based on 59

Fortunately, IE 11, Chrome 49 (usage 0.69%) and Android 4.x (4.4 usage 0.58%, 4.4.4 isn't strictly last 2 versions) acts as a stopgap preventing from excluding transform needed for old browsers. However, if user excludes them, they become dead, or their usage drops, they'll recognize as if it targets very modern browsers.

Proposal

I think Browserslist should:

  • maintain a mapping from their versions to Chromium version, like electron-to-chromium
    • Also possibly Opera
  • provide a mapToChromium options which adds or substitutes with corresponding Chrome versions.

For example, browserslist('baidu 7.12', {mapToChromium: true}) returns ['baidu 7.12', 'chrome 48'] or ['chrome 48'].

I'm willing to open a PR.

Alternative

I thought about creating another package for version mappings, but as there are only 7 versions of them caniuse provides, and as there is no reliable source other than user agent strings collected by analytic companies, it needs community contribution. (Only reliable source I can find is Samsung Internet release notes, but even it doesn't have latest versions.)

@ai
Copy link
Member

ai commented Aug 26, 2018

Hm, never thought that Babel just ignore others browsers 😣 In Autoprefixer and other PostCSS plugins we uses Can I Use and support all Browserslist’s browsers.

I am not sure that we need to change Browserslist if it is a Babel problem. Maybe we can just add browser to chrome convector to Babel?

@ylemkimon
Copy link
Author

@ai Babel (and possibly eslint-plugin-compat in the future) uses Kangax compatibility table, which doesn't provide data for those browsers. (compat-table/compat-table#1001, compat-table/compat-table#1247) I've opened an issue at babel/babel#8545 to request a feature to warn about them. But for Chromium-based browsers, I think it's better for upstream (Browserslist) to provide a mapping to Chromium versions, as it already has electron-to-chromium, it has to stay up-to-date with caniuse data, and other users and tools can use it.

@ai
Copy link
Member

ai commented Aug 27, 2018

There is one problem with adding this mapping to Browserslist. In case of Babel QQ works same as Chrome. But in case of other feature (like payment API) it could work in different way.

So with adding it to Browserslist we will make Babel/Kangax life easier, but in other hand we will make life much harder for other Browserslist’s users (like ESLint plugin which will warn you if some of your target browsers don't support JS API).

This is why I think that main problem here is Kangax. I will upvote your issue.

@ylemkimon
Copy link
Author

@ai I think we can make the new option false by default and add the caveat to the options documentation. But I share your concerns and opened babel/babel#8552. Thank you!

@ai
Copy link
Member

ai commented Aug 27, 2018

If we will have this mapping data, patching Kagnax will be very easy. And it will keep Browserslist API free from hacks and avoid other Kangax non-Browserslist users from making the same mistake of ignoring non-white browsers.

Why you think you should use it here, but not in Kagnax?

@ai
Copy link
Member

ai commented Oct 13, 2018

I am closing it since nobody decided to create a data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants