Fork me on GitHub

Is there an easy way to convert a javascript regex pattern to a pattern that will work in clojurescript source? Or do I just have to escape characters individually?

Thomas Meier03:12:01

keep running in circles with interop trying to turn this: data = event.dataTransfer.getData("text") into this (event is %) (let [data (. % .-dataTransfer -getData "text")]) and various other combinations with different errors each time


(let [data (.getData (.-dataTransfer %) "text")] ...)


I think you want .. if you want to "thread" things: (.. % -dataTransfer (getData "text")) off the top of my head.


Q re: Windows/WSL -- is anyone doing cljs development on Windows with the ClojureScript processes running on WSL2? When I run this command on WSL2, I get a Google Chrome instance running, displaying the cljs welcome page, but I never get an actual REPL prompt:

clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"}}}' -M -m cljs.main -r
If I then close the browser, the version and REPL prompt appears but of course errors out due to losing the connection to the browser:
ClojureScript 1.11.4
cljs.user=> Execution error (SocketException) at (
Broken pipe

Full report at:


That EDN file starts with

 "Execution error (SocketException) at (\nBroken pipe\n",
  :clojure.error/line 420,
  :clojure.error/cause "Broken pipe",
  :clojure.error/source "",
  :clojure.error/phase :execution},
  [{:type clojure.lang.ExceptionInfo,
    :message "Unexpected error during REPL initialization",
    :data {:cljs.repl/error :init-failed},
    :at [cljs.repl$repl_STAR_ invokeStatic "repl.cljc" 1220]}
    :message "Broken pipe",
    [ implWrite "" 420]}],
  [[ implWrite "" 420]
   [ write "" 440]
   [$2 write "" 826]
   [$SocketOutputStream write "" 1035]
   [jdk.internal.reflect.GeneratedMethodAccessor10 invoke nil -1]
   [java.lang.reflect.Method invoke "" 568]
   [clojure.lang.Reflector invokeMatchingMethod "" 167]
   [clojure.lang.Reflector invokeInstanceMethod "" 102]
   [cljs.repl.server$send_and_close invokeStatic "server.clj" 168]

Nechemya Ungar07:12:29

Maybe an idea to sidestep the problem could be to install chrome on the wsl2 itself? :thinking_face:


i've been doing dev on wsl2 for quite awhile now, i use shadow-cljs though and i'm able to connect to a repl just fine using any browser on windows side


i'll typically connect to a clj repl first then use cider-connect-sibling-cljs


"Start the REPL using the pattern described above, but with the browser as the evaluation environment.

(require '[cljs.repl :as repl])
(require '[cljs.repl.browser :as browser])  ;; require the browser implementation of IJavaScriptEnv
(def env (browser/repl-env)) ;; create a new environment
(repl/repl env) ;; start the REPL
Once the REPL has started, you will see the message "Starting server on port 9000". At this point, open the html page by going to http://localhost:9000 to complete the connection. Once the page is open and the connection is made, the REPL prompt will be displayed." [Edit] Um, so what does it mean "but with the browser as the evaluation environment"? I'm afraid I had assumed this was the process to create a browser cljs repl from say clj (this is what I thought cljs meant in the namespace), but this may be code to create ANOTHER browser repl from a browser repl. Before seeing Sean's post I was going to take a couple of weeks to read some source code behind this problem after having queried pez on #calva. I still have to take the time to read it, but I wanted to put my two cents in before then.


Forgot to press "shift enter" again. I will complete what I was going to write shortly. The above is from . It will fail at (repl/repl env) in WSL2 because of a socket not being released prior to an attempt to make a connection (I think). I am going to collect screenshots. I believe it is a Linux thing in general and not a WSL2 thing in particular, because says: "If you are running Linux and the REPL does not start, try disabling browser auto-launch and opening `http://localhost:9000` manually:" The article does not say WHY some Linux setups won't work properly, but I believe it is the same issue.


The purpose of this next screenshot is to show the browser window opened, although I have just said that already. I hesitate highlight the ?rel=1640775390178 part, because it is undoubtedly not relevant, but does anyone know what it means?


"Fire up the Clojurescript Quick Browser REPL" in Calva and the same thing happens. The browser repl opens in a browser window, but it is inaccessible to the editor. Incidentally, I have until yesterday thought the browser REPL was a process or sub-process within the browser instance. It may still be, but something I read yesterday talked in terms of the browser being a separate process serving a/the browser REPL. Anyway, Calva presents us with the following screen. It says "Connecting cljs repl:", but it never does; it gets stuck here just like repl/repl got stuck in the clj repl above. I understand a cljs prompt is meant to appear after this, but I have never seen one on my system.


When I close the browser window, Calva prints out additional lines 22-27: A SocketException; Write failed because of a broken pipe. Calva then evaluates core.cljs (in package hello_world), but in nrepl, not the browser repl that we want.


I will refer to this screenshot next, as the Slack appears to always present the graphics at the end of each comment in the thread.


The above nREPL log does not record an error (though nrepl does reply with a repl type of clj when I would expect cljs), but cider.piggieback/cljs-repl returns the following error when repeated in the editor (because, I presume the http server is holding onto a broken pipe making its socket unavailable):     Execution error (BindException) at (     Address already in use (Bind failed)


That's me for the moment. Good luck.


This was the magic piece I had missed: > "If you are running Linux and the REPL does not start, try disabling browser auto-launch and opening http://localhost:9000 manually:" Thanks @brendnz! If I start the basic REPL with --repl-opts '{:launch-browser false}' and then visit http://localhost:9000 in either Google Chrome on Linux or Edge on Windows, it all works as expected.

Mutasem Hidmi13:12:38

Hi guys. I am new to Clojure and clojurescript. What is the best way to use npm packages in clojurescript? I was searching for how to do a wrapper around an npm package, but I didn't find a very useful resource for that. I found many packages under the cljsjs link, but I also want to be able to build my own wrapper. I appreciate your help.


You can try using shadow-cljs. You can then require most of the npm libraries you have installed in your project doing something like (:require ["react" :as react])

Mutasem Hidmi13:12:52

Thanks Arthur. Does that have a downside on the performance?

Jon Boone14:12:53

What is the baseline against which you want to compare using shadow-cljs?

☝️ 1

What do you guys recommend to use for clojure/script time with time zone support? I can see juxt tick as being a good candidate, any other recommendations?



👆 1

tick is built on it, but its less of a “innovative” api

Ben Sless17:12:54

If I want to extend a protocol to the types for which the predicates map?, set? and sequential? are true, which types would they be in cljs?


According to a cljs REPL, map? is satisfies? IMap, set? is ISet, and sequential? is ISequential. (based on calling source on each of these)


(so you'll need to extend those protocols to whatever your new thing is)

Ben Sless17:12:57

It's for a walking protocol, so I won't need to extend them, but every type which implements them 😞


I suspected as much. Sorry.

Ben Sless17:12:29

Can you extend protocols to protocols on cljs or is it the same problem as in clj?


No idea. My knowledge of cljs and its differences from clj is minimal.

👍 1
Ben Sless18:12:43

Lol, seems like Ethan's solution is the way to go then.

Lone Ranger22:12:02

This is killing me:

Use of undeclared Var cljs.core.async.interop/p->c
Anybody seen this before?

Lone Ranger22:12:25

to answer my own question, <p! needs to be in :require not :require-macros