Skip to content

Commit

Permalink
docs: browserify-zlib-next begone!
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Jun 16, 2017
1 parent ee3dbec commit 9a41f0f
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 33 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,7 @@ The CLI is available by using the command `jsipfs` in your terminal. This is ali

### Use in the browser with browserify, webpack or any bundler

Simply require it as you would do for Node.js, but when transpiling+minifying with your bundler, make sure to swap `zlib` with a full replacement for the browser: `zlib: 'browserify-zlib-next'`. We have submitted PR's to browserify and WebPack to make this as part of the standard node libraries that are transpiled, you can follow this development in [browserify](https://github.com/substack/node-browserify/issues/1672), [webpack](https://github.com/webpack/node-libs-browser/issues/51).

You can also find examples of how to do this bundling at: `https://github.com/ipfs/js-ipfs/tree/master/examples`

Special note, if you are using webpack, make sure to use version 2 or above, otherwise it won't work.
You can find examples of how to do this bundling at: `https://github.com/ipfs/js-ipfs/tree/master/examples`. If you are using webpack, make sure to use version 2 or above, otherwise it won't work.

### Use in a browser using a script tag

Expand Down
5 changes: 0 additions & 5 deletions examples/bundle-browserify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,3 @@ You should see the following:

![](https://ipfs.io/ipfs/QmNtpcWCEd6LjdPNfBFDaVZdD4jpgT8ZTAwoFJXKhYMJdo/1.png)
![](https://ipfs.io/ipfs/QmNtpcWCEd6LjdPNfBFDaVZdD4jpgT8ZTAwoFJXKhYMJdo/2.png)

## Special note

In order to use js-ipfs in the browser, you need to replace the default `zlib` library by `browserify-zlib-next`, a full implementation of the native `zlib` package, full in Node.js.
See the package.json to learn how to do this and avoid this pitfall (see the `package.json`). More context on: https://github.com/ipfs/js-ipfs#use-in-the-browser-with-browserify-webpack-or-any-bundler
5 changes: 2 additions & 3 deletions examples/bundle-browserify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Bundle js-ipfs with Browserify",
"main": "index.js",
"scripts": {
"bundle": "browserify src/index.js --require browserify-zlib-next:zlib > public/bundle.js",
"bundle": "browserify src/index.js > public/bundle.js",
"serve": "http-server public -a 127.0.0.1 -p 8888",
"start": "npm run bundle && npm run serve"
},
Expand All @@ -13,8 +13,7 @@
"devDependencies": {
"browserify": "^14.0.0",
"concat-stream": "^1.6.0",
"http-server": "^0.9.0",
"browserify-zlib-next": "^1.0.1"
"http-server": "^0.9.0"
},
"dependencies": {}
}
8 changes: 0 additions & 8 deletions examples/bundle-webpack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,3 @@ Now open your browser at `http://localhost:3000`
You should see the following:

![](https://ipfs.io/ipfs/QmZndNLRct3co7h1yVB72S4qfwAwbq7DQghCpWpVQ45jSi/1.png)

## Special note

In order to use js-ipfs in the browser, you need to replace the default `zlib` library by `browserify-zlib-next`, a full implementation of the native `zlib` package, full in Node.js. See the WebPack config to learn how to do this and avoid this pitfall. More context on: https://github.com/ipfs/js-ipfs#use-in-the-browser-with-browserify-webpack-or-any-bundler

## Special note 2

You need to use WebPack@2 or above, version 1 won't work
1 change: 0 additions & 1 deletion examples/bundle-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"webpack-dev-server": "^2.4.5"
},
"dependencies": {
"browserify-zlib-next": "^1.0.1",
"safe-buffer": "^5.0.1"
}
}
11 changes: 0 additions & 11 deletions examples/bundle-webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,5 @@ module.exports = {
fs: 'empty',
net: 'empty',
tls: 'empty'
},
/*
* In order to transfer files, this is a very important step in your Webpack
* configuration, see more at:
* https://github.com/ipfs/js-ipfs#use-in-the-browser-with-browserify-webpack-or-any-bundler
*/
resolve: {
alias: {
zlib: 'browserify-zlib-next'
}
}

}

0 comments on commit 9a41f0f

Please sign in to comment.