Conversation
|
Now getting an error with this: <script src="bitauth.js"></script>
<script>
var bitauth = require('bitauth');
</script>
ReferenceError: require is not definedHowever 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. |
|
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 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 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 |
|
@braydonf Hey, it's been a long time and I completely forgot about this. I originally included the Are you still interested in this? If so I suppose I can get rid of the |
|
|
Simplifying externs (still doesn't work with advanced compilation)
Isn't functional with the Google Closure Compiler
|
Okay, I got rid of 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. |
This changes the output of the
gulp browser:uncompressedto 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:
Along with ClojureScript's UMD support (discussed here), this obviates my need for Google Closure support and thus closes #55 and cljsjs/packages#255.