Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Remove optional chaining from code that will be transpiled (ipfs-http-client) #3795

Closed
schettn opened this issue Aug 8, 2021 · 3 comments
Closed

Comments

@schettn
Copy link

schettn commented Aug 8, 2021

Hi! 👋

Firstly, thanks for your work on this project!

Today I used patch-package to patch ipfs-http-client@51.0.1 for the project I'm working on.

I use ipfs-http-client inside of https://github.com/storybookjs/storybook.
Due to optional chaining storybooks built in webpack configuration fails to build.

I am aware that this problem is mainly related to storybook however I saw the following PR #3698.
This topic is also taken up there.
It would be very nice to enjoy the next release of ipfs-http-client` without optional chaining.

Here is the diff that solved my problem:

diff --git a/node_modules/ipfs-http-client/src/index.js b/node_modules/ipfs-http-client/src/index.js
index 521aaa7..a2e90b4 100644
--- a/node_modules/ipfs-http-client/src/index.js
+++ b/node_modules/ipfs-http-client/src/index.js
@@ -42,7 +42,7 @@ function create (options = {}) {
     loadBase: options.ipld && options.ipld.loadBase
   })
   const codecs = new Multicodecs({
-    codecs: [dagPb, dagCbor, raw, json, id].concat(options.ipld?.codecs || []),
+    codecs: [dagPb, dagCbor, raw, json, id].concat(options.ipld && options.ipld.codecs || []),
     loadCodec: options.ipld && options.ipld.loadCodec
   })
   const hashers = new Multihashes({
@welcome
Copy link

welcome bot commented Aug 8, 2021

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

@achingbrain
Copy link
Member

Thanks for opening this - a fix for this went in as part of #3785 - could you please try with the latest rc?

$ npm i ipfs-http-client@next

@achingbrain
Copy link
Member

This was shipped in ipfs-http-client@52.0.0, please re-open if you're still having problems.

kleberbaum pushed a commit to snek-at/snek-tools that referenced this issue Aug 11, 2021
Patches are no longer required due to the release
of ipfs-http-client@52.0.0.

re ipfs/js-ipfs#3795 (comment)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants