mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-27 20:15:14 +03:00
Merge pull request #191 from ngg/fix-no-modules-export
Fix generated binding for functions returning structs.
This commit is contained in:
commit
94b59e0d6c
@ -56,9 +56,17 @@ impl<'a> Context<'a> {
|
|||||||
let contents = deindent(contents);
|
let contents = deindent(contents);
|
||||||
let contents = contents.trim();
|
let contents = contents.trim();
|
||||||
let global = if self.config.nodejs {
|
let global = if self.config.nodejs {
|
||||||
format!("module.exports.{} = {};\n", name, contents)
|
if contents.starts_with("class") {
|
||||||
|
format!("{1}\nmodule.exports.{0} = {0};\n", name, contents)
|
||||||
|
} else {
|
||||||
|
format!("module.exports.{} = {};\n", name, contents)
|
||||||
|
}
|
||||||
} else if self.config.no_modules {
|
} else if self.config.no_modules {
|
||||||
format!("__exports.{} = {}\n", name, contents)
|
if contents.starts_with("class") {
|
||||||
|
format!("{1}\n__exports.{0} = {0};\n", name, contents)
|
||||||
|
} else {
|
||||||
|
format!("__exports.{} = {};\n", name, contents)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if contents.starts_with("function") {
|
if contents.starts_with("function") {
|
||||||
format!("export function {}{}\n", name, &contents[8..])
|
format!("export function {}{}\n", name, &contents[8..])
|
||||||
|
Loading…
Reference in New Issue
Block a user