Fork me on GitHub

Hey! I’m a Clojurist who is about to dive into Clojurescript in a bit of a weird way, and I just realized I could probably save a ton of time by asking questions here rather than googling like mad for something approaching my use case.


The context is that I am collaborating with someone to build an Asciidoctor extension that will allow me (and others) to create diagrams like this:


I have that working great in Clojure, and now I need to port it to ClojureScript so that it can work in the node environment that hosts Asciidoctor extensions. So my basic question is, is there an example somewhere of using ClojureScript to create a JavaScript function to be called by other JS code? I have only seen examples going the other direction.


I have to say I’m delighted at how much of the Clojure language I’ve been able to provide access to through a safe EDN parser which requires no run-time compilation in an evening and afternoon! If anyone is curious, the Clojure implementation I am going to try to port to ClojureScript is here:


Ah! This looks promising! But I would definitely welcome more tips, thoughts and pointers:


I skimmed that article and it looks pretty good! I like all of lambdaisland's stuff that I've read. For tooling, I'd recommend you check out the shadow-cljs compiler instead of vanilla Leiningen. It's much nicer for JS interop, IMO. Haven't used this feature but the :npm-module target seems particularly suited to your use case:


shadow-cljs also lets you manage your JS deps with a regular ol' package.json, so if there's specific stuff from the Node ecoystem you want to integrate with/expose, it makes that really easy. Check out the #shadow-cljs room, Thomas (the author) hangs out there and typically responds quickly. :)


Ooh, thank you! I got the basic “hello world” example working with Leiningen (and that is the world I am much more familiar with) and quickly stepped on a rake that someone else had as well. I have heard several people rave about shadow-cljs, and this link makes it look quite compelling. I will change gears and try that!


I’ve done something pretty crazy over the weekend. I got working cljs REPL inside Blender: Note that Blender does not support javascript. Blender embeds Python engine and exposes its API for (interactive) python scripting. I ended up embedding V8 into Python and implementing bare minimum of DOM apis to get shadow-cljs :browser target working, including repl interaction. It is highly experimental at this point, but in general with this approach we can bring cljs anywhere where V8 can be embedded…

💯 28
👀 12
aw_yeah 8

If i have a symbol like (symbol "my-ns" "foobar"), how can I then resolve the value?


in CLJS you cannot


in development you can in theory but not after :advanced