Fork me on GitHub
#shadow-cljs
<
2023-12-18
>
donavan09:12:07

Is there an easy way to use a local shadow-cljs (e.g. in deps.edn {:local/root "../shadow-cljs"})? Trying that, and using shadow as a library (i.e. using shadow.cljs.devtools.api directly errors with

Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:476).
com.google.javascript.jscomp.ShadowCompiler
…I haven’t dug any further, thought I’d just check if it was at least easily possible first.

thheller09:12:01

there are some required java classes, so you need to run lein javac in the shadow-cljs project first

thheller09:12:51

depending on what you want to do there may be extra steps necessary

donavan09:12:16

Ah, easy enough 🙂 That works for what I was trying to do, which was really just to poke around inside shadow-cljs to get a sense of how it works.

thheller10:12:17

happy to answer questions if you have anything in mind

donavan11:12:32

Cheers, thanks Thomas 🙂

Aviv14:12:27

Hey, is there a way to fail the build based on some custom logic? maybe using :build-hooks? Thanks 🙏

thheller14:12:27

define fail?

Aviv14:12:34

raise an error

thheller14:12:45

yes, but define what that means

thheller14:12:28

i.e. what effect would that have as opposed to just finishing the build

Aviv14:12:25

I want to write some script, that reads the code and based on some rules i want to failure the build (some internal logic)

Aviv14:12:22

the effect is mostly that there is a script that runs in a ci and i don’t want the build to finish in case something happens (will force the developer to fix)

thheller14:12:07

that is still and extremely vague description of the error condition. what does "reads the code" mean?

thheller14:12:46

I mean build hooks can throw an exception and that will fail the build

👍 1
Aviv14:12:13

i’ll try to simplify the use case, let’s say i want to force that every “def” starts with a capital letter, in case there is one def that doesn’t start with a capital letter i want to fail the build (the real use case is more complex ofc..)

thheller15:12:02

sure that could be a build hook

👍 1
Aviv15:12:39

can you help me with the api? (for failing the build) couldn’t find it

thheller16:12:48

(throw (ex-info "your message" {}))

thheller16:12:59

in a build hook

thheller16:12:51

(defn hook
  {:shadow.build/stage :compile-finish}
  [build-state]
  (throw (ex-info "I always fail!" {})))

thheller16:12:15

:build-hooks [(that.ns/hook)]

Aviv16:12:57

Great, I'll try, thanks! 🙏

Aviv06:12:02

hooks must be .clj right? (and not .cljs)