How to use the @babel/preset-env 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 wojtkowiak / meteor-desktop / lib / electronApp.js View on Github external
async transpileAndMinify() {
        this.log.info('transpiling and uglifying');

        const settings = this.$.desktop.getSettings();
        const options = 'uglifyOptions' in settings ? settings.uglifyOptions : {};

        const uglifyingEnabled = 'uglify' in settings && !!settings.uglify;

        const preset = presetEnv({ assertVersion: () => { } }, { targets: { node: '12' } });

        const { data: files } = await this.$.utils.readDir(this.$.env.paths.desktopTmp.root);

        files.forEach((file) => {
            if (file.endsWith('.js')) {
                let { code } = transformFileSync(file, {
                    presets: [preset]
                });
                let error;
                if (settings.env === 'prod' && uglifyingEnabled) {
                    ({ code, error } = uglify.minify(code, options));
                }
                if (error) {
                    throw new Error(error);
                }
                fs.writeFileSync(file, code);
github parcel-bundler / parcel / packages / transformers / babel / src / env.js View on Github external
function getNeededPlugins(targets: BabelTargets): Array {
  return presetEnv(
    {assertVersion: () => true},
    {targets: targets},
  ).plugins.filter(p => p[0]);
}