forgot to add file

This commit is contained in:
2022-01-02 15:42:28 +01:00
parent 20365a0dd0
commit d239775411

View File

@@ -0,0 +1,21 @@
use std::path::Path;
use anyhow::Result;
pub fn filter_exports(in_path: &Path, out_path: &Path) -> Result<()> {
let mut module = walrus::Module::from_file(in_path)?;
let exports_to_delete: Vec<_> = module.exports.iter().filter_map(|export| match export.name.as_str() {
"upd" => None,
_ => Some(export.id())
}).collect();
for id in exports_to_delete {
module.exports.delete(id);
}
walrus::passes::gc::run(&mut module);
module.emit_wasm_file(out_path)?;
Ok(())
}