Skip to content

Commit fce4d98

Browse files
committed
Add __wbindgen_main to other backends
1 parent 97df65f commit fce4d98

File tree

1 file changed

+15
-1
lines changed
  • crates/cli-support/src/js

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,10 @@ impl<'a> Context<'a> {
415415
if needs_manual_start {
416416
footer.push_str("\nwasm.__wbindgen_start();\n");
417417
}
418+
419+
if self.start_found {
420+
footer.push_str("\nwasm.__wbindgen_main();\n");
421+
}
418422
}
419423

420424
OutputMode::Deno => {
@@ -429,6 +433,10 @@ impl<'a> Context<'a> {
429433
if needs_manual_start {
430434
footer.push_str("\nwasm.__wbindgen_start();\n");
431435
}
436+
437+
if self.start_found {
438+
footer.push_str("\nwasm.__wbindgen_main();\n");
439+
}
432440
}
433441

434442
// With Bundlers and modern ES6 support in Node we can simply import
@@ -463,6 +471,12 @@ impl<'a> Context<'a> {
463471
if needs_manual_start {
464472
start = Some("\nwasm.__wbindgen_start();\n".to_string());
465473
}
474+
475+
if self.start_found {
476+
start
477+
.get_or_insert_with(String::default)
478+
.push_str("\nwasm.__wbindgen_main();\n");
479+
}
466480
}
467481

468482
// With a browser-native output we're generating an ES module, but
@@ -909,7 +923,7 @@ impl<'a> Context<'a> {
909923
} else {
910924
""
911925
},
912-
main = if needs_manual_start && self.start_found {
926+
main = if self.start_found {
913927
"if (start == true) { wasm.__wbindgen_main(); }"
914928
} else {
915929
""

0 commit comments

Comments
 (0)