Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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');
}
"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);
});