Once the browser is connected to replo clojurescript, I previously had no way to call macros from repl. This is a problem that clojurescript has disabled me in the past, preferring to use javascript directly. Basically, I felt that cljs-repl was a bit lame, and I was returning to the compilation / debugging cycle, which was supposed to free us from clojure code.
Are there any good workarounds / workflows for pushing and testing code in clojurescript? Especially if macros can be evaluated?
An example of my problem:
(ns blad.client.main
(: require [noir.cljs.client.watcher: as watcher]
[clojure.browser.repl: as repl]
[crate.core: as crate])
(: use [jayq.core: only [$ append]])
(: use-macros [crate.macros: only [defpartial]]))
note the line (:use-macros [crate.macros :only [defpartial]])
I cannot use defpartial in a replica of a browser because it is a macro. The error I am getting is:
>> (crate.macros / defpartial [])
"Error evaluating:" (crate.macros / defpartial []): as "crate.macros.defpartial.call (null, cljs.core.Vector.fromArray ([])); \ n"
#
TypeError: Cannot read property 'defpartial' of undefined
Now defpartial is a pretty useful macro, and without it, it was a problem.
My problem got worse when I wanted to define another macro in the project with :use-macros . I could not debug what I wrote at all in the repl or browser, and after about half a day I realized that it was faster to use clj repl, check the macro there using macroexpand, and copy the results back to the browser. I have one cljs macro working in about a day, it wasn’t very fun. That was about 6 months ago. I hope there is a faster way to do it now.
source share