This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-14
Channels
- # announcements (7)
- # babashka (13)
- # beginners (98)
- # biff (20)
- # calva (3)
- # clj-kondo (5)
- # clj-otel (6)
- # cljs-dev (96)
- # clojure (22)
- # clojure-austin (30)
- # clojure-conj (4)
- # clojure-europe (53)
- # clojure-nl (2)
- # clojure-norway (63)
- # clojure-uk (3)
- # clojurescript (18)
- # cursive (10)
- # data-science (11)
- # datalevin (2)
- # datomic (7)
- # deps-new (1)
- # fulcro (3)
- # graphql (1)
- # gratitude (4)
- # hyperfiddle (43)
- # kaocha (4)
- # malli (15)
- # pathom (6)
- # polylith (2)
- # reagent (3)
- # reitit (2)
- # releases (6)
- # remote-jobs (1)
- # rewrite-clj (45)
- # ring (4)
- # shadow-cljs (47)
- # sql (5)
- # xtdb (8)
Hi, I’m seeing infer warnings for Reagent’s with-let
macro when using shadow-cljs versions relying on recent versions of com.google.javascript/closure-compiler-unshaded
.
Some googling yesterday gave me the impressing that Reagent https://github.com/reagent-project/reagent/issues/420 in 2019.
This code is from the Luminus template and if I’m not mistaken it has been working for years:
30 | (defn navbar []
31 | (r/with-let [expanded? (r/atom false)]
---------^----------------------------------------------------------------------
Cannot infer target type in expression (. with-let71820 -generation)
--------------------------------------------------------------------------------
32 | [:nav.navbar.is-dark>div.container
33 | [:div.navbar-brand
A combo that does not emit warning:
[com.google.javascript/closure-compiler-unshaded "v20220803"]
[thheller/shadow-cljs "2.20.0" :scope "provided"]
one that does:
[com.google.javascript/closure-compiler-unshaded "v20230103"]
[thheller/shadow-cljs "2.20.20" :scope "provided"]
I’m not sure which project/lib should correct the issue, but it’s keeping up with shadow-cljs that introduce it in my project.
Is there something I can do to avoid these warnings apart from not using with-let
?I'm not sure how you are changing that version, but shadow-cljs shouldn't even start with that combo
and more importantly it the closure compiler has nothing to do with this issue at all?
the issue is fixed in reagent master but has no release yet https://github.com/reagent-project/reagent/commit/44dc15bbeec4e8b0e5bad3bc12aef001ea160368
I guess you can create a externs/your-build.txt
with generation
as the content. that should make it shut up
Which combo were you referring to? I’m always following the versions specified for shadow-cljs on Clojars. Did I mess up?
[com.google.javascript/closure-compiler-unshaded "v20220803"]
[thheller/shadow-cljs "2.20.0" :scope "provided"]
When I noticed the warning with 2.20.20, I started going backwards to find one that worked.
https://github.com/thheller/shadow-cljs/commit/9d0ffb63af9518efd13ffca28321da05cf2c0b2f
this contained a breaking change and should make the older closure compiler version incompatible
but regardless. I know what the issue is and it is fixed in reagent, just waiting for a release
Thanks, let’s leave it at that. My code works, so I can live with the warnings until Reagent releases. Thanks for the quick reply as well!
Hi y'all, hi @thheller (and thanks for all your work 🙂),
I'm struggling to get a base shadow-cljs+expo project working with hot reload and was wondering if you could spot something I would have missed.
I started with your https://github.com/thheller/reagent-expo repository but figured that after some degree of nested components, code changes wouldn't be reloaded on my app. https://github.com/galaux/reagent-expo-nested-components reproduces my problem: it's based on https://github.com/thheller/reagent-expo/pull/12 (project won't build otherwise). I've added 3 nested components such that root
→ one
→ two
→ three
. I run npx shadow-cljs watch app
and npx expo start --clear --web
then visit http://localhost:19006 on my browser. Code changes to root
, one
or two
are effectively hot reloaded right away but not the ones to three
.
This looked similar to https://github.com/thheller/shadow-cljs/issues/544 where you advise to use the [root {:x (js/Date.now)}]
trick that I do use (if I open app/index.js
I can see the generated code bears the very last changes, they are just not rendered it seems). For the record, I've also read your blog post https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html that, unless I'm mistaken, I've followed. Interestingly enough: this problem doesn't show if I run my app using the phone app expo-go.
Can you spot anything I would've missed?
at some point reagent probably just decides that nothing has changed and stops rendering
the [root {:x (js/Date.now)}]
trick only helps to force it to render the root, it doesn't affect deeper levels
that'll make it always reload all files, which can become rather slow but helps for cases such as this
I don't use react-native/expo myself, so I'm a bit out of the loop when it comes to internals
Is there a command equivalent to lein deps
for shadow-cljs? That is, a command that does nothing but download dependencies of a project
My use case is for separating the dependency downloading and compilation steps in a Dockerfile, so that images can build much quicker rather than having to wait up to a minute to download JARs per build
cache your ~/.m2 folder between docker runs, then it won't have to redownload the deps all the time
several folks at Metabase are having issues with the shadow-cljs server not exiting when you ctrl-C a watch
. this seems to have started lately, either from moving from deps in shadow-cljs.edn
to deps.edn
, or more recently when bumping the version from 2.19.6 to 2.20.20.
regarding watch nothing has changed for years, and definitely not between 2.19.6 or 2.20.20
note that the server isn't supposed to exit if the watch
only joined one? if one was started previously that will keep running. either a npx shadow-cljs watch
or npx shadow-cljs server
? could be they have a lingering process they forget about?
a few of the scripts do shadow-cljs restart && shadow-cljs release app
or shadow-cljs restart && shadow-cljs watch app
etc. perhaps they should be gentler?
dropping that restart and just letting watch
start the server seems to work okay.
I usually recommend running shadow-cljs server
in some place. then all other commands will use that server. or you may also control the watch via the ui at http://localhost:9630
if server runs in a dedicated terminal its easy to keep track off and kill, also makes the occisional improperly routed output visible
much of the team isn't actively working on CLJS things, and just does yarn build-hot
, which runs dev-mode watches with shadow-cljs and webpack to keep the JS code live-updating. starting a server in a separate terminal in that case isn't great.
I think it was the background server from restart
causing the issues.
the watch is slow to start, but most people only restart that process once or twice a day, so that's fine. I think we can just drop the restarts from the main commands.