Allow type stripping in pnpm deploy monorepos
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.3k
- Merge trung bình
- 4 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 283
Mô tả
What is the problem this feature will solve?
node.js supports running a subset of typescript nativly, but for reasons doesn't allow this feature for files in node_modules.
A positive caveat is that node wants to support npm workspaces, where local sub packages are required thru node_modules. To do so it checks the real path of the file, and will type strip it if it's not within node_modules.
This also works in pnpm workspaces, but breaks in pnpm deploy. This repo demonstrates that behavior.
Read or run repro.sh steps to reproduce.
This difference between workspace and deploy structure
bin/node_modules/lib -> ../../lib
out/node_modules/lib -> .pnpm/lib@file++++lib/node_modules/lib
cause this error in out/index.ts, but not bin/index.ts
Error [ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING]: Stripping types is currently unsupported for files under node_modules, for "file:///out/node_modules/.pnpm/lib@file++++lib/node_modules/lib/index.ts"
This would also break in npm, pnpm and other dependency managers that use install-links or other steps that indirect the workspace dependencies into node_modules.
What is the feature you are proposing to solve the problem?
Either remove the node_modules restriction, add more detection's for 'local node_modules' cases - such as private: true or a new marker, or establish export conditions for type stripping.
I am okay with emitting .js and using it in my deployed app, but I want to use .ts in development, and I don't want dev tools to require possibly stale .js files.
I think a reasonable solution is an export condition for 'type stripping not supported' that node would use to fallback to .js instead of erroring.
"exports": {
"unsupportedTypeStripping": "out/index.js",
"default": "src/index.ts",
}
What alternatives have you considered?
No response
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Chạy repro.sh và so sánh trường hợp bin/index.ts chạy thành công với trường hợp out/index.ts bị lỗi, bao gồm cả các đường dẫn node_modules của chúng. Điều tra cách đường dẫn dependency workspace gián tiếp của pnpm deploy kích hoạt hạn chế tách kiểu trong node_modules; hoàn tất khi ứng dụng đã deploy có thể sử dụng dependency TypeScript của workspace mà không gặp ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING, đồng thời quá trình phát triển vẫn có thể tiếp tục sử dụng các tệp .ts.
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, node.js
- Lĩnh vực
- backend
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100