Fork me on GitHub

I’m using cljs.js/eval in the browser, which is working great, but I’m having trouble evaling sources that call macros that I wrote. below is a small repro:

(defn default-load-fn [{:keys [name macros path] :as m} cb]
  (prn "trying to load" m)
  (throw "whoops!"))

(defn wrap-js-eval [resource]
    (cljs/js-eval resource)
    (catch js/Object e
      {::error e})))

(def compiler-options
  {:source-map true
   ;; :context :statement
   :ns 'test.ns
   :verbose true
   :load default-load-fn
   :def-emits-var true
   :eval wrap-js-eval})

(def state (cljs/empty-state))

(defn eval-next [statements]
  (when-let [statement (first statements)]
    (prn "evaling " statement)
    (cljs/eval state
               #(do (prn "result: " %)
                    (eval-next (rest statements))))))
(eval-next [
            '(ns test.ns)
            '(defmacro test-macro [& body]
               `(vector 42 [email protected]))
            '(test-macro 123)
            ;; console log:
            ;; "evaling " (test-macro 123)
            ;; "result: " {:value (cljs.core/vector 42)}
basically, the macro is being created, but its arguments are nil and it’s acting like a regular function and just returning its data rather than acting like a macro. Anyone know what I’m missing or have an example with macros that I can follow? versions:
[org.clojure/clojure "1.10.0"]
[org.clojure/clojurescript "1.10.764"]