How to use babel-preset-env - 7 common examples

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 parcel-bundler / parcel / src / transforms / babel.js View on Github external
async function getEnvPlugins(targets, useBuiltIns = false) {
  if (!targets) {
    return null;
  }

  let key = JSON.stringify(targets);
  if (envCache.has(key)) {
    return envCache.get(key);
  }

  let plugins = presetEnv.default(
    {},
    {targets, modules: false, useBuiltIns: useBuiltIns ? 'entry' : false}
  ).plugins;

  // babel-preset-env version 6.x does not cover object-rest-spread so always
  // add it.
  plugins.push([
    require('babel-plugin-transform-object-rest-spread'),
    {useBuiltIns}
  ]);

  envCache.set(key, plugins);
  return plugins;
}
github DevExpress / testcafe / src / compiler / load-babel-libs.js View on Github external
export default function loadBabelLibs () {
    return {
        babel:                    require('babel-core'),
        presetStage2:             require('babel-preset-stage-2'),
        presetFlow:               require('babel-preset-flow'),
        transformClassProperties: require('babel-plugin-transform-class-properties'),
        transformRuntime:         require('babel-plugin-transform-runtime'),
        transformForOfAsArray:    require('babel-plugin-transform-for-of-as-array').default,
        presetFallback:           require('babel-preset-env').default(null, getOptsForPresetFallback()),
        presetEnv:                require('babel-preset-env').default(null, getOptsForPresetEnv())
    };
}
github DevExpress / testcafe / src / compiler / load-babel-libs.js View on Github external
export default function loadBabelLibs () {
    return {
        babel:                    require('babel-core'),
        presetStage2:             require('babel-preset-stage-2'),
        presetFlow:               require('babel-preset-flow'),
        transformClassProperties: require('babel-plugin-transform-class-properties'),
        transformRuntime:         require('babel-plugin-transform-runtime'),
        transformForOfAsArray:    require('babel-plugin-transform-for-of-as-array').default,
        presetFallback:           require('babel-preset-env').default(null, getOptsForPresetFallback()),
        presetEnv:                require('babel-preset-env').default(null, getOptsForPresetEnv())
    };
}
github Jigsaw-Code / outline-client / gulpfile.js View on Github external
function transpile(src, dest) {
  const sourcesHtmlSplitter = new polymer_build.HtmlSplitter();
  return gulp.src(src)
      .pipe(sourcesHtmlSplitter.split())
      .pipe(gulpif(/\.js$/, babel({presets: [babel_preset_env.default()]})))
      .pipe(sourcesHtmlSplitter.rejoin())
      .pipe(gulp.dest(dest));
}
github salesforce / design-system-react / preset / index.js View on Github external
module.exports = function buildPreset () {
	return {
		presets: [
			require('babel-preset-env').default(null, {
				targets: {
					browsers: ['last 2 versions', 'ie 11'],
					node: '8.9.4',
				},
				modules: false,
			}),
			require('babel-preset-react'),
		],
		plugins: [
			require('babel-plugin-transform-object-rest-spread'),
			require('babel-plugin-transform-class-properties'),
			require('babel-plugin-transform-export-extensions'),
		],
	};
};
github dadi / cdn / dadi / lib / handlers / js.js View on Github external
JSHandler.prototype.getBabelPluginsHash = function () {
  const babelOptions = this.getBabelEnvOptions(this.userAgent)
  const functions = babelPresetEnv(null, babelOptions).plugins.map(plugin => plugin[0])
  const hashSource = functions.reduce((result, functionSource) => {
    if (typeof functionSource === 'function') {
      return result + functionSource.toString()
    } else if (typeof functionSource.default === 'function') {
      return result + functionSource.default.toString()
    }

    return result
  }, '')
  const hash = farmhash.fingerprint64(hashSource)

  return hash
}
github NE-LOAN-FED / NE-Component / tools / es2015Preset.js View on Github external
const buildPreset = require('babel-preset-env').buildPreset

const BABEL_ENV = process.env.BABEL_ENV

module.exports = {
  presets: [
    [ buildPreset, {
      loose: true,
      modules: BABEL_ENV === 'es' ? false : 'commonjs'
    } ]
  ]
}

babel-preset-env

A Babel preset for each environment.

MIT
Latest version published 7 years ago

Package Health Score

58 / 100
Full package analysis

Popular babel-preset-env functions