shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
Misha Bohdan 2020-10-14T18:41:59.451800Z

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?

zilti 2020-10-14T18:53:27.452600Z

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

thheller 2020-10-14T19:23:39.455700Z

I honestly don't even know what devcontainers are 😛

thheller 2020-10-14T19:24:07.456300Z

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

thheller 2020-10-14T19:24:29.456800Z

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

Misha Bohdan 2020-10-14T19:26:39.458Z

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

Misha Bohdan 2020-10-14T19:31:16.459100Z

{: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?

thheller 2020-10-14T19:34:28.459300Z

yes

thheller 2020-10-14T20:14:42.460800Z

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

thheller 2020-10-14T20:16:48.461Z

but the hawk watcher is only used on macOS

thheller 2020-10-14T20:17:16.461200Z

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

Misha Bohdan 2020-10-14T20:22:01.461500Z

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 Bohdan 2020-10-14T20:31:07.461800Z

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

thheller 2020-10-14T20:37:52.462Z

for?

Misha Bohdan 2020-10-14T20:39:26.462200Z

for forcing the use of Hawk in config

Misha Bohdan 2020-10-14T20:43:27.462400Z

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 Bohdan 2020-10-14T20:44:14.462600Z

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

thheller 2020-10-14T20:54:24.462800Z

definitely not doing that

thheller 2020-10-14T20:54:43.463Z

but I'm ok with testing :hawk true

Misha Bohdan 2020-10-14T21:26:18.463200Z

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.

thheller 2020-10-14T21:40:32.463400Z

create an issue. I'll think about it.