Is there a way to configure the compilation progress output to include the files being compiled? So I have things like this in the log
[:dev] Build completed. (451 files, 3 compiled, 0 warnings, 5.12s)
And would like to have the file paths of the 3 compiled files.the UI might be a better option for that? as far as the CLI is concerned there is only --verbose
which is likely too verbose?
Looks like I can grep a bit on the verbose output and get what I want.
what do you want? if you actually want to do something with the "data" a build hook might help? https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks
A build hook might do it too. I have the output from the CLI in a terminal pane in VS Code. When I save a file or unstash something and such I like to see when the compilation is done, and also which files have been recompiled. It’s more “for my information” than anything else.
Tried with this hook now, but don’t see anything in the CLI output.
(defn print-compilation-info [build-state & args]
{:shadow.build/stages #{:compile-finish :flush}}
(prn [:build-state build-state
:args args])
build-state)
This in the build conf:
:build-hooks [(env.hooks/print-compilation-info 1 2 3)]
ehm yeah printing the build-state
is not a good idea. it will be several hunderd megabytes 😛
use tap>
and look at it in the UI
also the metadata is misplaced
before the args vector, not after.
That inspector. ❤️
With the metadata map at the right place things started to work of course.
We have just (yesterday) switched to shadow at work for our react native app. I am going to have so much use for the inspector I now realize. Totally wonderful.
Not sure I can hook myself to the output I want. Using verbose output it looks like I would want the -> Cache write: foo.cljs
rows in addition to the non-verbose output. But i don’t find the info I need in the build-state. You think it is there in any of the stages, @thheller?
@pez well you could replace the logger but I think it is enough if you just get the data you need and print what you want
for example
(defn pez-print
{:shadow.build/state :flush}
[{:keys [build-sources] :as build-state}]
(let [compiled (get-in build-state [:shadow.build/build-info :compiled])]
(doseq [src-id build-sources
:when (contains? compiled src-id)
:let [rc (get-in build-state [:sources src-id])]]
(prn [:compiled (:resource-name rc)])))
build-state)
:shadow-build/build-info :compiled
! Thanks. I’m tempted to name the hook like that. 😃
yeah I need to document the build-state data at some point. kind of a lot of stuff in there 🙂
rc
will also contain all the other info. :file
will have the <http://java.io|java.io>.File
instance if you need the full path. :resource-name
is just the name on the classpath
(not all sources fill have :file
though so make sure you are only accessing it if it exist. won't exist for classpath .jar resources for example)
I’ll run with this for now. Many thanks for the help!
(defn print-compiled-files
{:shadow.build/stages #{:flush}}
[{:keys [build-sources] :as build-state}]
(let [compiled
(get-in build-state
[:shadow.build/build-info
:compiled])
output
(->> rc
:resource-name
(for [src-id build-sources
:when (contains? compiled src-id)
:let [rc (get-in build-state
[:sources src-id])]])
(sort)
(into [:compiled]))]
(binding [clojure.pprint/*print-right-margin* 20]
(clojure.pprint/pprint output)))
build-state)
Posted in #cider and got no bites. Figured I’d repost here: Anyone else have any issues with cider-doc in a shadow-cljs? It is working fine in my clojure repl and in a different project that uses weasel. It isn’t even working for built-in clojure functions. Toggled messages and just see a (“done” “no-eldoc”). Any ideas?
shadow-cljs doesn't handle eldoc. the cider-nrepl
middleware does. did you install that?
Yep, got cider nrepl. Works for all the other projects I’m working on. But for some reason not working in my shadow-cljs project. (Posted in cider first because I know it isn’t shadow-cljs’s fault)
if you have the cider-nrepl listed as a proper dependency and a new enough shadow-cljs version it should work
but I don't use emacs or cider so I cannot help much with debugging
No worries. Like I said, not it isn’t shadow’s fault. Just want to see if anyone has run into it. I’m doing a jack-in. (Pasted the wrong one here see comment in thread for correct one) Using shadow version 2.11.17
Maybe it is a lack of piggieback?
Wait that was the wrong one sorry
;; Startup: /Users/jimmy/.npm-packages/bin/npx shadow-cljs -d nrepl:0.8.2 -d cider/piggieback:0.5.2 -d cider/cider-nrepl:0.25.4 server
43 ;;
44 ;; ClojureScript REPL type: shadow
45 ;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :frontend) (shadow/nrepl-select :frontend))
looks fine
and you've connected to the runtime? something like (js/alert "hi") will work? (making sure you're not still in a clojure repl or have connected to the js engine)
Yep, I can eval perfectly fine
m-x nrepl-toggle-message-logging
and then try again. you can inspect the nrepl messages to see if there are any clues there
(-->
id "51"
op "eldoc"
session "50e453a5-e9b4-4b65-8572-923074485504"
time-stamp "2021-02-24 11:35:14.713680000"
ns #("[my-namespace]" 0 40 (fontified t help-echo cider--help-echo cider-locals nil cider-block-dynamic-font-lock t face font-lock-type-face))
sym "helix/defnc"
)
(<--
id "51"
session "50e453a5-e9b4-4b65-8572-923074485504"
time-stamp "2021-02-24 11:35:14.717698000"
status ("done" "no-eldoc")
Doesn’t matter what symbol. That is what I always get.
m-x cider-describe-session
and choose either of the two connections listed (if you only have the one connection at the moment. one is tooling, one is regular interaction). It should open up a buffer with Supported ops: and list what the connection can do. you can see if eldoc and info are supported. also, eldoc is something that happens on hover i think. I think you want to find an op of "info"
(-->
id "23"
op "info"
session "dcdd12ab-8b2e-4411-8096-66c5e103943c"
time-stamp "2021-02-24 10:40:49.108554000"
ns #("metabase.sync.sync-metadata.tables-test" 0 39 (fontified t help-echo cider--help-echo cider-locals nil cider-block-dynamic-font-lock t face font-lock-type-face))
sym "testing"
)
(<--
id "23"
session "dcdd12ab-8b2e-4411-8096-66c5e103943c"
time-stamp "2021-02-24 10:40:49.113750000"
added "1.1"
arglists-str "[string & body]"
column 1
doc "Adds a new string to the list of testing contexts. May be n..."
file "jar:file:/Users/dan/.m2/repository/org/clojure/clojure/1.10...."
line 597
macro "true"
name "testing"
ns "clojure.test"
resource "clojure/test.clj"
see-also ("clojure.test/is" "clojure.test/deftest")
status ("done")
)
Yeah, info does the same sort of thing.
(-->
id "66"
op "info"
session "50e453a5-e9b4-4b65-8572-923074485504"
time-stamp "2021-02-24 12:24:05.124286000"
ns #("[my-ns]" 0 40 (fontified t help-echo cider--help-echo cider-locals nil cider-block-dynamic-font-lock t face font-lock-type-face))
sym "helix/defnc"
)
(<--
id "66"
session "50e453a5-e9b4-4b65-8572-923074485504"
time-stamp "2021-02-24 12:24:05.127422000"
status ("done" "no-info")
)
I do have two sessions. One shows me a big long list including eldoc and info. But the session listed above “50e453a5-e9b4-4b65-8572-923074485504” literally doesn’t open up anything when I do a cider-describe-nrepl-session
hmm. i can look into this tonight to see if i can reproduce. don't have time until then. sorry about this issue though
I think I figured out a commonality. Most of them that aren’t working are macros. There are non-macros that are working. (At first I thought none were working, I just kept accidentally trying macros)