taoensso / sente

Realtime web comms library for Clojure/Script
https://www.taoensso.com/sente
Eclipse Public License 1.0
1.73k stars 193 forks source link

Split server and client code to separate files #411

Closed khmelevskii closed 11 months ago

khmelevskii commented 1 year ago

It would be great to split sente.cljc to server.cljc and client.cljc. It will help not load unnecessary code on client. I can prepare PR if you think it can be implemented in sente

ptaoussanis commented 1 year ago

@khmelevskii Hi Yurii.

Before making any changes as an attempted solution, it'd be good to verify (and ideally try quantify) the problem.

What makes you believe that unnecessary code is being loaded on the client? This occurs with production (:advanced) builds? Any idea how much unnecessary code is being loaded?

Thanks

khmelevskii commented 1 year ago

@ptaoussanis I've just built client and can see the following statistic:

taoensso/sente.cljc | 42.93 KB
taoensso/sente/interfaces.cljc | 474
taoensso/encore.cljc | 27.02 KB
taoensso/timbre.cljc | 7.81 KB
taoensso/timbre/appenders/core.cljc | 1.93 KB
taoensso/truss/impl.cljs | 1.36 KB

~ 81KB

This is after optimization. I think it's pretty big for client. So, it would be awesome split server and client to separate files. I think it can reduce size a lot. Also it would be ideal to remove unnecessary dependencies on client like timbre.

ptaoussanis commented 1 year ago

@khmelevskii Hi Yurii,

Thanks for the info. Note though that the key question isn't how big the Sente client is, but how much smaller it could be by splitting to client/server namespaces.

To clarify: I'm not at all opposed to splitting - might be a nice change anyway. Just pointing out that if your motivation is a significant reduction in size, it's not immediately obvious to me how big of a difference this would make.

Would be happy to see a PR if you wanted to give this a try, but I'd recommend starting with a quick+dirty experiment to first quantify the difference. Depending on the results, it might/not be worth your time/effort (your call!).

Suggested namespace structure if you do want to a submit a PR:

Cheers :-)

Edit to add:

Also it would be ideal to remove unnecessary dependencies on client like timbre.

Ideas welcome if you have a suggestion for how to remove Timbre while still allowing opt-in for the same capabilities incl. namespace filtering, compile-time elision (handy for production clients), rate limiting, and support for Timbre appenders.

Please note that this'd need to be a separate PR - and that I'm skeptical that saving 7k (substantially less once compressed) would be worth anything but a trivial effort.

ptaoussanis commented 11 months ago

Closing for inactivity as part of issue triage.