|
|
@ -1,7 +1,6 @@ |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
/* |
|
|
|
* Example for usage of browserify with soop |
|
|
|
* |
|
|
|
* The key parameter 'pack' |
|
|
|
* The supplied 'custom_prelude.js' file is needed for |
|
|
@ -11,27 +10,23 @@ |
|
|
|
var fs = require('fs'); |
|
|
|
var browserify = require('browserify'); |
|
|
|
var browserPack = require('browser-pack'); |
|
|
|
var opts = {}; |
|
|
|
|
|
|
|
|
|
|
|
var preludePath = 'node_modules/soop/example/custom_prelude.js'; |
|
|
|
|
|
|
|
var pack = function (params) { |
|
|
|
var preludePath = 'node_modules/soop/example/custom_prelude.js'; |
|
|
|
params.raw = true; |
|
|
|
params.sourceMapPrefix = '//#'; |
|
|
|
params.prelude= fs.readFileSync(preludePath, 'utf8'); |
|
|
|
params.preludePath= preludePath; |
|
|
|
params.prelude = fs.readFileSync(preludePath, 'utf8'); |
|
|
|
params.preludePath = preludePath; |
|
|
|
return browserPack(params); |
|
|
|
}; |
|
|
|
|
|
|
|
opts.pack = pack; |
|
|
|
opts.debug = true; |
|
|
|
|
|
|
|
var modules = [ |
|
|
|
'Address', |
|
|
|
'Block', |
|
|
|
'Bloom', |
|
|
|
'Buffers.monkey', |
|
|
|
'Connection', |
|
|
|
'Deserialize', |
|
|
|
'Gruntfile', |
|
|
|
'Number.monkey', |
|
|
@ -51,12 +46,18 @@ var modules = [ |
|
|
|
'config', |
|
|
|
'const', |
|
|
|
'networks', |
|
|
|
'bitcore', |
|
|
|
]; |
|
|
|
|
|
|
|
var opts = {}; |
|
|
|
opts.pack = pack; |
|
|
|
opts.debug = true; |
|
|
|
opts.standalone = 'bitcore'; |
|
|
|
opts.insertGlobals = true; |
|
|
|
|
|
|
|
var b = browserify(opts); |
|
|
|
b.require('browserify-bignum/bignumber.js', {expose: 'bignum'} ); |
|
|
|
b.require('browserify-buffertools/buffertools.js', {expose:'buffertools'}); |
|
|
|
b.require('./bitcore', {expose: 'bitcore'}); |
|
|
|
b.require('buffer', {expose: 'buffer'}); |
|
|
|
b.require('base58-native'); |
|
|
|
b.require('./Key.js', {expose: 'KeyModule'}); |
|
|
@ -65,27 +66,20 @@ b.require('./util/util'); |
|
|
|
b.require('./util/EncodedData'); |
|
|
|
b.require('./util/VersionedData'); |
|
|
|
b.add('./browser/bignum_config.js'); |
|
|
|
b.require('./test/testdata.js', {expose: './testdata'}); |
|
|
|
b.transform('brfs'); |
|
|
|
modules.forEach(function(m) { |
|
|
|
b.require('./' + m + '.js' ,{expose: './'+m} ); |
|
|
|
}); |
|
|
|
b.require('soop'); |
|
|
|
|
|
|
|
b.require('./Connection', {expose: './Connection'}); |
|
|
|
b.bundle().pipe(fs.createWriteStream('browser/bundle.js')); |
|
|
|
|
|
|
|
modules.forEach(function(m) { |
|
|
|
b.require('./' + m + '.js' ,{expose:m} ); |
|
|
|
}); |
|
|
|
|
|
|
|
var bopts = { |
|
|
|
transform: ['brfs'] |
|
|
|
// detectGlobals: true,
|
|
|
|
// insertGlobals: 'Buffer',
|
|
|
|
// insertGlobalVars: {
|
|
|
|
// Buffer: function () {
|
|
|
|
// return 'require("buffer").Buffer';
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
}; |
|
|
|
opts.standalone = 'testdata'; |
|
|
|
var tb = browserify(opts); |
|
|
|
tb.require('./test/testdata', {expose: 'testdata'}); |
|
|
|
tb.transform('brfs'); |
|
|
|
|
|
|
|
b.bundle(bopts).pipe(process.stdout); |
|
|
|
tb.bundle().pipe(fs.createWriteStream('browser/testdata.js')); |
|
|
|
|
|
|
|
|
|
|
|
|