mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-29 13:06:06 +03: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");
|
||||
|
||||
self.globals.push_str(&format!("
|
||||
export function {new_name}(ptr) {{
|
||||
return addHeapObject(new {class}(ptr, token));
|
||||
}}", new_name=shared::new_function(&class), class=class));
|
||||
let new_name = shared::new_function(&class);
|
||||
if self.wasm_import_needed(&new_name) {
|
||||
self.globals.push_str(&format!("
|
||||
export function {new_name}(ptr) {{
|
||||
return addHeapObject(new {class}(ptr, token));
|
||||
}}
|
||||
", new_name = new_name, class = class));
|
||||
}
|
||||
} else {
|
||||
dst.push_str(&format!("
|
||||
constructor(ptr) {{
|
||||
@ -279,10 +283,14 @@ impl<'a> Context<'a> {
|
||||
"));
|
||||
ts_dst.push_str("constructor(ptr: number);\n");
|
||||
|
||||
self.globals.push_str(&format!("
|
||||
export function {new_name}(ptr) {{
|
||||
return addHeapObject(new {class}(ptr));
|
||||
}}", new_name=shared::new_function(&class), class=class));
|
||||
let new_name = shared::new_function(&class);
|
||||
if self.wasm_import_needed(&new_name) {
|
||||
self.globals.push_str(&format!("
|
||||
export function {new_name}(ptr) {{
|
||||
return addHeapObject(new {class}(ptr));
|
||||
}}
|
||||
", new_name = new_name, class = class));
|
||||
}
|
||||
}
|
||||
|
||||
dst.push_str(&format!("
|
||||
|
Loading…
Reference in New Issue
Block a user