Skip to content

Commit 550ac73

Browse files
authored
Merge pull request #1836 from OliverOffing/OliverOffing-patch-1
docs(browser): using a different build tool
2 parents e6c8a99 + e79060d commit 550ac73

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,20 @@ We are not an authoritative source of best practice, but, at the very least:
7676

7777

7878
### Browser
79-
The recommended method of using `bitcoinjs-lib` in your browser is through [Browserify](https://github.com/substack/node-browserify).
80-
If you're familiar with how to use browserify, ignore this and carry on, otherwise, it is recommended to read the tutorial at https://browserify.org/.
79+
The recommended method of using `bitcoinjs-lib` in your browser is through [browserify](http://browserify.org/).
80+
81+
If you'd like to use a different (more modern) build tool than `browserify`, you can compile just this library and its dependencies into a single JavaScript file:
82+
83+
```sh
84+
$ npm install bitcoinjs-lib browserify
85+
$ npx browserify --standalone bitcoin - -o bitcoinjs-lib.js <<<"module.exports = require('bitcoinjs-lib');"
86+
```
87+
88+
Which you can then import as an ESM module:
89+
90+
```javascript
91+
<script type="module">import "/scripts/bitcoinjs-lib.js"</script>
92+
````
8193

8294
**NOTE**: We use Node Maintenance LTS features, if you need strict ES5, use [`--transform babelify`](https://github.com/babel/babelify) in conjunction with your `browserify` step (using an [`es2015`](https://babeljs.io/docs/plugins/preset-es2015/) preset).
8395

0 commit comments

Comments
 (0)