I’ve been doing Clojure long enough that I remember when Clojure just was a JAR provided in a ZIP file. As I much as I benefit from all the work around modern Clojure tooling, it was less ceremonious in the old days to play around without big plans in mind.

During the Clojure Tooling Working Group meetup (coordinated by the awesome Christoph Neumann) at the Conj this year, Rich Hickey said that Clojure should be useful without needing to create a formal project. That struck a chord and reminded me of the simpler times.

It also got me thinking how even experienced Clojurists still find ClojureScript difficult or unnatural to setup. That’s really unfortunate as folks like António Monteiro, Mike Fikes, myself and others put in an incredible amount of work over the years to make using ClojureScript more like using Clojure. Let’s see what I mean. Edit your ~/.clojure/deps.edn to include the following:

{:aliases
 {:#cljs {:extra-deps
          {org.clojure./clojurescript {:mvn/version "1.12.116"}}
          :main-opts ["-m" "cljs.main" "-r"]}}}

That’s really all you need. No extra compiler flags, no build configuration EDN or files. Pick whatever global alias name makes sense for you. The idea is to not surprise yourself later. Go ahead and launch a ClojureScript REPL, it doesn’t matter where. Don’t worry, since we didn’t specify an output directory, ClojureScript will write to a tmp directory.

clj -M:#cljs

A browser window will open. Type a few things at the REPL. Then make a file called whatever you want but ending in .cljs. user.cljs works if you’re not feeling inspired. Again, we’re just aimlessly exploring - how does the new proxy functionality in ClojureScript work? Add the following to your file:

(require '[cljs.proxy :refer [builder]])

(def proxy (builder))
(def proxied-map (proxy {:first "Foo" :last "Bar"}))

Note we didn’t define a namespace. We don’t need to! Let’s load the file in the REPL with (load-file "user.cljs") or whatever name you came up with. Right-click on the browser REPL page to open the browser inspector (in Safari you’ll need to enable Developer tools). Navigate to the Console. Try typing the following into the JavaScript Console:

cljs.user.proxied_map["first"]
cljs.user.proxied_map["last"]
Object.keys(cljs.user.proxied_map)

That’s it! No project, no namespaces - just experiments and explorations. You never know what might happen. I actually wrote the code that became cljs.proxy without concrete goals in mind in exactly this way.