How to use the @babel/preset-env.isPluginRequired 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 sebastian-software / babel-preset-edge / src / parts / async.js View on Github external
export default function async(presets, plugins, options) {
  // Directly ask babel-preset-env whether we want to use transform-async
  // based on currently configured targets. Only if that's the case we
  // transform our async/await code. Otherwise we assume it works without
  // any transpilation.
  const requiresAsync = isPluginRequired(
    getTargets(getEnvTargets(options)),
    envPlugins["transform-async-to-generator"]
  )

  // Alternative to Babel Regenerator
  // Implements the ES7 keywords async and await using syntax transformation
  // to at Promises at compile-time, rather than using generators.
  // https://github.com/babel/babel/pull/7076 (NEW: bundled plugin with Babel)
  // https://www.npmjs.com/package/fast-async (OLD: separate Babel plugin)
  if (requiresAsync) {
    plugins.push(fastAsyncPlugin)
  }

  if (options.debug) {
    console.log("- Async/Await Transpilation:", requiresAsync)
  }
github babel / ember-cli-babel / index.js View on Github external
isPluginRequired(pluginName) {
    let targets = this._getTargets();

    // if no targets are setup, assume that all plugins are required
    if (!targets) { return true; }

    const isPluginRequired = require('@babel/preset-env').isPluginRequired;
    const pluginList = require('@babel/preset-env/data/plugins');

    return isPluginRequired(targets, pluginList[pluginName]);
  },
github nuxt / nuxt.js / packages / babel-preset-app / src / index.js View on Github external
  return includes.filter(item => isPluginRequired(builtInTargets, builtInsList[item]))
}
github vuejs / vue-cli / packages / @vue / babel-preset-app / index.js View on Github external
return includes.filter(item => {
    return isPluginRequired(builtInTargets, builtInsList[item])
  })
}