developit / developit/unfetch

Package.json conditional exports points to non-existent files

Open
#163 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.7k
Forks
204
PR merge metrics
No merged PRs in 30d

Description

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

https://github.com/developit/unfetch/blob/ee5810e7f9cd769677984b159d7e250adf4611b9/package.json#L16-L20

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 https://github.com/microsoft/TypeScript/issues/48235)

Therefore, I believe the correct exports should've been:
```json
"exports": {
".": {
"types": "./src/index.d.ts",
"import": "./dist/unfetch.mjs",
"default": "./dist/unfetch.js"
},
```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Inspect package.json and verify that each conditional export path exists under src/ and dist/. Reproduce the import with TypeScript 4.9 using NodeNext module resolution; done means the package resolves successfully and its type declarations are found.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
developer-experience
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.