Skip to content

Commit b012a75

Browse files
authored
Fixed incorrect deprecation warning (#4074)
1 parent d813df7 commit b012a75

File tree

3 files changed

+54
-24
lines changed

3 files changed

+54
-24
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
# `wasm-bindgen` Change Log
22
--------------------------------------------------------------------------------
33

4+
## Unreleased
5+
6+
### Fixed
7+
8+
* Fixed linked modules emitting snippet files when not using `--split-linked-modules`.
9+
[#4066](https://github.com/rustwasm/wasm-bindgen/pull/4066)
10+
11+
* Fixed incorrect deprecation warning when passing no parameter into `default()` (`init()`) or `initSync()`.
12+
[#4074](https://github.com/rustwasm/wasm-bindgen/pull/4074)
13+
14+
--------------------------------------------------------------------------------
15+
416
## [0.2.93](https://github.com/rustwasm/wasm-bindgen/compare/0.2.92...0.2.93)
517

618
Released 2024-08-13

crates/cli-support/src/js/mod.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -870,10 +870,13 @@ impl<'a> Context<'a> {
870870
if (wasm !== undefined) return wasm;
871871
872872
{init_stack_size}
873-
if (typeof module !== 'undefined' && Object.getPrototypeOf(module) === Object.prototype)
874-
({{module{init_memory_arg}{init_stack_size_arg}}} = module)
875-
else
876-
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
873+
if (typeof module !== 'undefined') {{
874+
if (Object.getPrototypeOf(module) === Object.prototype) {{
875+
({{module{init_memory_arg}{init_stack_size_arg}}} = module)
876+
}} else {{
877+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
878+
}}
879+
}}
877880
878881
const imports = __wbg_get_imports();
879882
@@ -892,10 +895,13 @@ impl<'a> Context<'a> {
892895
if (wasm !== undefined) return wasm;
893896
894897
{init_stack_size}
895-
if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
896-
({{module_or_path{init_memory_arg}{init_stack_size_arg}}} = module_or_path)
897-
else
898-
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
898+
if (typeof module_or_path !== 'undefined') {{
899+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {{
900+
({{module_or_path{init_memory_arg}{init_stack_size_arg}}} = module_or_path)
901+
}} else {{
902+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
903+
}}
904+
}}
899905
900906
{default_module_path}
901907
const imports = __wbg_get_imports();

crates/cli/tests/wasm-bindgen/main.rs

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,13 @@ async function __wbg_init(module_or_path) {
336336
if (wasm !== undefined) return wasm;
337337
338338
339-
if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
340-
({module_or_path} = module_or_path)
341-
else
342-
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
339+
if (typeof module_or_path !== 'undefined') {
340+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
341+
({module_or_path} = module_or_path)
342+
} else {
343+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
344+
}
345+
}
343346
344347
if (typeof module_or_path === 'undefined') {
345348
module_or_path = new URL('default_module_path_target_web_bg.wasm', import.meta.url);
@@ -371,10 +374,13 @@ fn default_module_path_target_no_modules() {
371374
if (wasm !== undefined) return wasm;
372375
373376
374-
if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
375-
({module_or_path} = module_or_path)
376-
else
377-
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
377+
if (typeof module_or_path !== 'undefined') {
378+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
379+
({module_or_path} = module_or_path)
380+
} else {
381+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
382+
}
383+
}
378384
379385
if (typeof module_or_path === 'undefined' && typeof script_src !== 'undefined') {
380386
module_or_path = script_src.replace(/\\.js$/, '_bg.wasm');
@@ -400,10 +406,13 @@ async function __wbg_init(module_or_path) {
400406
if (wasm !== undefined) return wasm;
401407
402408
403-
if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
404-
({module_or_path} = module_or_path)
405-
else
406-
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
409+
if (typeof module_or_path !== 'undefined') {
410+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
411+
({module_or_path} = module_or_path)
412+
} else {
413+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
414+
}
415+
}
407416
408417
409418
const imports = __wbg_get_imports();",
@@ -428,10 +437,13 @@ fn omit_default_module_path_target_no_modules() {
428437
if (wasm !== undefined) return wasm;
429438
430439
431-
if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
432-
({module_or_path} = module_or_path)
433-
else
434-
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
440+
if (typeof module_or_path !== 'undefined') {
441+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
442+
({module_or_path} = module_or_path)
443+
} else {
444+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
445+
}
446+
}
435447
436448
437449
const imports = __wbg_get_imports();",

0 commit comments

Comments
 (0)