fix: add CommonJS support via "require" export in package.json#139
fix: add CommonJS support via "require" export in package.json#139techniq merged 4 commits intotechniq:mainfrom
Conversation
|
Hi @abcdannyyoo 👋 We dropped CJS support in Adding it back will require a separate build step to produce a |
fb0ee27 to
11c6b47
Compare
|
Hi @techniq, Thanks for the context! I've updated the PR with a Vite config that now produces both ESM and CJS outputs. It might sound a bit silly, but I noticed there were no actual |
|
Hi @abcdannyyoo. There is a
...and is the recommend extension to help Node.js distinguish between CommonJS ( @enure performed the previous Vite migration and tsconfig cleanup and might have some suggestions here as well. I also don't want to break any current ESM use cases at the expense of re-supporting CJS. |
|
@techniq Ah, I wasn't entirely sure how I'll give it another go and make some changes sometime today. |
|
@techniq Just pushed an update reverting the ESM output back to |
c39be5a to
1f45898
Compare
|
Thanks @abcdannyyoo, I appreciate the iterations. I took a quick look and everything looks in order. I noticed 2 warnings in the console.
Looks like we can remove Also, the warning about named and default exports is rather interesting. Been a lot of discussion on this in the past but never knew it was "intentional". I'm going to see if others have any additional improvements, but looks good to me from a quick local check.
|
|
@abcdannyyoo actually, can you rename |
|
@techniq Done ✌️ |
5c3c27c to
94d3627
Compare
|
Thanks again @abcdannyyoo. One last request and should be it. Can you add a changeset ( |
|
@techniq All good. Just added the changeset file. Let me know if there's anything else. |
|
Released as 8.0.4 |
|
@techniq Appreciate the merge and thanks for being open to reintroduce cjs support. |




Hey team,
I came across an issue when trying to use buildQuery from "odata-query" in a CommonJS project, importing it like this:
import buildQuery from "odata-query";which throws an error:
Error: No "exports" main defined in odata-query/package.jsonThis PR adds
"require": "./dist/index.js.mjs"to package.jsonI believe this change allows CommonJS compatibility while preserving existing ESM behavior.