Optimized gruntfile (manually remove weird pulled in dependencies).

This commit is contained in:
ricmoo 2017-02-27 00:08:48 -05:00
parent 0c1615aef5
commit b1190e6e0b
2 changed files with 101 additions and 13 deletions

@ -1,3 +1,95 @@
var through = require('through');
var undef = "module.exports = undefined;";
var empty = "module.exports = {};";
var transforms = {
"ripemd.js": "module.exports = {ripemd160: null}",
"precomputed/secp256k1.js": undef,
"elliptic/curve/edwards.js": empty,
"elliptic/curve/mont.js": empty,
"elliptic/lib/elliptic/eddsa/.*": empty,
"elliptic/lib/elliptic/eddsa/.*": empty,
"elliptic/lib/elliptic/hmac-drbg.js": empty,
// "elliptic/package.json" :
"base64-js/.*": undef,
"browser-resolve:.*": undef,
"buffer/.*": undef,
"buffer-shims/.*": undef,
"cipher-base/.*": undef,
"core-util-is/.*": undef,
"create-hash/.*": undef,
"create-hmac/.*": undef,
"events/.*": undef,
"hmac-drbg/lib/hmac-drbg.js": undef,
"ieee754/.*": undef,
"isarray/.*": undef,
"pbkdf2/.*": undef,
"process/.*": undef,
"readable-stream/.*": undef,
"sha.js/.*": undef,
"stream-browserify/.*": undef,
"string_decoder/.*": undef,
};
var modified = {};
var unmodified = {};
function transformFile(path) {
for (var pattern in transforms) {
if (path.match(new RegExp(pattern + '$'))) {
modified[pattern] = true;
return transforms[pattern];
}
}
return null;
}
function transform(path, options) {
var data = '';
return through(function(chunk) {
data += chunk;
}, function () {
var transformed = transformFile(path);
if (transformed != null) {
//console.log('Transform: ' + path + ' => ' + transformed);
data = transformed;
} else {
unmodified[path] = true;
//console.log('Not transformed:', path);
}
//console.log(data.length, 'FOOBAR', path);
this.queue(data);
this.queue(null);
});
}
function checkBundle(error, source, next) {
var passed = Object.keys(unmodified);
passed.sort();
console.log('Unmodified:');
passed.forEach(function(path) {
console.log(' ' + path);
});
/*
var skipped = Object.keys(transforms);
Object.keys(modified).forEach(function(key) {
delete skipped[key];
});
skipped.sort();
if (skipped.length) {
console.log('Unused Patterns:');
skipped.forEach(function(pattern) {
console.log(' ' + pattern);
});
}
*/
next(error, source);
}
module.exports = function(grunt) {
grunt.initConfig({
browserify: {
@ -6,13 +98,18 @@ module.exports = function(grunt) {
'dist/ethers.js': './index.js',
'dist/ethers-contracts.js': './contracts/index.js',
'dist/ethers-hdnode.js': './hdnode/index.js',
'dist/ethers-providers.js': './providers/index.js',
'dist/ethers-utils.js': './utils/index.js',
'dist/ethers-wallet.js': './wallet/index.js',
},
options: {
transform: [
[ transform, { global: true } ],
],
browserifyOptions: {
standalone: 'ethers'
}
standalone: 'ethers',
},
postBundleCB: checkBundle
},
},
},
@ -22,6 +119,7 @@ module.exports = function(grunt) {
'dist/ethers.min.js' : [ './dist/ethers.js' ],
'dist/ethers-contracts.min.js' : [ './dist/ethers-contracts.js' ],
'dist/ethers-hdnode.min.js' : [ './dist/ethers-hdnode.js' ],
'dist/ethers-providers.min.js' : [ './dist/ethers-providers.js' ],
'dist/ethers-utils.min.js' : [ './dist/ethers-utils.js' ],
'dist/ethers-wallet.min.js' : [ './dist/ethers-wallet.js' ],
}

@ -9,20 +9,10 @@
},
"dependencies": {
},
"browser": {
},
"devDependencies": {
"ethereumjs-abi": "0.6.2",
"ethereumjs-tx": "1.1.1",
"ethereumjs-util": "4.3.0",
"grunt": "^0.4.5",
"grunt-browserify": "^5.0.0",
"grunt-contrib-uglify": "^1.0.1",
"nodeunit": "0.9.1",
"web3": "0.15.3",
"ethereumjs-vm": "1.4.0",
"solc": "0.3.5"
"grunt-contrib-uglify": "^1.0.1"
},
"keywords": [
"ethereum",