clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
JB 2020-11-18T00:18:52.242400Z

Has anyone tried to have docstrings for their compiled JS packages? We're trying to ship a shadow-cljs->js package that is friendly for javascript users and trying to get docstrings to render in VSCode.

👀 1
2020-11-18T14:50:35.251300Z

Are there any ClojureScript runtimes / platforms (not sure of the common term there -- the JavaScript engine plus whatever is around it for running ClojureScript with a REPL) that enable two or more REPL connections to it simultaneously? I know this is built-in with Clojure on the JVM, but if I understand correctly that is trivial with a multi-threaded JVM. It seems like it would be much trickier with a single-threaded JavaScript runtime.

dnolen 2020-11-18T15:11:04.252Z

@andy.fingerhut ClojureScript socket REPLs support that

dnolen 2020-11-18T15:11:17.252200Z

it wasn't really that tricky

2020-11-18T15:12:40.253100Z

Are there multiple threads handling the multiple REPL interactions outside of the JavaScript runtime? Or are they just all somehow handled in some kind of event loop in a single thread?

dnolen 2020-11-18T15:13:11.253300Z

there are no multiple threads

dnolen 2020-11-18T15:13:23.253700Z

but that doesn't really make multiple connections challenging in any meaningful way

2020-11-18T18:29:09.254600Z

I'm not certain if this is the right place to ask this, so if it isn't, I appologize:

2020-11-18T18:29:32.255400Z

I'm trying to understand how reagent decides to re-render components, so if I have something like this: https://gist.github.com/LeifAndersen/037507a44a0945fba2807b0bb63f28d6

2020-11-18T18:29:48.255800Z

In particular:

(defn counter-view [db]
  [:h1 (:counter db)])

(defn home-page [db]
  [counter (select-keys db [:counter])])

2020-11-18T18:30:17.256400Z

If some part of db that is not :counter gets modified, will counter-view get updated?

2020-11-18T18:31:27.257Z

And by modified, I just mean another element changes:

(defn default-db []
  {:counter (r/atom 0)
   :label (r/atom "Count")})

2020-11-18T18:31:50.257500Z

So in this case, say label gets changed with (reset! (:label db) "foobar")

p-himik 2020-11-18T18:31:55.257600Z

#reagent is probably a better place.

2020-11-18T20:04:33.259Z

Okay, by putting println statements before returning the elements, it 'looks' like only the components with changed atoms are re-rendered.

2020-11-18T20:30:28.260500Z

Okay, another question, I find that functions like this tend to work:

(defn foo [fs]
  (fs.readdirSync ...))
Is this actually supposed to be possible, or is it some undefined behavior that just 'happens' to work?

2020-11-18T20:31:19.261400Z

Basically, fs is bound, but fs.readdirSync is not, unless the . character is special?

thheller 2020-11-18T20:43:59.262400Z

. just happened to work accidentally mostly. (.readdirSync fs ...) would be the more correct way but unlikely that the other way will be removed at this point

thheller 2020-11-18T20:45:18.263500Z

or if fs is an alias from a :require in the ns then (fs/readdirSync ...) would also work

devn 2020-11-18T21:54:46.265200Z

Hello friends, I am trying to make this https://clojurescript.org/guides/webpack work, and running into an error: "[webpack-cli] Compilation finished\nasset main.js 644 bytes [emitted] (name: main)\n\nERROR in main\nModule not found: Error: Can't resolve 'out/index.js' in '/path/to/myproject/foo'\n\nwebpack 5.5.1 compiled with 1 error in 35 ms\n",

2020-11-19T16:08:55.301800Z

I run into the same issue myself, when following the https://clojurescript.org/guides/webpack exactly. I think I resolved both issues by changing “out/main.js” in the recommended build.edn to “./out”.

2020-11-19T16:12:06.302Z

The “hello world” works at that point; I’m not clear on whether or not this is quite what was intended. It felt odd to have a main.js file inside a main.js directory.

adkelley 2020-11-25T16:26:56.426100Z

I ran into the same issue. Here is the corrected build.edn file:

{:main hello-bundler.core
 :output-to "out/index.js"
 :output-dir "out"
 :target :bundle
 :bundle-cmd {:none ["npx" "webpack" "./out/index.js" "-o" "./out" "--mode=development"]
              :default ["npx" "webpack" "./out/index.js" "-o" "./out"]}
 :closure-defines {cljs.core/*global* "window"}} ;; needed for advance

devn 2020-11-18T21:55:05.265300Z

Specifically, when I get to the `

clj -m cljs.main -co build.edn -v -c -r
step

thheller 2020-11-18T21:57:03.265500Z

thats in build.edn? like you have out/index.js somewhere when you need "./out/index.js"

thheller 2020-11-18T21:57:07.265700Z

webpack is picky about paths

devn 2020-11-18T21:58:46.265900Z

yeah, still no dice 😕

thheller 2020-11-18T21:59:26.266100Z

in the webpack config maybe? can't be that many places 🙂

devn 2020-11-18T21:59:38.266300Z

actually no! i missed a spot! you nailed it.

devn 2020-11-18T21:59:40.266500Z

thank you!

👍 1
devn 2020-11-18T22:00:51.266800Z

Now I run into: > cljs.user=> Exception in thread “Thread-6” http://java.io.FileNotFoundException: ./out/main.js (Is a directory)

devn 2020-11-18T22:01:17.267Z

I don’t suppose you have any insight there?

thheller 2020-11-18T22:01:58.267200Z

gotta be careful with those paths 🙂