Skip to content

Commit

Permalink
add Opera Mobile compat data
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 6, 2019
1 parent b7126f7 commit 10d2211
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Changelog
##### Unreleased
- Added Opera Mobile compat data
- Generate `core-js-compat/modules` since often we need just the list of `core-js` modules

##### 3.4.7 - 2019.12.03
Expand Down
2 changes: 2 additions & 0 deletions packages/core-js-compat/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const mapping = new Map([
['and_ff', 'firefox'],
['ie_mob', 'ie'],
['ios_saf', 'ios'],
['op_mob', 'opera_mobile'],
]);

const validTargets = new Set([
Expand All @@ -22,6 +23,7 @@ const validTargets = new Set([
'ios',
'node',
'opera',
'opera_mobile',
'phantom',
'safari',
'samsung',
Expand Down
8 changes: 7 additions & 1 deletion packages/core-js-compat/src/build-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const data = require('./data');
const {
ChromeToNode,
ChromeToSamsung,
ChromeToOperaMobile,
ChromeToAndroid,
ChromeToElectron,
SafariToIOS,
Expand All @@ -20,7 +21,7 @@ for (const [key, module] of Object.entries(data)) {
const source = semver(version);
for (const [from, to] of mapping) {
if (compare(source, '<=', from)) {
module[targetKey] = to;
module[targetKey] = String(to);
return;
}
}
Expand All @@ -37,6 +38,11 @@ for (const [key, module] of Object.entries(data)) {
if (!module.opera) {
module.opera = String(chrome <= 23 ? 15 : chrome <= 29 ? 16 : chrome - 13);
}
if (!module.opera_mobile && module.opera && module.opera <= 42) {
module.opera_mobile = module.opera;
} else {
map(ChromeToOperaMobile, chrome, 'opera_mobile');
}
if (key.startsWith('es')) {
map(ChromeToNode, chrome, 'node');
}
Expand Down
15 changes: 15 additions & 0 deletions packages/core-js-compat/src/mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ module.exports = {
[67, '9.2'],
[71, '10.2'],
],
ChromeToOperaMobile: [
[59, 43],
[60, 44],
[61, 45],
[63, 46],
[66, 47],
[69, 48],
[70, 49],
[71, 50],
[72, 51],
[73, 52],
[74, 53],
[76, 54],
[77, 55],
],
ChromeToAndroid: [
[30, '4.4'],
[33, '4.4.3'],
Expand Down

0 comments on commit 10d2211

Please sign in to comment.