How to use the @babel/preset-env/lib/targets-parser.default function in @babel/preset-env

To help you get started, we’ve selected a few @babel/preset-env 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 / ember-cli-babel / index.js View on Github external
_getTargets() {
    let targets = this.project && this.project.targets;

    let parser = require('@babel/preset-env/lib/targets-parser').default;
    if (typeof targets === 'object' && targets !== null) {
      return parser(targets);
    } else {
      return targets;
    }
  },
github chialab / rna-cli / lib / Targets.js View on Github external
toObject() {
        return targetsParser({ browsers: this.toQuery() });
    }
github vuejs / vue-cli / packages / @vue / babel-preset-app / index.js View on Github external
function getPolyfills (targets, includes, { ignoreBrowserslistConfig, configPath }) {
  const { isPluginRequired } = require('@babel/preset-env')
  const builtInsList = require('core-js-compat/data')
  const getTargets = require('@babel/preset-env/lib/targets-parser').default
  const builtInTargets = getTargets(targets, {
    ignoreBrowserslistConfig,
    configPath
  })

  return includes.filter(item => {
    return isPluginRequired(builtInTargets, builtInsList[item])
  })
}
github nuxt / nuxt.js / packages / babel-preset-app / src / index.js View on Github external
function getPolyfills (targets, includes, { ignoreBrowserslistConfig, configPath, corejs }) {
  const { isPluginRequired } = require('@babel/preset-env')
  const builtInsList = require(coreJsMeta[corejs.version].builtIns)
  const getTargets = require('@babel/preset-env/lib/targets-parser').default
  const builtInTargets = getTargets(targets, {
    ignoreBrowserslistConfig,
    configPath
  })

  return includes.filter(item => isPluginRequired(builtInTargets, builtInsList[item]))
}
github chialab / rna-cli / lib / Targets.js View on Github external
static parse(query) {
        if (query === 'esmodules') {
            let list = targetsParser({ esmodules: true });
            query = Object.keys(list).map((browser) => `${browser} ${list[browser].replace(/(\.0)*$/, '')}`).join(', ');
        } else if (query === 'node') {
            let list = targetsParser({ node: true });
            query = Object.keys(list).map((browser) => `${browser} ${list[browser].replace(/(\.0)*$/, '')}`).join(', ');
        } else if (Array.isArray(query)) {
            query = query.join(', ');
        } else if (typeof query === 'object') {
            query = Object.keys(query).map((browser) => `${browser} ${query[browser]}`).join(', ');
        }

        return new Targets(query);
    }