fix: ESM and CJS type definitions conflict #1750
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The recent #1742 explicitly exports TypeScript type definitions from package.json:
Unfortunately, as documented in the TypeScript Handbook, CommonJS (
require
) and ESM (import
) module versions cannot share the same index.d.ts file:I am seeing the compiler errors that this documentation warns of.
This issue appears to have been recently fixed in
the unbuild build tool that js-lingui depends upon (see issue unjs/unbuild#238 and fix unjs/unbuild#273), and that fix was released in unbuild 2.0.0-rc0.
This fix for detect-locale, therefore, is to upgrade to unbuild 2.0.0, and use the separate .d.cts and .d.mts type declaration files it outputs.
Note: This moves detect-locale onto a newer major version of unbuild than the other packages in this monorepo.
It may be preferred to upgrade them all,
but I am not familiar enough with the other packages to do this quickly.
Types of changes
Checklist