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

Commit 4c03bb2

Browse files
authored
fix: shared node demo (#3203)
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.
1 parent 98e58dd commit 4c03bb2

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

examples/browser-sharing-node-across-tabs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"worker-plugin": "4.0.3"
2424
},
2525
"dependencies": {
26-
"ipfs": "^0.47.0",
26+
"ipfs": "^0.48.0",
2727
"ipfs-message-port-client": "^0.0.1",
2828
"ipfs-message-port-server": "^0.0.1"
2929
},

examples/browser-sharing-node-across-tabs/src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const main = async () => {
1818

1919
const uploader = async (ipfs) => {
2020
document.body.outerHTML += '<div>Adding "hello world!" to shared IPFS node</div>'
21-
const entry = await ipfs.add(ipfs, new Blob(['hello world!'], { type: "text/plain" }))
21+
const entry = await ipfs.add(new Blob(['hello world!'], { type: "text/plain" }))
2222
const path = `/ipfs/${entry.cid}/`
2323
document.body.outerHTML += `<div class="ipfs-add">File was added:
2424
<a target="_blank" href="${new URL(`#${path}`, location)}">${path}</a>

examples/browser-sharing-node-across-tabs/webpack.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var path = require('path')
44
var webpack = require('webpack')
55
const WorkerPlugin = require('worker-plugin')
6+
const CopyWebpackPlugin = require('copy-webpack-plugin')
67

78
module.exports = {
89
devtool: 'source-map',
@@ -13,14 +14,18 @@ module.exports = {
1314
],
1415
output: {
1516
path: path.join(__dirname, 'dist'),
16-
filename: 'static/bundle.js'
17+
filename: 'static/bundle.js',
18+
publicPath: '/'
1719
},
1820
plugins: [
1921
new WorkerPlugin({
2022
sharedWorker: true,
2123
globalObject: 'self'
2224
}),
23-
new webpack.HotModuleReplacementPlugin()
25+
new webpack.HotModuleReplacementPlugin(),
26+
new CopyWebpackPlugin([{
27+
from: 'index.html'
28+
}])
2429
],
2530
module: {
2631
rules: [

0 commit comments

Comments
 (0)