bitauth
bitauth copied to clipboard
Browserify UMD
This changes the output of the gulp browser:uncompressed
to generate a Universal Module Definition (UMD) as described here.
I have verified that the generated UMD file can be loaded in phantomjs with the following command:
var bitauth = require('./bitauth');
Along with ClojureScript's UMD support (discussed here), this obviates my need for Google Closure support and thus closes #55 and https://github.com/cljsjs/packages/pull/255.
Now getting an error with this:
<script src="bitauth.js"></script>
<script>
var bitauth = require('bitauth');
</script>
ReferenceError: require is not defined
However this will work:
<script src="bitauth.js"></script>
<script>
console.log(window.bitauth);
</script>
The use of require makes it much more Node.js and Browserify compatible, as there isn't a need to use:
if (!process.browser) {
var bitauth = require('bitauth');
};
Could this be another build, e.g. bitauth.standalone.js
?
Good call, I'll go make a second build
Okay, I've added a second build.
To clarify, the second "standalone" build creates a UMD that can be required with systems that already have a require
module system like phantomjs and node.js. For example:
phantomjs> var bitauth = require('./bitauth.standalone.js');
undefined
phantomjs> bitauth
{
"PREFIX": {
"type": "Buffer",
"data": [
15,
2
]
},
"_generateRandomPair": "[Function]",
"_getPublicKeyFromPrivateKey": "[Function]",
"_sign": "[Function]",
"_verifySignature": "[Function]",
"generateSin": "[Function]",
"getPublicKeyFromPrivateKey": "[Function]",
"getSinFromPublicKey": "[Function]",
"sign": "[Function]",
"validateSin": "[Function]",
"verifySignature": "[Function]"
}
But browserify has it's own module loading system that it creates and injects when you don't specify --standalone
on the command line, which may be preferred.
The default browserify bundle doesn't work at all with Google Closure; this is kind of an obscure defect and maybe should be documented somewhere...
I hope things are clear to any onlookers what is going on here. My downstream ClojureScript code needs Closure support so it means a lot to me that you guys are willing to support two different browser bundles :D
Looks like the browserify build bitauth.js
is committed in, can you rebase without the bitauth.js
bundled file?
@braydonf Hey, it's been a long time and I completely forgot about this.
I originally included the bitauth.js
file because CLJSJS are leery of building artifacts they package.
Are you still interested in this? If so I suppose I can get rid of the bitauth.js
file and skip CLJSJS and just package my own ClojureScript distribution of this library.
bitauth.js
build is included in tagged releases https://github.com/bitpay/bitauth/commit/90ac1f5f3d088e71383880083642111bcae0b8f7 without being included in the master branch.
Okay, I got rid of bitauth.js
.
I tried to revise my google extern file for this but for whatever reason I cannot get the closure compiler to work with your library, so I deleted it.
If you want I can squash these commits.