Fork me on GitHub
#clojurescript
<
2022-04-18
>
volgar1x11:04:04

Hello, is it possible for a figwheel client to connect on another host than localhost?

volgar1x11:04:31

I tried to configure :server-ip inside :figwheel map of project.clj without success, neither with :websocket-host in :cljsbuild>`:figwheel`

Yang20:04:19

Are there any cljs-based projects designed explicitly for good interoperability with existing node js frameworks & react libraries? Basically something building upon thheller’s https://github.com/thheller/next-cljs proof-of-concept to make it more mature and production ready. I really want to write cljs instead of jsx by default, but Fulcro & Re-frame are too opinionated (I think hooks are good), Rum doesn’t support newer isomorphic js developments like incremental static regeneration (https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration), and in general it feels like isomorphic Clojure web projects with a JVM backend are just playing catch-up with isomorphic js, where most practical innovations happen first, especially from React itself & Next.

p-himik20:04:18

Re-frame doesn't really dictate whether you can use hooks. But they won't work with it very well if you manage some data with re-frame and some data with hooks. In any case, re-frame is built on top of Reagent, and the latter definitely allows you to use hooks just fine. As an alternative, there's https://github.com/lilactown/helix designed to be a thin layer between CLJS and React.

rayat21:04:58

Can attest to using helix + re-frame with ease with @U4YGF4NGM

rayat21:04:04

Though no SSR for now

Yang21:04:54

Yeah, I’ve been using vanilla Reagent and it’s great. I was mostly curious about the SSR/ISR part.

Yang21:04:52

In terms of the future of isomorphic web dev with Clojure, I wonder if it’s more likely that stuff like ISR gets added to JVM/JS hybrid projects like Rum, and the same with any other advances from the JS ecosystem, or if cljs just becomes more deeply integrated with the existing node/browser isomorphic ecosystem

lilactown21:04:58

the SSR story for ClojureScript is pretty bad rn because either you're rendering in the JVM, which is going to lack the bleeding edge features and support that things like next.js has, or you're doing CLJS on Node.js which IME is a second class experience compared to both writing your app in JS or using the JVM on the server

1
lilactown21:04:12

at my previous gig we did SSR via Node.js on the backend, and it was not a fun experience overall. the tooling might have gotten better since then tho

p-himik21:04:29

Oh, BTW - would it be possible to run next.js on GraalJS?

Yang21:04:02

A big part of the benefit of NextJS is its integration with Vercel, so that probably wouldn’t work

lilactown21:04:31

my understanding is that a lot of the value that next.js outside of vercel brings is in the compiler toolchain and marrying the front end and back end

Yang21:04:35

What were some of the problems you ran into using Node with CLJS?

1
lilactown21:04:58

but i could be wrong. i haven't use any of the meta frameworks built on React yet

Yang21:04:10

Right, especially with Next’s new compiler. It wouldn’t be fun to have to compile twice

lilactown21:04:10

there's much less mind share on the CLJS side for deploying Node.js apps, so most of the time you're going to be writing interop in your app

lilactown21:04:54

there's been development here, e.g. with sitefox. at the time, we used macchiato which IIRC wraps express, and required me to get my hands dirty a number of times to dig into the internals

lilactown21:04:11

to get a lot of the benefits of doing SSR on Node.js, you need a data fetching framework that knows how to fetch data on the backend and front end

lilactown21:04:44

there's basically nothing like this in CLJS. I built one, but it was buggy and weird.

Yang21:04:52

Can’t you just use fetch/node-fetch directly via js interop?

Yang21:04:05

I’m thinking basically compile cljs straight to js with pretty much no optimizations, and let Next take care of the rest

lilactown21:04:06

with suspense this might become vastly easier, but at the time there was no suspense. so if your components fetched after mounting, you had no way of waiting for that result when rendering on the server unless you built a mechanism for it

lilactown21:04:16

maybe next can handle that part

Yang21:04:51

But I wonder if Next would require a different compile target than either “browser” or “node” from shadow-cljs

Yang21:04:15

Or does the default cljs compiler provide something like this?

lilactown21:04:54

i don't know - i would try shadow-cljs' ESM target, assuming next.js uses ES modules

lilactown21:04:38

the problem with using another compiler toolchain with cljs is that it becomes really hard to get a REPL into your app at dev time

Yang21:04:04

Right, but the ISR stuff isn’t that important at dev time either

Yang21:04:26

I could just dev in pure client rendered cljs and then do the conversions only when I need to deploy to prod

lilactown21:04:10

idk, typically you want to develop your app as close to what production is going to be as possible. maybe it's worth it though

Yang21:04:42

I think in my case the interactive parts of the app are decoupled enough from the content I want to be prerendered by the server to not make a huge difference. I’ll at least play around a bit with the ESM target like you suggested

1
rayat02:04:00

Curious what you end up with @U03BQMGDM9C!

dgb2306:04:17

Maybe have a look here. The plugins linked expose more control than Next. You might find a better foundation to work with here: https://vitejs.dev/guide/ssr.html