       (emitln "if(!COMPILED) " loaded-libs " = cljs.core.set();"))
     (doseq [lib (remove (set (vals seen)) (distinct (vals libs)))]
       (cond
-        (ana/foreign-dep? lib)
-        (let [{:keys [target optimizations]} (get @env/*compiler* :options)]
-          ;; we only load foreign libraries under optimizations :none
-          (when (= :none optimizations)
-            (if (= :nodejs target)
-              ;; under node.js we load foreign libs globally
-              (let [{:keys [js-dependency-index options]} @env/*compiler*
-                    ijs-url (get-in js-dependency-index [(name lib) :url])]
-                (emitln "cljs.core.load_file(\""
-                  (str (io/file (util/output-directory options) (util/get-name ijs-url)))
-                  "\");"))
-              (emitln "goog.require('" (munge lib) "');"))))
+        #?@(:clj
+            [(ana/foreign-dep? lib)
+             (let [{:keys [target optimizations]} (get @env/*compiler* :options)]
+               ;; we only load foreign libraries under optimizations :none
+               (when (= :none optimizations)
+                 (if (= :nodejs target)
+                   ;; under node.js we load foreign libs globally
+                   (let [{:keys [js-dependency-index options]} @env/*compiler*
+                         ijs-url (get-in js-dependency-index [(name lib) :url])]
+                     (emitln "cljs.core.load_file(\""
+                       (str (io/file (util/output-directory options) (util/get-name ijs-url)))
+                       "\");"))
+                   (emitln "goog.require('" (munge lib) "');"))))])
 
         (or (-> libs meta :reload)
             (= (get reloads lib) :reload))

  (interpose "," xs))

(defn- escape-char [^Character c]
  (let [cp (.hashCode c)]
    (case cp
      ; Handle printable escapes before ASCII
      34 "\\\""

                    [cljs.source-map :as sm]
                    [clojure.data.json :as json]
                    [cljs.js-deps :as deps])
     :cljs (:require [goog.string :as gstring]
                     [clojure.string :as string]
                     [cljs.tools.reader :as reader]
                     [cljs.env :as env]
                     [cljs.analyzer :as ana]
                     [cljs.source-map :as sm]))
  #?(:clj (:import java.lang.StringBuilder
                   java.io.File)
     :cljs (:import [goog.string StringBuffer])))

(set! *warn-on-reflection* true)

