You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
1.7 KiB
88 lines
1.7 KiB
'use strict';
|
|
|
|
/*
|
|
* Example for usage of browserify with soop
|
|
*
|
|
* The key parameter 'pack'
|
|
* The supplied 'custom_prelude.js' file is needed for
|
|
* .load function of soop.
|
|
*/
|
|
|
|
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) {
|
|
params.raw = true;
|
|
params.sourceMapPrefix = '//#';
|
|
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',
|
|
'Opcode',
|
|
'Peer',
|
|
'PeerManager',
|
|
'PrivateKey',
|
|
'RpcClient',
|
|
'SIN',
|
|
'SINKey',
|
|
'Script',
|
|
'ScriptInterpreter',
|
|
'Sign',
|
|
'Transaction',
|
|
'Wallet',
|
|
'WalletKey',
|
|
'config',
|
|
'const',
|
|
'networks',
|
|
'bitcore',
|
|
];
|
|
|
|
var b = browserify(opts);
|
|
b.require('browserify-bignum/bignumber.js', {expose: 'bignum'} );
|
|
b.require('browserify-buffertools/buffertools.js', {expose:'buffertools'});
|
|
b.require('buffer', {expose: 'buffer'});
|
|
b.require('base58-native');
|
|
b.require('./Key.js', {expose: 'KeyModule'});
|
|
b.require('./util/log');
|
|
b.require('./util/util');
|
|
b.require('./util/EncodedData');
|
|
b.require('./util/VersionedData');
|
|
b.add('./browser/bignum_config.js');
|
|
|
|
modules.forEach(function(m) {
|
|
b.require('./' + m + '.js' ,{expose:m} );
|
|
});
|
|
|
|
var bopts = {
|
|
// detectGlobals: true,
|
|
// insertGlobals: 'Buffer',
|
|
// insertGlobalVars: {
|
|
// Buffer: function () {
|
|
// return 'require("buffer").Buffer';
|
|
// },
|
|
// },
|
|
};
|
|
|
|
b.bundle(bopts).pipe(process.stdout);
|
|
|
|
|
|
|
|
|
|
|