Fork me on GitHub
#clojure-nl
<
2020-03-29
>
Kevin09:03:51

Hey all. I wrote a watcher that looks at EDN file for changes. Once it finds a change it'll aggregate these files and output them into a CLJS file. I wanted to be able to write .edn format without having to use HTTP requests to get them. https://github.com/kwrooijen/cljs-auto

Kevin09:03:09

Any feedback would be appreciated 🙂 Maybe I'm not even solving this issue the right way

Kevin09:03:42

It also allows you to watch for newly created CLJS files, and add them in the :require option for the generated namespace. This is useful if you're using integrant in Clojurescript, since it doesn't support dynamic requires. Integrant has a feature to automatically require namespaces, but that isn't supported in CLJS

borkdude09:03:03

@kevin.van.rooijen The way people solve including files from the filesystem inside CLJS is usually with a macro (which is executed at compile time by the JVM)

Kevin09:03:46

Ahh, that's a good one. Does it also support auto reloading in that case?

Kevin09:03:59

If you're using shadow-cljs for example?

borkdude09:03:20

I think so?

borkdude09:03:40

Just like any other macro

Kevin09:03:49

All right, that seems like a much cleaner solution then! I'll try that out

Kevin09:03:32

I wonder if I could use macros to automatically add require statements to the namespace

borkdude09:03:53

I'm afraid that doesn't work well with CLJS.

Kevin09:03:11

That's too bad

borkdude09:03:38

CLJS is less dynamic than CLJ when it comes to namespaces

borkdude09:03:03

which imo is not a bad thing, makes it a lot easier on the tooling (e.g. clj-kondo)

borkdude09:03:21

but sometimes it's annoying

borkdude09:03:33

the main reason it's like this has to do with advanced compilation

Kevin09:03:35

Well it's not a big issue. Just a bit annoying having to require every module purely to access the multimethods

borkdude09:03:48

@kevin.van.rooijen What cannot be solved with macros can be solved with a simple scripts and code generation outside of the normal dev workflow

Kevin09:03:18

Well, I guess my tool has some purpose then haha

Kevin09:03:53

Thanks for the pointers