Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function(
_: any,
{ corejs, include, exclude, polyfillTargets, debug }: InternalPluginOptions,
) {
const polyfills = filterItems(
corejs3Polyfills,
include,
exclude,
polyfillTargets,
null,
);
const available = new Set(getModulesListForTargetVersion(corejs.version));
function shouldReplace(source, modules) {
if (!modules) return false;
if (
// Don't replace an import with itself to avoid an infinite loop
modules.length === 1 &&
polyfills.has(modules[0]) &&
available.has(modules[0]) &&
getModulePath(modules[0]) === source
) {
return false;
}
return true;
}
const isPolyfillImport = {
debug,
}: InternalPluginOptions,
) {
const polyfills = filterItems(
proposals
? corejs3Polyfills
: shippedProposals
? corejs3PolyfillsWithShippedProposals
: corejs3PolyfillsWithoutProposals,
include,
exclude,
polyfillTargets,
null,
);
const available = new Set(getModulesListForTargetVersion(corejs.version));
function resolveKey(path, computed) {
const { node, parent, scope } = path;
if (path.isStringLiteral()) return node.value;
const { name } = node;
const isIdentifier = path.isIdentifier();
if (isIdentifier && !(computed || parent.computed)) return name;
if (!isIdentifier || scope.getBindingIdentifier(name)) {
const { value } = path.evaluate();
if (typeof value === "string") return value;
}
}
function resolveSource(path) {
const { node, scope } = path;
let builtIn, instanceType;