shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
Schpaa 2020-10-21T09:35:16.060500Z

I am experimenting with build-hooks in shadow-cljs and I wondered why this fragment wont kick in when building a release:

(defn simple-user-test {:shadow.build/stages #{:configure :flush :compile-prepare}} [state args]
  (println "HELLO:")
  (println (with-out-str (pprint args)))
  (println (:shadow.build/stage state)))
  state) 
but if I pass in a keyword, like :flush (instead of the set) it works fine…?

Schpaa 2020-10-21T09:35:50.060900Z

This is what the docs say:

The hook is a just a normal Clojure function with some additional metadata. The {:shadow.build/stage :flush} metadata informs the compiler to call this hook for :flush only. You may instead configure {:shadow.build/stages #{:configure :flush}} if the hook should be called after multiple stages. At least one configured stage is required since the hook otherwise would never do anything.

simongray 2020-10-21T09:37:47.061200Z

I’m not really qualified to answer this, but in your example code snippet you seem to be missing the ^ marking the map as metadata?

Schpaa 2020-10-21T09:40:32.061400Z

interesting, well it works fine without the set

Schpaa 2020-10-21T09:41:08.061600Z

and https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks does not involve any ^

thheller 2020-10-21T09:41:46.062Z

@schpaencoder when using a set it is stages not stage

Schpaa 2020-10-21T09:42:23.062400Z

ah!! dang

simongray 2020-10-21T09:42:34.062600Z

my bad, apparently the defn macro allows for attaching metadata using a plain map. I didn’t realise that 🙂

thheller 2020-10-21T09:42:34.062800Z

easy to miss 😛

Schpaa 2020-10-21T09:43:10.063Z

yeah!

Schpaa 2020-10-21T09:44:03.063100Z

yup, cheers

neilyio 2020-10-21T16:40:07.064900Z

Is there a way to get the shadow-cljs classpath from the command line? This is mentioned in https://github.com/thheller/shadow-cljs/issues/558, I'm just wondering what the best solution is to use clj-kondo, https://github.com/borkdude/clj-kondo#project-setup.

dpsutton 2020-10-21T16:43:53.066Z

shadow-cljs classpath. described in shadow-cljs --help

neilyio 2020-10-21T16:44:05.066300Z

Yep just saw that... Thanks for the reply!

jmckitrick 2020-10-21T21:42:37.067Z

@thheller (or anyone else who might know) not long ago, you suggested I ignore that ‘builds’ page that pops up after a successful build.

jmckitrick 2020-10-21T21:43:01.067600Z

Does that page have or will it have a useful purpose? Or is it just a relic or diagnostic tool?

thheller 2020-10-21T21:52:56.068300Z

@jmckitrick not a clue what you mean. what is "‘builds’ page that pops up after a successful build"?

jmckitrick 2020-10-21T21:54:10.069200Z

I assume it’s shadow-cljs, but I could be wrong. a question pops up after CIDER starts the CLJS REPL and says Visit '<http://localhost:9630>' in a browser? (y or n)

jmckitrick 2020-10-21T21:54:31.069700Z

Some told me ‘just say no and ignore this’

thheller 2020-10-21T21:54:54.070200Z

that is a cider question. it isn't coming from shadow-cljs. not a clue what controls it.

jmckitrick 2020-10-21T21:58:53.070500Z

ok, sorry…

thheller 2020-10-21T22:00:16.070800Z

the page it wants to open is the shadow-cljs UI

thheller 2020-10-21T22:00:33.071100Z

if you don't care about it you don't need to use it

thheller 2020-10-21T22:01:07.071400Z

but the prompt is not from shadow-cljs

dpsutton 2020-10-21T22:03:13.071600Z

(setq cider-offer-to-open-cljs-app-in-browser nil)

thheller 2020-10-21T22:06:26.072400Z

@dpsutton if that supposed to open the actual user app? then it is opening the wrong URL maybe?

thheller 2020-10-21T22:06:47.073Z

9630 is always the shadow-cljs UI, never anything the user builds

dpsutton 2020-10-21T22:07:08.073500Z

correct. i believe its usally spot on. when the port is 3000 it offers that port. been a bit but i wouldn't be surprised if this is maybe when deps are managed by lein or deps perhaps

dpsutton 2020-10-21T22:08:50.074Z

i have 3000 listed as my port but that's occupied so shadow bumped up to 3001. i was correctly offered to see 3001

dpsutton 2020-10-21T22:09:55.074500Z

searches the nrepl server output for (search-forward-regexp "<http://localhost>:[0-9]+" nil 'noerror)

dpsutton 2020-10-21T22:11:09.075100Z

parsing this output

shadow-cljs - HTTP server available at <http://localhost:3001>
shadow-cljs - server version: 2.8.37 running at <http://localhost:9630>
is it deterministic that the HTTP server output is before the shadow server output?

thheller 2020-10-21T22:12:42.075400Z

not a clue actually 😛

thheller 2020-10-21T22:13:17.075900Z

but the line is different so maybe just ignore the server line?

dpsutton 2020-10-21T22:13:43.076300Z

yeah i should open an issue. maybe look around for all of the different versions to watch out for