Closed fitzgen closed 6 years ago
Yes, sounds good.
Could you also please provide the commands to run?
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.
Thanks, should also the binary/pass be optional by default and required'able?
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.
Ok so I wasm-snip
is configured it's required.
https://github.com/rustwasm/wasm-snip
I'm imagining exposing options like:
wasm-snip.snip-rust-panicking-code: Boolean
: Whether to remove the rust`std::panicking
code.wasm-snip.snip-rust-fmt-code: Boolean
: Whether to remove the ruststd::fmt
code.wasm-snip.functions: Array<String|RegExp>
Exact function names or regexp patterns to snip.