Fork me on GitHub
Eric Scott00:05:23

@lilactown, @noisesmith and @mfikes. The problem I describe above happened when I had separate clj and cljs files. It went away when I combined them into a single cljc file with lots of ugly reader conditionals in it.

Eric Scott00:05:28

Thanks for your help!

Shako Farhad00:05:56

Anyone know how to set JavaScript directives in ClojureScript? In the below docs it is shown to be used for some worklet API in re-animated v2. I just have a hard time understanding how that looks in clojurescript. Anyone seen this before, or used something similar? 🙂


Hi! What is directive? Is it this string in the source file like 'use strict' ?

Shako Farhad09:05:34

I believe so. I am not sure either. I am not really a javascript developer. But in the link it gives some examples of how it is written in javascript. @dnolen, hello David Nolen sir. Do you know how this can be accessed through clojurescript, sir?


@shakof91 that is a very good question; I really tried to find a way to set this but no luck… maybe someone else can chime in…


Is there anyone who uses emacs (Doom) with Clojurescript and Shadow Cljs? I'm having trouble connecting to an already started Shadow cltjs server. When I did M-x cider-connect there are a few options, I'm not sure which to choose. I did get a REPL session, but the namespace is still cljs.user> not the expected my program's namespace. For example, there are two options related to shadow: shadow and shadow-select. With shadow selected, there are also options for builds: :app , :cards, :test, e2e, browser-repl, node-repl With :app selected, this what I got:

;; Connected to nREPL server - 
;; CIDER 0.25.0snapshot, nREPL 0.7.0
;; Clojure 1.10.1, Java 11.0.2
;;     Docs: (doc function-name)
;;           (find-doc part-of-name)
;;   Source: (source function-name)
;;  Javadoc: (javadoc java-object-or-class)
;;     Exit: <C-c C-q>
;;  Results: Stored in vars *1, *2, *3, an exception in *e;
;; ClojureScript REPL type: shadow
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :app) (shadow/nrepl-select :app))
WARNING: CIDER requires cider-nrepl to be fully functional. Some features will not be available without it!
         More  quit, type: :cljs/quit
;; => [:selected :app]WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.5.0 and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.
Now, I expect to go to my program's namesapce to be able to do evaluation in my program, the namespace of mine is defined in
(ns app.hello
  (:require [reagent.core :as r]))
Using C-c M-n M-n (`cider-set-ns`) doesn't work.


I wonder what's the significance of my selected options: shadow vs. `shadow-select` :app , `:cards`, `:test`, `e2e`, `browser-repl`, `node-repl` I wonder if my selections are correct.


Eventually, I found a work-around: Instead of cider-connect to the already started server, I can kill the started server and start from my emacs clojurescript file's buffer cider-jack-in for cljs, then with the same selections (`shadow`, :app) I was able to start the server and got a working repl that I can change the namespace to my program's. I can evaluate an expression in my source code buffer. I wish you can give me some pointers on how I can do better. Thanks in advance!


When you jack-in, cider injects all the relevant dependencies and middleware for you (which is what the REPL was complaining about). If you connect, you have to provide them yourself. Check the giant string that appears on the mini buffer when you jack in.


I see that's why it's a lot harder to get connect working right.


It seems that the reple to select should be shadow not shadow-select? Why?


Hi, does anyone know a decent WYSIWYG editor that works well with ClojureScript? I tried to use Slate, but it fails with some very weird error when I try to edit content. Seems like closure compiler doesn't play well with that. Thanks in advance!


which library should I use if I want to have a ClojureScript interpreter in ClojureScript.


I've enjoyed using lumo in the past - it runs on node


there's another one that runs via platform specific system js interpreters (so instead of the portability of npm, you get the platform integration of your OS desktop environment) - planck


both self host, you need to decide whether node vs. OS native has more advantages for your use case


there might be something more recent / better maintained out there though


@shakof91 it's not possible to properly emit directives w/ ClojureScript


there's a implementation detail thing called js* which you can use, look at how the js-comment macro works


js* usage is strongly discouraged, but your only option at the moment - a enhancement ticket for a js-directive macro is also welcome


@dnolen thanks for the pointer


@shakof91 this might do it (needs to be in .cljc file that you require like

(:require-macros [my-project.macros :as macro])


(defmacro js-directive
  (list 'js* (str "'" directive "'")))


I haven’t tested with re-animated, but it seems to output the code when you print the function with (set! print-fn-bodies true)


(defn test-directive [x]
  (macro/js-directive "worklet")
  (+ 1 x))
rf.shared.main=> #object[rf$shared$main$test_directive “function rf$shared$main$test_directive(x){ ‘worklet’; return ((1) + x); }“]

Shako Farhad17:05:56

@dnolen, thank you for your answer! How or where do I make a ticket about this? I have never done such a thing. ^^ @raspasov thanks! That looks interesting. Hopefully it works with re-animated v2. The output surely suggests that it will work! I will save it. Thanks!

Shako Farhad18:05:55

@raspasov I have never created cljc files before. My folder structure is like this: app_name -> src -> cljs -> app_name -> cljs files Do I make a cljc folder and have a macros.cljc file with this content?

(ns app-name.macros)

(defmacro js-directive
          (list 'js* (str "'" directive "'")))
I am getting all kinds of warnings from intellij. SO probably not like this 😄 Edit: NVM, it was correct, but I needed to create the cljc folder within the cljs folder, or just have the macros.cljc in the cljs folder. It wasn't found when it was outside unfortunatly. Probably I have my filepaths and project structure setup wrong from the get go. Or I just need to rename the cljs folder to src or something. Not sure


Next to your cljs files should be fine, it doesn’t have to be in its own folder


the file needs to be named my-file.cljc


not my-file.cljs

Shako Farhad18:05:52

Alright good. I am not sure about these things. I thought maybe there was some convention surrounding these things 😄


let me know if it works

Shako Farhad18:05:19

Yes, I got it working. I look forward to re-animated v2. Even though I have gotten a lot done in v1. 😄


awesome, glad it works


If a cljsjs package uses foreign-libs, that means it won't go through the Closure compiler correct?

Shako Farhad02:05:21

I am not quite sure about the :foreign-libs. If you have something like :infer-externs then maybe you are good, but usually you need to provide externs or use the foreign library with string names since the Closure compiler respects strings and doesnt munge them. But I am not sure about this. Hope it helps though!


:foreign-libs are not processed in any way yes. they are just prepended to the final compilation output.