-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
package.json
exports and types are not compatible with TypeScript's node16
moduleResolution
#355
Labels
bug
A bug in the library
Comments
Hi @AlCalzone, Thanks for detailing the issue and the solution so nicely :) I'll make a PR for this once I get to a computer, unless you want to take a crack at it? Regards, |
5 tasks
This was referenced May 24, 2024
This was referenced Sep 21, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
TypeScript added a new module resolution strategy
node16
that better mimicks Node.js. Only under this option (ornodenext
) is theexports
field evaluated.When authoring a
.ts
file in a CommonJS project and using this importTypeScript complains about trying to require an ES module from CommonJS. This is because there's only one
.d.ts
file for both the CJS and ESM entrypoint and TypeScript considers that to be ESM due to the nearestpackage.json
.https://www.typescriptlang.org/docs/handbook/esm-node.html#packagejson-exports-imports-and-self-referencing mentions at the bottom that each needs their own declaration file.
As awkward as this is, this can be fixed by
index.d.ts
toindex.d.mts
index.d.mts
toindex.d.cts
package.json
exports like this:Library version
6.7.0
Node version
16.20.0
Typescript version (if you are using it)
5.1.6
Module system
CommonJS
The text was updated successfully, but these errors were encountered: