swc icon indicating copy to clipboard operation
swc copied to clipboard

Confusing warning message when using __wbg_init in @swc/wasm-web v1.7.x

Open catloversg opened this issue 1 year ago • 1 comments

Describe the bug

Starting from @swc/wasm-web v1.7.x, I see this warning message: using deprecated parameters for the initialization function; pass a single object instead when calling __wbg_init without a parameter. Current documentation at https://swc.rs/docs/usage/wasm does not say anything about a required parameter.

When I check code in node_modules\@swc\wasm-web\wasm.d.ts and node_modules\@swc\wasm-web\wasm.js, I see that:

  • __wbg_init allows module_or_path to be optional. It says Passing InitInput directly is deprecated. With this way of phrasing, I think it means: "If you want to pass InitInput, you need to pass {module_or_path:InitInput} instead of plain InitInput". It does not say anything about skipping module_or_path. This is how I interpret it.
  • Implementation of __wbg_init shows that if module_or_path is undefined, it will print the warning message.

Can you confirm that skipping module_or_path is also deprecated? If that's the case, I suggest:

Input code

No response

Config

No response

Playground link (or link to the minimal reproduction)

https://swc.rs/docs/usage/wasm

SWC Info output

No response

Expected behavior

Actual behavior

No response

Version

1.7.11

Additional context

No response

catloversg avatar Aug 16 '24 16:08 catloversg

Actually it's generated by wasm-pack and wasm-bindgen, and I don't have any idea about them at the moment.

kdy1 avatar Aug 19 '24 05:08 kdy1

This issue was fixed in wasm-bindgen. Ref: https://github.com/rustwasm/wasm-bindgen/issues/4122#issuecomment-2380562394

catloversg avatar Nov 29 '24 10:11 catloversg

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

swc-bot avatar Jan 01 '25 12:01 swc-bot