Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[wasm-opt] `--minify-imports-and-exports-and-modules` does not report module renames.

Đang mở
#7,657 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.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
wasm
Lĩnh vực
cli, compilers

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện sự cố với wasm-opt phiên bản 123 bằng test.wat được cung cấp, lệnh wat2wasm và cờ --minify-imports-and-exports-and-modules. Kiểm tra đầu ra ánh xạ của cờ và so sánh với đầu ra của wasm2wat; được xem là hoàn tất khi stdout báo cáo cả việc đổi tên module lẫn function, bao gồm cả các tên module đã được hợp nhất.

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

Mô tả

When using wasm-opt with the --minify-imports-and-exports-and-modules flag, the tool correctly minifies both the import module names and the import function names. It often merges multiple import modules into a single new minified name.

However, the mapping printed to stdout is incomplete. It includes the remapping for the function names but completely omits the remapping for the module names. This makes it impossible for tools that rely on this map to correctly patch the host JavaScript environment, breaking the application.

Environment
  • wasm-opt Version: wasm-opt version 123
Minimal Reproducible Example (MRE)

1. Input .wat file (test.wat):

This file defines a module that imports two functions from two different, uniquely named modules.

(module
  (type (;0;) (func))
  (import "long_module_name_a" "long_function_name_foo" (func (;0;) (type 0)))
  (import "long_module_name_b" "long_function_name_bar" (func (;1;) (type 0)))
)

2. Assemble to .wasm:

wat2wasm test.wat -o test.wasm

3. Run wasm-opt:

wasm-opt test.wasm -o output.wasm --minify-imports-and-exports-and-modules
Results
Actual stdout Output:

The tool only prints the mapping for the function names:

long_function_name_foo => a
long_function_name_bar => b
Actual Contents of output.wasm (decompiled with wasm2wat):

The output Wasm shows that the module names were also minified and merged into "a":

(module
  (type (;0;) (func))
  (import "a" "a" (func (;0;) (type 0)))
  (import "a" "b" (func (;1;) (type 0)))
)
Expected Behavior

The stdout mapping should be complete and reflect all minification operations performed on the import/export interface. A correct and unambiguous output would look something like this:

long_module_name_a => a
long_module_name_b => a
long_function_name_foo => a
long_function_name_bar => b

This would provide all the necessary information for a host environment to correctly wire up the minified module.

Ngôn ngữ chính
WebAssembly
Star
8.6k
Fork
885
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
77

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.

Issue khác của WebAssembly/binaryen

Tất cả issue của WebAssembly/binaryen

Issue tương tự

Thêm issue về CLI

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.