Fix esmodule: "intersect" on iOS versions (#12996)

This commit is contained in:
Huáng Jùnliàng 2021-03-12 16:14:00 -05:00 committed by GitHub
parent bc856e03c2
commit 71417bbfcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 4 deletions

View File

@ -9,9 +9,10 @@
"opera": "48", "opera": "48",
"op_mob": "48", "op_mob": "48",
"safari": "10.1", "safari": "10.1",
"ios_saf": "10.3", "ios": "10.3",
"samsung": "8.2", "samsung": "8.2",
"android": "61", "android": "61",
"electron": "2.0" "electron": "2.0",
"ios_saf": "10.3"
} }
} }

View File

@ -8,7 +8,7 @@ const { addElectronSupportFromChromium } = require("./chromium-to-electron");
const browserNameMap = { const browserNameMap = {
chrome_android: "and_chr", chrome_android: "and_chr",
firefox_android: "and_ff", firefox_android: "and_ff",
safari_ios: "ios_saf", safari_ios: "ios",
nodejs: "node", nodejs: "node",
webview_android: "android", webview_android: "android",
opera_android: "op_mob", opera_android: "op_mob",
@ -58,8 +58,13 @@ function process(source) {
} }
const dataPath = path.join(__dirname, "../data/native-modules.json"); const dataPath = path.join(__dirname, "../data/native-modules.json");
const processed = process(compatData.statements.export);
// Todo(Babel 8): remove `ios_saf` as it is identical to ios
if (processed.ios) {
processed.ios_saf = processed.ios;
}
const data = { const data = {
"es6.module": process(compatData.statements.export), "es6.module": processed,
}; };
fs.writeFileSync(dataPath, `${JSON.stringify(data, null, 2)}\n`); fs.writeFileSync(dataPath, `${JSON.stringify(data, null, 2)}\n`);
exports.process = process; exports.process = process;

View File

@ -7,6 +7,12 @@ Object {
} }
`; `;
exports[`getTargets esmodules can be intersected with ios browsers option 1`] = `
Object {
"ios": "12.0.0",
}
`;
exports[`getTargets esmodules can be intersected with the browsers option 1`] = ` exports[`getTargets esmodules can be intersected with the browsers option 1`] = `
Object { Object {
"chrome": "70.0.0", "chrome": "70.0.0",

View File

@ -245,6 +245,15 @@ describe("getTargets", () => {
).toMatchSnapshot(); ).toMatchSnapshot();
}); });
it("can be intersected with ios browsers option", () => {
expect(
getTargets({
esmodules: "intersect",
browsers: ["ios >= 12"],
}),
).toMatchSnapshot();
});
it("can be intersected with a .browserslistrc file", () => { it("can be intersected with a .browserslistrc file", () => {
expect( expect(
getTargets( getTargets(