Browse Source

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.
patch-2
Ryan X. Charles 11 years ago
parent
commit
4a59418c82
  1. 17
      browser/build.js
  2. 212
      browser/bundle.js
  3. 4
      package.json

17
browser/build.js

@ -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')

212
browser/bundle.js

File diff suppressed because one or more lines are too long

4
package.json

@ -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",

Loading…
Cancel
Save