How to use the core-js-builder.then function in core-js-builder

To help you get started, we’ve selected a few core-js-builder examples, based on popular ways it is used in public projects.

github jedwards1211 / meteor-webpack-react / core-js-custom-build.js View on Github external
dirs.lib = path.join(dirs.webpack, 'lib');
if (!fs.existsSync(dirs.lib)) mkdir(dirs.lib);

var coreJsVersion = JSON.parse(fs.readFileSync('node_modules/core-js/package.json')).version;
var targetFileName = 'core-js-no-number.js';
var currentFileExist = fs.existsSync(path.join(dirs.lib, targetFileName));
var currentFileFewLines = currentFileExist ?
  fs.readFileSync(path.join(dirs.lib, targetFileName)).toString().substr(0, 130) : '';
var currentFileVersionRegex = /core-js (\d.\d.\d+)/m;
var currentFileVersion = currentFileVersionRegex.test(currentFileFewLines) ?
  currentFileVersionRegex.exec(currentFileFewLines)[1] : false;

if (coreJsVersion !== currentFileVersion) {
  echo('Building core-js@' + coreJsVersion + ' without ES6 number constructor...');
  require('core-js-builder')({
    modules: ['es5', 'es6', 'es7', 'core.dict', 'web'],
    blacklist: ['es6.number.constructor'],
  }).then(function(code) {
    fs.writeFileSync(path.join(dirs.lib, targetFileName), code);
  }).catch(function(error) {
    console.error('core-js build error');
  });
}
else {
  echo('core-js@' + coreJsVersion + ' without ES6 number constructor is up to date');
}
github marclaval / optimize-angular-app / scripts / custom-core.js View on Github external
"use strict";

const fs = require('fs');
const UglifyJS = require("uglify-js");

require('core-js-builder')({
  modules: [
    'es6.symbol',
    'es6.object.assign',
    'es6.string.starts-with',
    'es6.string.ends-with',
    'es6.array',
    'es7.reflect'
  ],
  blacklist: []
}).then(code => {
  const result = UglifyJS.minify(code, {fromString: true});
  fs.writeFileSync('./tmp/core.min.js', result.code, 'utf-8');
}).catch(error => {
  console.log(error);
});

core-js-builder

core-js builder

MIT
Latest version published 5 days ago

Package Health Score

80 / 100
Full package analysis

Popular core-js-builder functions