           (update :closure-defines merge (repl-defines worker-state))
           (update-in [:modules (:default-module compiler-state) :entries] prepend '[cljs.user shadow.devtools.client.node])
           ))))
+
+(defn inject-devtools
+  [{:keys [build-config] :as proc-state}]
+  (let [{:keys [target]} build-config]
+    (cond
+      (or (= :node-library target)
+          (= :node-script target)
+          (= :node (get-in build-config [:devtools :runtime])))
+      (inject-node-repl proc-state)
+
+      ;; defaults to browser repl unless otherwise specified
+      (or (= :browser target)
+          (let [rt (get-in build-config [:devtools :runtime])]
+            (or (nil? rt)
+                (= :browser rt))))
+      (inject-devtools-browser proc-state)
+      )))
 
 (defn >!!output [worker-state msg]
   {:pre [(map? msg)


      (-> worker-state
          (assoc :compiler-state compiler-state)
          (cond->
            ;; defaults to browser repl unless otherwise specified
            (or (= :browser target)
                (let [rt (get-in build-config [:devtools :runtime])]
                  (or (nil? rt)
                      (= :browser rt))))
            (inject-devtools)

            (or (= :node-library target)
                (= :node-script target)
                (= :node (get-in build-config [:devtools :runtime])))
            (inject-node-repl))

          (update :compiler-state comp/process-stage :config-complete true)
          ))


     (boolean reload-with-state)
     }))

(defn inject-devtools-browser
  [{:keys [build-config] :as proc-state}]
  (let [{:keys [console-support]}
        (:devtools build-config)]
