This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-31
Channels
- # announcements (2)
- # babashka (145)
- # beginners (260)
- # calva (17)
- # chlorine-clover (7)
- # clj-kondo (9)
- # cljsrn (1)
- # clojure (88)
- # clojure-dev (65)
- # clojure-europe (31)
- # clojure-france (4)
- # clojure-nl (4)
- # clojure-uk (61)
- # clojuredesign-podcast (1)
- # clojurescript (31)
- # code-reviews (1)
- # cursive (32)
- # data-science (2)
- # datascript (9)
- # datomic (39)
- # docker (3)
- # events (1)
- # figwheel (95)
- # figwheel-main (4)
- # fulcro (17)
- # kaocha (2)
- # keechma (1)
- # malli (1)
- # meander (35)
- # nrepl (4)
- # off-topic (1)
- # pathom (8)
- # re-frame (4)
- # reagent (8)
- # reitit (3)
- # releases (1)
- # remote-jobs (2)
- # shadow-cljs (182)
- # sql (30)
- # tools-deps (89)
- # xtdb (31)
so the namespace is (ns example.test-server) the folder is test/cljs/example/test_runner.cljs and the files do not appear to be put in the target folder
fixed it in the end just not 100% sure how one thing I am curious about is do the test files filename matter ? as in do they have to match the namespace in the main app with _test appending or should they be picked up regardless ?
seems when changing a Clojure file it does reload it as documented, but my after-load hook isn't being run. When I change a cljs file it does run. Is there something I can do to have the hook also be triggered when it's a clojure-only change?
reading through the code it seems like this is currently not possible, found a very hacky way around it. Our use case it to have hot reloading of server rendered routes by naively refetching the page and replacing the body
(ns lambdaisland.ui.main
(:require [kitchen-async.promise :as p]))
(defn fetch-and-replace-body! []
(p/let [response (js/fetch (str js/location))
text (.text response)]
(let [parser (js/DOMParser.)
doc (.parseFromString parser text "text/html")
new-body (.querySelector doc "body")]
(set! (.-innerHTML js/document.body)
(.-innerHTML new-body)))))
;; Figwheel hooks don't work here because they only fire when ClojureScript
;; namespaces are reloaded, not when only Clojure namespaces change. Instead
;; hook into the function that schedules the conditional execution of the
;; after-load hook so we get called every time.
(defonce monkey-patch-figwheel
(let [after-reloads js/figwheel.repl.after_reloads]
(set! js/figwheel.repl.after_reloads
(fn [f]
(after-reloads f)
(fetch-and-replace-body!)))))