cherry

Gregory Bleiker 2025-10-04T15:14:38.857859Z

General question: can cherry also compile dependencies? Or does require always refer to JS packages?

Gregory Bleiker 2025-10-06T11:22:23.603829Z

Thanks for the clarification @christian767! In the browser, does replicant do more? Especially what needs to be updated in the DOM?

cjohansen 2025-10-06T13:37:23.582739Z

Not sure what you mean by does it do more? Replicant takes hiccup and creates matching DOM. It then updates it as efficiently as possible on successive renders.

Gregory Bleiker 2025-10-06T13:46:38.522539Z

Is the "efficiently as possible" part by creating diffd to the current DOM?

Gregory Bleiker 2025-10-06T13:47:47.028839Z

I should probably go and read some code...

cjohansen 2025-10-06T13:51:29.136629Z

Ah, yeah. It tries to make as few changes to the DOM as possible to match the updated hiccup.

cjohansen 2025-10-06T13:51:37.813679Z

Sorry for being unclear.

borkdude 2025-10-04T15:17:13.853949Z

Currently the compilation model is very basic: one file at a time without following require stuff, so require just gets translated to an ES import and that's it. Squint has better support for translating symbols to relative string imports in require if you use a squint.edn config file which cherry doesn't yet have. Having said that, you can just do this:

(:require ["./my_other_namespace.mjs" :as o])

borkdude 2025-10-04T15:17:27.146279Z

and then compile the other namespace and that will work

Gregory Bleiker 2025-10-04T15:21:04.603549Z

so if I would like to import replicant, I'd have to go through all the replicant clj(s) files, and adjust the imports, correct?

Gregory Bleiker 2025-10-04T15:22:12.097939Z

would something like replicant compile with squint, do you think?

borkdude 2025-10-04T15:22:15.318829Z

oh sorry, I thought you meant: other CLJS files in your project. Hmm, I don't think many existing CLJS dependencies will work as of yet with cherry to be honest. Since many of them depend on CLJS specifics like goog.* and cljs.compiler etc

borkdude 2025-10-04T15:22:27.195949Z

not as is

borkdude 2025-10-04T15:22:40.591659Z

what would be your use case for it?

Gregory Bleiker 2025-10-04T15:22:46.313099Z

thanks for the clarifications!

borkdude 2025-10-04T15:22:54.086849Z

compared to compiling with normal CLJS I mean

Gregory Bleiker 2025-10-04T15:24:04.659209Z

I'm a deno-head, so I just so much like the idea of doing stuff without the jvm. But it's just a vain effort

borkdude 2025-10-04T15:25:19.823709Z

you can use replicant with scittle as of today though

😮 2
Gregory Bleiker 2025-10-04T15:27:49.491609Z

you have too many projects! I thought scittle was for clojure in script tags?

borkdude 2025-10-04T15:28:34.439359Z

yes, I assumed you wanted to use replicant in the browser

borkdude 2025-10-04T15:28:41.094169Z

since that's the natural use case for it

Gregory Bleiker 2025-10-04T15:29:41.185459Z

I'd like to use it for server side

borkdude 2025-10-04T15:30:29.396919Z

just to generate some hiccup -> html? don't you think replicant is a bit overkill for that?

Gregory Bleiker 2025-10-04T15:31:30.039569Z

as a replacement for reagent

Gregory Bleiker 2025-10-04T15:32:54.476669Z

I thought replicant also wrapped all components into web components etc? Also, portfolio would be a nice feature

borkdude 2025-10-04T15:33:58.498769Z

do you mean the web standard web components? then no

borkdude 2025-10-04T15:34:20.793089Z

what replicant basically does is turn hiccup into dom nodes (client side)

borkdude 2025-10-04T15:34:59.646369Z

on the server you can use it to generate HTML if you want to use it for SSR but just as a basic hiccup library, I think it's overkill on the server. the primary use case is client side. we have had this conversation before I believe

borkdude 2025-10-04T15:42:35.326809Z

maybe I'm just misunderstanding what you're looking for, but wouldn't just a hiccup library satisfy your needs?

Gregory Bleiker 2025-10-04T15:47:06.907439Z

I haven't digged into replicant enough, but my hope would be that it provides a higher layer of abstraction over hiccup in the sense that the component wiring and referencing is taken care of when I use it. So I can write something like [:my-component] and convention makes it clear how the custom my-component is generated in the browser (registered as custom component). Also, I was hoping that replicant had support for updating only the parts that changed when client side state changed, so if I push some new state (just the state) to the page, it would update itself

borkdude 2025-10-04T15:51:49.407549Z

I think you might be confusing replicant with projects like HTMX and datastar which do server -> client diffing. That's not what replicant does. Replicant builds the UI from a state and then diffs the current DOM against the to-be DOM like a virtual dom would.

borkdude 2025-10-04T15:52:44.903479Z

Registering custom hiccup tags is possible with replicant, but with a normal hiccup library you can just write functions that generate hiccup and call those, no complexity needed.

(defn foo [] [:div "My component"])

(defn bar [] [:div "Another component" (foo)])

(hiccup/html (bar))

borkdude 2025-10-04T15:53:34.648899Z

I'm not a replicant expert so I might have some details wrong. So let's just summon @christian767 again just in case.

Gregory Bleiker 2025-10-04T15:54:15.715269Z

going all in 🙂

Gregory Bleiker 2025-10-04T20:57:10.859879Z

@borkdude can't the diffing part be done on the server and then datastar be used to send patch messages to the frontend? so the flow would be "build initial ui"(in backend) ->"send to frontend"->"state changes"(on backend, might be because of datastar actions)->"replicant figures out what needs to change"(this is the part I'm trying not to do manually)->"datastar sends patch sse events to frontend"

borkdude 2025-10-04T20:59:24.480089Z

"replicant figures out what needs to change" - this is really not the job of replicant on the server, this is what datastar is doing.

borkdude 2025-10-04T20:59:56.030809Z

you can find a datastar sdk here: https://github.com/starfederation/datastar-clojure it even works in babashka

borkdude 2025-10-04T21:02:00.712559Z

well I got this wrong I think, datastar itself also doesn't diff on the server. the idea is that you have parts of your UI that gets refreshed. datastar sends HTML only for that UI element. then on the client there is some DOM patching/diffing going on

borkdude 2025-10-04T21:02:22.242899Z

but both replicant and datastar do not diff on the client SERVER I think

cjohansen 2025-10-05T06:59:59.255419Z

That's right 😊 Replicant on the server is just a hiccup to string library (as of now). It's useful if you have Replicant on the client (same hiccup dialect), otherwise it's probably overkill, like @borkdude said.

cjohansen 2025-10-05T07:03:09.375129Z

As for custom components. Replicant call these aliases. Their benefit over a regular function is to help DOM updates be faster by moving the realization to the latest possible moment, and to be able to serialize custom hiccup without sending functions. https://replicant.fun/alias/

cjohansen 2025-10-05T07:04:09.430999Z

I have some ideas for how Replicant could be more useful as a server side tool, but haven't gotten around to working on them.