Skip to content

Instantly share code, notes, and snippets.

@torgeir torgeir/compile.cljs
Last active Mar 9, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.