Add exports.types to package.json #3

Closed
prichey wants to merge 1 commit from patch-1 into main
prichey commented 2023-01-24 18:59:23 +01:00 (Migrated from github.com)

Resolves https://github.com/codemirror/dev/issues/891

Codemirror is not able to compile since TypeScript 4.7 with "moduleResolution": "node16" enabled, because it is unable to find types associated with the ESM export, ./dist/index.js. This PR adds the proper types export, which should be backwards compatible with both Node and TS runtimes.

More context on that here and here.

I'm happy to submit PRs to all the other repos if this approach works. Thanks for the consideration!

Resolves https://github.com/codemirror/dev/issues/891 Codemirror is not able to compile since TypeScript 4.7 with `"moduleResolution": "node16"` enabled, because it is unable to find `types` associated with the ESM export, `./dist/index.js`. This PR adds the proper `types` export, which should be backwards compatible with both Node and TS runtimes. More context on that [here](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#package-json-exports-imports-and-self-referencing) and [here](https://github.com/microsoft/TypeScript/issues/49160#issuecomment-1137482639). I'm happy to submit PRs to all the other repos if this approach works. Thanks for the consideration!
prichey commented 2023-01-26 18:16:32 +01:00 (Migrated from github.com)

@marijnh Any objections to pulling this in?

@marijnh Any objections to pulling this in?
marijnh commented 2023-01-27 17:19:41 +01:00 (Migrated from github.com)

I've been holding off on this because node16 resolution is (was?) unstable and it seemed like this kind of breakage might be a temporary bug. But indeed, they seem to have made it worse in 4.9. The syntax used in this PR is different from what the announcement shows (though definitely less verbose, so in principle more palatable)—do we know for sure that this is going to keep working as they stabilize it? See also the apparently even different new resolution method in TypeScript 5. What I'd really like to avoid is to have these kinds of changes to all the CodeMirror packages every three weeks as TypeScript breaks or fixes or changes its oddly picky new resolution algorithms.

I've been holding off on this because node16 resolution is (was?) unstable and it seemed like this kind of breakage might be a temporary bug. But indeed, they seem to have made it worse in 4.9. The syntax used in this PR is different from what [the announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#package-json-exports-imports-and-self-referencing) shows (though definitely less verbose, so in principle more palatable)—do we know for sure that this is going to keep working as they stabilize it? See also the apparently even different new resolution method in [TypeScript 5](https://devblogs.microsoft.com/typescript/announcing-typescript-5-0-beta/#moduleresolution-bundler). What I'd really like to avoid is to have these kinds of changes to all the CodeMirror packages every three weeks as TypeScript breaks or fixes or changes its oddly picky new resolution algorithms.
rix0rrr commented 2024-01-04 14:01:18 +01:00 (Migrated from github.com)

In May of 2022, a TypeScript dev commented that this behavior is on purpose, and they consider a missing export.types field a packaging mistake.

Please reconsider merging this? Not being able to use node16 is causing us pain trying to mix CJS and ESM modules together.

In May of 2022, a [TypeScript dev commented](https://github.com/microsoft/TypeScript/issues/49160#issuecomment-1137482639) that this behavior is on purpose, and they consider a missing `export.types` field a packaging mistake. Please reconsider merging this? Not being able to use `node16` is causing us pain trying to mix CJS and ESM modules together.
marijnh commented 2024-01-04 14:52:40 +01:00 (Migrated from github.com)

This has been fixed in another way (making the type declaration file names correspond to TS's expectations).

This has been fixed in another way (making the type declaration file names correspond to TS's expectations).
rix0rrr commented 2024-01-04 15:01:32 +01:00 (Migrated from github.com)

So it is, looks like we were on an old version. Thanks!

So it is, looks like we were on an old version. Thanks!

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/state!3
No description provided.