Uniswap / widgets

widgets-uniswap.vercel.app
GNU General Public License v3.0
126 stars 184 forks source link

v2.25: Cannot find module @uniswap/conedison/dist/format #404

Open au2001 opened 1 year ago

au2001 commented 1 year ago

Bug Description Whenever I try to start or build my app, the following error is raised:

Error: Cannot find module '/app/node_modules/@uniswap/conedison/dist/format'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:1016:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:1009:15)
    at resolveExports (node:internal/modules/cjs/loader:529:14)
    at Module._findPath (node:internal/modules/cjs/loader:569:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:981:27)
    at mod._resolveFilename (/app/node_modules/next/dist/build/webpack/require-hook.js:23:32)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/app/node_modules/@uniswap/widgets/dist/cjs/index-48446dbf.cjs:66:14) {
  code: 'MODULE_NOT_FOUND',
  path: '/app/node_modules/@uniswap/conedison/package.json'
}

Steps to Reproduce

  1. Create a Next.js app
  2. Install @uniswap/widgets version 2.25.0 or higher
  3. Add the component to a page
  4. Start or build the app

Expected Behavior The app should not throw an error.

Temporary Solution Downgrading to version 2.24.0 solves this issue.

zyrm commented 1 year ago

Same

rharkor commented 1 year ago

Same

just-toby commented 1 year ago

this is a known issue in our conedison number formatting library. until we can fix it on that side, you can try mapping the library like we do in our interface: https://github.com/Uniswap/interface/blob/main/craco.config.cjs#L42

ZiggStardust commented 1 year ago

@just-toby which is the stable version ? If we are waiting for the conedison number formatting library to update ?

just-toby commented 1 year ago

@ZiggStardust i don't think there's a breaking change in this repo - we've always remapped our imports of conedison as shown in the link above.

houman-sanati commented 1 year ago

@ZiggStardust vetsion 2.24.0 is working like a charm and is not missing any dependencies.

Tomiblanchard commented 1 year ago

@ZiggStardust i don't think there's a breaking change in this repo - we've always remapped our imports of conedison as shown in the link above.

Here's what I tried for a NextJS app with version 2.25.0 or higher :

  1. yarn add @uniswap/widgets

  2. yarn dev

  3. Hit with a Server Error Error: Cannot find module '.../node_modules/@uniswap/conedison/dist/provider'

  4. Remapping in next.config.js as advised by @just-toby config.resolve.alias['@uniswap/conedison'] = '@uniswap/conedison/dist'

  5. Hit with a Module not found error

    ./node_modules/@uniswap/widgets/dist/clientSideSmartOrderRouter-3dbdcd6a.js:46:0
    Module not found: Can't resolve '@uniswap/conedison/provider'
marcinciarka commented 1 year ago

Had luck with disabling SSR for that particular component with a dynamic component: https://blog.bitsrc.io/using-non-ssr-friendly-components-with-next-js-916f38e8992c

misha256 commented 1 year ago

@marcinciarka like that? const { SwapWidget, darkTheme, lightTheme } = dynamic( () => import('@uniswap/widgets'), { ssr: false }, );

victaphu commented 1 year ago

Not sure if this will help, but I struggled with the dynamic imports until I did the following:

const SwapWidget = dynamic( async() => { const res = await import('@uniswap/widgets'); return res.SwapWidget; }, {ssr: false} )

I tried the above with what @misha256 mentioned but it threw an exception

keirongulrajani commented 1 year ago

this is a known issue in our conedison number formatting library. until we can fix it on that side, you can try mapping the library like we do in our interface: https://github.com/Uniswap/interface/blob/main/craco.config.cjs#L42

Following this advice in the resolve > alias part of my webpack config seems to have resolved the issue for me too:

....
module.exports = {
   ...
  resolve: {
    alias: {
      ...
      '@uniswap/conedison': '@uniswap/conedison/dist',
    }
  },
ZowieTao commented 1 year ago
info  - Collecting page data ...Error: Cannot find module '/Users/.../node_modules/@uniswap/conedison/dist/provider/signing'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:1096:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:1089:15)
    at resolveExports (node:internal/modules/cjs/loader:565:14)
    at Module._findPath (node:internal/modules/cjs/loader:634:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1061:27)
    at mod._resolveFilename (/Users/.../node_modules/next/dist/build/webpack/require-hook.js:23:32)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/Users/.../node_modules/@uniswap/widgets/dist/cjs/index-4f48ae8b.cjs:47:15) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/.../node_modules/@uniswap/conedison/package.json'
}

> Build error occurred
Error: Failed to collect page data for /
    at /Users/.../node_modules/next/dist/build/utils.js:963:15 {
  type: 'Error'
}

widget version: 2.51.2

celsosa commented 1 year ago
info  - Collecting page data ...Error: Cannot find module '/Users/.../node_modules/@uniswap/conedison/dist/provider/signing'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:1096:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:1089:15)
    at resolveExports (node:internal/modules/cjs/loader:565:14)
    at Module._findPath (node:internal/modules/cjs/loader:634:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1061:27)
    at mod._resolveFilename (/Users/.../node_modules/next/dist/build/webpack/require-hook.js:23:32)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/Users/.../node_modules/@uniswap/widgets/dist/cjs/index-4f48ae8b.cjs:47:15) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/.../node_modules/@uniswap/conedison/package.json'
}

> Build error occurred
Error: Failed to collect page data for /
    at /Users/.../node_modules/next/dist/build/utils.js:963:15 {
  type: 'Error'
}

widget version: 2.51.2

same error here

WyattMufson commented 1 year ago

Related issue https://github.com/Uniswap/widgets/issues/580