This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-30
Channels
- # announcements (5)
- # babashka (5)
- # beginners (39)
- # calva (1)
- # chlorine-clover (22)
- # circleci (4)
- # clara (5)
- # clj-kondo (1)
- # cljs-dev (2)
- # cljsrn (8)
- # clojure (46)
- # clojure-canada (15)
- # clojure-norway (3)
- # clojure-uk (6)
- # clojurescript (39)
- # conjure (10)
- # core-async (9)
- # datomic (2)
- # figwheel-main (26)
- # fulcro (33)
- # ghostwheel (9)
- # jobs (6)
- # leiningen (1)
- # malli (7)
- # music (1)
- # off-topic (48)
- # re-frame (11)
- # reagent (1)
- # shadow-cljs (86)
- # spacemacs (8)
@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.
Thanks for your help!
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. https://docs.swmansion.com/react-native-reanimated/docs/worklets I just have a hard time understanding how that looks in clojurescript. Anyone seen this before, or used something similar? 🙂
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.
shadow.user>
cljs.user>
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.
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 https://github.com/anmonteiro/lumo - 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 https://planck-repl.org/
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
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
@shakof91 this might do it (needs to be in .cljc file that you require like
(:require-macros [my-project.macros :as macro])
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);
}“]@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!
@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
[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 sureAlright good. I am not sure about these things. I thought maybe there was some convention surrounding these things 😄
Yes, I got it working. I look forward to re-animated v2. Even though I have gotten a lot done in v1. 😄
Thanks mate!
If a cljsjs package uses foreign-libs, that means it won't go through the Closure compiler correct?
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!