Skip to content

Commit

Permalink
chore: map mobile browser data to their desktop version (#10814)
Browse files Browse the repository at this point in the history
* chore: map mobile browser data to their desktop version

* chore: skip android until upstream support is resolved

* Revert "chore: skip android until upstream support is resolved"

This reverts commit 436e9af.

* Update fixtures

Co-authored-by: Nicol貌 Ribaudo <nicolo.ribaudo@gmail.com>
  • Loading branch information
JLHwung and nicolo-ribaudo committed Jan 24, 2020
1 parent 1815c34 commit b54a946
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
7 changes: 5 additions & 2 deletions packages/babel-compat-data/data/built-in-modules.json
Expand Up @@ -6,7 +6,10 @@
"safari": "10.1",
"opera": "48",
"ios_saf": "10.3",
"and_chr": "71",
"and_ff": "64"
"android": "61",
"op_mob": "48",
"and_chr": "61",
"and_ff": "60",
"samsung": "8.2"
}
}
34 changes: 19 additions & 15 deletions packages/babel-compat-data/scripts/build-modules-support.js
Expand Up @@ -3,29 +3,33 @@ const fs = require("fs");

const moduleSupport = require("caniuse-db/features-json/es6-module.json");

const skipList = new Set(["android", "samsung"]);
const acceptedWithCaveats = new Set(["safari", "ios_saf"]);

const browserNameMap = {
and_chr: "chrome",
and_ff: "firefox",
android: "chrome", // map to chrome here as Android WebView 61 is Chromium-based
op_mob: "opera",
};
const { stats } = moduleSupport;

const allowedBrowsers = {};

Object.keys(stats).forEach(browser => {
if (!skipList.has(browser)) {
const browserVersions = stats[browser];
const allowedVersions = Object.keys(browserVersions)
.filter(value => {
// Edge 16/17 are marked as "y #6"
return acceptedWithCaveats.has(browser)
? browserVersions[value][0] === "a"
: browserVersions[value].startsWith("y");
})
.sort((a, b) => a - b);
const browserName = browserNameMap[browser] || browser;
const browserVersions = stats[browserName];
const allowedVersions = Object.keys(browserVersions)
.filter(value => {
// Edge 16/17 are marked as "y #6"
return acceptedWithCaveats.has(browserName)
? browserVersions[value][0] === "a"
: browserVersions[value].startsWith("y");
})
.sort((a, b) => a - b);

if (allowedVersions[0] !== undefined) {
// Handle cases where caniuse specifies version as: "11.0-11.2"
allowedBrowsers[browser] = allowedVersions[0].split("-")[0];
}
if (allowedVersions[0] !== undefined) {
// Handle cases where caniuse specifies version as: "11.0-11.2"
allowedBrowsers[browser] = allowedVersions[0].split("-")[0];
}
});

Expand Down

0 comments on commit b54a946

Please sign in to comment.