mirror of
https://github.com/fluencelabs/js-peer-id
synced 2025-07-04 04:31:49 +00:00
dist file
This commit is contained in:
@ -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
55163
dist/peer-id.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -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') }
|
||||
|
@ -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
30
webpack.config.js
Normal 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: []
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user