nodejs / nodejs/node

Add async alternative to import.meta.resolve() with additional options

Đang mở
#54,051 16 bình luận 2 reaction 0 người được giao Xem trên GitHub

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

feature request loaders
Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.4k
Merge trung bình
4 ngày 3 giờ
Pull request đã merge (30 ngày)
272

Mô tả

What is the problem this feature will solve?

Tools often need to resolve imports of files they are analyzing, which requires a resolve API that import.meta.resolve() isn't suited for.

  • The resolve() call needs a referrer path, which is only available with a flag and is non standard
  • The tool might want to specify import conditions, which are non-standard
  • The call should be async, so that file system access isn't blocking. This is especially important for online resolution in servers.

Node might be able to add non-standard options via a second argument, though I'm a bit dubious of this approach because it might preclude import.meta.resolve() from adding a standard second argument.

So currently, we have complex user land resolvers that try to emulate what Node does, like Rollup's.

What is the feature you are proposing to solve the problem?

I think node:module should provide a function to perform built-in resolution, given a referrer path and import conditions.

This API would be free from having to conform to the import.meta.resolve() standard. import.meta.resolve() would still exist for cross-platform needs of resolving from within the referrer only.

What alternatives have you considered?

No response

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 việc xem xét hành vi hiện có của Node đối với import.meta.resolve() và bề mặt API node:module được mô tả trong issue. Xác định một trình phân giải tích hợp bất đồng bộ chấp nhận đường dẫn referrer và các điều kiện import, đồng thời duy trì import.meta.resolve() cho việc sử dụng đa nền tảng tiêu chuẩn; được xem là hoàn tất khi API được đề xuất và các tác động tương thích của nó đã được thống nhất.

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
api, 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
38/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.