Wasm-pack: Add some kind of (likely toml) configuration

Created on 7 Jun 2018  路  4Comments  路  Source: rustwasm/wasm-pack

As we add more options and flags (#159 #158 #153 etc) it would be great if we didn't have to keep passing the same command line arguments for every build all the time, and instead could canonicalize configurations in a toml file.

changelog - feature

Most helpful comment

After trying tools that use an external .toml file vs putting configuration in Cargo.toml, I would argue that putting it in Cargo.toml is much nicer. All of your configuration is in one file, rather than an increasing number of .toml files. See https://github.com/rust-osdev/bootimage#configuration for example; you could put this in

[package.metadata.wasm-pack.build.debug]

instead of just

[build.debug].

All 4 comments

@fitzgen it would be really useful in discussing this if we had a strawman proposal. do you think you could write up an example of what you think it might look like and we can discuss from there? thanks! (of course, anyone else reading this should also feel free to post an example of how they think configuration should work!)

(also, i updated the title because, while i think we'll likely want to use TOML, i don't want to close the convo off to potentially other formats, assuming there's a good rationale, of course)

This is what I imagine the defaults from #153 would look like, as described in a strawman toml format

[build.debug]
debug = true
features = ["console_error_panic_hook"]
rustc-opt-level = 0
wasm-opt = false
wasm-snip = false
wasm-bindgen = true

[build.profiling]
debug = true
features = ["console_error_panic_hook", "wee_alloc"]
rustc-opt-level = "s"
wasm-opt = { opt-level = "z" }
wasm-snip = false
wasm-bindgen = true

[build.production]
debug = false
features = ["wee_alloc"]
rustc-opt-level = "s"
wasm-opt = { opt-level = "z" }
wasm-snip = { snip-rust-fmt-code = true, snip-rust-panicking-code = true }
wasm-bindgen = true

After trying tools that use an external .toml file vs putting configuration in Cargo.toml, I would argue that putting it in Cargo.toml is much nicer. All of your configuration is in one file, rather than an increasing number of .toml files. See https://github.com/rust-osdev/bootimage#configuration for example; you could put this in

[package.metadata.wasm-pack.build.debug]

instead of just

[build.debug].

Was this page helpful?
0 / 5 - 0 ratings

Related issues

netgusto picture netgusto  路  4Comments

tbillington picture tbillington  路  3Comments

grovesNL picture grovesNL  路  4Comments

pablosichert picture pablosichert  路  4Comments

ashleygwilliams picture ashleygwilliams  路  3Comments