-
Notifications
You must be signed in to change notification settings - Fork 299
Provide access to bundled libraries when run in browser #406
Comments
Related with ipfs/js-ipfs#525 (comment) @lidel wanna help us achieve both? |
I am sorry, I have limited free time and need to prioritize my activities. |
Hello @diasdavid I read the Issue 525, particularly your comment previously referenced and the PRs associated. I have been analyzing how to implement this feature for both
https://github.com/ipfs/js-ipfs/blob/master/src/core/index.js#L131 exports.util = {
Buffer: Buffer,
crypto: crypto,
dagPB: dagPB,
dagCBOR: dagCBOR,
multibase: multibase,
multihash: multihash,
stream: stream
} Usage: const ipfs = require('ipfs')
const util = ipfs.util even cleaner using imports: import IPFS, { util } from 'ipfs'; In spite of being possible to provide the
Taking into account the second point, I think for consistency among repos, I should expose the util inside the class for the What do you think? |
We should call it |
So, in the For the |
Go for it :) |
For It also doesn't depend on The exact same thing happened in the PR to In the case of |
Hey @alanshaw I agree that there are several cases where the bundle size was increased with no benefit. That's why I mentioned the increase in the bundle size on the PR. However, I think that if we support this on Moreover, I also suggested removing the Buffer in a breaking change, since it is automatically added by the bundlers nowadays. This way, we could also decrease the bundle size removing it. |
We need that tree-shaking, it will come once ESM support is everywhere :) |
I just found this, I'm curious why it was defined based on an instance of ipfs, rather than something static since it points at the statically defined types. My specific use case is to do something like The current code does |
I wonder if there are any cons to exposing libraries such as
is-ipfs
,multiaddr
andmultihashes
underipfs.util.lib.*
or maybe only in browser-specific build underwindows.ipfsLibs
?I feel people who use browserified artifact would really appreciate it as it would remove code duplication in smaller projects (no need to ship library twice just to have it available as
window.foo
).Perhaps there are better ways to do this that I am not aware of? Any thoughts on this?
The text was updated successfully, but these errors were encountered: