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

Fixed incorrect deprecation warning when using default module path #4074

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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