File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 171171 (= path (cond->> " /main.js" output-dir (str " /" output-dir )))
172172 (let [closure-defines (-> `{clojure.browser.repl/HOST ~host
173173 clojure.browser.repl/PORT ~port}
174+ (merge (:closure-defines @browser-state))
174175 cljsc/normalize-closure-defines
175176 json/write-str)]
176177 (server/send-and-close conn 200
302303 (cljsc/create-client-js-file
303304 {:optimizations :simple
304305 :output-dir working-dir}
305- (io/file working-dir " brepl_client.js" )))))
306+ (io/file working-dir " brepl_client.js" ))
307+ :closure-defines (:closure-defines opts))))
306308 ; ; TODO: this could be cleaner if compiling forms resulted in a
307309 ; ; :output-to file with the result of compiling those forms - David
308310 (when (and output-dir (not (.exists (io/file output-dir " clojure" " browser" " repl" " preload.js" ))))
Original file line number Diff line number Diff line change 196196 (when (or (not (contains? *loaded-libs* name)) reload)
197197 (set! *loaded-libs* (conj (or *loaded-libs* #{}) name))
198198 (js/CLOSURE_IMPORT_SCRIPT
199- (unchecked-get (.. js/goog -dependencies_ -nameToPath) name))))))))))
199+ (unchecked-get (.. js/goog -dependencies_ -nameToPath) name)))))))
200+ (node-eval repl-env
201+ (str " goog.global.CLOSURE_UNCOMPILED_DEFINES = "
202+ (json/write-str (:closure-defines opts)) " ;" )))))
200203
201204(defrecord NodeEnv [host port path socket proc]
202205 repl /IReplEnvOptions
Original file line number Diff line number Diff line change 1010 (:refer-clojure :exclude [load-file])
1111 (:require [clojure.string :as string]
1212 [clojure.java.io :as io]
13+ [clojure.data.json :as json]
1314 [cljs.compiler :as comp]
1415 [cljs.closure :as closure]
1516 [cljs.analyzer :as ana]
154155 (when (or (not (contains? *loaded-libs* name)) reload)
155156 (set! *loaded-libs* (conj (or *loaded-libs* #{}) name))
156157 (js/CLOSURE_IMPORT_SCRIPT
157- (goog.object/get (.. js/goog -dependencies_ -nameToPath) name)))))))))
158+ (goog.object/get (.. js/goog -dependencies_ -nameToPath) name)))))))
159+
160+ ; ; set closure-defines
161+ (rhino-eval repl-env " CLOSURE_UNCOMPILED_DEFINES" 1
162+ (str " goog.global.CLOSURE_UNCOMPILED_DEFINES = "
163+ (json/write-str (:closure-defines opts)) " ;" ))))
158164
159165; ; Catching errors and rethrowing in Rhino swallows the original trace
160166; ; https://groups.google.com/d/msg/mozilla.dev.tech.js-engine.rhino/inMyVKhPq6M/cY39hX20_z8J
Original file line number Diff line number Diff line change 6060 (shell/sh " node" (str (io/file dir " out" " main.js" ))))))
6161 (-> (cljs-main " -t" " node" " -o" " out/main.js" " -O" " advanced" " -c" " foo.core" )
6262 (output-is ))))))
63+
64+ (deftest test-cljs-2645
65+ (with-sources {" src/foo/core.cljs"
66+ " (ns foo.core) (goog-define configurable \" default-value\" ) (defn -main [& args] (println configurable))" }
67+ (-> (cljs-main " -m" " foo.core" )
68+ (output-is " default-value" ))
69+ (-> (cljs-main " -co" " {:closure-defines {foo.core/configurable \" configured-value\" }}" " -m" " foo.core" )
70+ (output-is " configured-value" ))))
You can’t perform that action at this time.
0 commit comments