-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Does not work with UglifyJS version 2 #938
Comments
Thanks for reporting this, @lightninglu10 🌟 I believe this issue is related to libp2p/js-libp2p#65. tl;dr; We use the constructor name for the type checks and since Uglify changes it per module, a lack of treeshaking makes it create different names for the same module. Weird to me that we actually do not use the constructor name anywhere in CID, I wonder if you are using the latest version of all the modules. @lightninglu10 mind trying using js-ipfs by installing it from the repo with |
@diasdavid Installed via |
@lightninglu10 yeah, the issue comes from uglify or what uglify tries to do. We have to change the way we do some of the duck typing. |
Could it be that you're not transpiling ES6? create-react-app notoriously won't compile ES6 unless you eject (which removes all the advantages of using create-react-app) |
Same issue as ipfs-inactive/js-ipfs-http-client#611 (comment) |
@diasdavid Unfortunately, you're essentially saying that |
@lightninglu10 I had the same problem with my project (build with Angular 4), when I tried to go with production mode. Let me know if you were using angular, I can help with the Uglify problem. |
You will likely run into issues with other deps using |
@thisconnect @cristiano-belloni what worked for me was adding it from unpkg in index.html and then calling it in my component via |
Has anyone tried the latest create-react-app? Related: |
The latest create-react-app doesn't have the most recent uglify-js, since they're currently waiting until a bigger 2.0 release to include it :(. |
@diasdavid this is with
We are currently working around the issue using this trick while we wait for create-react-app to use uglify-es or for this to land in a release |
@fazo96 thanks so much for checking and providing those links. That trick should do it for the other folks while create-react-app doesn't get a new release. 👍 ❤️ |
The real issue is our "poor duck typing" used in some modules by checking the constructor name. @pgte's proposal at #1131 (comment) is sound and should be the adopted one. @fsdiogo this would be a great contribution :) |
I've started the release party! multiformats and libp2p done \o/, next up is IPLD and then IPFS |
@diasdavid js-libp2p-webrtc-star and js-libp2p-utp didn't get released, only merged to master, so they haven't been updated in the libp2p dependencies. |
@fsdiogo understood. releasing webrtc-star. utp won't be necessary as it isn't used anywhere. |
@diasdavid awesome, thanks 👍 libp2p only got merged too, can you address that as well? 😇 |
Did some more work on merging and releasing. Repos missing (by order): |
@diasdavid great, thanks! The dependencies of the following repos should be updated too: |
I'm having some problems with the way npm hoists the js-ipfs dependencies. When testing locally everything works fine because when npm linking some repos, the latest version gets used, but that's not the case when I clone, update the Expect some PRs updating the deps, I hope I can circumvent the problem that way. I'll list here what needs to be merged and released: |
done :) |
@fsdiogo can we get a confirmation from your example that everything is working as expected and also a PR to ipfs/aegir to bring back uglify and reduce the bundle size? |
@diasdavid Not quite, right now I'm using the browser-script-tag example to test the bundled ipfs versions, but I'm getting this error creating a node, even in the non-uglified bundle: Going to look into it. EDIT: a new version of -- About the I think we should open a new issue in AEgir to serve a transpiled version of IPFS that can be used with CRA and like-minded tools, and start closing and pointing issues like this one to that issue that has all of this info. What do you guys think? |
Opened a PR enabling the uglify mangling and compress. |
@fsdiogo the issue with I encountered the problem in an unrelated context but had success with forcing that package to version |
Hey @fazo96, you're right 👍, although a bit too late as I've already submitted a PR (ipld/js-ipld-dag-pb#66) a few days ago with that solution an has been merged and released, so it should be good now! But thanks for pointing that out 🙂 |
I've lost track of what this is incorporated in, Does this mean we can build the compact (production) version of an app that embeds IPFS with webpack now? And if so, will that work with ipfs 0.28.2 or will it have to wait for the next release? |
Hey @mitra42, this issue is pretty confusing and it's mixing multiple problems.
|
Thanks @fsdiogo - I think I'm looking at the first issue (not being able to minify due to type checks). We are using "require ipfs" to include IPFS in the larger app, and already have it working with webpack in non-minified way. I think the (example)[https://github.com/ipfs/js-ipfs/tree/master/examples/browser-webpack] is overcomplex for that, most of the webpack config seems to be to get the HTML/React examples working rather than IPFS itself. The only config we needed was the usual stuff to exclude node modules though its interesting to see you've exclude "net" and "tls" as well as the usual "fs". So if I understand correct I have to wait till js-ipfs 0.28.3 which should have your type-checking fixes in it. |
It won't be a patch, it'll be a minor release, due to my commit 5b2cf8c. But yes, you'll then be able to uglify it and not have errors due to the type checks, just be sure to use |
Minor release meaning 0.28.3 ? |
No, that would be a patch. Minor release is |
I've started the issue for the next release -- #1320 --, I hope it to be ready this week and released by early next :) |
Let us continue this discussion in #1321. |
Type: Bug
Severity: Critical
Description:
Trying to build IPFS node in the browser, uglifyJS through webpack won't build the app.
Hey guys, I'm trying to build an IPFS node in my browser. Building the app with
yarn run build
using create-react-app gives the error above. It looks like it doesn't like the type CID. I've installed CID as well, but no go. Anyone know what's going on here?The text was updated successfully, but these errors were encountered: