Add an option to "uglify" imports

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.
This commit is contained in:
Alex Crichton
2017-12-24 15:32:40 -08:00
parent 240d3cd1a1
commit bef908a9b1
6 changed files with 275 additions and 59 deletions

View File

@ -37,9 +37,10 @@ fn main() {
.unwrap_or_else(|e| e.exit());
let mut b = Bindgen::new();
b.input_path(&args.arg_input);
b.nodejs(args.flag_nodejs);
b.debug(args.flag_debug);
b.input_path(&args.arg_input)
.nodejs(args.flag_nodejs)
.debug(args.flag_debug)
.uglify_wasm_names(!args.flag_debug);
let ret = b.generate().expect("failed to generate bindings");
if let Some(ref ts) = args.flag_output_ts {
ret.write_ts_to(ts).expect("failed to write TypeScript output file");