Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Commit 0446599

Browse files
authored
rename init() to init_panic_hook()
if this function is named `init` it will conflict with `init` function in the code generated by `wasm-build --target web` it would produce code like: ```js /** */ export function init() { wasm.init(); } // ... function init(module) { if (typeof module === 'undefined') { module = import.meta.url.replace(/\.js$/, '_bg.wasm'); // ... ``` and parsing will fail with: ``` SyntaxError: unknown: Identifier 'init' has already been declared (136:9) 134 | } 135 | > 136 | function init(module) { | ^ 137 | if (typeof module === 'undefined') { 138 | module = import.meta.url.replace(/\.js$/, '_bg.wasm'); 139 | } ```
1 parent 7c09829 commit 0446599

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/reference/debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ code path:
7575

7676
```rust
7777
#[wasm_bindgen]
78-
pub fn init() {
78+
pub fn init_panic_hook() {
7979
console_error_panic_hook::set_once();
8080
}
8181
```

0 commit comments

Comments
 (0)