Skip to content

Commit

Permalink
Merge pull request web3#120 from dchambers/make-browserify-compatibile
Browse files Browse the repository at this point in the history
Make browserify compatibile
  • Loading branch information
debris committed Mar 16, 2015
2 parents cb7c209 + 768d4bf commit 517eff9
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 31 deletions.
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var browserifyOptions = {
debug: true,
insert_global_vars: false, // jshint ignore:line
detectGlobals: false,
bundleExternal: false
bundleExternal: true
};

gulp.task('versionReplace', function(){
Expand Down Expand Up @@ -58,6 +58,7 @@ gulp.task('build', ['clean'], function () {
return browserify(browserifyOptions)
.require('./' + src + '.js', {expose: 'web3'})
.add('./' + src + '.js')
.ignore('crypto')
.bundle()
.pipe(exorcist(path.join( DEST, dst + '.js.map')))
.pipe(source(dst + '.js'))
Expand Down
3 changes: 1 addition & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ module.exports = function (config) {

// list of files / patterns to load in the browser
files: [
'node_modules/bignumber.js/bignumber.js',
'test/*.js',
'test/*.js'
],


Expand Down
5 changes: 1 addition & 4 deletions lib/solidity/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
* @date 2015
*/

if (process.env.NODE_ENV !== 'build') {
var BigNumber = require('bignumber.js'); // jshint ignore:line
}

var BigNumber = require('bignumber.js');
var utils = require('../utils/utils');
var c = require('../utils/config');

Expand Down
3 changes: 3 additions & 0 deletions lib/utils/browser-xhr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

exports.XMLHttpRequest = window.XMLHttpRequest;
4 changes: 1 addition & 3 deletions lib/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
*/

/// required to define ETH_BIGNUMBER_ROUNDING_MODE
if (process.env.NODE_ENV !== 'build') {
var BigNumber = require('bignumber.js'); // jshint ignore:line
}
var BigNumber = require('bignumber.js');

var ETH_UNITS = [
'wei',
Expand Down
4 changes: 1 addition & 3 deletions lib/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
* @constructor
*/

if (process.env.NODE_ENV !== 'build') {
var BigNumber = require('bignumber.js'); // jshint ignore:line
}
var BigNumber = require('bignumber.js');

var unitMap = {
'wei': '1',
Expand Down
4 changes: 1 addition & 3 deletions lib/web3/httpprovider.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
* @date 2014
*/

if (process.env.NODE_ENV !== 'build') {
var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line
}
var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line

var HttpProvider = function (host) {
this.name = 'HTTP';
Expand Down
18 changes: 3 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
},
"dependencies": {
"bignumber.js": ">=2.0.0",
"envify": "^3.0.0",
"unreachable-branch-transform": "^0.1.0",
"xmlhttprequest": "*"
},
"browser": {
"xmlhttprequest": "./lib/utils/browser-xhr.js"
},
"devDependencies": {
"bower": ">=1.3.0",
"browserify": ">=6.0",
Expand Down Expand Up @@ -53,19 +54,6 @@
"bugs": {
"url": "https://github.com/ethereum/ethereum.js/issues"
},
"browserify": {
"transform": [
[
"envify",
{
"NODE_ENV": "build"
}
],
[
"unreachable-branch-transform"
]
]
},
"keywords": [
"ethereum",
"javascript",
Expand Down

0 comments on commit 517eff9

Please sign in to comment.