How to use the core-js-compat/get-modules-list-for-target-version function in core-js-compat

To help you get started, we’ve selected a few core-js-compat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github babel / babel / packages / babel-preset-env / src / polyfills / corejs3 / entry-plugin.js View on Github external
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 = {
github babel / babel / packages / babel-preset-env / src / polyfills / corejs3 / usage-plugin.js View on Github external
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;

core-js-compat

core-js compat

MIT
Latest version published 9 days ago

Package Health Score

94 / 100
Full package analysis