diff --git a/CHANGELOG.md b/CHANGELOG.md index d57db931c27f..48f5bd94a98e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/core-js-compat/compat.js b/packages/core-js-compat/compat.js index 29dc918f51be..57fb88f87ff8 100644 --- a/packages/core-js-compat/compat.js +++ b/packages/core-js-compat/compat.js @@ -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([ @@ -22,6 +23,7 @@ const validTargets = new Set([ 'ios', 'node', 'opera', + 'opera_mobile', 'phantom', 'safari', 'samsung', diff --git a/packages/core-js-compat/src/build-data.js b/packages/core-js-compat/src/build-data.js index 138ebd372a99..b51ee36529a9 100644 --- a/packages/core-js-compat/src/build-data.js +++ b/packages/core-js-compat/src/build-data.js @@ -6,6 +6,7 @@ const data = require('./data'); const { ChromeToNode, ChromeToSamsung, + ChromeToOperaMobile, ChromeToAndroid, ChromeToElectron, SafariToIOS, @@ -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; } } @@ -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'); } diff --git a/packages/core-js-compat/src/mapping.js b/packages/core-js-compat/src/mapping.js index 9f5a321ec201..6da1acaa344b 100644 --- a/packages/core-js-compat/src/mapping.js +++ b/packages/core-js-compat/src/mapping.js @@ -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'],