A minimalstic and hard way approach to clojurescript app

So assuming I would build skeleton for a minimal app with clojurescript, and reagent, I was interested to know how to do the minimal way without a framework.

As requirement I would just need to create a reagent components saying hello world, with a simple index.html page. I want also to use deps.edn without any lein plug-in etc. Which library I would then need more then the 2 above? My goal is to put the app to a tomcat server.

In the clojure world I use mostly Emacs with cider

Any hints for this would be welcome

1 Like

You can just use vanilla ClojureScript for this. It has a good main CLI nowadays: https://clojurescript.org/reference/repl-and-main
But I can really recommend setting up a new project with figwheel-main, so you get proper reloading, etc.

3 Likes

Here is a minimal deps.edn + CLJS + Reagent + CIDER + Figwheel

2 Likes

I have my own workflow for a minimal cljs app, which is not in Reagent, but might be interesting: https://github.com/Respo/minimal-respo/ .

1 Like

what is really minimalstic, may not be so useful. I just create my new project, setup it up with shadow-cljs, reagent and deps.edn. It took me a very long time, where is the cost?

Since I have focused on Clojure development for one year, I didn’t follow the updates of new tooling in ClojureScript world.

When I start, I first go for figwheel-main, I add that dependency, create a minimal app.cljs.edn, due to the version I picked, I ran into this. Then I switch to the new snapshot version and it works.

Then I think I need take a look at how to split my builds, so I go for Figwheel Code Splitting, Oh, it works. I also add a .dir-locals to make it start easier. Then I tried an advanced build, Bang! I think it could be a bug, so failed. (I didn’t save that error messages, but when I have time, I will try to reproduce). So far I spend about one day and half.

Cause I want I can get a available version quickly, I go for shadow-cljs, on this way, I met other problems, when you create a new file, If you evaluate the namespace(via cider repl, I am a Emacs user) before you save it, this source file will lost the relation with the target file, this namespace will not recompile until you restart shadow-cljs. But once I knew this, It’s ok, so I am go on.

I already have a Clojure project, so I fire up two REPLs for Clojure and ClojureScript in Emacs. Then I met a problem that If the last repl buffer is a clj repl, I can’t evaluate cljs code, vice versa. So I wrote about 10 lines elisp to patching. (I’m not sure about which part is the cause yet).

Okay now everything looks like great, but it spend me nearly 3 days. I am not saying figwheel-main, shadow-cljs or cider is bad, they are awesome tools and I love them. I’m just not a smart people so it cost me a lot time to put things together. But maybe for a new user, maybe he will do worse than me.

So I think a skeleton should do these well:

  1. Stable. Carefully pick the versions of each part, have a test on the combination to make sure it will works, using the latest after testing.
  2. Solutions prepared. This could be tutorials or docs, not code. User need to know how to start those basics. Most skeleton may only give dev and prod builds. this is not enough. User should know how to build, how to use clojure library, how to use javascript library, how to split modules, etc.
  3. Editor Integration. Like how to use it with VSC, Atom, Cursive, Emacs, etc.
  4. Minimal on code.
2 Likes

If you know how to reproduce a bug please report it as an issue so it gets fixed. Please get as detailed as possible and things get fixed much quicker if you can reproduce it without cider too since I can’t easily test all cider things myself.

1 Like

Hi, I create a reproduce repo for the issue.

Hope this help, ask me for any more detail.

2 Likes

Hope this helps :slight_smile: https://betweentwoparens.com/start-a-clojurescript-app-from-scratch

2 Likes

Really nice thx! What do you for creating the web pages? Do you use github.io with Hugo or similar? I was searching a clojure way for doing such blogs

I have not yet used ClojureScript to build a static site for a blog. My current approach is to use Netlify + Gatsby see https://github.com/tkjone/blog for speed of development reasons.

Are you interested in a static site, spa, or server side app for a blog style site? Each of these will use the starting point outlined in the article I provided, the difference comes in actually implementing the app itself. This is why I did not write about that in specific, because there are many different paths to take :slight_smile:

1 Like