Skip to content

Commit

Permalink
some stylistic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 20, 2019
1 parent edf8bbf commit ebddf97
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions packages/core-js-compat/targets-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,23 @@ const validTargets = new Set([
'samsung',
]);

function browserslistEntries(targets) {
return browserslist(targets).map(it => it.split(' '));
}

module.exports = function (targets) {
let list;
if (typeof targets == 'object' && !Array.isArray(targets)) {
const { esmodules, browsers, node, ...rest } = targets;
list = Object.entries(rest);
if (esmodules) {
list = list.concat(Object.entries(external.modules));
}
if (browsers) {
list = list.concat(browserslistEntries(browsers));
}
if (node) {
list.push(['node', node === 'current' ? process.versions.node : node]);
}
} else list = browserslistEntries(targets);
if (typeof targets !== 'object' || Array.isArray(targets)) {
targets = { browsers: targets };
}

const { browsers, esmodules, node, ...rest } = targets;
const list = Object.entries(rest);

if (browsers) {
list.push(...browserslist(browsers).map(it => it.split(' ')));
}
if (esmodules) {
list.push(...Object.entries(external.modules));
}
if (node) {
list.push(['node', node === 'current' ? process.versions.node : node]);
}

const normalized = list.map(([engine, version]) => {
if (has(browserslist.aliases, engine)) {
Expand Down

0 comments on commit ebddf97

Please sign in to comment.