I use it to show a little OS notification if I get a warning (usually I keep shadow's term hidden).
Using Shadow-cljs, is there a way to run a hook inside the context of the reloaded cljc source files? From my test on the hooks, it seems that the source code is only loaded once.
This is my use case: https://clojurians.slack.com/archives/C07UQ678E/p1609647836133300
scanning for generic things like that is difficult but build hooks receive the entire build state and can inspect it however they need
I took a look at the build-state
and made the mistake of printing its content 😛
the best option I have found so far however is using a dedicated css
macro or so that collects these things during compilation. much easier to extract but slightly more verbose in the code
(def button-style (css :border :p-2 :shadow :lg/p-4))
or so(tap> build-state)
and look at it in the inspect UI
oh, good idea (for the tap>)
:sources
has all the sources
:output
has all the outputs of those sources (in :flush
) stage, otherwise might still be empty
I made a macro which adds the css in the metadata attached to the clojure var already. I am looking at how to read it from the hook.
you can take a look at this macro I wrote https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745
it stores state in the analyzer data for the namespace
you could read that out later in the build hook via [:compiler-env :cljs.analyzer/namespaces your.ns :your.thing/key]
or so
Thx, I am taking a look now.
@thheller this worked !
(tap> (get-in build-state
[:compiler-env
:cljs.analyzer/namespaces
'<http://acme.frontend.app|acme.frontend.app>
:defs
'my-fn
:css]))
Big thank you !when you add custom keys to the analyzer data make sure they are namespaced
otherwise you might at some point clash with implementation details