microsoft / microsoft/TypeScript

"basic"/"relative" moduleResolution

Đang mở
#62,368 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Awaiting More Feedback Suggestion
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ả

🔍 Search Terms

module resolution, relative paths

✅ Viability Checklist
⭐ Suggestion

Hi all, I am writing a custom JavaScript runtime that only supports module imports using relative paths with file extensions present.

This is akin to browser-based module resolution (minus import maps).

At present, the compilerOptions.moduleResolution settings are:

  • classic (deprecated)
  • node/node10
  • node16
  • nodenext
  • bundler

I think classic might work but am hesitant to use a deprecated feature.

Could we include a

{
  "compilerOptions": {
    "moduleResolution": "relative"
  }
}

That only permits resolving module import paths that are relative to the current file and requires that import paths include file extensions?

import * as foo from "./foo.js" // 👍 
import * as foo from "./foo.ts" // 👍 

import * as foo from "./foo" // 👎 
import * as foo from "foo" // 👎 
📃 Motivating Example
💻 Use Cases
  1. Accurate import semantics for consumers not using Node.js or contexts compatible with Node.js import resolution semantics

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách đọc cách compiler xử lý các tùy chọn phân giải module hiện có classic, node10, node16, nodenext và bundler. Theo dõi điểm vào compilerOptions.moduleResolution và so sánh các test hiện tại cho import tương đối và import package. Công việc được xem là hoàn tất khi một chế độ tương đối mới chấp nhận các import tương đối có phần mở rộng, đồng thời từ chối các import không có phần mở rộng và các import không tương đối, với coverage cho các ví dụ được yêu cầu.

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
compilers
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
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.