Last active
March 9, 2019 10:22
-
-
Save torgeir/e84f4872f747a682d4e792e2c8d5f243 to your computer and use it in GitHub Desktop.
Using clojurescript to compile clojurescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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