LIT-Protocol / Issues-and-Reports

For bug reports, feature requests, and implementation questions related to Lit Protocol and use of the Lit SDK.
0 stars 0 forks source link

[Charli] ✘ [ERROR] No known conditions for "./cid" specifier in "multiformats" package [node_modules/@lit-protocol/contracts-sdk/src/lib/contracts-sdk.js:34:18:] #19

Closed zach-is-my-name closed 5 months ago

zach-is-my-name commented 5 months ago

Is there an existing issue for this?

SDK version: ^5.0.0

Lit Network: cayenne

Description: Can't build with Vite

Severity of the bug: High. Can't build with version 5

Steps To Reproduce

This vite.confit.js

import path from 'path';

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import tsconfigPaths from 'vite-tsconfig-paths'
import nodeResolve from 'rollup-plugin-node-resolve';

export default defineConfig({
  root: __dirname,
  cacheDir: '../../node_modules/.vite/apps/frontend',

  server: {
    port: 4200,
    host: 'localhost',
  },

  preview: {
    port: 4300,
    host: 'localhost',
  },

  plugins: [
    react(),
    nodePolyfills(),
    tsconfigPaths({root: '../../'}),
    nodeResolve({
      preferBuiltins: false,
      mainFields: ['browser', 'module', 'main'],
    }),
  ],

  build: {
    outDir: '../../dist/apps/frontend',
    reportCompressedSize: true,

    // sourcemap: 'inline'
    commonjsOptions: {
      transformMixedEsModules: true,
    },

    sourcemap: true
  },
  logLevel: 'info',
  define: {
    'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
    '__dirname': JSON.stringify('/')
  },
});

Receiving this error:



> @charli/source@0.0.0 dev
> vite --config apps/frontend/vite.config.ts

The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.

  VITE v5.2.10  ready in 473 ms

  ➜  Local:   http://localhost:4200/
  ➜  press h + enter to show help
✘ [ERROR] No known conditions for "./cid" specifier in "multiformats" package [plugin vite:dep-pre-bundle]

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

  This error came from the "onResolve" callback registered here:

    node_modules/vite/node_modules/esbuild/lib/main.js:1293:20:
      1293 │       let promise = setup({
           ╵                     ^

    at setup (file:///home/zmg/Projects/3-Idea/charli/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:48583:19)
    at handlePlugins (/home/zmg/Projects/3-Idea/charli/node_modules/vite/node_modules/esbuild/lib/main.js:1293:21)```
zach-is-my-name commented 5 months ago

Closing for now. I'm in a monorepo and hoisting seems to have resolved it