Synphonyte / leptos-use

Collection of essential Leptos utilities inspired by React-Use / VueUse / SolidJS-USE
https://leptos-use.rs/
Apache License 2.0
309 stars 66 forks source link

Gate `web-sys` features behind features #152

Closed Baptistemontan closed 3 weeks ago

Baptistemontan commented 4 weeks ago

I want to continue the conversation started in #148 about web-sys features, I just felt it needed it's own place of discussion instead of a somewhat related issue.

The main point was compilation time, but I've always been on the side of "compilation time are always second to DX". Yes they are an issue, but gaining some ergonomics is always the better choice when against compile time.

But, I started experiencing an issue when introducing leptos-use to leptos_i18n: Rust-Analyzer. Having so much web-sys features enabled make Rust-Analyzer index so much things and spend probably about 50% of the full project analysis on web-sys.

So I would like to submit a proposal:

Add a feature for every module of leptos-use, make a "full" feature that enable them all, make that "full" feature the default, and make every module feature activate the web-sys feature they need.

This would basically add 3-4 lines per module and not change much things, as by default every features are enabled, but when someone use leptos-use for one or two functions, just using

leptos-use = { version = "0.X.X", default-features = false, features= ["use_locale", "use_cookie"] }

would make analysis time much shorter.

This request is also preventive, when this project will grow, adding more and more hooks in the future this will probably needed at some point, and introducing this now will make things easier in the future.

maccesch commented 3 weeks ago

So the day has finally come... 😀

You're probably right, that once we have implemented it, it's not going to be the end of world for maintainability. But introducing it will take a bit of work.

Baptistemontan commented 3 weeks ago

I'm gonna work on the i18n for struct-table, if this is still open when I'm done I would happily work on this

maccesch commented 3 weeks ago

Very nice! I've already started on this, but I don't know when I'll finish. So please let me know when the time has come 😄