Package.json conditional exports points to non-existent files
- Ngôn ngữ chính
- JavaScript
- Star
- 5.7k
- Fork
- 204
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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"`
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Kiểm tra package.json và xác minh rằng mỗi đường dẫn export có điều kiện đều tồn tại trong src/ và dist/. Tái hiện thao tác import bằng TypeScript 4.9 với cơ chế phân giải module NodeNext; được xem là hoàn tất khi package được phân giải thành công và các khai báo kiểu của nó được tìm thấy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, typescript
- Lĩnh vực
- developer-experience
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 35/100