This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-01
Channels
- # aleph (1)
- # announcements (2)
- # aws (3)
- # bangalore-clj (1)
- # beginners (136)
- # boot (3)
- # calva (89)
- # cider (44)
- # cljdoc (1)
- # cljs-dev (31)
- # clojure (101)
- # clojure-europe (3)
- # clojure-italy (52)
- # clojure-nl (7)
- # clojure-spec (12)
- # clojure-uk (34)
- # clojurescript (62)
- # community-development (46)
- # cursive (25)
- # datomic (6)
- # duct (26)
- # events (6)
- # figwheel-main (4)
- # fulcro (25)
- # graphql (2)
- # jackdaw (4)
- # jukebox (3)
- # kaocha (57)
- # leiningen (31)
- # off-topic (3)
- # onyx (4)
- # other-languages (22)
- # pathom (18)
- # re-frame (9)
- # reitit (3)
- # shadow-cljs (60)
- # spacemacs (9)
- # speculative (22)
- # sql (39)
- # tools-deps (45)
- # vim (37)
Hello,
Wondering if anyone can help me with a NodeJS + CLJS setup.
I’ve got an app already written in CLJS for the browser, but there’s some code in there I want to share with an already written NodeJS server app.
My plan is to separate out the shared code into its own library; using shadow-cljs :node-library
target to be able to build a JS version for use on the NodeJS server, and pull the library into the CLJS browser app as a normal CLJS dependency. Does that sound sensible?
The next question I have after having trying the above is: when I’m developing this library, how can I get live reloading / REPL based workflow with a :node-library
target?
I’ve tried running the shadow-cljs watcher in one terminal, calling node ./dist/lib.js
and then shadow-cljs cljs-repl lib
to connect a CLJS repl but live reload doesn’t seem to pick up changes after file save (but I can get changes if I eval the code changes within the REPL).
@austinbirch live-reload is a bit more restricted in node-library since we can't modify things after they were exported
so live-reload from within CLJS should work but if you the stuff loaded from node can't
but it should work depending on what you do. may need to manually enable it though :devtools {:autoload true}
Ah, I should have also mentioned that I set :devtools {:autoload true}
and had live reloading working with :node-script
(but then this isn’t consumable as a npm dependency). Maybe I should just create a :node-script
build for development and a :node-library
build for release?
I wouldn't recommend that. you want your dev build to be as close as possible to release
Yes (been there…!)
I actually might have been testing by updating the exported function, so maybe that’s it. If I export functionA
that calls functionB
, update functionB
and save the file, would you expect that the live reload would run the new functionB
?
I will try now and get back to you. Thanks so much for all the help!
Just tried and that’s working perfectly now. Very pleased!
Thanks again for your help.
When I was testing I’m pretty sure I had something like:
(defn exported-fn
[]
"returning 1")
and was just updating the string to see live reloading work. So your explanation above makes perfect sense. Easy for me to just have the exported function call others in the CLJS namespace and work from there.yeah I tried making the exports dynamic once but it had a bunch of issues so I opted out of that
Makes sense. I better get back to actually writing the code now then 🙂
I see that it runs shadow-cljs: call shadow.test.browser/start
when the code reloads, but this doesn't seem to actually update the UI with new tests
Ah, actually no, that wasn't specifically my issue, it is that if I add a new test with deftest that test isn't run, regardless of whether it's Brave or Chrome
can anyone recommend getting started with https://github.com/minimal-xyz/minimal-shadow-cljs-browser versus the shadow-cljs lein template?
I know this isn’t necessarily a beginner forum, but whenever I kill my repls and then restart (via cider-connect-clj&cljs -> shadow -> app) I get Stale Client! in the browser window … which goes away if I hard-refresh the page
@ccann this is absolutely a beginner forum 🙂 unfotrunately I can't help with cider issues as I know nothing about that
stale client is the message you get when you load js that was not compiled by the current watch