Skip to content

Commit

Permalink
Fix esmodule: "intersect" on iOS versions (#12996)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Mar 12, 2021
1 parent bc856e0 commit 71417bb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/babel-compat-data/data/native-modules.json
Expand Up @@ -9,9 +9,10 @@
"opera": "48",
"op_mob": "48",
"safari": "10.1",
"ios_saf": "10.3",
"ios": "10.3",
"samsung": "8.2",
"android": "61",
"electron": "2.0"
"electron": "2.0",
"ios_saf": "10.3"
}
}
9 changes: 7 additions & 2 deletions packages/babel-compat-data/scripts/build-modules-support.js
Expand Up @@ -8,7 +8,7 @@ const { addElectronSupportFromChromium } = require("./chromium-to-electron");
const browserNameMap = {
chrome_android: "and_chr",
firefox_android: "and_ff",
safari_ios: "ios_saf",
safari_ios: "ios",
nodejs: "node",
webview_android: "android",
opera_android: "op_mob",
Expand Down Expand Up @@ -58,8 +58,13 @@ function process(source) {
}

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 = {
"es6.module": process(compatData.statements.export),
"es6.module": processed,
};
fs.writeFileSync(dataPath, `${JSON.stringify(data, null, 2)}\n`);
exports.process = process;
Expand Up @@ -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`] = `
Object {
"chrome": "70.0.0",
Expand Down
Expand Up @@ -245,6 +245,15 @@ describe("getTargets", () => {
).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", () => {
expect(
getTargets(
Expand Down

0 comments on commit 71417bb

Please sign in to comment.