-
Notifications
You must be signed in to change notification settings - Fork 164
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
Can't be used with Next.js: Consider publishing non ESM modules: is a nightmare to setup and make it work! #385
Comments
See jantimon/favicons-webpack-plugin#291 just replace |
Thanks for the help, but after spending countless hours I fixed in 30 minutes (including creating a npm account). I tried all kind of imports... but seems like magic. Maybe my lack of understanding of esm. I ended up republishing with es5 and ts: https://www.npmjs.com/package/@esm-to-es5/favicons works out of the box with everything :) and no need to install @types. |
I'm also having a lot of trouble with this. A lot of tooling (e.g. e2e test runners) expects you to use either CJS or MJS, not a mix of the two, and as almost everything else on NPM is CJS, I therefore cannot use any MJS packages at this time. |
CJS is available since v7.0.0-beta.4 |
I have to add this util
Then when I want to use it:
Took me hours to figure out. In addition:
ts-node
must start withts-node --esm
tsconfig needs:
Also can't import types obviously this way. Maybe with
import type
?In addition, using
--esm
will break next.js with this error:[Error: EPERM: operation not permitted, open \.next\trace
.New edit: the
import-esm.js
must also be manually copied in the build when run in production.. So much work to use this library.The text was updated successfully, but these errors were encountered: