Fork me on GitHub
#shadow-cljs
<
2020-10-14
>
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?

zilti18:10:27

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

thheller19:10:39

I honestly don't even know what devcontainers are 😛

thheller19:10:07

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

thheller19:10:29

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?

thheller20:10:42

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

thheller20:10:48

but the hawk watcher is only used on macOS

thheller20:10:16

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 https://github.com/wkf/hawk/issues/10#issuecomment-173656507 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

thheller20:10:24

definitely not doing that

thheller20:10:43

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.

thheller21:10:32

create an issue. I'll think about it.

Misha Bohdan19:10:39

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