Fork me on GitHub
#clojurescript
<
2020-11-18
>
JB00:11:52

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.

šŸ‘€ 3
andy.fingerhut14:11:35

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.

dnolen15:11:04

@andy.fingerhut ClojureScript socket REPLs support that

dnolen15:11:17

it wasn't really that tricky

andy.fingerhut15:11:40

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?

dnolen15:11:11

there are no multiple threads

dnolen15:11:23

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

leif18:11:09

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

p-himik18:11:55

#reagent is probably a better place.

leif18:11:32

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

leif18:11:48

In particular:

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

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

leif18:11:17

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

leif18:11:27

And by modified, I just mean another element changes:

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

leif18:11:50

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

leif20:11:33

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

leif20:11:28

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?

leif20:11:19

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

thheller20:11:59

. 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

thheller20:11:18

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

devn21:11:46

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",

devn21:11:05

Specifically, when I get to the `

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

thheller21:11:03

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

thheller21:11:07

webpack is picky about paths

devn21:11:46

yeah, still no dice šŸ˜•

thheller21:11:26

in the webpack config maybe? can't be that many places šŸ™‚

devn21:11:38

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

devn21:11:40

thank you!

šŸ‘ 3
devn22:11:51

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

devn22:11:17

I donā€™t suppose you have any insight there?

thheller22:11:58

gotta be careful with those paths šŸ™‚

galdre16:11:55

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ā€.

galdre16:11:06

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.

adkelley16:11:56

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