Skip to content

Commit

Permalink
Fixed incorrect deprecation warning (#4074)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda authored Aug 13, 2024
1 parent d813df7 commit b012a75
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 24 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# `wasm-bindgen` Change Log
--------------------------------------------------------------------------------

## Unreleased

### Fixed

* Fixed linked modules emitting snippet files when not using `--split-linked-modules`.
[#4066](https://github.com/rustwasm/wasm-bindgen/pull/4066)

* Fixed incorrect deprecation warning when passing no parameter into `default()` (`init()`) or `initSync()`.
[#4074](https://github.com/rustwasm/wasm-bindgen/pull/4074)

--------------------------------------------------------------------------------

## [0.2.93](https://github.com/rustwasm/wasm-bindgen/compare/0.2.92...0.2.93)

Released 2024-08-13
Expand Down
22 changes: 14 additions & 8 deletions crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,10 +870,13 @@ impl<'a> Context<'a> {
if (wasm !== undefined) return wasm;
{init_stack_size}
if (typeof module !== 'undefined' && Object.getPrototypeOf(module) === Object.prototype)
({{module{init_memory_arg}{init_stack_size_arg}}} = module)
else
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
if (typeof module !== 'undefined') {{
if (Object.getPrototypeOf(module) === Object.prototype) {{
({{module{init_memory_arg}{init_stack_size_arg}}} = module)
}} else {{
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
}}
}}
const imports = __wbg_get_imports();
Expand All @@ -892,10 +895,13 @@ impl<'a> Context<'a> {
if (wasm !== undefined) return wasm;
{init_stack_size}
if (typeof module_or_path !== 'undefined' && 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')
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}
const imports = __wbg_get_imports();
Expand Down
44 changes: 28 additions & 16 deletions crates/cli/tests/wasm-bindgen/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,13 @@ async function __wbg_init(module_or_path) {
if (wasm !== undefined) return wasm;
if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
({module_or_path} = module_or_path)
else
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
if (typeof module_or_path !== 'undefined') {
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
({module_or_path} = module_or_path)
} else {
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
}
}
if (typeof module_or_path === 'undefined') {
module_or_path = new URL('default_module_path_target_web_bg.wasm', import.meta.url);
Expand Down Expand Up @@ -371,10 +374,13 @@ fn default_module_path_target_no_modules() {
if (wasm !== undefined) return wasm;
if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
({module_or_path} = module_or_path)
else
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
if (typeof module_or_path !== 'undefined') {
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
({module_or_path} = module_or_path)
} else {
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
}
}
if (typeof module_or_path === 'undefined' && typeof script_src !== 'undefined') {
module_or_path = script_src.replace(/\\.js$/, '_bg.wasm');
Expand All @@ -400,10 +406,13 @@ async function __wbg_init(module_or_path) {
if (wasm !== undefined) return wasm;
if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
({module_or_path} = module_or_path)
else
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
if (typeof module_or_path !== 'undefined') {
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
({module_or_path} = module_or_path)
} else {
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
}
}
const imports = __wbg_get_imports();",
Expand All @@ -428,10 +437,13 @@ fn omit_default_module_path_target_no_modules() {
if (wasm !== undefined) return wasm;
if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
({module_or_path} = module_or_path)
else
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
if (typeof module_or_path !== 'undefined') {
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
({module_or_path} = module_or_path)
} else {
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
}
}
const imports = __wbg_get_imports();",
Expand Down

0 comments on commit b012a75

Please sign in to comment.