Webpack has trouble dealing with some ES Modules dependencies #64942
minenwerfer
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
None that I know of.
Background
When using the
bson
package inside a Server Action, Webpack complains of a top-level await being used. This can be patched using the following innext.config.js
:I am a library developer and my library depends on the
bson
package, so every NextJS user that wished to integrate with my library would have to patch their configs manually, make adoption harder.Proposal
My idea is, NextJS should provide a
webpack
(ornextjs
) conditional export name that will be preferred overimport
so library developers could use this strategy to force problematic dependencies to be handled as CommonJS. Something like the following:So I would be able to open a PR in
bson
setting this conditional export to a CommonJS file and changes innext.config.js
wouldn't be needed anymore. This is also great because it is very unlikely to break anything.Beta Was this translation helpful? Give feedback.
All reactions