LIT-Protocol / js-sdk

The Lit Protocol SDK provides developers with a framework for implementing Lit functionality into their own applications.
https://developer.litprotocol.com
MIT License
99 stars 60 forks source link

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

Closed 0x62 closed 4 months ago

0x62 commented 5 months ago

Is there an existing issue for this?

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

aimensahnoun commented 5 months ago

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

Ansonhkg commented 5 months ago

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 commented 5 months ago

It's now published to 5.1.0!

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