Fork me on GitHub
#shadow-cljs
<
2020-08-03
>
Crispin03:08:32

Hi. Does anyone know of a good leining starting project template that combines lein + jvm web server + shadow-cls client build? (hopefully without too much extra baggage, would like websocket support (so not jetty), but would like client side to not have any deps (like no reagent for example))?

robert-stuttaford07:08:04

you'll learn a tremendous amount of permanently useful and valuable stuff by piecing this together yourself 🙂

robert-stuttaford07:08:21

to answer your question directly, i'm not aware of one that does these things specifically. you might try for sente + shadow-cljs ?

sergey.shvets17:08:12

Check https://luminusweb.com/. But I woud advice to setup a separate build for shadow-cljs instead of managing deps in leiningen.

Crispin03:08:26

oh, I also use cider, so something that supports cider-jack-in-clj&cljs would be great!

robert-stuttaford07:08:17

is there a way to force a config reload + rebuild from inside the clj/cljs repls provided by shadow?

steveb8n08:08:02

are you using a watch? if so, you can touch the shadow-cljs.edn and it will rebuild everything

steveb8n08:08:42

otherwise shadow.cljs.devtools.api/compile! should do it

thheller08:08:09

build config reloads should be automatic already

thheller08:08:55

otherwise there is a shadow.cljs.devtools.api/watch-compile! and shadow.cljs.devtools.api/watch-compile-all! to force building a running watch. which however won't reload any config since that should be automatic?

Saikyun09:08:06

@thheller wrt: slurping source -- I've tried the solution you suggested: > slurp with `(io/resource the-file)` should it seems though that sometimes when this code is run during initial compilation (e.g. when running shadow-cljs watch app), it can't find the file.

thheller09:08:24

what are you slurping?

Saikyun09:08:42

(slurp (io/resource ana/*cljs-file*))

thheller09:08:36

yes but which file?

thheller09:08:02

I mean it won't work in the REPL since that has no file

Saikyun09:08:12

nah, not in the repl

thheller09:08:16

but other than that all files should exist

Saikyun09:08:53

(defmacro run-tests!
          []
          (read-string (str "(do " (rewrite/rewrite-without-non-comment-blocks-cljs (slurp (io/resource ana/*cljs-file*))) ")"))))

Saikyun09:08:43

hm, now that I think about it, I might have a clue.

thheller09:08:49

looks like you should revise your macro setup. :refer-macros is sooo outdated https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html

Saikyun09:08:06

okay, thanks for the link

thheller09:08:08

otherwise looks file

thheller09:08:29

well its missing some quoting which the macro is supposed to do

Saikyun09:08:41

I found that the error originated from the same run-tests! that is run in clj-mode. so it had nothing with cljs-file to do

Saikyun09:08:50

or to put it in a different way, I needed to use (io/resource *file*) in the clj macro 🙂 rather than just *file*

Saikyun09:08:32

wrt quoting, it's on purpose, in order to put the forms from read-string into the place the macro is run

Saikyun09:08:30

iiuc I can't run read-string if I quote it, right?

thheller09:08:26

`(do ~(read-string ...))

thheller09:08:31

well that doesn't change much I guess

Saikyun09:08:13

why not 🙂

Saikyun09:08:05

hm, strangely enough it didn't work if I did (do ~(read-string ...))`

Saikyun09:08:05

oh now I remember

Saikyun09:08:14

it's because read-string only reads one form

Saikyun09:08:20

while the code can contain multiple forms

Saikyun09:08:29

so that's why I did the str solution

Saikyun13:08:02

thanks again for the link about macros. didn't know you could refer to macros like that 🙂

ghaskins15:08:51

@thheller the proxy-predicate feature works nicely, ty

👍 3