mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-09 13:46:05 +00:00
Only generate JS class constructor export if import is needed
This commit is contained in:
parent
86625e78bc
commit
540ccfac9d
@ -267,10 +267,14 @@ impl<'a> Context<'a> {
|
|||||||
"));
|
"));
|
||||||
ts_dst.push_str("constructor(ptr: number, sym: Symbol);\n");
|
ts_dst.push_str("constructor(ptr: number, sym: Symbol);\n");
|
||||||
|
|
||||||
self.globals.push_str(&format!("
|
let new_name = shared::new_function(&class);
|
||||||
export function {new_name}(ptr) {{
|
if self.wasm_import_needed(&new_name) {
|
||||||
return addHeapObject(new {class}(ptr, token));
|
self.globals.push_str(&format!("
|
||||||
}}", new_name=shared::new_function(&class), class=class));
|
export function {new_name}(ptr) {{
|
||||||
|
return addHeapObject(new {class}(ptr, token));
|
||||||
|
}}
|
||||||
|
", new_name = new_name, class = class));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dst.push_str(&format!("
|
dst.push_str(&format!("
|
||||||
constructor(ptr) {{
|
constructor(ptr) {{
|
||||||
@ -279,10 +283,14 @@ impl<'a> Context<'a> {
|
|||||||
"));
|
"));
|
||||||
ts_dst.push_str("constructor(ptr: number);\n");
|
ts_dst.push_str("constructor(ptr: number);\n");
|
||||||
|
|
||||||
self.globals.push_str(&format!("
|
let new_name = shared::new_function(&class);
|
||||||
export function {new_name}(ptr) {{
|
if self.wasm_import_needed(&new_name) {
|
||||||
return addHeapObject(new {class}(ptr));
|
self.globals.push_str(&format!("
|
||||||
}}", new_name=shared::new_function(&class), class=class));
|
export function {new_name}(ptr) {{
|
||||||
|
return addHeapObject(new {class}(ptr));
|
||||||
|
}}
|
||||||
|
", new_name = new_name, class = class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dst.push_str(&format!("
|
dst.push_str(&format!("
|
||||||
|
Loading…
x
Reference in New Issue
Block a user