solana-auth icon indicating copy to clipboard operation
solana-auth copied to clipboard

Package doesn't work with Next.js because of invalid ESM

Open phoenixeliot opened this issue 2 years ago • 3 comments

As far as I understand, ESM (at least in Next.js) doesn't support the "importing a folder implicitly means importing its index.js" feature. I get this error, when running the example project given in this very repo:

error - unhandledRejection: Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/private/tmp/crossmint-solana-auth/node_modules/@crossmint/solana-auth-base/lib/esm/handlers' is not supported resolving ES modules imported from /private/tmp/crossmint-solana-auth/node_modules/@crossmint/solana-auth-base/lib/esm/index.js

I can temporarily resolve this by deleting the esm folder from the node_modules for this package, forcing Next to use the cjs folder instead, but there is no good way to reproduce that programmatically.

phoenixeliot avatar Apr 01 '22 03:04 phoenixeliot

I ended up temporarily hacking around this by doing import {...} from '../../../../node_modules/@crossmint/solana-auth-base/lib/cjs'

phoenixeliot avatar Apr 01 '22 03:04 phoenixeliot

Hi @phoenixeliot! We are working on fixing this.

For now, we suggest using the next-transpile-modules package as explained here in the README.

jiito avatar Apr 06 '22 17:04 jiito

I get this same error, even with next-transpile-modules

Steenos avatar Jul 08 '22 16:07 Steenos