const buildCjs = ({ env }) => ({
  input,
  external,
  output: {
    file: `./dist/${pkg.name}.cjs.${env}.js`,
    format: "cjs",
    sourcemap: true,
  },
  plugins: [
    resolve(),
    replace({
      "process.env.NODE_ENV": JSON.stringify(env),
    }),
    sourceMaps(),
    sizeSnapshot(),
    env === "production" &&
      terser({
        sourcemap: true,
        output: { comments: false },
        compress: {
          keep_infinity: true,
          pure_getters: true,
        },
        warnings: true,
        ecma: 5,
        // Compress and/or mangle variables in top level scope.
        // @see https://github.com/terser-js/terser
        toplevel: true,
      }),
  ],
});
Example #2
0
function getPlugins(
  entry,
  babelOpts,
  paths,
  filename,
  bundleType,
  isRenderer,
  manglePropertiesOnProd
) {
  const plugins = [
    replace(Modules.getDefaultReplaceModules(bundleType)),
    babel(updateBabelConfig(babelOpts, bundleType)),
    alias(
      Modules.getAliases(paths, bundleType, isRenderer, argv.extractErrors)
    ),
  ];
  switch (bundleType) {
    case UMD_DEV:
    case NODE_DEV:
    case FB_DEV:
    case RN_DEV:
      plugins.push(
        replace(stripEnvVariables(false)),
        // needs to happen after strip env
        commonjs(getCommonJsConfig(bundleType))
      );
      break;
    case UMD_PROD:
    case NODE_PROD:
    case FB_PROD:
    case RN_PROD:
      plugins.push(
        replace(stripEnvVariables(true)),
        // needs to happen after strip env
        commonjs(getCommonJsConfig(bundleType)),
        uglify(
          uglifyConfig(
            bundleType !== FB_PROD,
            manglePropertiesOnProd,
            bundleType === UMD_PROD
          )
        )
      );
      break;
  }
  // this needs to come last or it doesn't report sizes correctly
  plugins.push(
    sizes({
      getSize: (size, gzip) => {
        const key = `${filename} (${bundleType})`;
        Stats.currentBuildResults.bundleSizes[key] = {
          size,
          gzip,
        };
      },
    })
  );

  return plugins;
}
Example #3
0
function genConfig (opts) {
  const config = {
    input: {
      input: resolve('src/index.js'),
      plugins: [
        flow(),
        node(),
        cjs(),
        replace({
          __VERSION__: version
        }),
        buble()
      ]
    },
    output: {
      file: opts.file,
      format: opts.format,
      banner,
      name: 'VueRouter'
    }
  }

  if (opts.env) {
    config.input.plugins.unshift(replace({
      'process.env.NODE_ENV': JSON.stringify(opts.env)
    }))
  }

  return config
}
Example #4
0
function plugins (options = {}) {
  const plugins = [
    replace(options.replace),
    babel({
      runtimeHelpers: true,
      sourceMap: true,
      include: [
        'src/**/*',
      ],
    }),
    resolve({
      main: true,
      module: true,
      jsnext: true,
      browser: true,
    }),
    cjs(),
  ]
  if (options.min) {
    plugins.push(uglify({
      mangle: true,
      sourceMap: true,
      compress: {
        warnings: false,
      },
      output: {
        preamble: options.banner,
      },
    }))
  }
  return plugins
}
Example #5
0
File: build.js Project: smadey/ylib
.then(function () {
  // Standalone Production Build
  return rollup.rollup({
    entry: 'src/index.js',
    plugins: [
      replace({
        'process.env.NODE_ENV': "'production'"
      }),
      babel({
        presets: ['es2015-rollup', 'stage-2']
      })
    ]
  })
  .then(function (bundle) {
    var code = bundle.generate({
      format: 'umd',
      moduleName: 'y'
    }).code
    var minified = banner + '\n' + uglify.minify(code, {
      fromString: true,
      output: {
        ascii_only: true
      }
    }).code
    return write('dist/y.min.js', minified)
  })
  .then(zip)
})
Example #6
0
const build = function(opts) {
  rollup
    .rollup({
      input: opts.input,
      plugins: (opts.plugins || []).concat([
        buble(),
        commonjs(),
        nodeResolve(),
        replace({
          __VERSION__: version,
          'process.env.SSR': false
        })
      ])
    })
    .then(function(bundle) {
      var dest = 'lib/' + (opts.output || opts.input)

      console.log(dest)
      bundle.write({
        format: 'iife',
        file: dest,
        strict: false
      })
    })
    .catch(function(err) {
      console.error(err)
    })
}
Example #7
0
    .then(function () {
        return rollup.rollup({
                entry: "src/index.js",
                plugins: [
                    replace({
                        'process.env.NODE_ENV': "'production'"
                    }),
                    babel({
                        babelrc: false,
                        exclude: 'node_modules/**',
                        presets: [ "es2015-rollup" ]
                    })
                ]
            })
            .then(function (bundle) {
                var code = bundle.generate({
                    format: 'umd',
                    moduleName: 'WalnutValidator',
                    globals: {
                        jquery: 'jQuery'
                    }
                }).code;

                var minified = banner + '\n' + uglify.minify(code, {
                        fromString: true,
                        output: {
                            ascii_only: true
                        }
                    }).code;
                return write('dist/walnut-validator.min.js', minified);
            })
    })
Example #8
0
 .then(function() {
     // Standalone Production Build
     return rollup.rollup({
             entry: entry,
             plugins: [
                 replace({
                     'process.env.NODE_ENV': "'production'"
                 }),
                 babel({
                     loose: 'all'
                 })
             ]
         })
         .then(function(bundle) {
             var code = bundle.generate({
                 format: 'umd',
                 moduleName: 'React'
             }).code
             var minified = banner + '\n' + uglify.minify(code, {
                 fromString: true
             }).code
             return write('dist/' + filename + '.min.js', minified)
         })
         .then(zip)
 })
Example #9
0
 .then(function () {
     return rollup.rollup({
         entry: "src/index.js",
         plugins: [
             replace({
                 'process.env.NODE_ENV': "'production'"
             }),
             babel({
                 babelrc: false,
                 exclude: 'node_modules/**',
                 presets: [ "es2015-rollup" ]
             })
         ]
     })
         .then(function (bundle) {
             return write('dist/walnut-validator.js', bundle.generate({
                 format: 'umd',
                 moduleName: 'WalnutValidator',
                 banner: banner,
                 globals: {
                     jquery: 'jQuery'
                 }
             }).code)
         })
 })
Example #10
0
.then(function () {
  // Standalone Production Build
  return rollup.rollup({
    entry: 'src/index.js',
    plugins: [
      replace({
        'process.env.NODE_ENV': "'production'"
      }),
      babel({
        presets: ['es2015-loose-rollup']
      })
    ]
  })
  .then(function (bundle) {
    var code = bundle.generate({
      format: 'umd',
      moduleName: classify(pack.name)
    }).code
    var minified = banner + '\n' + uglify.minify(code, {
      fromString: true
    }).code
    return write('dist/' + pack.name + '.min.js', minified)
  })
  .then(zip)
})
const nodeUmdRollupConfigFactory = (isProduction) => {
  const nodeRollupConfig = {
    input: `dist-esm/${outputName}.js`,
    output: {
      file: `dist/${outputName}.js`,
      banner: banner,
      format: "umd",
      name: "Microsoft.ApplicationInsights",
      sourcemap: true
    },
    plugins: [
      replace({
        delimiters: ["", ""],
        values: {
          "// Copyright (c) Microsoft Corporation. All rights reserved.": "",
          "// Licensed under the MIT License.": ""
        }
      }),
      nodeResolve()
    ]
  };

  if (isProduction) {
    nodeRollupConfig.output.file = `dist/${outputName}.min.js`;
    nodeRollupConfig.plugins.push(
      uglify({
        output: {
          preamble: banner
        }
      })
    );
  }

  return nodeRollupConfig;
};
Example #12
0
 return Promise.all(versions.map(function (isBrowser) {
   return rollup({
     entry: path.resolve(filepath, './src/index.js'),
     external: depsToSkip,
     plugins: [
       nodeResolve({
         skip: depsToSkip,
         jsnext: true,
         browser: isBrowser || forceBrowser
       }),
       replace({
         // we have switches for coverage; don't ship this to consumers
         'process.env.COVERAGE': JSON.stringify(!!process.env.COVERAGE)
       })
     ]
   }).then(function (bundle) {
     var dest = isBrowser ? 'lib/index-browser.js' : 'lib/index.js';
     return bundle.write({
       format: 'cjs',
       dest: path.resolve(filepath, dest)
     }).then(function () {
       console.log('  \u2713' + ' wrote ' +
         path.basename(filepath) + '/' + dest + ' in ' +
           (isBrowser ? 'browser' :
           versions.length > 1 ? 'node' : 'vanilla') +
         ' mode');
     });
   });
 }));
Example #13
0
function generateBundledProd() {
  return rollup
    .rollup({
      entry: 'index.js',
      external: [ 'vue' ],
      plugins: [
        replace({
          'process.env.NODE_ENV': '\'production\'',
        }),
      ],
    })
    .then(function(bundle) {
      return bundle.generate({
        format: 'iife',
        moduleName: 'VueFocus',
        globals: { vue: 'Vue' },
      }).code;
    })
    .then(function(code) {
      return uglify.minify(code, {
        fromString: true,
        compress: {
          screw_ie8: true,
        },
      }).code;
    })
    .then(function(code) {
      return write('dist/vue-focus.min.js', code);
    }); 
}
const umdConfig = ({minify} = {}) => ({
  input: pkg.source,
  external: ['react', 'react-dom', 'prop-types'],
  output: {
    name: 'SortableHOC',
    file: minify ? pkg.browser.replace('.js', '.min.js') : pkg.browser,
    format: 'umd',
    globals: {
      react: 'React',
      'react-dom': 'ReactDOM',
      'prop-types': 'PropTypes',
    },
  },
  plugins: [
    resolve(),
    babel(
      babelConfig({
        targets: {browsers: ['last 2 versions', 'safari >= 7']},
      }),
    ),
    replace({
      'process.env.NODE_ENV': JSON.stringify(
        minify ? 'production' : 'development',
      ),
    }),
    commonjs(),
    minify && uglify(),
    filesize(),
  ],
});
Example #15
0
function umd(components, cb) {
  const config = getConfig();
  const env = process.env.NODE_ENV || 'development';
  const target = process.env.TARGET || config.target || 'universal';
  const format = process.env.FORMAT || config.format || 'umd';
  const output = getOutput();

  rollup.rollup({
    input: './src/core/framework7.js',
    cache,
    plugins: [
      replace({
        delimiters: ['', ''],
        'process.env.NODE_ENV': JSON.stringify(env), // or 'production'
        'process.env.TARGET': JSON.stringify(target),
        'process.env.FORMAT': JSON.stringify(format),
        '//IMPORT_COMPONENTS': components.map(component => `import ${component.capitalized} from './components/${component.name}/${component.name}';`).join('\n'),
        '//INSTALL_COMPONENTS': components.map(component => component.capitalized).join(',\n  '),
        '//ES_IMPORT_HELPERS': '',
        '//NAMED_ES_EXPORT': '',
      }),
      resolve({ jsnext: true }),
      commonjs(),
      buble(),
    ],
  }).then((bundle) => {
    cache = bundle;
    return bundle.write({
      strict: true,
      file: `${output}/js/framework7.js`,
      format: 'umd',
      name: 'Framework7',
      sourcemap: env === 'development',
      sourcemapFile: `${output}/js/framework7.js.map`,
      banner,
    });
  }).then(() => {
    if (env === 'development') {
      if (cb) cb();
      return;
    }
    // Minified version
    gulp.src(`${output}/js/framework7.js`)
      .pipe(sourcemaps.init())
      .pipe(uglify())
      .pipe(header(banner))
      .pipe(rename((filePath) => {
        filePath.basename += '.min';
      }))
      .pipe(sourcemaps.write('./'))
      .pipe(gulp.dest(`${output}/js/`))
      .on('end', () => {
        cb();
      });
  }).catch((err) => {
    if (cb) cb();
    console.log(err.toString());
  });
}
module.exports = function(grunt) {
    var babel = require('rollup-plugin-babel');
    var nodeResolve = require('rollup-plugin-node-resolve');
    var commonjs = require('rollup-plugin-commonjs');
    var riot = require('rollup-plugin-riot');
    var uglify = require('rollup-plugin-uglify');
    var ruReplace = require('rollup-plugin-replace');
    
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        watch: {
            client: {
                files: ['client/*.js', 'client/**/.tag'],
                tasks: ['build']
            }
        },

        rollup: {
            options: {
                entry: './client/app.js',

                plugins: [
                    riot(),

                    nodeResolve({
                        main: true,
                        jsnext: true,
                        browser: true
                    }),

                    ruReplace({
                        'process.env.NODE_ENV': JSON.stringify('production')
                    }),

                    commonjs(),

                    babel({
                        exclude: 'node_modules/**',
                        presets: ['es2015-rollup']
                    })//,

                    /*uglify({
                        wrap: true
                    })*/
                ]
            },

            files: {
                src: 'client/app.js',
                dest: 'assets/app.js'
            }
        }
    });

    grunt.loadNpmTasks('grunt-rollup');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.registerTask('build', ['rollup']);
};
const rollupPluginFactory = async () =>  {
  const vue = await vueWarpper()
  return [  // resolve
  aliasPlugin({
    resolve: ['.js', '.json', '/index.js', '.css', '.vue', '.svg'], // @TODO '/index.js' hack
    'mand-mobile/components': resolve('components'),
    'mand-mobile/lib': resolve('lib'),
    'mand-mobile': resolve('components'),
    '@examples/assets/images/bank-zs.svg': resolve('examples/assets/images/bank-zs.svg'),
    '@examples/assets/images/tip-package.svg': resolve('examples/assets/images/tip-package.svg')
  }),
  nodeResolvePlugin({
    extensions: [ '.js', '.json', '.vue' ],
  }),

  common({
    include: 'node_modules/**',
  }),

  // inject
  replacePlugin({
    'process.env.NODE_ENV': `"${process.env.NODE_ENV}"`,
    'MAN_VERSION': `"${pkg.version}"`
  }),
  svgSpritePlugin(),
  // resource
  urlPlugin({
    limit: 10 * 1024,
  }),
  jsonPlugin(),
  ...vue,
  stylusCompilerPlugin({
    fn: stylusMixin,
  }),
  postcss({
    config: {
      path: resolve('postcss.config.js')
    }
  }),
  babel(babelrc({
    addModuleOptions: false,
    findRollupPresets: true,
    addExternalHelpersPlugin: false,
  })),

  // dest
  uglify({
    compress: {},
  }),
  fillHtmlPlugin({
    template: resolve('examples/index.html'),
    // publicPath: '/mand-mobile/examples/',
    publicPath: '/mand-mobile/examples/',
    destFile: path.resolve(EXAMPLE_OUTPUT_DIR, 'index.html')
  }),
  // cli
  progress(),
  filesize(),
]}
const plugins = () => basePlugins().concat(
    replace({
        'process.env.BENCHMARK_VERSION': JSON.stringify(process.env.BENCHMARK_VERSION),
        'process.env.MAPBOX_ACCESS_TOKEN': JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN),
        'process.env.MapboxAccessToken': JSON.stringify(process.env.MapboxAccessToken),
        'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
    })
);
const plugins = () => basePlugins().concat(
    replace({
        'process.env.BENCHMARK_VERSION': JSON.stringify(process.env.BENCHMARK_VERSION),
        'process.env.MAPBOX_ACCESS_TOKEN': JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN),
        'process.env.MapboxAccessToken': JSON.stringify(process.env.MapboxAccessToken),
        // should we rewrite this as 'production' if BUILD==='production'?
        'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
    })
);
Example #20
0
function build(cb) {
  const env = process.env.NODE_ENV || 'development';
  const target = process.env.TARGET || 'universal';
  const f7VuePath = env === 'development'
    ? '../src/framework7-vue'
    : '../dist/framework7-vue.esm.js';
  const components = getComponents();

  const IMPORT_PLUGIN = 'import VuePlugin from \'./vue-plugin.js\';';
  const IMPORT_COMPONENTS = components.map(c => `import ${c.name} from './components/${c.file}';`).join('\n');
  const EXPORT = `
export {
  ${components.map(c => `${c.name},`).join('\n  ')}
};
export default VuePlugin;

  `.trim();

  rollup.rollup({
    input: './kitchen-sink/src/app.js',
    cache,
    plugins: [
      replace({
        delimiters: ['', ''],
        'process.env.NODE_ENV': JSON.stringify(env), // or 'production'
        'process.env.TARGET': JSON.stringify(target),
        "'framework7-vue'": () => `'${path.resolve(__dirname, f7VuePath).replace(/\\/g, '/')}'`,
        IMPORT_PLUGIN,
        IMPORT_COMPONENTS,
        EXPORT,
        IMPORT_COMPONENTS_BUNDLE: '',
        REGISTER_COMPONENTS_BUNDLE: '',
      }),
      resolve({ jsnext: true }),
      commonjs(),
      vue(),
      buble(),
    ],
  }).then((bundle) => {
    cache = bundle;
    return bundle.write({
      format: 'umd',
      name: 'app',
      strict: true,
      sourcemap: false,
      cache,
      file: './kitchen-sink/js/app.js',
    });
  }).then(() => {
    if (cb) cb();
  }).catch((err) => {
    if (cb) cb();
    console.log(err.toString());
  });
}
const buildUmd = ({ env }) => ({
  input,
  external: ["react", "react-native"],
  output: {
    name: "ReactFuzzyFilter",
    format: "umd",
    sourcemap: true,
    file: `./dist/react-fuzzy-filter.umd.${env}.js`,
    exports: "named",
    globals: {
      react: "React",
      "react-native": "ReactNative",
    },
  },

  plugins: [
    rollupAlias({
      valoo: 'valoo/dist/valoo'
    }),
    resolve(),
    babel(babelOptions),
    replace({
      "process.env.NODE_ENV": JSON.stringify(env),
    }),
    commonjs({
      include: /node_modules/,
      namedExports: {
        "node_modules/prop-types/index.js": [
          "object",
          "oneOfType",
          "string",
          "node",
          "func",
          "bool",
          "element",
        ],
      },
    }),
    sourceMaps(),
    sizeSnapshot(),
    env === "production" &&
      terser({
        sourcemap: true,
        output: { comments: false },
        compress: {
          keep_infinity: true,
          pure_getters: true,
        },
        warnings: true,
        ecma: 5,
        toplevel: false,
      }),
  ],
});
Example #22
0
const buildUmd = ({ env }) => ({
  input,
  external,
  output: {
    name: 'Formik',
    format: 'umd',
    sourcemap: true,
    file:
      env === 'production'
        ? `./dist/formik.umd.${env}.js`
        : `./dist/formik.umd.${env}.js`,
    exports: 'named',
    globals: {
      react: 'React',
      'react-native': 'ReactNative',
    },
  },

  plugins: [
    resolve(),
    replace({
      exclude: 'node_modules/**',
      'process.env.NODE_ENV': JSON.stringify(env),
    }),
    commonjs({
      include: /node_modules/,
      namedExports: {
        'node_modules/prop-types/index.js': [
          'object',
          'oneOfType',
          'string',
          'node',
          'func',
          'bool',
          'element',
        ],
      },
    }),
    sourceMaps(),
    env === 'production' && filesize(),
    env === 'production' &&
      uglify({
        output: { comments: false },
        compress: {
          keep_infinity: true,
          pure_getters: true,
        },
        warnings: true,
        ecma: 5,
        toplevel: false,
      }),
  ],
});
Example #23
0
function genConfig (opts) {
  const config = {
    entry: opts.entry,
    dest: opts.dest,
    external: opts.external,
    format: opts.format,
    banner: opts.banner,
    moduleName: opts.moduleName || 'Vue',
    plugins: [
      replace({
        __WEEX__: !!opts.weex,
        __MPVUE__: !!opts.mp,
        __WEEX_VERSION__: weexVersion,
        __MPVUE_VERSION__: mpVueVersion,
        __VERSION__: version
      }),
      flow(),
      buble(),
      alias(Object.assign({}, aliases, opts.alias))
    ].concat(opts.plugins || [])
  }

  if (opts.env) {
    config.plugins.push(replace({
      'process.env.NODE_ENV': JSON.stringify(opts.env)
    }))
  }

  // hack fix MP LIFECYCLE_HOOKS
  if (opts.mp) {
    config.plugins.push(replace({
      "'deactivated'\n]": `'deactivated', ${mpLifecycleHooks}\n]`
    }))
    config.plugins.push(replace({
      'inBrowser && window.navigator.userAgent.toLowerCase': `['mpvue-runtime'].join`
    }))
  }

  return config
}
Example #24
0
export default commandOptions => {
	const COMMAND_OPTIONS = JSON.stringify(commandOptions);
	delete commandOptions['some-option'];
	delete commandOptions['another-option'];
	commandOptions.format = 'cjs';
	return {
		input: 'main.js',
		onwarn(warning) {
			throw new Error(`Unexpected warning: ${warning.message}`);
		},
		plugins: [replace({ COMMAND_OPTIONS })]
	};
};
Example #25
0
export default function (config) {
  return {
    input: 'src/turndown.js',
    name: 'TurndownService',
    output: config.output,
    external: ['jsdom'],
    plugins: [
      commonjs(),
      replace({ 'process.browser': JSON.stringify(!!config.browser) }),
      resolve()
    ]
  }
}
module.exports = function (env) {
    return [
        inject({
            include: '**/*.js',
            //exclude: 'node_modules/**',
            modules: {
                $: 'jquery',
                jQuery: 'jquery',
                moment: 'moment'
            }
        }),
        resolve({
            // use "module" field for ES6 module if possible
            mainFields: [
                // use "module" field for ES6 module if possible
                'module'
            ],

            // some package.json files have a `browser` field which
            // specifies alternative files to load for people bundling
            // for the browser. If that's you, use this option, otherwise
            // pkg.browser will be ignored
            browser: false  // Default: false
        }),
        json(),
        commonjs(),
        handlebars({
            handlebars: {
                options: {
                    sourceMap: env !== 'production' ? 'inline': false
                }
            },
            templateExtension: '.hbs'
        }),
        buble({
            objectAssign: 'Object.assign',
            transforms: {
                dangerousForOf: true
            }
        }),
        replace({
          'process.env.NODE_env': JSON.stringify(env)
        }),
        env === 'production' && uglify({
            compress: {
                dead_code: true,
                drop_console: true
            }
        }, minify)
    ];
};
Example #27
0
function umd(components, cb) {
  const env = process.env.NODE_ENV || 'development';
  const target = process.env.TARGET || config.target;

  rollup({
    input: './src/swiper.js',
    plugins: [
      replace({
        'process.env.NODE_ENV': JSON.stringify(env),
        'process.env.TARGET': JSON.stringify(target),
        '//IMPORT_COMPONENTS': components.map(component => `import ${component.capitalized} from './components/${component.name}/${component.name}';`).join('\n'),
        '//INSTALL_COMPONENTS': components.map(component => `${component.capitalized}`).join(',\n  '),
        '//EXPORT': 'export default Swiper;',
      }),
      resolve({ jsnext: true }),
      buble(),
    ],
    format: 'umd',
    name: 'Swiper',
    strict: true,
    sourcemap: env === 'development',
    banner,
  })
    .on('error', (err) => {
      if (cb) cb();
      console.error(err.toString());
    })
    .pipe(source('swiper.js', './src'))
    .pipe(buffer())
    .pipe(gulp.dest(`./${env === 'development' ? 'build' : 'dist'}/js/`))
    .on('end', () => {
      if (env === 'development') {
        if (cb) cb();
        return;
      }
      // Minified version
      gulp.src('./dist/js/swiper.js')
        .pipe(sourcemaps.init())
        .pipe(uglify())
        .pipe(header(banner))
        .pipe(rename((filePath) => {
          /* eslint no-param-reassign: ["error", { "props": false }] */
          filePath.basename += '.min';
        }))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./dist/js/'))
        .on('end', () => {
          cb();
        });
    });
}
export default config => {
  return {
    input: 'src/index.js',
    output: {
      format: config.format,
      file: config.dest
    },
    external: external,
    plugins: [
      buble(),
      replace({'process.browser': JSON.stringify(!!config.browser)})
    ]
  };
};
Example #29
0
export default async function buildWeb() {
  const start = new Date();
  console.log('Running rollup...');
  await rollup({
    rollup: {
      entry: path.join(process.cwd(), config.root, 'es6', 'index.js'),
      plugins: [
        commonjs({
          include: [`${__dirname}/../node_modules/**`, 'node_modules/**'],
          sourceMap: false,
        }),
        builtins(),
        nodeGlobals(),
        nodeResolve({
          jsNext: true,
          main: true,
          browser: true,
        }),
        bundleBabel({
          main: true,
          jsNext: true,
        }),
        babel({
          exclude: ['node_modules/babel-runtime/**', 'node_modules/core-js/**'],
          presets: [[
            'es2015',
            {
              modules: false,
            },
          ], 'stage-0', 'react'],
          plugins: ['transform-runtime', 'external-helpers'],
          runtimeHelpers: true,
        }),
        json(),
        replace({
          'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
        }),
        config.uglify ? uglify() : undefined,
      ].filter(x => x != null),
      onwarn: Function.prototype,
    },
    bundle: {
      format: 'umd',
      dest: path.join(process.cwd(), 'bin', 'index.js'),
      moduleId: npmPackage.name,
      moduleName: config.global || npmPackage.name,
    },
  });
  console.log(`Build finished in ${(new Date() - start) / 1000} seconds.`);
}
const createConfig = ({ output, browser = false, umd = false, env } = {}) => {
  const min = env === 'production';

  return {
    input: 'src/index.js',
    output: ensureArray(output).map(format =>
      Object.assign({}, format, {
        name: 'TextareaAutosize',
        exports: 'named',
        globals: {
          react: 'React'
        }
      })
    ),
    plugins: [
      nodeResolve({
        jsnext: true
      }),
      babel({
        exclude: 'node_modules/**',
        runtimeHelpers: true,
        plugins: [
          [
            '@babel/transform-runtime',
            { useESModules: output.format !== 'cjs' }
          ]
        ]
      }),
      commonjs(),
      replace(
        Object.assign(
          env ? { 'process.env.NODE_ENV': JSON.stringify(env) } : {},
          {
            'process.env.BROWSER': JSON.stringify(browser)
          }
        )
      ),
      min &&
        uglify({
          compress: {
            pure_getters: true,
            unsafe: true,
            unsafe_comps: true,
            warnings: false
          }
        })
    ].filter(Boolean),
    external: makeExternalPredicate(umd ? external : allExternal)
  };
};