Can I conditionally compile clojure / clojurescript?

Viewed 730

Is there a way to in clojure / clojurescript to conditionally compile something depending on whether you're compiling to JVM bytecode of Javascript?

I am writing a small game in ClojureScript but want to keep the majority of the code platform neutral so I can convert to Clojure at some point. I also find that compiling in Clojure is better for finding errors in my code.

I have this working fine by having a directory of clj files that cljsbuild converts to cljs using crossovers.

Where I've come unstuck is trying to use core.async in my clj files. This is needed for cljs:

(ns gaz.system
    (:require-macros [cljs.core.async.macros :refer [go]])
    (:require 
        [cljs.core.async]))

While this is needed for clj to work

(ns gaz.system
    (:require
        [core.async ]))

I'd love to have one file with some form conditional require depending on how it's being compiled. Is that possible at all? Con

1 Answers
Related