This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-23
Channels
- # announcements (26)
- # babashka (8)
- # babashka-sci-dev (3)
- # beginners (93)
- # biff (44)
- # calva (1)
- # cider (7)
- # clj-kondo (13)
- # cljdoc (1)
- # clojure (121)
- # clojure-australia (2)
- # clojure-europe (18)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-uk (1)
- # clojurescript (35)
- # conjure (1)
- # core-async (2)
- # datalevin (6)
- # datomic (28)
- # emacs (25)
- # events (1)
- # fulcro (5)
- # introduce-yourself (2)
- # jobs (8)
- # leiningen (2)
- # off-topic (13)
- # other-languages (1)
- # podcasts-discuss (1)
- # polylith (7)
- # rdf (6)
- # re-frame (1)
- # reagent (53)
- # releases (3)
- # rewrite-clj (7)
- # scittle (5)
- # shadow-cljs (63)
- # specter (1)
- # squint (5)
- # tools-build (5)
- # xtdb (7)
> It is strongly recommended to use the standalone shadow-cljs
version. The command does a lot of things to optimize the user experience (e.g. faster startup) which are not done by other tools. You’ll also save yourself a lot of headaches dealing with dependency conflicts and other related errors.
is this still strong advice? just curious because I use deps.edn
for almost everything these days and am wondering what I am missing out on. (I guess mainly fast startup? I haven’t experienced much in the way of dependency conflicts)
using deps.edn to manage dependencies but still running everything through the shadow-cljs command is fine
faster startup you only get by default when using shadow-cljs.edn
as it defaults to using the AOT package by default
deps.edn you can swtich thheller/shadow-cljs
to thheller/shadow-cljs$aot
to get the same
https://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html
not quite accurate anymore since it doesn't AOT compile on demand but the reasons still apply
Hello, I currently learning ClojureScript with Reagent and tailwind, and hot reload doesn't work. I run
npx shadow-cljs watch frontend
And when I save a file(views/app), changes don't affect the web page on reload
And every time when I change something I need to restart the server to see the changes
Here's my core.cljs
(ns frontend.core
(:require [reagent.core :as r]
[reagent.dom :as rdom]
[frontend.views :as views]))
(defn ^:dev/after-load start
[]
(rdom/render [views/app]
(.getElementById js/document "app")))
(defn ^:export main
[]
(start))
How can I fix it?@U05224H0W Sorry for the such long response So, when I boot up shadow-cljs and open localhost in the web console writes this: shadow-cljs: #3 ready! and with every page reload number increases. And when I change anything in the code, nothing new happens
No, I think not, sorry I am a complete noob in Clojure. I have just a simple shadow-cljs, reagent, and tailwind app without any additions
not a clojure question. how do you run shadow-cljs? in docker or something like that? or the cloud? or just normally local in a terminal?
No just local in terminal
This is what terminal outputs:
No, nothing changes in terminal when i change a file
*and save it
not sure why it wouldn't though. everything seems to look correct. you sure you are editing the correct file?
No, i'm edditing correct one, I even tried to edit same file where i have render function. (here, I editing "ui" component and rendering it, but nothing changes)
hmm so the only explanation I have is that the file watcher doesn't work. which happens when running in containers such as docker. what kind of computer/os do you use?
I using windows, and for terminal linux/oh-my-zsh
may it can be because of IDE? I using intellij idea with Cursive
yes as you said
otherwise it only works if you run in wsl and also edit the files in wsl, ie. directly in /home/wherever
Oh, i'll try that
yeah file watchers in general don't work when using wsl1 but editing files from windows directly. nothing I can do about that unfortunately
Yep, now everything is working, Thank you so much!
didn't even thought that problem can be this)
Does anyone have any general tips for ensuring things that aren't needed are eliminated from the final compiled build? I'm looking at a build report and some of the things e.g. npm libraries are included when not needed (I have a couple of builds with different entry points, one needs these libraries and the other doesn't).
For example, is it OK to 'exclude' npm libs using :js-options {:resolve
when i know they're not needed by the build? Since the closure compiler/shadow doesn't exclude them via DCE
a common solution is using ns-aliases
e.g. https://github.com/dvingo/fulcro-release-build-incl-pprint/blob/main/shadow-cljs.edn
Still seems like the easiest thing is (if i know they will never be caled) is:
:js-options {:resolve {"slate" {:target :global :global "window"}
"slate-react" {:target :global :global "window"}
"slate-history" {:target :global :global "window"}}}
With ns-aliases, I still have to define things within the noop ns"window"
because target is browser and it won't error
That's what this resolve option is intended for, but in my case I know these dependencies are not needed by this build so I'm not including anything.
The compiler can't deduce that they aren't needed, since they're npm libraries.
I guess the usual solution is to not include the namespaces in the release build somehow (preloads are one way) but I don't know the requirements/constraints of your app, so this seems like a good solution
the other way I've gone about this is having a dev namespace for a file and a release version still using ns-aliases e.g. https://github.com/matterandvoid-space/todomvc-fulcro-subscriptions/blob/766d27be316c3f2ab6a23bd8db30932ec0601a4f/shadow-cljs.edn#L11
Right yeah, it's probably also the case that my namespaces could be better organized to make some of this easier.
i.e. i am using parts of this namespace, but not others. Maybe i can better separate them by build.
ah gotcha. yea probably sounds like it. But if it works, then oh well 🙂 thanks for sharing the solution btw - learned a new trick
@U0DHDNZR9 you can just :resolve {"slate" false}
to not include it at all, but yeah its better to organize the namespaces in a way they don't get included in the first place
Even better, thanks!