Skip to content

preset-env: use Chromium versions for Chromium-based browsers#8552

Open
ylemkimon wants to merge 4 commits intobabel:masterfrom
ylemkimon:preset-env-chromium
Open

preset-env: use Chromium versions for Chromium-based browsers#8552
ylemkimon wants to merge 4 commits intobabel:masterfrom
ylemkimon:preset-env-chromium

Conversation

@ylemkimon
Copy link
Copy Markdown
Contributor

@ylemkimon ylemkimon commented Aug 27, 2018

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

@babel/preset-env only uses Android, Chrome, Edge, Firefox, IE, iOS, Safari, Node versions for detecting which transforms to include:

const browserNameMap = {
android: "android",
chrome: "chrome",
and_chr: "chrome",
edge: "edge",
firefox: "firefox",
ie: "ie",
ios_saf: "ios",
safari: "safari",
node: "node",
};

and silently ignores other browsers:

const normalizedBrowserName = browserNameMap[browserName];
if (!normalizedBrowserName) {
return all;
}

However, there are local-popular or manufacturer-specific browsers such as Opera Mini, UC browser, QQ browser, Baidu browser, and Samsung Internet. Please see browserslist/browserslist#250 for their importance.

In Browserslist default, 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 but is in Browserslist default) acts as a stopgap preventing from excluding transform needed for old browsers. However, if user excludes them, they become dead, or their usage drops, preset-env will recognize as if it targets very modern browsers. Also, user may explicitly target them, using Browserslist config.

For Chromium-based browsers, we can use their base Chromium versions to detect features, like electron-to-chromium, as a best-effort basis. This PR adds a mapping for versions that are/were provided by caniuse, of Samsung Internet and UC Browser for Android, which is popular in Samsung devices and China, respectively.

"samsung 4": "44",
"samsung 5": "51",
"samsung 6.2": "56",
"samsung 7.2": "59",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also "samsung 3": "38"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@chicoxyzzy caniuse added Samsung Internet starting with samsung 4: Fyrd/caniuse@16d76e4. Therefore browserslist never returns samsung 3.

@zloirock
Copy link
Copy Markdown
Member

Feel free to add a mapping for those browsers to core-js-compat and compat-table (Samsung Internet already added) and it will be added to babel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Samsung Internet browser

3 participants