Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console warning: "using deprecated parameters for the initialization function; pass a single object instead" #4122

Closed
TheMythologist opened this issue Sep 20, 2024 · 8 comments
Labels

Comments

@TheMythologist
Copy link

I am currently encountering this issue: swc-project/swc#9443

Seems like the default_module_path is performed too late, only after the object destructuring check:

if (typeof module_or_path !== 'undefined') {{
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {{
({{module_or_path{init_memory_arg}{init_stack_size_arg}}} = module_or_path)
}} else {{
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
}}
}}
{default_module_path}

Is it possible to shift this default block to the top of the function (or at least before the object destructuring)?
Alternatively, if the intention was to ensure that the default would be provided in the event that {} was provided, could you add an else if (typeof module_or_path !== 'undefined') before emitting the warning in the console? Or would you recommend swc to change the recommended way to await initSwc({});

@TieWay59
Copy link

I am currently building the browser extension template project at https://github.com/Mubelotix/wasm-extension-template. When I deploy this template extension to the latest Chrome browser, I get this warning. I think it's a similar situation.

image

@alpancs
Copy link

alpancs commented Sep 24, 2024

@TheMythologist this problem exists in version 0.2.93 bot not in version 0.2.92.

try this to confirm it in your work environment:

[dependencies]
wasm-bindgen = "=0.2.92" # not "0.2.92" nor "0.2"

@TieWay59
Copy link

TieWay59 commented Sep 26, 2024

try this to confirm it in your work environment:

[dependencies]
wasm-bindgen = "=0.2.92" # not "0.2.92" or "0.2"

Sorry @alpancs, I'm not able to help with the testing of wasm-bindgen 0.2.92. The reason is that my project depends on several other libraries, which rely on wasm-bindgen version 0.2.93.I wish I could be of more assistance. If there's anything else I can do to help or if you have any other requests, please let me know.

Details

❯ cargo tree 
demo02 v0.1.0 (/home/taiwei.wu/github/webextplaygrand/demo02)
├── chrono v0.4.38
│   ├── iana-time-zone v0.1.61
│   └── num-traits v0.2.19
│       [build-dependencies]
│       └── autocfg v1.3.0
├── console_error_panic_hook v0.1.7
│   ├── cfg-if v1.0.0
│   └── wasm-bindgen v0.2.93
│       ├── cfg-if v1.0.0
│       ├── once_cell v1.19.0
│       └── wasm-bindgen-macro v0.2.93 (proc-macro)
│           ├── quote v1.0.37
│           │   └── proc-macro2 v1.0.86
│           │       └── unicode-ident v1.0.13
│           └── wasm-bindgen-macro-support v0.2.93
│               ├── proc-macro2 v1.0.86 (*)
│               ├── quote v1.0.37 (*)
│               ├── syn v2.0.77
│               │   ├── proc-macro2 v1.0.86 (*)
│               │   ├── quote v1.0.37 (*)
│               │   └── unicode-ident v1.0.13
│               ├── wasm-bindgen-backend v0.2.93
│               │   ├── bumpalo v3.16.0
│               │   ├── log v0.4.22
│               │   ├── once_cell v1.19.0
│               │   ├── proc-macro2 v1.0.86 (*)
│               │   ├── quote v1.0.37 (*)
│               │   ├── syn v2.0.77 (*)
│               │   └── wasm-bindgen-shared v0.2.93
│               └── wasm-bindgen-shared v0.2.93
├── js-sys v0.3.70
│   └── wasm-bindgen v0.2.93 (*)
├── percent-encoding v2.3.1
├── wasm-bindgen v0.2.93 (*)
├── wasm-bindgen-futures v0.4.43
│   ├── cfg-if v1.0.0
│   ├── js-sys v0.3.70 (*)
│   └── wasm-bindgen v0.2.93 (*)
├── web-extensions v0.3.0
│   ├── gloo-utils v0.1.7
│   │   ├── js-sys v0.3.70 (*)
│   │   ├── serde v1.0.210
│   │   │   └── serde_derive v1.0.210 (proc-macro)
│   │   │       ├── proc-macro2 v1.0.86 (*)
│   │   │       ├── quote v1.0.37 (*)
│   │   │       └── syn v2.0.77 (*)
│   │   ├── serde_json v1.0.128
│   │   │   ├── itoa v1.0.11
│   │   │   ├── memchr v2.7.4
│   │   │   ├── ryu v1.0.18
│   │   │   └── serde v1.0.210 (*)
│   │   ├── wasm-bindgen v0.2.93 (*)
│   │   └── web-sys v0.3.70
│   │       ├── js-sys v0.3.70 (*)
│   │       └── wasm-bindgen v0.2.93 (*)
│   ├── js-sys v0.3.70 (*)
│   ├── serde v1.0.210 (*)
│   ├── serde_derive v1.0.210 (proc-macro) (*)
│   ├── serde_json v1.0.128 (*)
│   ├── thiserror v1.0.64
│   │   └── thiserror-impl v1.0.64 (proc-macro)
│   │       ├── proc-macro2 v1.0.86 (*)
│   │       ├── quote v1.0.37 (*)
│   │       └── syn v2.0.77 (*)
│   ├── wasm-bindgen v0.2.93 (*)
│   ├── wasm-bindgen-futures v0.4.43 (*)
│   └── web-extensions-sys v0.4.1
│       ├── js-sys v0.3.70 (*)
│       ├── wasm-bindgen v0.2.93 (*)
│       └── wasm-bindgen-futures v0.4.43 (*)
├── web-extensions-sys v0.4.1 (*)
└── web-sys v0.3.70 (*)

@daxpedda
Copy link
Collaborator

Or would you recommend swc to change the recommended way to await initSwc({});

No changes are necessary. This is a bug in wasm-bindgen v0.2.93 and was fixed in #4074.

@allsey87
Copy link
Contributor

allsey87 commented Oct 17, 2024

I am still getting this warning in v0.2.95, when building with the web target. This the html that I am using to instantiate the module:

<script type="module">
    import init from "./wasm-rayon-test.js"; // get the default export __wbg_init
    init()
</script>

This produces the error since the "first" argument to init is null for which typeof returns 'object' instead of 'undefined'. I can get rid of this error by just passing undefined as the first argument, although I want to check that I am not doing something wrong here first.

@daxpedda
Copy link
Collaborator

That's strange, I'm unable to reproduce this.
AFAIK undefined parameters shouldn't be null, they should indeed be undefined.

Maybe there is something else involved here?
E.g. does Rayon call init() somewhere to instantiate modules in workers?

@allsey87
Copy link
Contributor

You can use this repository to reproduce the problem. You can open it in GitHub codespaces and once it's built, run the build/serve script run.py

@daxpedda
Copy link
Collaborator

daxpedda commented Oct 31, 2024

You can use this repository to reproduce the problem. You can open it in GitHub codespaces and once it's built, run the build/serve script run.py

Just looking at wasm-bindgen-rayon I can see it didn't update how it executes the init() function, so I assume its just that.

If you still want me to try it out locally I'm happy to if you compile the whole thing for me so I just need to serve it without all the tooling around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants