Fork me on GitHub
#reagent
<
2019-08-19
>
tianshu16:08:31

Can I use reagent with something like preact, it is said only 3kb.

juhoteperi16:08:19

Not officially supported nor tested. But it might work. Reagent requires react and react-dom "namespaces"/JS Modules so you'd need to overwrite the ones from Cljsjs packages.

dominicm16:08:07

Fwiw, hicada provides a flag for providing the dom function

juhoteperi16:08:46

If you use tooling with Webpack, it could be quite simple: https://github.com/developit/preact-compat#usage-with-webpack (I think figwheel-main can use Webpack)

tianshu17:08:06

@U061V0GG2 thanks, I'm using shadow-cljs, but I think maybe I can just webpack bundle that. I just don't know will it lack some features that reagent need

tianshu17:08:11

@U09LZR36F thanks for the advance, but I already have my project written in clojurescript with reagent and re-frame. But I did not include any other react npm library, so I wonder how can I reduce the bundle size. I mean if react is large and I can replace it with something else, that will be great in my case.

juhoteperi18:08:03

You can analyze the optimized build to check how much the libs take up size: https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report React probably isn't that large compared to Cljs standard library etc.

juhoteperi18:08:54

And one option could be to load React from a external CDN. If (when) user already has a cached version, nothing needs to be downloaded.

tianshu18:08:06

thanks, I will first take a look at the size of React

juhoteperi16:08:19

Not officially supported nor tested. But it might work. Reagent requires react and react-dom "namespaces"/JS Modules so you'd need to overwrite the ones from Cljsjs packages.

juhoteperi16:08:46

If you use tooling with Webpack, it could be quite simple: https://github.com/developit/preact-compat#usage-with-webpack (I think figwheel-main can use Webpack)

juhoteperi18:08:03

You can analyze the optimized build to check how much the libs take up size: https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report React probably isn't that large compared to Cljs standard library etc.