microsoft / microsoft/TypeScript
Recursively Resolving Modules
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.3k
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 132
Mô tả
TypeScript Version: 2.1.0
I'm using ts-loader and Webpack to compile my .ts files. In My Webpack config I have the following configuration:
resolve: {
modulesDirectories: ['shared', 'node_modules']
}
This allows me to import a component that lives in the shared directory without spelling out the full relative path. Example:
import Button from 'components/Button'
Webpack will walk up the directory tree and use the first shared directory it finds (the same way it does with the node_modules directories). This way, the component can live in the ../../shared/components/Buttton.tsx and Webpack will find it and bundle it.
My files compile fine because I am using ts-loader but I am getting can not find module errors in my editor.
Is there a way to tell the TS compiler to recursively look for the component in the shared directories?
I noticed the new baseUrl and paths configuration option but to my knowledge you can not use paths to recursively look for a directory.
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
Issue không nêu tệp nguồn hay bài kiểm thử nào. Hãy bắt đầu bằng việc đọc cách TypeScript xử lý việc phân giải module xoay quanh baseUrl và paths, sau đó so sánh với việc tra cứu modulesDirectories của Webpack. Công việc được hoàn tất khi compiler và editor có thể phân giải các import như components/Button thông qua các thư mục dùng chung phù hợp mà không gặp lỗi không tìm thấy module.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript, webpack
- Lĩnh vực
- compilers
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100