use a Set

This commit is contained in:
Henry Zhu 2017-04-06 11:59:41 -04:00
parent a48cf8b53f
commit 88d4df437e
2 changed files with 6 additions and 3 deletions

View File

@ -243,7 +243,10 @@ export default function buildPreset(context, opts = {}) {
);
if (useBuiltIns === true) {
plugins.push([addUsedBuiltInsPlugin, { polyfills, regenerator, debug }]);
plugins.push([
addUsedBuiltInsPlugin,
{ polyfills: new Set(polyfills), regenerator, debug },
]);
} else if (useBuiltIns === "entry") {
plugins.push([useBuiltInsEntryPlugin, { polyfills, regenerator }]);
}

View File

@ -38,12 +38,12 @@ export default function({ types: t }) {
function addUnsupported(path, polyfills, builtIn, builtIns) {
if (Array.isArray(builtIn)) {
for (const i of builtIn) {
if (polyfills.indexOf(i) !== -1) {
if (polyfills.has(i)) {
addImport(path, `core-js/modules/${i}`, builtIns);
}
}
} else {
if (polyfills.indexOf(builtIn) !== -1) {
if (polyfills.has(builtIn)) {
addImport(path, `core-js/modules/${builtIn}`, builtIns);
}
}