Interaction with `configureAll` from Custom Descriptors

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

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

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
30/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Ít trao đổi
Công nghệ
javascript, wasm
Lĩnh vực
web-dev

Hướng nghiên cứu

Start with the custom descriptors proposal's Overview.md section on the configureAll configuration API, then review the issue's ESM integration approach using a start function, exported mutable globals, and property access helpers. Determine whether a better way exists to export constructors created by configureAll, including the relationship with configured prototypes; the issue is done when a concrete integration direction is agreed.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

The custom descriptors proposal includes a new configureAll builtin. Among other things, configureAll has the ability to wrap WebAssembly function references to make them callable with new. configureAll takes a JS object as an externref argument and writes all the constructors it creates this way as properties on that object.

This way of "returning" an arbitrary number of constructors by writing them to an object works great for hand-written JS (the object they are written to can even be globalThis, making the constructors ambiently available), but does not play well with ESM integration. With ESM integration, it would ideally be possible to export these constructors directly, which is presumably what an equivalent JS module would do.

The best method I've come up with for exporting constructors created by configureAll is to do this:

  1. Import helper functions for creating a fresh JS object and accessing an object's properties by name.
  2. In the start function, call configureAll, passing it a fresh JS object allocated via the allocation helper.
  3. In the start function, use the property access helper to pull out each configured constructor and assign it to an exported mutable global.

AFAICT, there's no way to avoid the exported globals being mutable because they cannot be initialized with constant expressions.

If anyone has any better ideas, I'd love to hear them. The only other thing I've come up with is that we could have a name mangling scheme on function exports that tells ESM integration to generate the same new-callable wrapper that configureAll would have generated. This is only a partial solution, though, because it does not link up the constructor function with a configured prototype the way configureAll does.

Ngôn ngữ chính
WebAssembly
Star
458
Fork
40
Merge trung bình
10 ngày 37 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

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.

Issue khác của WebAssembly/esm-integration

Tất cả issue của WebAssembly/esm-integration

Issue tương tự

Thêm issue về Web Dev

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.