-
-
Notifications
You must be signed in to change notification settings - Fork 63
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: exports types #183
fix: exports types #183
Conversation
Makes sure that the correct Typescript definitions is exported when exports property in package.json is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thank you for submitting the PR. There are still some problems left to fix. Let me know if you need any help. See the following image:
Testing done with https://arethetypeswrong.github.io/.
Essentially, exports need to be reformatted (split) as follows:
{
"exports": {
".": {
"import": {
"types": "./index.d.ts",
"default": "./index.js"
},
"require": {
"types": "./index.d.cts",
"default": "./index.cjs"
}
}
}
}
There also has to be an additional types declaration file (see index.d.cts in the example) for the CJS format.
After reviewing the code, there is a mix of default and named exports which can (rarely) cause problems when package is consumed in CJS format (see https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSOnlyExportsDefault.md). Rollup does not correctly handle this case, so the solution is to either patch the code to add the interopability, patch the output, or remove the default export (which is of course, a breaking change). This one can wait 😄
@stefan-karlsson @MilanKovacic Thank you both for your efforts at continuing to improve this lib. Any chance we can get this PR updated and merged? |
@stefan-karlsson If you do not have time to make the proposed changes, let me know and I will do them. |
You are free to help out if you want. Have quite a lot at my work atm :) |
Close in favor of #196 |
Makes sure that the correct Typescript definitions are exported when export property in package.json is used.
Issue reference: #170