Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix: shared node demo (#3203)
Browse files Browse the repository at this point in the history
Shared worker example stopped working, and we have not noticed because for some reason CI doesn't seem to run it. There were several problems:

1. I'm guessing ipfs was bumped to 0.48 while things were in the review. And demo was getting older version with older `ipfs.add` API.
2. When I incorporated `add` / `addAll`, I have regressed the example 2302b2f#diff-48144c5d1809a34109f2559846446f22R21.  Have not noticed that, because CI doesn't seem to run it.
3. When I first wrote a example I used `CopyWebpackPlugin` which then I thought was unnecessary and removed. However `index.html` was placed in `dist` from prior runs so after change tests were still passing (and CI never seemed to have run this example).

This pull addresses all of those problems so that example passes tests. I'm still not sure why CI isn't executing this, test but we can figure out in the separate pull.
  • Loading branch information
Gozala authored Aug 3, 2020
1 parent 98e58dd commit 4c03bb2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/browser-sharing-node-across-tabs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"worker-plugin": "4.0.3"
},
"dependencies": {
"ipfs": "^0.47.0",
"ipfs": "^0.48.0",
"ipfs-message-port-client": "^0.0.1",
"ipfs-message-port-server": "^0.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-sharing-node-across-tabs/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const main = async () => {

const uploader = async (ipfs) => {
document.body.outerHTML += '<div>Adding "hello world!" to shared IPFS node</div>'
const entry = await ipfs.add(ipfs, new Blob(['hello world!'], { type: "text/plain" }))
const entry = await ipfs.add(new Blob(['hello world!'], { type: "text/plain" }))
const path = `/ipfs/${entry.cid}/`
document.body.outerHTML += `<div class="ipfs-add">File was added:
<a target="_blank" href="${new URL(`#${path}`, location)}">${path}</a>
Expand Down
9 changes: 7 additions & 2 deletions examples/browser-sharing-node-across-tabs/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var path = require('path')
var webpack = require('webpack')
const WorkerPlugin = require('worker-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')

module.exports = {
devtool: 'source-map',
Expand All @@ -13,14 +14,18 @@ module.exports = {
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'static/bundle.js'
filename: 'static/bundle.js',
publicPath: '/'
},
plugins: [
new WorkerPlugin({
sharedWorker: true,
globalObject: 'self'
}),
new webpack.HotModuleReplacementPlugin()
new webpack.HotModuleReplacementPlugin(),
new CopyWebpackPlugin([{
from: 'index.html'
}])
],
module: {
rules: [
Expand Down

0 comments on commit 4c03bb2

Please sign in to comment.