@@ -6,42 +6,19 @@ var through = require('through');
6
6
var ellipticPackage = require ( 'elliptic/package.json' ) ;
7
7
ellipticPackage = JSON . stringify ( { version : ellipticPackage . version } ) ;
8
8
9
- var versions = {
10
- 'ethers' : require ( './package.json' ) . version ,
11
- } ;
12
-
13
- var depVersions = require ( './package.json' ) . dependencies ;
14
-
15
- // Make sure the versions we are building a dist from are the most rescent
16
- [ 'contracts' , 'providers' , 'utils' , 'wallet' ] . forEach ( function ( name ) {
17
- var npmVersion = require ( './node_modules/ethers-' + name + '/package.json' ) . version ;
18
- var liveVersion = require ( './' + name + '/package.json' ) . version ;
19
- var depVersion = depVersions [ 'ethers-' + name ] ;
20
-
21
- if ( npmVersion !== liveVersion ) {
22
- console . log ( name , ( 'npm=' + npmVersion ) , ( 'live=' + liveVersion ) ) ;
23
- throw new Error ( 'version mismatch for ' + name + ' - redo npm install' ) ;
24
- }
25
- if ( npmVersion !== depVersion ) {
26
- console . log ( name , ( 'npm=' + npmVersion ) , ( 'depVersion=' + depVersion ) ) ;
27
- throw new Error ( 'dependency version mismatch for ' + name + ' - update package.json' ) ;
28
- }
29
-
30
- versions [ name ] = liveVersion ;
31
-
32
- console . log ( 'Including: ' , name + '@' + npmVersion ) ;
33
- } ) ;
34
-
35
-
9
+ var version = require ( './package.json' ) . version ;
36
10
37
11
38
12
var undef = "module.exports = undefined;" ;
39
13
var empty = "module.exports = {};" ;
40
14
41
15
// We already have a random Uint8Array browser/node safe source
42
- var brorand = "var randomBytes = require('ethers-utils').randomBytes; module.exports = function(length) { return randomBytes(length); };" ;
16
+ // @TODO : Use path construction instead of ../..
17
+ var brorand = "var randomBytes = require('../../utils').randomBytes; module.exports = function(length) { return randomBytes(length); };" ;
43
18
44
19
var transforms = {
20
+ 'ethers.js/package.json' : JSON . stringify ( { version : version } ) ,
21
+
45
22
// Remove the precomputed secp256k1 points
46
23
"elliptic/lib/elliptic/precomputed/secp256k1.js" : undef ,
47
24
@@ -55,6 +32,9 @@ var transforms = {
55
32
56
33
// Remove RIPEMD160
57
34
"hash.js/lib/hash/ripemd.js" : "module.exports = {ripemd160: null}" ,
35
+ "hash.js/lib/hash/sha/1.js" : empty ,
36
+ "hash.js/lib/hash/sha/224.js" : empty ,
37
+ "hash.js/lib/hash/sha/384.js" : empty ,
58
38
59
39
// Swap out borland for the random bytes we already have
60
40
"brorand/index.js" : brorand ,
@@ -84,6 +64,7 @@ function transform(path, options) {
84
64
} , function ( ) {
85
65
var transformed = transformFile ( path ) ;
86
66
if ( transformed != null ) {
67
+ console . log ( 'Transformed:' + path ) ;
87
68
data = transformed ;
88
69
} else {
89
70
unmodified [ path ] = true ;
@@ -103,15 +84,8 @@ function postBundle(error, source, next) {
103
84
if ( error ) {
104
85
console . log ( error ) ;
105
86
106
- } else {
107
- // We setup the utils instance to be able to create a stand-alone package
108
- source = source . toString ( ) ;
109
- var lengthBefore = source . length ;
110
- var source = source . replace ( / " _ _ S T A N D _ A L O N E _ F A L S E _ _ " / g, '"__STAND_ALONE_TRUE__"' ) ;
111
- if ( lengthBefore - source . length !== 1 ) {
112
- next ( new Error ( 'multiple stand-alone variables changed' ) ) ;
113
- return ;
114
- }
87
+ // } else {
88
+ // source = source.toString();
115
89
}
116
90
117
91
inflight --
@@ -169,7 +143,7 @@ module.exports = function(grunt) {
169
143
[ transform , { global : true } ] ,
170
144
] ,
171
145
browserifyOptions : {
172
- // standalone: '_ethers ',
146
+ standalone : 'ethers ' ,
173
147
} ,
174
148
preBundleCB : preBundle ,
175
149
postBundleCB : postBundle
0 commit comments