add concept of "main" bundle and remove BIP39

Some features of bitcore will be too large to be included in the browser bundle
by default. Since BIP39 pretty much requires the giant list of words to be
used, I am excluding it by default. The ability to exclude some features by
default will become useful with some particularly large features to come,
particularly BIP70.
This commit is contained in:
Ryan X. Charles 2014-06-20 19:31:01 -07:00
parent 54c8e04738
commit 4a59418c82
3 changed files with 118 additions and 115 deletions

View File

@ -80,11 +80,21 @@ var createBitcore = function(opts) {
exec('sh concat.sh', puts);
process.chdir(cwd);
if (!opts.includeall && (!opts.submodules || opts.submodules.length === 0)) {
if (!opts.stdout) console.log('Must use either -s or -a option. For more info use the --help option');
if (!opts.includeall && !opts.includemain && (!opts.submodules || opts.submodules.length === 0)) {
if (!opts.stdout) console.log('Must use either -s or -a or -m option. For more info use the --help option');
process.exit(1);
}
var submodules = opts.submodules;
if (opts.includemain) {
submodules = JSON.parse(JSON.stringify(modules));
submodules.splice(submodules.indexOf('lib/BIP39'), 1);
submodules.splice(submodules.indexOf('lib/BIP39WordlistEn'), 1);
var assert = require('assert');
assert(submodules.length == modules.length - 2);
}
if (opts.submodules) {
for (var i = 0; i < opts.submodules.length; i++) {
var sm = opts.submodules[i];
@ -113,7 +123,7 @@ var createBitcore = function(opts) {
expose: 'bitcore'
});
modules.forEach(function(m) {
if (opts.includeall || opts.submodules.indexOf(m) > -1) {
if (opts.includeall || submodules.indexOf(m) > -1) {
if (!opts.stdout) console.log('Including ' + m + ' in the browser bundle');
b.require('./' + opts.dir + m + '.js', {
expose: './' + m
@ -157,6 +167,7 @@ if (require.main === module) {
program
.version('0.0.1')
.option('-a, --includeall', 'Include all submodules.')
.option('-m, --includemain', 'Include main submodules.')
.option('-d, --dontminify', 'Don\'t minify the code.')
.option('-o, --stdout', 'Specify output as stdout')
.option('-D, --dir <dir>', 'Specify a base directory')

File diff suppressed because one or more lines are too long

View File

@ -47,9 +47,9 @@
},
"scripts": {
"install": "node-gyp rebuild",
"test": "node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"test": "node browser/build.js -a && node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter spec test",
"prepublish": "node browser/build.js -a"
"prepublish": "node browser/build.js -m"
},
"dependencies": {
"grunt-browserify": "~2.0.0",