Skip to content

Commit 4e2ce83

Browse files
author
dnolen
committed
fix browser REPL concurrency bug, it's not safe to build on the static
file serving threads only build the default stuff if output-dir is present and it doesn't already exist on disk
1 parent 267cc9f commit 4e2ce83

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/main/clojure/cljs/repl/browser.clj

+7-8
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,6 @@
172172
clojure.browser.repl/PORT ~port}
173173
cljsc/normalize-closure-defines
174174
json/write-str)]
175-
;; TODO: this could be cleaner if compiling forms resulted in a
176-
;; :output-to file with the result of compiling those forms - David
177-
(let [f (io/file "out/cljs_deps.js")]
178-
(when-not (.exists f)
179-
(spit f
180-
(build/build
181-
'[(require '[clojure.browser.repl.preload])] {:optimizations :none}))))
182175
(server/send-and-close conn 200
183176
(str "var CLOSURE_UNCOMPILED_DEFINES = " closure-defines ";\n"
184177
"var CLOSURE_NO_DEPS = true;\n"
@@ -281,7 +274,7 @@
281274
;; =============================================================================
282275
;; BrowserEnv
283276

284-
(defn setup [{:keys [working-dir] :as repl-env} opts]
277+
(defn setup [{:keys [working-dir] :as repl-env} {:keys [output-dir] :as opts}]
285278
(binding [browser-state (:browser-state repl-env)
286279
ordering (:ordering repl-env)
287280
es (:es repl-env)
@@ -294,6 +287,12 @@
294287
{:optimizations :simple
295288
:output-dir working-dir}
296289
(io/file working-dir "brepl_client.js")))))
290+
;; TODO: this could be cleaner if compiling forms resulted in a
291+
;; :output-to file with the result of compiling those forms - David
292+
(when (and output-dir (not (.exists (io/file output-dir))))
293+
(spit (io/file "out/cljs_deps.js")
294+
(build/build
295+
'[(require '[clojure.browser.repl.preload])] {:optimizations :none})))
297296
(repl/err-out
298297
(println "Serving HTTP on" (:host repl-env) "port" (:port repl-env))
299298
(println "Listening for browser REPL connect ..."))

0 commit comments

Comments
 (0)