-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: remove non default ipld formats in the browser #1980
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but lets cc @olizilla as this impacts IPLD Explorer in Web UI
|
||
To add support for other formats we provide two options, one sync and another async. | ||
|
||
Examples for the sync option: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the wonderful documenting @hugomrdias, I love it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is rad. 👍 I look forward to tweaking IPLD explorer for this change.
The only thing that could make it better is a mechanim that would allow the user to provided custom implementations of dag-pb
and dag-cbor
and dag-raw
. I don't know if that's a feature that anyone wants, but as js-ipld will throw if it finds duplicate handlers for a single format, and the defaults are added regardless, it's the only issue that occured to me as I read the (beautiful) code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
They actually are not added regardless in IPLD, but i forced it on IPFS side with this PR. new IPLD({
formats: [require('ipld-git'])
}) He only gets git and NOT pb, cbor and raw but now with IPFS the user gets pb, cbor, raw and git. Regarding your comment on custom dag-pb it's a design problem |
I'm 👍 on making the bundle size smaller and I'm 👍 on providing a build of IPFS that doesn't have these IPLD formats for developers who do not use and will never use other IPLD formats. I'm 👎 on removing them by default because it won't help IPLD adoption. It raises a barrier for people experimenting with IPLD that the project just doesn't need at this point in it's life. People should just be able to fetch a git commit or an ethereum block from their web app if they want to and experience the magic without having to learn about IPLD format modules and how to programmatically load them. The documentation in this PR is great, but do you think that someone putting a script tag on their page and trying to In general the default IPFS you get when you IMHO the solution to the problem of the IPLD modules being big or incomplete is not to remove them from IPFS (or even IPLD for that matter) but to fix them. I feel like we're focusing our energies in the wrong place. That said, what if we iterate on this PR and add an additional browser build that doesn't include the more exotic IPLD formats and a There seems to be a lot of support for this PR so I'm not going to stand in the way of merging this if the @ipfs/javascript-team team really believes it's necessary. If you're in agreement with the compromise I suggested above (or something similar) then please vote with a 👍 and if you disagree and would prefer to merge this as is then 👎 on this comment and I'll get it done. |
This is basically the standard problem of magic vs control, IMO we should go for control because were are coding the build blocks of the decentralized web, magic should come in with the devs building apps and frameworks with our code. These devs will want control over magic.
We can make our bundle the one used when loaded using UNPKG with a script tag, include all the formats easily using .aegir.js to add an alias for webpack.
Agreed, still i don't think we should force all users to include them, goes back to control over magic.
For me this would raise more questions in the user mind than a well written error message with a link to the simple solution. |
Good point! I'm very much favour of fixing the IPLD formats. Alan's point about focusing our efforts on where they can do most good is important. IPLD Explorer and anyone wanting to experience the magic wont get much futher than files, cbor and git today, regardless of if they are bundled by default, or have clear instructions on how to add them. But perf and bundle size is important too, and the browser runtime is arguably more important to us than node is. I'm in favour of not supporting all formats by default in js-ipfs. I'd be in favour of a compromise like including My real dream......is that we pull out the `dag` api entirely to it's own tool called `ipld` and we focus the ipfs story on files, and then follow up with "you want arbitrary, cross-system, merkle graphs with friends!? we got you! try out the `ipld` tool. |
FYI, we’re working on a new JS stack for IPLD authoring https://github.com/ipld/js-ipld-stack One change is that the Block interface dynamically loads the necessary codec using a new library called Update: here’s a more complete sample of what I’m thinking for |
I think that's a good compromise - can we do this please @hugomrdias? To confirm:
|
@mikeal that's rad! I'm excited for Did you see #1830? Similar kind of idea but loading directly from IPFS. It had significant push back (see the PR comments) so my next step was to pull it out into a module people could use, similar to |
Yes
Yes, correct. |
Co-Authored-By: hugomrdias <mail@hugodias.me>
eafef16
to
6bfca39
Compare
@hugomrdias I've rebased for green CI |
Folks, this seems like a good win when it comes to bundle size. Did you get the chance to make sure that the experience of https://github.com/ipfs/js-ipfs/tree/master/examples/traverse-ipld-graphs && https://github.com/ipfs/js-ipfs/tree/master/examples/explore-ethereum-blockchain is still flawless? Also, I see that no tests were added to check the remaining formats integration. Was this intentional? |
Since these are Node.js based examples they should be fine - in Node.js all the formats are still included (as always). This would also have been checked as part of the release process for 0.35.
No that would be a good test to add. We don't do any testing with the built CDN bundle and we really should. |
@alanshaw our karma tests, effectively test our "built CDN bundle" just doesn't run terserjs to increase speed. There is an issue in aegir to add terserjs to karma to be 100% the same thing. |
This PR removes non default ipld formats in the browser, these formats are extremely big, some of them aren't finished and are not commonly used in the wild.
Considering that we now have options to add support for them in the config passed to the IPFS constructor in both sync and async ways, we should let the developer choose which formats to support and make their bundle smaller and faster to load.
Documentation was added to explain how to handle the ipld config in several ways.