I used the compile for browser instructions on bitcoinjs.org
and the follow error was shown
`as-MacBook-Pro:test a$ sudo npm install -g browserify uglify-js
/usr/local/bin/uglifyjs -> /usr/local/lib/node_modules/uglify-js/bin/uglifyjs
/usr/local/bin/browserify -> /usr/local/lib/node_modules/browserify/bin/cmd.js
Hey Christian.
What version of node are you using? Try switching nvm to use v7
seems my handle gave me away
node version is v8.1.2
I think the issue has something to do with
https://github.com/bitcoinjs/bech32/blob/master/index.js
maybe it doesnt like let?
@mandelmonkey it appears that uglify-js doesn't support ES6 let statements.
In repository, we track LTS node versions for tracking backwards compatibility.
Maybe use --transform [ babelify ] on your browserify build step to downgrade to ES5.
I think this should be something we outline in the README, with steps.
Thoughts @bitcoinjs/committers ?
This decision would also mean we can upgrade the repository to use let instead of var throughout.
Will update README in a PR for discussion...
I agree. Let’s. ;-)
Closing in favour of #903
thanks I managed to browserify using the github readme instructions
https://github.com/bitcoinjs/bitcoinjs-lib#browser
@mandelmonkey was #903 helpful?
Yes thank you!
On Mon, Sep 25, 2017 at 3:22 PM, Daniel Cousens notifications@github.com
wrote:
@mandelmonkey https://github.com/mandelmonkey was #903
https://github.com/bitcoinjs/bitcoinjs-lib/pull/903 helpful
?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/bitcoinjs/bitcoinjs-lib/issues/902#issuecomment-331787484,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGRBNwPlc7tX35RkvrRL3cg-fmuA5O6fks5sl0a_gaJpZM4Pheo8
.
Hey @mandelmonkey would you mind sharing what you did to get yours running? I'm still having that issue with the bech32 lib not compiling to es5.
My script is browserify src/index.js --transform [ babelify --presets [ env ] ] --standalone bitcoinjs-lib > bin/bitcoinjs-lib.js
I must be missing something!
EDIT: I got it to work for now by making it a global transform.
EDIT: I got it to work for now by making it a global transform.
can you elaborate?
@tweeres04 I know that if your node version is too low it wouldn't support the 'let'
@dcousens @mandelmonkey It looks like by default browserify transforms only apply to files at or below the directory level of the entry file. The bech32 library (the one in es6 that was causing me problems) is one level up (at ./node_modules/bech32) from BitcoinJS's ./src/index.js, so by adding the --global flag to my transform I was able to get it to compile.
For those who encounter this issue, my full script for compiling is browserify src/index.js --t [ babelify --global --presets [ env ] ] --standalone bitcoinjs-lib | uglifyjs --compress --mangle reserved=['BigInteger,ECPair,Point'] > bin/bitcoinjs-lib.min.js
Ah, you are doing a --standalone compilation, that explains it, my bad I didn't see that in your OP.
I suspect many users are not doing --standalone, but simply using browserify at the top of their stack.
Right. Yeah I have an existing project with webpack so I'm compiling just BitcoinJS with browserify.
Most helpful comment
Hey Christian.
What version of node are you using? Try switching nvm to use v7