twitchax / kord

A music theory binary and library for Rust / JS.
MIT License
209 stars 10 forks source link

Make `main` optional when compiling to WASM #11

Closed barafael closed 1 year ago

barafael commented 1 year ago

Not sure this is idiomatic. However, I noticed, that when compiling to e.g. a yew app, which has a main, it conflicts with the existing main from kord. The double negation of not("wasm_no_main") is because I didn't want to make this a breaking change, which I guess a feature "wasm_main" would have been. Let me know if you prefer a feature "wasm_main" as part of the default-features perhaps, or something else entirely.

twitchax commented 1 year ago

Actually, I think the right thing to do idiomatically is to delete the main entirely. It probably shouldn't have a main, except for debugging, so maybe that's the best way to cfg it away.

barafael commented 1 year ago

Here's a variant without a main in WASM at all. One could add it for debugging. I have kept set_panic_hook in, however I'd also argue it is up for removal. A library user would do it themselves, so certainly a pub function seems out of place.

Maybe a good compromise would be to simply keep the original fn main but comment it out. No features and no set_panic_hook. This would be a breaking change, however.

What do you think?

twitchax commented 1 year ago

Yeah, I think we should remove them altogether.