wasm-tool / rust-plugin

Rust plugin for Webpack
MIT License
13 stars 1 forks source link

Add support for wasm-snip #1

Closed fitzgen closed 6 years ago

fitzgen commented 6 years ago

https://github.com/rustwasm/wasm-snip

I'm imagining exposing options like:

xtuc commented 6 years ago

Yes, sounds good.

Could you also please provide the commands to run?

fitzgen commented 6 years ago

There is a detailed description of the flags available here: https://github.com/rustwasm/wasm-snip#executable

I would expect the flags to straightforwardly translate into options for the plugin, ie:

Webpack plugin option wasm-snip flag
wasm-snip.snip-rust-panicking-code: true --snip-rust-panicking-code
wasm-snip.snip-rust-fmt-code: true --snip-rust-fmt-code
wasm-snip.functions: ["blah"] "blah"
wasm-snip.functions: [/blah.*/] --pattern "blah.*"

The only other thing to note is that wasm-snip takes some .wasm file as input and either writes it to stdout (the default behavior) or if you provide -o path/to/out.wasm it will write the output to the given path.

xtuc commented 6 years ago

Thanks, should also the binary/pass be optional by default and required'able?

fitzgen commented 6 years ago

This is the kind of thing where I don't see the benefit of being optional.

With wasm-opt, you are asking to optimize a .wasm binary, and you just get a slightly slower and larger .wasm binary if it is missing. I view these optimizations as optional if you aren't making a production build.

With wasm-snip, you are asking to remove functions from the .wasm binary, and if wasm-snip is missing, you don't remove any functions. The only time you want to remove these functions is when making a production build, so it didn't do its one job. Seems to me like it should require that wasm-snip is installed.

xtuc commented 6 years ago

Ok so I wasm-snip is configured it's required.