-
Notifications
You must be signed in to change notification settings - Fork 10
Devise an approach for dealing with pure ESM libraries #298
Comments
After further research, this looks like the same problem as I am encountering when trying to use an ESM library called |
This approach from (https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) may work:
|
The PR #358 demonstrates one way to use a ESM only library. Either do one of the following next:
|
Since this approach will be in the codebase for a while, let's document why the following warning occurs:
|
This issue is generally on hold as we wait for the dust to settle between nextjs, ReScript, and esm. |
This was done in #412. |
After #445, there are very few dependencies remaining. This issue might not arise for a while, so I will close this for now. |
"Next.js live" represents the upcoming effort to support esm fully within Next.js: https://nextjs.org/blog/next-11#nextjs-live-preview-release. |
I suspect the error I was getting when trying to convert _app.js into rescript was an esm vs commonjs issue. |
Uh oh!
There was an error while loading. Please reload this page.
Create an empty rescript nextjs project, add bindings for unist-util-visit or mdast-util-to-string, and make use of the binding. You will encounter the following error: "Must use import to load ES module".
mdast-util-to-string
links to this very useful article explaining ways to make use of ESM only libraries: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c.This issue is complete once we understand what the root cause of this problem is and what workarounds are available, if any. We have no current plans to make use of
unist-util-vist
. We do usemdast-util-to-string
, but we can use an older version which doesn't require ESM for now. We may use other similar utility libraries from theunist-util-*
set of libraries. It would be helpful to be prepared to use those libraries when the need arises.Originally posted by @kanishka-work in #296 (comment)
The text was updated successfully, but these errors were encountered: