-
Notifications
You must be signed in to change notification settings - Fork 103
Description
Description
One of the differences introduced by TypeScript v5 is that .d.ts files are affected by esm and cjs contexts. So, sharing a single .d.ts file between the two can lead to invalid formats when a library is dual publishing for these contexts.
The solution is to generate .d.mts & .d.cjs files.
https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md
https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseESM.md
Under what circumstance would Vite create these wrong, I am not sure. However, for integrity, it would be best for these to be split up.
Suggested solution
Create an option to generate different, or multiple versions of the output files. It's not necessarily a requirement for the library to add specific support to generate .d.mts, .d.cts variants, but the ability to do it yourself would work.
Perhaps this is already possible through one of the included hooks. However, this I am not sure of.
Alternative
I don't really think there is an alternative.
Additional context
Alternatively/additionally, a section on the FAQ could also help.
This could also be a vue-tsc related issue, as I don't think they generate those files.
Validations
- Read the FAQ.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.