xmtp / xmtp-web

XMTP web SDKs and examples, including a React SDK and quickstart example app
https://xmtp.github.io/xmtp-web/
31 stars 12 forks source link

Bug: Next.js Support - ERR_UNSUPPORTED_DIR_IMPORT #124

Closed doktordos-eth closed 11 months ago

doktordos-eth commented 11 months ago

Describe the bug

@xmtp/react-sdk throws the follwing error in the console when executing "yarn dev" and the application gets stuck there:

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/Users/doktordos/Developer/ensvision/node_modules/date-fns/min' is not supported resolving ES modules imported from /Users/doktordos/Developer/ensvision/node_modules/@xmtp/react-sdk/lib/index.js Did you mean to import date-fns/min/index.js?

I tried changing the imports in node_modules/@xmtp/react-sdk as follows: /node_modules/@xmtp/react-sdk/lib/index.js

Lines 10-11:

import Gt from 'date-fns/min'; import $t from 'date-fns/subSeconds';

to:

import { min as Gt} from 'date-fns'; import { subSeconds as $t} from 'date-fns';

and afterwards all works as expected.

Could you please change the following imports so the package will work out of the box on next.js: https://github.com/xmtp/xmtp-web/commit/0b215a6813e9896f7c69e4d0193948478411b568

Expected behavior

See above.

Steps to reproduce the bug

Installed package @xmtp/react-sdk in next.js project via yarn add @xmtp/react-sdk throws above mentioned error in console.

doktordos-eth commented 11 months ago

fixed with latest release https://github.com/xmtp/xmtp-web/releases/tag/%40xmtp%2Freact-sdk%402.2.6