Fork me on GitHub
Misha Bohdan18:10:59

Hello! Did anyone try to use shadow-cljs from devcontainers? I found that it works much better than WSL but hot reloading is not working for some reason. Any ideas why could it be?


I haven't, but just in case you didn't know: shadow-cljs, npm, and clojure run perfectly fine directly on Windows. No need for either WSL or any kind of container


I honestly don't even know what devcontainers are 😛


but by having container in the name I'm assuming its virtualized which might mean that file watching doesn't work


maybe :fs-watch {:polling true} in shadow-cljs.edn makes it work

Misha Bohdan19:10:16

{:nrepl {:port 8777}
 :source-paths ["src/cljs"]
 :fs-watch {:polling true}
 :builds {:app {:target :browser
                :output-dir "resources/public/js/compiled"
                :asset-path "/js/compiled"
                :modules  {:app {:init-fn mui.core/init}}
                :autobuild true
                :devtools {:http-root "resources/public"
                           :http-port 8280
                           :autobuild true
                           :preloads [devtools.preload]}}}
 :devtools {:after-load mui.core/start}}
Is it correct?


what do you mean see? this is the :fs-watch map?


but the hawk watcher is only used on macOS


oh hmm right that might mean that :polling true doesn't actually do anything since it is a hawk only option 😛

Misha Bohdan20:10:01

I found the solution and tried it with Hawk. For now I'll try to force Hawk in the container

Misha Bohdan20:10:07

Yes, it's working! @U05224H0W, could I create a pull request?

Misha Bohdan20:10:26

for forcing the use of Hawk in config

Misha Bohdan20:10:27

I've made a change into the shadow.cljs.devtools.server.fs-watch file

-        (if (and (str/includes? os-name "Mac") (not (false? (:hawk config))))
+        (if (not (false? (:hawk config)))
and config
:fs-watch {:watcher :polling
           :hawk true}
After these changes, hot reloading finally started to work!

Misha Bohdan20:10:14

By default hawk is false so there is shouldn't be a problem


definitely not doing that


but I'm ok with testing :hawk true

Misha Bohdan21:10:18

Thank you so much for your help! Should I create an issue instead? It still needs to be supported in the codebase since devcontainer is a Docker container and OS in it is Linux and it will fail (str/includes? os-name "Mac") precondition.


create an issue. I'll think about it.

Misha Bohdan19:10:39

It's just a docker container with needed runtime and vscode service.