Skip to content

Commit 02adf6d

Browse files
committed
Fix generated binding for functions returning structs.
This only affects --no-modules and --nodejs modes. Fixes #190.
1 parent 6d16711 commit 02adf6d

File tree

1 file changed

+10
-2
lines changed
  • crates/cli-support/src/js

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,17 @@ impl<'a> Context<'a> {
5656
let contents = deindent(contents);
5757
let contents = contents.trim();
5858
let global = if self.config.nodejs {
59-
format!("module.exports.{} = {};\n", name, contents)
59+
if contents.starts_with("class") {
60+
format!("{1}\nmodule.exports.{0} = {0};\n", name, contents)
61+
} else {
62+
format!("module.exports.{} = {};\n", name, contents)
63+
}
6064
} else if self.config.no_modules {
61-
format!("__exports.{} = {}\n", name, contents)
65+
if contents.starts_with("class") {
66+
format!("{1}\n__exports.{0} = {0};\n", name, contents)
67+
} else {
68+
format!("__exports.{} = {};\n", name, contents)
69+
}
6270
} else {
6371
if contents.starts_with("function") {
6472
format!("export function {}{}\n", name, &contents[8..])

0 commit comments

Comments
 (0)