-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Parcel fails to build js-ipfs (and many other things) #1344
Comments
Thank you for troubleshooting this 👍 I've observed some intermittent issues with parcel when developing the example, but wasn't able to reliably reproduce them. They were mostly performance issues that would manifest after running the example for prolonged periods of time. However, this seems to be a different issue, I wonder if it was introduced recently or if it exists in previous versions as well? |
Yeah, was going to say the same: could we fix this by locking in the Parcel version a little tighter? It definitely worked for me while reviewing the PR. (Unless what actually happened is: a change in |
As a separate issue, it might be useful to make sure all the examples use the same bundling system (whether Parcel or something else). Less confusion about different tools across the examples and less to download and, ideally, fewer latent issues because they’ll show up everywhere instead in just one example. |
I can change it to browserify if that is preferred. |
How about seeing if pinning directly to |
+1 for pinning. There is value in having the examples show a variety of different packaging methods, and parcel is useful for getting started quickly. It sounds like the PR to fix it will be mergable this week. |
To dedupe, Parcel uses the source file as a key in a Map. identical files are deduped, regardless of where in the tree they came from. Our ipld resolver modules follow a pattern that means they often have identical index.js files, like
so for a production build, those two index.js files get deduped, and ipld-dag-cbor is returned for both requires. |
@gabrielpoca I just spotted in the #ipfs irc logs that you hit the same error a while back trying to bundle js-ipfs with parcel. Good news (a little late, but better late than never!) there is a PR to fix this on parcel over at parcel-bundler/parcel#1011 |
Hey @olizilla I wasnt expecting to be notified about something I asked on irc, thank you! This was awsome! |
@dryajov @Mr0grog alas it looks like all versions of parcel exhibit this problem, as the dedupe logic is in v1.0.1 parcel-bundler/parcel@96bf882#diff-b61d675f2dd7341e1925f9d7e7767689 Also of note, the example here is still totally useable, |
Ah! I had completely missed that part. No wonder I didn’t see the issue — I don’t think I ever tried |
Thanks @olizilla! That makes sense. Tho I agree with @olizilla on showing different bundlers in action, perhaps, the best way of doing that would be through docs, and smaller examples that would demonstrate specifically the bundler functionality and how to use it with js-ipfs, and leaving the larger examples working with browserify (or whatever bundler we decide). |
Fix is merged to parcel master, just waiting for the next release now. |
For anyone else wondering if it was released yet - when parcel version is >1.9.4 this will be fixed |
It is released, anyone available to test? |
Type:
Bug / Warning to others
Severity:
High
Description:
It's not currently possible use parcel to create production builds of apps that depend on js-ipfs. This is due to an issue in parcel, not js-ipfs.
The
parcel build
command tries to dedupe modules to reduce bundle size, but an error in the logic is leading it to incorrectly dedupeipld-git
andipld-dag-cbor
to the same module, which causes an error in js-ipld, when we try to add two identical resolvers. Ipld correctly throws an error in that case. The error is that the parcel build has resolvedrequire('ipld-git')
to the same module asrequire('ipld-dag-cbor')
Notice how ipld-git and ipld-dag-cbor map to the same integer. The same bad dedupe has happened to
ipld-bitcoin
andpld-zcash
as well, but we hit the ipld-git error first.This issue is here as warning to others.
The fix for this issue is in parcel-bundler/parcel#1011
Workarounds
build
command. Not ideal as your bundle will be unoptimised.Steps to reproduce the error:
You can see it on the circuit-relaying example in this repo:
Loading the app in a browser shows the following error:
The text was updated successfully, but these errors were encountered: