cljs-dev

dnolen 2025-06-05T16:45:52.996069Z

been poking around at tree shaking issue w/ the cljs.core - I don't think the problem really has anything to do w/ printing anymore - I think the issue is actually protocols - and I think it can be fixed

❤️ 4
thheller 2025-06-05T16:48:50.509839Z

which tree shaking issue?

dnolen 2025-06-05T16:53:35.331269Z

the fact that just using a few functions in cljs.core doesn't lead to a fairly small artifact

dnolen 2025-06-05T16:53:49.497409Z

this would also mean that protocols are a problems when used in libraries

dnolen 2025-06-05T16:54:23.872689Z

anyways, I used to think that printing was problem but it's really not

dnolen 2025-06-05T16:54:44.352239Z

(-lookup ...) has the same effect all by itself

thheller 2025-06-05T16:54:52.337059Z

last time I checked using any of the collections causes a lot of things to stay alive

dnolen 2025-06-05T16:55:17.385529Z

I'm sure there might be a couple of other problems

thheller 2025-06-05T16:55:22.257759Z

and a fairly large chunk having to do with Ifn invoke stuff

dnolen 2025-06-05T16:55:29.642019Z

but the protocol one should be fixable

dnolen 2025-06-05T16:55:41.700069Z

IFn is a protocol so it suffers for sure

thheller 2025-06-05T16:56:10.929529Z

it is not only a protocol given that it affects where/how the thing is called

dnolen 2025-06-05T16:56:30.347939Z

setting the other problems aside

dnolen 2025-06-05T16:56:41.855099Z

(-lookup ...) is one of the easiest issues to understand

dnolen 2025-06-05T16:56:52.961749Z

it involves no other cljs.core lib calls

dnolen 2025-06-05T16:57:01.747609Z

it's a fn prototype and some fns

thheller 2025-06-05T16:57:05.215969Z

like the foo.cljs$ifn$x ? foo.cljs$ifn$x(...) : foo.call(...)

dnolen 2025-06-05T16:57:08.530949Z

yet it drags in cljs.core

dnolen 2025-06-05T16:57:53.491539Z

I noticed that protocols don't declare the actual interface they are expecting

dnolen 2025-06-05T16:58:08.188409Z

so maybe this interacts badly w/ the types that declare implementing it

dnolen 2025-06-05T16:58:21.070839Z

so the protocol site is purely duck typed

dnolen 2025-06-05T16:58:37.844659Z

and finally after the assertion that we have the thing we want, we might need a cast

dnolen 2025-06-05T17:00:38.171129Z

basically (-lookup ...) is exactly the kind of case I think that Closure should understand, but it's not working

dnolen 2025-06-05T17:05:45.276449Z

one interesting thought is that if the cljs.core tree shaking issue can be sorted out a "light weight" mode would be interesting

dnolen 2025-06-05T17:06:41.995199Z

i.e. a flag to emit copy-on-write data structures instead of the persistent ones

👍 3