This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-02-01
Channels
- # aleph (6)
- # announcements (37)
- # aws (1)
- # beginners (67)
- # calva (9)
- # clerk (5)
- # clj-kondo (3)
- # clojure (19)
- # clojure-europe (40)
- # clojure-nl (1)
- # clojure-norway (36)
- # clojure-uk (5)
- # clojuredesign-podcast (7)
- # clojurescript (28)
- # datomic (9)
- # emacs (8)
- # figwheel-main (4)
- # fulcro (6)
- # hyperfiddle (19)
- # integrant (4)
- # java (9)
- # lsp (131)
- # malli (9)
- # missionary (85)
- # off-topic (13)
- # pathom (3)
- # polylith (11)
- # releases (1)
- # sci (4)
- # shadow-cljs (7)
- # specter (2)
- # vscode (1)
- # xtdb (2)
Two general cljs/js questions? 1. Why exactly did the cljs community gravitate towards Express? 2. Sitefox, Macchiato, and ____? What are the mature cljs server projects? Do they all use Express? 3. Is this a ring thing? If so why don’t the cljs servers implement the spec? 4. Is there a good story for getting a reagent app to SSR on Cloudflare Workers/Pages
As for 1-3, I think just nobody wrote a ring compliant server for node. For 4, I’d recommend a more minimal React wrapper, although it shouldn’t be impossible with Reagent. What specifically is unclear maybe? Main challenge usually is that components (or even namespaces) require browser APIs and then usually it’ll be more difficult to get SSR to work.
Appreciate the comeback. I was just trying to get a handle on cljs for server. It’s a strange story. My conclusion after a few hours is that I like sitefox. I don’t have any use for it, but it’s very cool. And squint may create something transcendentally cool for clojure, but for now I’m straight JVM server side.
I’ve never seen anyone use express and would love to know how youve reached that conclusion. Macchiato offers a somewhat Ring-compliant adapter to the default http server in Node. No idea about Cloudflare Workers since I dont use that. People tend to prefer JVM Clojure for their web servers (probably due to more libraries available, and probably due to much better performance and tooling for debugging, deployment, etc.)
1. I can't speak for others but Express is mature and already what I knew on Node, so I chose it for Sitefox.
2. Sitefox is not mature. It says "WIP" (work in progress) because I don't think it's ready for other people to build production code on just yet. I have production code on it myself but that's because it's my own code and I love fixing production bugs at 3am. 😁 I am working towards removing the "WIP" tag at the moment thanks to ClojuristsTogether funding.
3. I don't use ring and don't know much about it. I wanted to build Sitefox on the JS standard stack.
4. I don't think it would be difficult at all to SSR Reagent forms in Cloudflare workers . Just use Reagent's render-to-static-markup
in your worker code and build to a js artifact for deployment. If it's useful you can look at some of the https://github.com/chr15m/sitefox/blob/main/src/sitefox/html.cljs#L74-L96 for doing this (and also for injecting fragments into a static HTML blob). I find the function I use the most is select-apply
which is vaguely like enlive in that it lets you make various modifications to the HTML including injecting Reagent before sending it back to the client.
Hope this helps and thanks for your interest!
A clueless newbie question:
When you refer to 'ring', what technology do you mean here?
Neither Google nor Wikipedia were helpful for me. The word 'ring' has several meanings in every relevant context.
My best guess is:
Is it the correct guess?
I disambiguated by searching google for "clojure ring", @U06BDSLBVC6. Then that ^^ was the first hit. hth!
If I want to generate a ClojureScript project using lein, I need to choose a suitable template for lein new
command.
I found a list of leiningen templates for ClojureScript in
The advice of lein help new
was to search
for 3rd party templates.
However, I saw no easy way to find advice for choosing a template with which to start a simple ClojureScript project.
So I am asking here for advice.
IMO the best way is to simply create what you need by hand.
A minimal project is just a single project.clj
file (with a bit of boilerplate that's easier to type than to remember the name of a template) and a src
directory.
Your suggestion is good for someone who is experienced in developing in ClojureScript, as you left out the step of finding a suitable boilerplate. I happen to be a beginner, and should have asked in #beginner. My bad :white_frowning_face:
To a beginner, I'd recommend doing it manually even more so. It's a very valuable learning experience.
Plenty of pain in the direction of easy starts, normal development, and hard truths about wrong choices.
I'd recommend using tools.deps
instead of Leiningen (so, deps.edn
instead of project.clj
) and shadow-cljs as a CLJS compiler, which has great docs: https://shadow-cljs.github.io/docs/UsersGuide.html
There's also a bare-bones shadow-cljs-based project to get you up and running when developing for a browser: https://github.com/shadow-cljs/quickstart-browser
If you decide to use it, I'd definitely recommend going through its code while checking everything with the shadow-cljs docs so you know what's going on.
(You might've guessed that templates are somewhat of a pet peeve of mine. Dictated by poor quality or unmaintained templates, and a lot of vicariously experienced pain with create-react-app
which is not too dissimilar to templates).
@U2FRKM4TW, Thanks for the links. In a way, they answer my quest for a ClojureScript quickstart.
for a beginner id not recommend either lein or deps.edn. instead, use pure shadow-cljs until you have a reason to use lein or deps.edn
that way all you need to do is
npm install shadow-cljs
npx shadow-cljs init
and you're set
this assumes you've installed node.js alreadyUsing deps.edn
with shadow-cljs is trivial and immediately enables all the tooling. Not a lot of things support shadow-cljs.edn
.
there's also templates on npm like npx create-cljs-app
(or create-helix-app, or uix starter template, ...) that offer tons of more scaffolding but that requires you to be familiar with tools used in the template
@U2FRKM4TW what are these "things"? the only reason id integrate jvm clojure tooling is to make use of e.g. git deps, or integrate cljs into an existing clj project i dont expect beginners to run into these situations, hence prefer a single tool rather than two tools
IDEs (Cursive and, last time I checked, clojure-lsp), any tools that work with deps.edn
(antq, clj-kondo also doesn't support it I think, tools.deps.graph
, and so on).
VS Code, Emacs, and Vim plugins support shadow-cljs. Cursive is the exception, not the rule. Antq definitely scans shadow-cljs.edn files — I use it all the time. Ditto for clj-kondo (I use this indirectly via clojure-lsp)
For a beginner I would definitely recommend VS Code over Cursive (not even personal preference, simply because VS Code is what has the most tutorials and documentation out there. I personally use Emacs). And Calva uses Clojure LSP under the hood, I have used it successfully in projects with only shadow-cljs in them
There’s definitely benefits to integrating shadow-cljs with deps or lein, but for a beginner, it’s more likely to present additional cognitive load rather than any immediate, tangible benefit.
Ah, alright, my knowledge is outdated then.
But to make sure that the OP still considers it - integrating shadow-cljs with deps.edn
is just specifying all the dependencies in deps.edn
and adding :deps true
to shadow-cljs.edn
. That's it.
The only downside is that you have to restart shadow-cljs when changing the set of dependencies.
https://github.com/thheller/shadow-cljs?tab=readme-ov-file#quick-start maybe that helps too