-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Issues bundling ipfs
with browserify
#3742
Comments
Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
Finally, remember to use https://discuss.ipfs.io if you just need general support. |
This is probably related to some of the magic that multiformats does around esm/cjs/browser transpilation and bundling. |
I think there's something messed up with how esbuild handles the The import is here. It should be covered by either the //...
"exports": {
//...
"./hashes/sha2": {
"browser": "./esm/src/hashes/sha2-browser.js",
"require": "./cjs/src/hashes/sha2",
"import": "./esm/src/hashes/sha2"
},
//...
"browser": {
//...
"./hashes/sha2": "./cjs/src/hashes/sha2-browser.js", but I don't think it's using those fields to resolve internal imports, so it tries to load the default It starts to work if I change the //...
"browser": {
//...
"./hashes/sha2": "./cjs/src/hashes/sha2-browser.js",
"./esm/src/hashes/sha2.js": "./esm/src/hashes/sha2-browser.js" This field is generated by ipjs. To generate the above json.browser[key] = _join('cjs', _browser)
if (_import !== _browser) {
json.browser[_join('esm', _import)] = _join('esm', _browser)
json.browser[_join('cjs', _import)] = _join('cjs', _browser)
} |
(nb. I see this with the examples during the post-install bundling of ipfs-core, before it's even got to the browserify bit). |
That said I'm having problems replicating this outside of this repo. |
Actually this is trivial to replicate. Just do: const basics = require('multiformats/basics') The The relevant esbuild logs are:
So esbuild checks the |
@oliveriosousa this should be fixed now, though you'll need to delete any node_modules folders and lockfiles you have to make sure you get |
@achingbrain works like a charm 👍 . |
Version:
"ipfs": "^0.55.4"
Platform:
Subsystem:
Severity:
Medium
Description:
Error bundling
ipfs
with browserify using the examplebrowser-browserify
Error: Can't walk dependency graph: Cannot find module 'multiformats/hashes/sha2'
This error may be related to the latest commits to
js-libp2p-crypto
Steps to reproduce the error:
ipfs
The text was updated successfully, but these errors were encountered: