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

chore: map mobile browser data to their desktop version #10814

Merged
merged 4 commits into from Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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