microsoft / microsoft/TypeScript
"basic"/"relative" moduleResolution
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ả
🔍 Search Terms
module resolution, relative paths
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ 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
- Browsers using JavaScript modules without a bundler
- Custom JavaScript resolution algorithms
- (shameless plug) https://github.com/alshdavid/ion
💻 Use Cases
- 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
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
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