slava-sh / rust-bundler

Creates a single-source-file version of a Cargo package
https://crates.io/crates/bundler
MIT License
20 stars 8 forks source link

minify option #2

Open MarcosCosmos opened 6 years ago

MarcosCosmos commented 6 years ago

Along with the existing pretty print, it may be useful to support minified code output.

I assume this won't be especially difficult since you're already using syntax trees?

slava-sh commented 6 years ago

I'm not aware of an existing Rust minifier.

The bundler currently runs rustfmt on a stringified TokenStream, which look like this:

fn main ( ) { println ! ( "Hello, world!" ) ; }

A simple way to "minify" the output would be to not run rustfmt and stringify the token stream in a way that doesn't include unnecessary whitespace.