Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit efc503b

Browse files
authored
fix: update ipfs versions (#365)
Updates all examples to use ESM versions of IPFS, swaps parcel for vite everywhere and removes old browserify example because it only understands CJS.
1 parent 2e763dc commit efc503b

File tree

6 files changed

+34
-22
lines changed

6 files changed

+34
-22
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/>
1919
<link rel="shortcut icon" href="favicon.ico" />
2020

21-
<script type="module" src="./src/index.js" defer></script>
21+
<script type="module" src="./src/index.jsx" defer></script>
2222
</head>
2323
<body class="montserrat f5">
2424
<div id="root"></div>

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,35 @@
22
"name": "example-http-client-upload-file",
33
"version": "1.0.0",
44
"private": true,
5+
"type": "module",
56
"description": "Upload file to IPFS via browser using js-ipfs-http-client",
67
"license": "MIT",
78
"author": "Harlan T Wood <[email protected]>",
89
"contributors": [
910
"Victor Bjelkholm <[email protected]>"
1011
],
1112
"scripts": {
12-
"clean": "rimraf ./dist ./.cache ./.parcel-cache",
13-
"build": "parcel build index.html --no-scope-hoist",
14-
"serve": "parcel serve index.html --open -p 8888",
13+
"clean": "rimraf ./dist ./.cache ./node_modules/.vite",
14+
"build": "vite build",
15+
"serve": "vite dev --port 8888",
1516
"start": "npm run serve",
1617
"test": "npm run build && playwright test tests"
1718
},
1819
"browserslist": "last 1 Chrome version",
1920
"dependencies": {
20-
"ipfs-http-client": "^56.0.0",
21+
"ipfs-http-client": "^57.0.1",
2122
"react": "^17.0.2",
2223
"react-dom": "^17.0.2"
2324
},
2425
"devDependencies": {
2526
"@babel/core": "^7.14.8",
2627
"@playwright/test": "^1.12.3",
27-
"ipfs": "^0.62.0",
28-
"parcel": "^2.3.2",
28+
"ipfs": "^0.63.3",
2929
"playwright": "^1.12.3",
3030
"process": "^0.11.10",
3131
"rimraf": "^3.0.2",
3232
"test-util-ipfs-example": "^1.0.2",
33-
"util": "^0.12.4"
33+
"util": "^0.12.4",
34+
"vite": "^3.0.0-beta.1"
3435
}
3536
}

src/app.js renamed to src/app.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/* eslint-disable no-console */
2-
'use strict'
3-
42
import { create } from 'ipfs-http-client'
53
import React, { useState, useEffect } from 'react'
6-
import logo from "url:./../public/ipfs-logo.svg";
4+
import logo from '../public/ipfs-logo.svg'
75

86
const Connect = ({ setIpfs }) => {
97
const [multiaddr, setMultiaddr] = useState('/ip4/127.0.0.1/tcp/5001')
@@ -153,7 +151,7 @@ const Details = ({keys, obj}) => {
153151
{keys?.map((key) => (
154152
<div className='mb4' key={key}>
155153
<h2 className='f5 ma0 pb2 aqua fw4'>{key}</h2>
156-
<div className='bg-white pa2 br2 truncate monospace' data-test={key}>{obj[key]}</div>
154+
<div className='bg-white pa2 br2 truncate monospace' data-test={key}>{obj[key].toString()}</div>
157155
</div>
158156
))}
159157
</>
@@ -221,4 +219,4 @@ const App = () => {
221219
)
222220
}
223221

224-
module.exports = App
222+
export default App
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-unused-vars */
22
'use strict'
3-
const React = require('react')
4-
const ReactDOM = require('react-dom')
5-
const App = require('./app')
3+
import React from 'react'
4+
import ReactDOM from 'react-dom'
5+
import App from './app.jsx'
66

77
ReactDOM.render(<App />, document.getElementById('root'))

tests/test.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
'use strict'
1+
import { test, expect } from '@playwright/test';
2+
import path from 'path'
3+
import { playwright } from 'test-util-ipfs-example';
4+
import { fileURLToPath } from 'url'
5+
import * as ipfsModule from 'ipfs'
6+
import * as ipfsHttpModule from 'ipfs-http-client'
27

3-
const { test, expect } = require('@playwright/test');
4-
const path = require('path')
5-
const { playwright } = require('test-util-ipfs-example');
8+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
69

710
// Setup
811
const play = test.extend({
912
...playwright.servers(),
1013
...playwright.daemons(
1114
{
12-
ipfsHttpModule: require('ipfs-http-client'),
13-
ipfsBin: require('ipfs').path()
15+
ipfsHttpModule,
16+
ipfsBin: ipfsModule.path()
1417
},
1518
{},
1619
[

vite.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
build: {
3+
target: 'esnext',
4+
minify: false
5+
},
6+
define: {
7+
'process.env.NODE_DEBUG': 'false',
8+
'global': 'globalThis'
9+
}
10+
}

0 commit comments

Comments
 (0)