orbitdb-archive / ipfs-log

Append-only log CRDT on IPFS
https://orbitdb.github.io/ipfs-log/
MIT License
398 stars 55 forks source link

Working example #345

Closed mateuszjarzewski closed 2 years ago

mateuszjarzewski commented 2 years ago

Is it possible to find example of working ipfs-log in browser?

The best I got is this:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    </head>
<body>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://cdn.jsdelivr.net/npm/ipfs/dist/index.min.js"></script>
    <script src="http://cdn.jsdelivr.net/npm/ipfs-log@5.4.0/dist/ipfslog.min.js"></script>
    <script src="http://cdn.jsdelivr.net/npm/orbit-db@0.28.3/dist/orbitdb.min.js"></script>
    <script src="http://cdn.jsdelivr.net/npm/orbit-db-identity-provider@0.4.0/dist/index-browser.min.js"></script>
    <script>

        new IdentityProvider.createIdentity({ id: "peerid" })

    </script>
</body>
</html>
Uncaught ReferenceError: process is not defined
    at Object.9539 (index-browser.min.js:2:966801)
    at __webpack_require__ (index-browser.min.js:2:982609)
    at Object.4918 (index-browser.min.js:2:629973)
    at __webpack_require__ (index-browser.min.js:2:982609)
    at Object.2147 (index-browser.min.js:2:628121)
    at __webpack_require__ (index-browser.min.js:2:982609)
    at Object.1301 (index-browser.min.js:2:628995)
    at __webpack_require__ (index-browser.min.js:2:982609)
    at Object.6687 (index-browser.min.js:2:868618)
    at __webpack_require__ (index-browser.min.js:2:982609)

Sadly it does not work. IPFS alone works fine.

I mean I always thought having example like this is essential for any javascript in-browser-also-or-perhaps-first project. For people that just want to get up and go and test this technology, for people with no access or no knowledge required to build this project. It's like 100 ft. wall for 90% of exceptionally good javascript developers.

evilrobot-01 commented 2 years ago

I've been looking at this recently and found that some of the packages are maybe based on node modules, so need additional bits such as https://www.npmjs.com/package/process included to get working. I'm new to modern JavaScript so still re-acquainting myself.

The approach by https://github.com/DougAnderson444/ipfs-vite-svelte-kit helped me a lot.

mateuszjarzewski commented 2 years ago

So this cannot work in browser? Why there is browser example then?

tabcat commented 2 years ago

this looks like an issue with how the orbit-db-identity-provider bundle was built. The package uses webpack 5 but looks like its missing the polyfill configuration in https://github.com/orbitdb/orbit-db-identity-provider/blob/main/conf/webpack.config.js

mateuszjarzewski commented 2 years ago

I guess this project have more dependies than typical project so this might be the root of my confusion. Thanks for help.