Skip to content

Instantly share code, notes, and snippets.

@torgeir
Last active March 9, 2019 10:22
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 torgeir/e84f4872f747a682d4e792e2c8d5f243 to your computer and use it in GitHub Desktop.
Save torgeir/e84f4872f747a682d4e792e2c8d5f243 to your computer and use it in GitHub Desktop.
Using clojurescript to compile clojurescript
(ns example.core
(:require [cljs.js :as cjs]
[cljs.analyzer :as ana :include-macros true]
[cljs.reader :as r]
[cljs.pprint :as pprint]))
(enable-console-print!)
(let [src "(ns t.math)
(defn increase [n] (inc n))"
opts {:eval cjs/js-eval
:verbose false}]
(cjs/compile-str (cjs/empty-state)
src
"the compilation"
opts
(fn [{:keys [value]}]
(prn value)
(js/eval value))))
;; "goog.provide('t.math');\ngoog.require('cljs.core');\nt.math.increase = (function t$math$increase(n){\nreturn (n + (1));\n});\n"
;; t.math.increase(1)
;; => 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment