Fork me on GitHub
#fulcro
<
2019-10-30
>
henrik11:10:41

For data that is static for the lifetime of the server, can {:reconciler-options {:shared … be load!ed from the server?

thheller11:10:47

@tony.kay I just cut a significant amount of code from the shadow-cljs UI release build by adding this file to my local code: https://github.com/thheller/shadow-cljs/blob/master/src/dev/com/fulcrologic/guardrails/core.cljs

thheller11:10:29

build goes from Module: :app [JS: 1.2 MB] [GZIP: 309.45 KB] to Module: :app [JS: 998 KB] [GZIP: 248.96 KB]

thheller11:10:40

mostly because cljs.analyzer isn't included anymore

thheller11:10:39

not sure if guardrails actually still works though, but you are falling for the typical CLJC issues that I mentioned here https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html

thheller11:10:58

where the macro code leaks into the CLJS side

thheller11:10:24

my UI code still runs fine but the guardrails stuff is disabled, so if it is enabled my hack might break stuff

tony.kay14:10:21

So I didn’t need analyzer…that was cruft I accidentally copied in from ghostwheel. Looks like I can get guardrails almost completely out of a production build. Working on a release to update Fulcro…testing now.

tony.kay14:10:25

If you have a moment @thheller, force in version 0.0.9-SNAPSHOT of guardrails and remove your file. That should eliminate the need for analyzer, and also shrink the guardrails overhead to nearly nothing (I get 5.5k on a react native build, but I suspect there is something more DCE could do that I’m missing)

tony.kay14:10:37

ah, I was using simple optimizations…with DCE it is removed entirely :thumbsup:

thheller15:10:39

it is not that simple unfortunately 😛

thheller15:10:09

yes, the guardrails code is gone. but expound remains, which brings in cljs.pprint

thheller15:10:10

-> com.fulcrologic.fulcro.application -> com.fulcrologic.guardrails.core -> expound.alpha -> expound.printer -> cljs.pprint

thheller15:10:54

so with your fix my build goes to Module: :app [JS: 1.03 MB] [GZIP: 263.7 KB] while mine is at Module: :app [JS: 869.25 KB] [GZIP: 222.68 KB]

tony.kay15:10:31

hm, why doesn’t expound get removed I wonder

thheller15:10:49

I wish all this would work better ... but I can't think of a reasonable way to handle all this

tony.kay15:10:52

in my build guardrails disappears, which means there is no ref to expound anymore

thheller15:10:02

basically any library using a defmulti can't be eliminated

tony.kay15:10:23

argh….so, I get to rewrite expound as well 😜

thheller15:10:52

and fulcro while you are at it 😛

tony.kay15:10:11

why fulcro???

thheller15:10:15

unfortunately there are many things that the closure compiler doesn't understand

thheller15:10:21

defmulti is one of them

thheller15:10:23

spec is another

tony.kay15:10:49

well, the side-effecting of specs is handled by guardrails…but spec itself is going to come in, yes

tony.kay15:10:33

but part of the point of guardrails is to be able to not bloat the registry

thheller15:10:42

but as far as I could tell stubbing out this namespace still works fine

thheller15:10:58

as the specs seem to be only used by the guardrails stuff

tony.kay15:10:04

oh, I can fix that

tony.kay15:10:20

there is already a >def macro that elides when gr is not enabled

thheller15:10:33

since it was bringing in all the test.check stuff and generated a bunch of spec generators

tony.kay15:10:44

that can be helped too

thheller15:10:48

none of them are ever relevant to my build

thheller15:10:15

yes, for sure. I was just digging through things because I wondered why my build got so big

thheller15:10:29

was gonna report my findings in more detail at some point

thheller15:10:53

and was thinking about possibly teaching the closure compiler about this stuff so it can remove more

tony.kay15:10:26

cool. I’ll glance at expound…it does bother me that it is bloating the build.

tony.kay15:10:33

when it is only a dev-time concern

thheller15:10:56

did you checkout my "Inspect" stuff?

tony.kay15:10:11

um…vague memory…remind me?

thheller15:10:53

already looks completely different

thheller15:10:15

but basically think fulcro-inspect built-in available for everything

thheller15:10:46

and one thing I want to work on at some point is tracing

thheller15:10:42

and maybe something spec related like the ghostwheel stuff

thheller15:10:49

but with full support from the compiler

thheller15:10:03

so basically I hope to support more "dev-time" stuff in a way that doesn't mess with the build too much

thheller15:10:12

right now it is way to difficult to keep a build clean

tony.kay15:10:10

Yeah, that’s nice. In the guardrails use-case I really just find using specs as a loose type system brings quite a bit of value to dev and testing.

thheller15:10:46

yes absolutely

tony.kay15:10:50

but data exporation is also a big help (thus Fulcro Inspect)…but having REBL like facilities we could hook into (auto-follow idents) would be super nice

thheller15:10:07

the problem is in spec itself, just generates way too muchs tuff

thheller15:10:58

REBL, fulcro-inspect and re-frame-10x are my references

thheller15:10:05

REBL = neat but clojure only

thheller15:10:11

fulcro, 10x = neat but CLJS only

thheller15:10:46

basically I'm building this out to solve my own issues in shadow-cljs

thheller15:10:59

in that I can barely ever print anything since its just too large 😛

thheller15:10:13

fulcro-inspect also still copies all data I believe?

tony.kay15:10:17

yes, that is a lot of the reason F. Inspect exists

tony.kay15:10:29

actually, inspect does an initial copy, and then sends diffs

tony.kay15:10:00

so, startup overhead, but light at each step

thheller11:10:29

Module: :app [JS: 869.28 KB] [GZIP: 222.68 KB] after a couple more tweaks but those weren't fulcro related

tony.kay13:10:25

@thheller thanks for the heads up. I’ll see if I can make all the macro stuff go away for cljs.

tony.kay13:10:41

I hadn’t started optimizing yet

tony.kay14:10:14

I’ve release 0.0.9 of Guardrails and 3.0.8 of Fulcro (which upgrades deps). The production build size and CPU overhead of guardrails in CLJS is now zero in advanced builds (assuming you don’t enable guardrails in production).

🚀 4
twicebaked15:10:49

Haven't done much with guard rails, but I switched my project over today to 3.0.6 and Guardrails 0.0.9. All seems well.

twicebaked15:10:26

I don't see any 3.0.8 though, just the snapshot version on github of 3.0.7 you pushed.

tony.kay16:10:57

I updated the Fulcro 3 release of workspaces to also remove ghostwheel references. Version 1.0.0-RC2 on clojars. https://clojars.org/com.github.awkay/workspaces

👍 12
tony.kay16:10:16

Template also updated. Fulcro 3.0.7-SNAPSHOT is also out there, and includes various optimizations. Feel free to play with it. It should not cause regressions, but I’d love to hear if any are noticed.