-
-
Notifications
You must be signed in to change notification settings - Fork 145
fix: Set correct module type in basic package #729
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
Conversation
@danez Oh, I didn’t know there was such a solution. I’m not sure if there’s any documentation available for me to learn from, but can I merge it first? It looks like this change won’t affect the dependent packages. I noticed that you didn’t remove the exports and types fields from the original package.json. thx! |
Yes this PR works as is. I did not remove the fields from package.json, because I did not want to break vite and stuff. With this PR it should be fixed and no need to remove. |
@danez Alright, I'll go ahead and merge this. Based on my testing, it doesn't affect our existing project. |
Hmm. I'm still seeing the error showing up: All I have to do to trigger this is Thanks for the quick response on this. And hopefully there's a similarly easy fix for the remaining bug. Let me know if you need any other info about my project. Cheers. |
@JimCarnicelli I’m not sure if this will fully resolve the issue, but I didn’t encounter any problems during my testing. You can refer to this example: React Codemirror Next.js Example. |
This is a fix/workaround for the CommonJS/esm issue.
The root cause was adding the
exports
fields inpackage.json
. Before it was introduced, Node.js would pick up what is defined in themain
field (cjs) and bundlers used themodule
field (esm). When theexports
field was introduced, Node.js started picking up the esm version too, but is nagging about notypes
field inpackage.json
. After thetypes
field was added, commonjs in bundlers is not working anymore becausepackage.json
says that all.js
files in the package are ESM.Possibilities:
exports
andtype
fields in package.jsonpackage.json
files and define the type correctly for the generated files. (What this PR does)Fixes #724
Fixes #719
Ref #710
Ref #680