This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-07-11
Channels
- # announcements (18)
- # babashka (6)
- # beginners (54)
- # biff (3)
- # calva (1)
- # cider (2)
- # cljdoc (25)
- # cljfx (17)
- # clojure (29)
- # clojure-brasil (2)
- # clojure-europe (20)
- # clojure-losangeles (3)
- # clojure-nl (2)
- # clojure-norway (8)
- # clojure-portugal (2)
- # clojure-uk (9)
- # clojurescript (18)
- # cursive (6)
- # data-science (10)
- # datalevin (4)
- # datomic (17)
- # emacs (8)
- # gratitude (3)
- # honeysql (4)
- # humbleui (13)
- # hyperfiddle (33)
- # lsp (4)
- # malli (12)
- # missionary (6)
- # music (5)
- # off-topic (9)
- # pedestal (5)
- # polylith (7)
- # releases (4)
- # shadow-cljs (10)
- # xtdb (8)
Hi, I have a Node-js application for which code does not reload correctly. Here is config:
:screenshot {:target :node-script
:main orgpad.screenshot.core/main
:output-to "screenshot/screenshot.js"
:devtools {:autoload true}
:compiler-options {:optimizations :simple}}
I run shadow-cljs watch screenshot, it compiles. Then I run node screenshot.
When I do a change, shadow-cljs watch detects it and recompiles screenshot. But the change is not available in running node screenshot, only after killing it and starting again. For example, I introduce a new function orgpad.server.core/test. I get the following in shadow-cljs watch output:
[:screenshot] Compiling ...
[:screenshot] Build completed. (221 files, 1 compiled, 7 warnings, 0.29s)
Nothing is in node screenshot output, it should contain shadow-cljs - #N ready
I think.There might be some problems with our self-signed certificates. But the same build for our JS client correctly reloads. So I am not sure whether it is related at all.
kinda impossible to answer since I do not know what the app does. hot reload always works the same. the process connects back to shadow-cljs, gets infos about builds, and triggers a reload when a build completes
node is also known for keeping state in function closures, which cannot be hot reloaded
I have added :after-load into :devtools, as a simple function which logs something to the console. And now the files are correctly reloaded. For example adding some function allows me to run it in REPL. So when this hook is missing, Shadow-cljs does nothing with updated code?
it should still be reloading all code normally. the after-load function is just normally the thing that "realizes" the changes. e.g. in the client re-renders the UI, or in node restarts something
I have found this in documentation yesterday: "If neither :after-load
nor :before-load
are set the compiler will only attempt to hot reload the code in the :browser
target. If you still want hot reloading but don’t need any of the callbacks you can set :autoload true
instead." But autoload was set before.
What happened before that I added a new function in a namespace, and it was not accessible in REPL. After adding :after-load, it is now correctly accessible. Not sure what was happening.