mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-27 15:31:05 +00:00
This commit adds an option to "uglify" the wasm module's imports/exports so those which are controlled by bindgen are renamed to a shorter (probably one letter) names. This'll hopefully help cut down on both the wasm size slightly and also the generated JS as the glue we're talking to wasm over won't require such large names all the time.
43 lines
1.0 KiB
Rust
43 lines
1.0 KiB
Rust
extern crate test_support;
|
|
|
|
#[test]
|
|
fn works() {
|
|
test_support::project()
|
|
.uglify(true)
|
|
.file("src/lib.rs", r#"
|
|
#![feature(proc_macro)]
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
wasm_bindgen! {
|
|
pub struct A {}
|
|
|
|
impl A {
|
|
pub fn new() -> A {
|
|
A {}
|
|
}
|
|
}
|
|
pub fn clone(a: &JsObject) -> JsObject {
|
|
drop(a.clone());
|
|
a.clone()
|
|
}
|
|
}
|
|
"#)
|
|
.file("test.ts", r#"
|
|
import * as assert from "assert";
|
|
import { Exports, Imports } from "./out";
|
|
|
|
export const imports: Imports = {};
|
|
|
|
export function test(wasm: Exports) {
|
|
let sym = Symbol('a');
|
|
assert.strictEqual(wasm.clone(sym), sym);
|
|
let a = wasm.A.new();
|
|
a.free();
|
|
}
|
|
"#)
|
|
.test();
|
|
}
|