Skip to content

Instantly share code, notes, and snippets.

@nbeloglazov
Created February 20, 2016 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbeloglazov/38c1fc9a1da2eeca5b33 to your computer and use it in GitHub Desktop.
Save nbeloglazov/38c1fc9a1da2eeca5b33 to your computer and use it in GitHub Desktop.
(ns my.core
(:require [cljs.nodejs :as nodejs]
cljs.js
[clojure.string :as cstr]))
(nodejs/enable-util-print!)
(def bar-source
"(ns my.bar)
(defmacro abs [x]
`(if (pos? ~x)
~x
(- ~x)))")
(def main-source
"(ns my.foo
(:require [my.bar :as b :include-macros true]))
(+ (b/abs -4)
(b/abs 5))")
(def sources
{'my.bar bar-source})
(defn load-library-inline [{:keys [name macros]} cb]
(println "Loading" name "macros" macros)
(if-let [source (sources name)]
(cb {:lang :clj :source source})
(cb nil)))
(defn -main [& args]
(cljs.js/compile-str (cljs.js/empty-state) main-source
"test"
{:eval cljs.js/js-eval
:load load-library-inline}
(fn [f] (println f))))
(set! *main-cli-fn* -main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment