Skip to content
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 conditional exports points to non-existent files #163

Open
IronGeek opened this issue Feb 5, 2023 · 1 comment
Open

Package.json conditional exports points to non-existent files #163

IronGeek opened this issue Feb 5, 2023 · 1 comment

Comments

@IronGeek
Copy link

IronGeek commented Feb 5, 2023

The conditional exports in package.json points to files which does not exist:

unfetch/package.json

Lines 16 to 20 in ee5810e

"exports": {
".": {
"import": "./index.mjs",
"default": "./index.js"
},

This causes the following errors when importing unfetch with typescript:

Cannot find module 'unfetch' or its corresponding type declarations.ts(2307)

Also, if you're declaring conditional exports and have type declarations (d.ts) in different location, I think you need to add "types" as the first export condition (see: https://www.typescriptlang.org/docs/handbook/esm-node.html, and microsoft/TypeScript#48235)

Therefore, I believe the correct exports should've been:

  "exports": {
    ".": {
      "types": "./src/index.d.ts",
      "import": "./dist/unfetch.mjs",
      "default": "./dist/unfetch.js"
    },

FWIW, I'm using Typescript 4.9 with moduleResolution": "NodeNext"

@IronGeek
Copy link
Author

IronGeek commented Feb 5, 2023

Sorry, I just realized this might be related to this issue: #162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant