dist file

This commit is contained in:
nginnever
2016-03-03 14:19:10 -08:00
parent b3e3dbe3c0
commit 73b42ff2aa
5 changed files with 55204 additions and 5 deletions

View File

@ -30,14 +30,14 @@ const PeerId = require('peer-id')
### In the Browser through browserify
Same as in Node.js, you just have to [browserify](https://github.com/substack/node-browserify) the code before serving it. See the browserify repo for how to do that.
TODO: Figure out how to get this working with browserify and webpack. Browserify can't bundle our replacement of ```fs.readFileSync``` with ```require('buffer!./file')```.
### In the Browser through `<script>` tag
Make the [peer-id.min.js](/dist/peer-id.min.js) available through your server and load it using a normal `<script>` tag, this will export the `peerId` constructor on the `window` object, such that:
Make the [peer-id.js](/dist/peer-id.js) available through your server and load it using a normal `<script>` tag, this will export the `PeerId` object, such that:
```JavaScript
const PeerId = window.PeerId
const Id = PeerId
```
#### Gotchas

55163
dist/peer-id.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -17,6 +17,10 @@ module.exports = (config) => {
},
webpack: {
output: {
path: __dirname + '/dist',
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.js', '.json'],
alias: { 'node-forge': path.resolve(__dirname, 'deps/forge.bundle.js') }

View File

@ -8,7 +8,8 @@
"test": "npm run test:node && npm run test:browser",
"test:node": "mocha tests/test.js",
"test:browser": "karma start karma.conf.js",
"coverage": "istanbul cover --print both -- _mocha tests/test.js"
"coverage": "istanbul cover --print both -- _mocha tests/test.js",
"build": "webpack"
},
"keywords": [
"IPFS"
@ -33,6 +34,7 @@
},
"homepage": "https://github.com/diasdavid/js-peer-id",
"devDependencies": {
"browserify": "^13.0.0",
"buffer-loader": "0.0.1",
"chai": "^3.5.0",
"istanbul": "^0.4.2",
@ -47,7 +49,7 @@
"mocha": "^2.4.5",
"pre-commit": "^1.1.1",
"standard": "^6.0.7",
"webpack": "^1.12.13"
"webpack": "^1.12.14"
},
"dependencies": {
"bs58": "^3.0.0",

30
webpack.config.js Normal file
View File

@ -0,0 +1,30 @@
var webpack = require("webpack")
var path = require("path")
module.exports = {
name: 'peerid',
context: __dirname,
entry: "./src/index.js",
output: {
path: __dirname + '/dist',
filename: 'peer-id.js',
libraryTarget: "var",
library: "PeerId"
},
resolve: {
extensions: ['', '.js', '.json'],
alias: { 'node-forge': path.resolve(__dirname, 'deps/forge.bundle.js') }
},
externals: {
fs: '{}'
},
node: {
Buffer: true
},
module: {
loaders: [
{ test: /\.json$/, loader: 'json' }
],
noParse: []
}
}