Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include CommonJS exports in addition to ESM so this library can be used in a next.js custom server #443

Open
MorganDavid opened this issue Mar 4, 2024 · 5 comments
Labels
needs-repro We need a minimal reproduction to investigate

Comments

@MorganDavid
Copy link

MorganDavid commented Mar 4, 2024

Next.js Custom servers don't support ESM exports in third party libraries (vercel/next.js#36940)

Since next-mdx-remote doesn't have commonjs exports, it's difficult to get this library to work in projects that use a custom server.

vercel/next.js#36940

Trying to use this library in the custom server, results in this error:

Error: require() of ES Module <path> not supported.
Instead change the require of index.js in <path> to a dynamic import() which is available in all CommonJS modules

I realise this is probably a next.js problem... but thought I'd leave this here in case anybody runs into this problem.

@MorganDavid MorganDavid changed the title Include CommonJS exports in addition to ESM Include CommonJS exports in addition to ESM so this library can be used in a next.js custom server Mar 4, 2024
@MorganDavid MorganDavid changed the title Include CommonJS exports in addition to ESM so this library can be used in a next.js custom server Include CommonJS exports in addition to ESM so this library can be used in a next.js server Mar 4, 2024
@MorganDavid MorganDavid changed the title Include CommonJS exports in addition to ESM so this library can be used in a next.js server Include CommonJS exports in addition to ESM so this library can be used in a next.js custom server Mar 4, 2024
@dstaley
Copy link
Contributor

dstaley commented Mar 14, 2024

@MorganDavid Thanks for reporting this! I'm reasonably confident this isn't something we're going to implement as we've already taken the plunge to be an ESM only package (and have been so for over two years). That being said I'd be happy to take a look at a minimal reproduction of the issue if you're down to make one; the linked issue does not have a clear reproduction, and is using Next.js v12, which is practically ancient at this point.

@dstaley dstaley added the needs-repro We need a minimal reproduction to investigate label Mar 14, 2024
@karlhorky
Copy link

@MorganDavid did you try the NodeNext workaround mentioned by @nicholasgriffintn in the issue?

@bcigdemoglu
Copy link

NodeNext workaround does not work for me

@karlhorky
Copy link

@bcigdemoglu probably need more context (any error messages, what exactly you've tried, reproduction repo, what your guess is of the problem) if you're looking for some help from others here :)

@lei-cao
Copy link

lei-cao commented May 18, 2024

there was another ticket
#381 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-repro We need a minimal reproduction to investigate
Projects
None yet
Development

No branches or pull requests

5 participants