Fork me on GitHub
#shadow-cljs
<
2022-05-06
>
David Vujic06:05:15

One simplistic approach is to have a command basically copying the css (probably in a “dist” folder within the package in node_modules), and add it as an html tag in your html template. If you don't want to set up a postcss/webpack flow. Something like this in package.json: `"scripts": { "copy-css": "cp ./node_modules/@mylib-xxxx/dist/the-css….css ./public/css/the-css”`

mkvlr09:05:34

hey, 👋 there's no hook for the first initial compile, correct?

Carlo10:05:36

https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks comes to mind, but I'm not sure what you're searching for

mkvlr12:05:42

yeah, I mean only for the first compile, ie when the app is ready, but I can do it with a compile hook that only does something the first time it's called

thheller15:05:35

yeah, just put something in the build state so you know it ran already

👍 1
mkvlr16:05:55

to shadow.cljs.devtools.cli-actual/main I mean or should i be using a different entrypoint?

thheller18:05:40

why are you calling that at all? that is only the entry point for the command line tools. what is the goal there?

mkvlr11:05:29

thanks, yeah that’s better. I thought it would be much more work to get the same thing but turns out it’s only two lines 🙃

mkvlr11:05:50

only difference to my invocation via main is that I’m seeing a few extranous log lines

May 07, 2022 1:43:39 PM io.undertow.Undertow start
INFO: starting server: Undertow - 2.2.4.Final
May 07, 2022 1:43:39 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.8.0.Final
May 07, 2022 1:43:39 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.8.0.Final
May 07, 2022 1:43:39 PM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 3.1.0.Final
May 07, 2022 1:43:40 PM io.undertow.Undertow start
INFO: starting server: Undertow - 2.2.4.Final
shadow-cljs - HTTP server available at 

mkvlr11:05:11

do you do something in shadow to silence those that I can copy?

thheller13:05:19

do you use jvm logging in any way? log4j, logback etc?

mkvlr13:05:06

not to my knowledge

thheller13:05:10

btw if you drive all this from the clojure api

thheller13:05:56

you could get more access to stuff without need a build hook

mkvlr13:05:39

like a different kind of callback you mean?

mkvlr13:05:26

have a pointer for this?

thheller13:05:02

well. what are you looking to do?

mkvlr13:05:34

do something after the first flush

thheller13:05:58

well shadow.cljs.devtools.api/watch returns when the build finishes. that might be enough?

mkvlr13:05:12

oh yes, perfect

thheller13:05:22

so just (shadow/watch :the-build) (do-stuff) sequentially should be fine

mkvlr13:05:48

should simplify things a bit, thanks you!

thheller16:05:01

why are you starting 2 nrepl servers? 😛

thheller16:05:00

shadow-cljs starts one. might be useful since that one also supports cljs while the other one does not?

mkvlr16:05:26

disabled the shadow one and starting it myself in order to start it earlier

mkvlr16:05:40

but haven't benchmarked the difference yet

mkvlr16:05:41

I've given up on cljs repls

mkvlr18:05:06

booting only nrepl takes 4-5s on my machine, and nrepl via shadow adds another ~3 seconds…

mkvlr18:05:16

another small things why I’m starting nrepl manually: then the same port file is written regardless of when I use jack-in (for clj-only dev) vs starting only shadow

mkvlr18:05:06

unsure if it might make sense for shadow to delete .nrepl-port when it boots. Maybe after checking that there’s nothing listening on the port but might also be too much magic…

thheller18:05:11

no, shadow won't delete that file as that would interfere with stuff it doesn't control. it writes its own .shadow-cljs/nrepl.port file

mkvlr18:05:44

yeah, but when I kill the process that’s writing .nrepl-port and start shadow afterwards I manually need to delete it

mkvlr18:05:01

no big deal and probably not a common problem

thheller18:05:05

I don't understand the issue sorry 😛

mkvlr19:05:50

when working on clerk, I sometimes do clj-only dev, and jack-in using cider, so shadow isn’t even on the classpath. This writes a .nrepl-port file. When I kill that process or it dies, the .nrepl-port sticks around, and when I launch nrepl via shadow next time, cider doesn’t consider shadow’s shadow-cljs/nrepl.port file, because the other one takes precedence and I need to manually delete it so I can connect again.

mkvlr19:05:10

like I said, I believe it’s a pretty rare edge case.

thheller05:05:19

seems like something cider should handle on its own? I mean it knows if the connect succeeded or not?

👍 1
Yuhri Graziano Bernardes14:05:11

Hi everyone. Hope you are all doing well! What docker image do you use to run shadow-clj apps? I found these two, but they seem kinda unmaintained

mauricio.szabo16:05:55

Do you mean, to compile the code? I usually use a node docker image with Alpine and just install OpenJDK on it

Yuhri Graziano Bernardes22:05:58

I mean use as runtime (for dev and prod)

mauricio.szabo04:05:53

I have no idea what you mean then... Shadow-cljs is only to compile ClojureScript into Javascript, the resulting code is pure JS and you only need to run on a webserver (for browser targets), or on node (for node library and script targets), or at Android and iOS (for react-native). In that sense, maybe you need to look for a apache or nginx docker, or a node docker to run your compiled code?

mauricio.szabo16:05:25

Is there any way to use def but alter the :arglists meta? I tried the suggested solutions but they all failed to update :arglists (tried with alter-meta!, that didn't change any metadata at all, tried with (declare ^{:arglists '([a b])} my-fun)`, that also didn't work)

dpsutton17:05:43

I've reported a similar problem in cljs itself. Might not be shadows bug

thheller19:05:09

var metadata doesn't exist at runtime in cljs. if only lives in the analyzer data on the compiler CLJ side. as such any var based meta programming is severly limited and imho should not be considered at all. just treat it as if vars don't exist. what is your goal with modifying :arglists?