-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
fix: fix esm support and types #57
Conversation
The non-standard `package.json` field `module` was used. This pointed to a faux ESM file (Uses ESM syntax, but has a `.js` file extension in a package which doesn’t specify `"type": "module"`. ESM support was fixed by using the `.mjs` file extension for the ESM export and defining a proper `exports` field in `package.json. The types reflected a package that has the `module.exports.default` field. This was incorrect. The CommonJS types have now been fixed to use `export =`, which is the correct way to type modules that use `module.exports` assignments. Additional types were added for ESM support.
clsx already works with The rest of this PR is adding breaking changes:
|
Node 13-13.7 had a different exports map specification. The finalized spec throws an error in these versions and there’s no way to support both. Thus adding sny exports map is breaking as it has to be done with a minimum version bump.
Yes it is. You can define “types” for exports to a standard .d.ts file, even for nodenext/node16 mode. The mts extension is just to force/guarantee that TS treats the file as ESM, similar to .mjs even tho .js can also contain ESM. In fact, mts is a front/stand-in for would-be-emitted .mjs files. |
@lukeed I kindly ask you to reconsider this or equivalent PR. Incorrect types are causing us a ton of problems which may force us to replace clsx with correctly typed classnames in many repositories and that would be a huge bummer. |
I'll cut a new major version that includes an "exports" map |
Codecov ReportPatch and project coverage have no change.
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## master #57 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 22 22
=========================================
Hits 22 22 ☔ View full report in Codecov by Sentry. |
Thanks for merging and releasing this! ❤️ |
Thank you for the PR & patience! |
related to: lukeed/clsx#57 also related to: react-grid-layout#667
The non-standard
package.json
fieldmodule
was used. This pointed to a faux ESM file (Uses ESM syntax, but has a.js
file extension in a package which doesn’t specify"type": "module"
.ESM support was fixed by using the
.mjs
file extension for the ESM export and defining a properexports
field in `package.json.The types reflected a package that has the
module.exports.default
field. This was incorrect. The CommonJS types have now been fixed to useexport =
, which is the correct way to type modules that usemodule.exports
assignments.Additional types were added for ESM support.
This fixes the following issues that have previously been closed without a solution.
Closes #27
Closes #43
Closes #50
To try this locally, try running the following in the Node.js repl from the package root: