js-sdk icon indicating copy to clipboard operation
js-sdk copied to clipboard

No known conditions for "./cid" specifier in "multiformats" package

Open 0x62 opened this issue 1 year ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

SDK version

5.0.0

Lit Network

All

Description of the bug/issue

I'm trying to use the SDK in a project with Remix + Vite. I get the error:

✘ [ERROR] No known conditions for "./cid" specifier in "multiformats" package [plugin vite:dep-pre-bundle]

The plugin "vite:dep-pre-bundle" was triggered by this import

    ../node_modules/@lit-protocol/contracts-sdk/src/lib/contracts-sdk.js:34:18:
      34 │     CID = require('multiformats/cid');

The error is triggered by this line in the contracts SDK package.

I'm not sure why this is the only dependancy imported with require(). I use the CID package in my project as well, where it is imported with:

import { CID } from 'multiformats/cid'

This error has only appeared after migrating Remix from their built-in bundler to Vite. However, while using this package before the migration the console was constantly spammed with "CID not found", so it looks like the import wasn't working in the first place.

Severity of the bug

Blocking

Steps To Reproduce

  1. Create a Remix + Vite project (you may also be able to reproduce this on any framework using Vite, but I haven't tried)
  2. Import the SDK and build
  3. Error triggered

Link to code

No response

Anything else?

No response

0x62 avatar Apr 29 '24 21:04 0x62

Is there any update on the progress of this issue? I'm trying to implement Lit, but blocked by this error.

aimensahnoun avatar May 15 '24 12:05 aimensahnoun

Is there any update on the progress of this issue? I'm trying to implement Lit, but blocked by this error.

Yes, we have a PR up for this https://github.com/LIT-Protocol/js-sdk/pull/467

Ansonhkg avatar May 15 '24 13:05 Ansonhkg

It's now published to 5.1.0!

Please let me know if this is working for you :) @aimensahnoun @0x62

Ansonhkg avatar May 15 '24 15:05 Ansonhkg