Fork me on GitHub
#clojurescript
<
2018-04-30
>
henrik09:04:10

I’m trying to wrap my head around the new build system. So, I want to achieve automatic recompilation of some Node targeted stuff. I stuck this stuff in a file called compile.sh:

#!/bin/sh
clj -m cljs.main --target node --output-to resources/server/main.js -c landing-page.core
node resources/server/main.js
Then I figured, I just need to re-run it on file changes in src. I reached for nodemon for that:
nodemon -e clj,cljs --watch src --exec "./compile.sh"
While compile.sh works well on it’s on, it throws SIGSEGV (0xb) at pc=0x00000001110884d4, pid=4447, tid=0x0000000000000307 when run via nodemon. So, what’s the correct way to achieve this goal?

mfikes12:04:56

@henrik FWIW, cljs.main has a --watch option. See https://clojurescript.org/reference/repl-and-main

👍 8
henrik12:04:52

Thanks @mfikes, works well

mfikes12:04:47

@henrik You aren't using it this way, but there is this defect to be on the lookout for https://dev.clojure.org/jira/browse/CLJS-2684

👍 4
leobm13:04:00

I'm searching a clojurescript library to modify a hiccup syntax tree instead html markup. who know any library for this?

leobm13:04:16

with a simple selector api...

gnl13:04:44

(unless I misunderstood the question)

leobm13:04:50

@clojurians.net thanks, it looks interesting

gnl13:04:56

I've used it on a number of projects and consider it absolutely essential for any even slightly complex data transformation. "Clojure's missing piece" is a fairly accurate description.

leobm13:04:38

@clojurians.net easier than what I tried with clojure.walk

gnl13:04:13

It'll save you a ton of code, bugs and trouble when dealing with any nested structure.

gnl13:04:21

Okay, enough selling. 🙂

Casey14:04:36

i'm using lein and lein-cljsbuild.. the auto functionality works really well... but is there a way to run a function after every re-build?

Casey14:04:40

something like the watch-fn param to cljs.build.api/watch

pesterhazy14:04:00

:notify-command maybe?

soulflyer14:04:31

I'm playing with zippers, ie clojure.zip in clojurescript and the basics seem to work, but this example which creates a zipper for a mixed structure of maps and vecs fails for me: https://clojuredocs.org/clojure.zip/zipper#example-5845617fe4b0782b632278d3 It works ok if I cut and paste it into the clojure repl, but fails with

#object[TypeError TypeError: Cannot read property 'MapEntry' of undefined]
in the clojurescript repl. Is this expected?

Casey14:04:43

notify-command execs a shell program 😕

pesterhazy14:04:56

@soulflyer sounds like an issue with the latest ClojureScript version

pesterhazy14:04:05

(which introduced changes related to MapEntry)

pesterhazy14:04:28

or maybe it's the opposite, that you need a more recent version of ClojureScript

soulflyer14:04:28

I'm on 1.10.238, which seems to be the latest

pesterhazy14:04:37

@soulflyer I'm seeing the same issue with lumo 1.7.0... not sure what's going on there

tmulvaney14:04:30

clojure.lang isn't a thing in CLJS so its probably complaining about MapEntry not being a field of clojure.lang

tmulvaney14:04:07

You'll want to use (instance? MapEntry x) instead or even (map-entry? x)

👍 4
pesterhazy14:04:21

oohh. totally missed that

soulflyer14:04:45

this line here?

(if (isa? (type p) clojure.lang.MapEntry)

tmulvaney14:04:40

Yeah just make it MapEntry rather than clojure.lang.MapEntry @soulflyer

soulflyer14:04:14

thanks that did it @tmulvaney

pesterhazy14:04:39

isa? is incorrect as well isn't it?

tmulvaney14:04:54

yeah isa? is fine.

pesterhazy14:04:05

should be instance?

tmulvaney14:04:44

Weird that you don't actually get a undefined variable error for clojure.lang.MapEntry though.

pesterhazy14:04:05

I think the "undeclared Var" warnings don't show up for when you're using the dot syntax, like: (prn a.b.c)

stathissideris20:04:48

say I want to work on a cljs library that uses react. I have to pick between om, reagent, rum etc, there is no way to do it generically, right?

mfikes20:04:32

Hmm. Presumably you could just interact with React using plain JavaScript interop, in a way that can then be reused by apps using Om, Reagent, re-frame, etc.

stathissideris21:04:04

I’m not sure how I would approach this, but If you think it might work, I think I’ll investigate further

stathissideris21:04:55

Can you think of any libraries with a similar goal out there?

ajs10:05:17

If you'd like to see a bare-bones approach to React directly from clojurescript, check out @weavejester Brutha library for tips

chadhs21:04:08

this is hopefully an easy question, but what’s the best approach to including a value in a div tag? for example within a let if have this

[:div.cond-display
      [:i.wi.wi-owm-800]]
but rather than hardcoding that 800 i want that to be determined by the value of $foo

joelsanchez21:04:13

your question says one thing but your code says another: you ask "how to include a value" but your code says "I want to have a dynamic class on this element", to which I reply:

(let [your-value 800]
  [:div.cond-display
   [:i.wi {:class (str "wi-owm-" your-value)}]])

joelsanchez21:04:37

if you meant the other thing:

(let [your-value 800]
  [:div.cond-display
   [:i.wi.wi-owm your-value]])

chadhs21:04:55

@joelsanchez thank you, i didn’t know how to formulate my Q 🙂 but succeeded in communicating the gist of it

chadhs21:04:13

i meant what you said first 👍:skin-tone-2:

joelsanchez21:04:21

most hiccup implementations (all?) will happily merge inline classes with :class, so that will work, we do it all the time

chadhs21:04:28

dynamic class to display a weather icon actually

joelsanchez21:04:40

yeah, common problem 🙂

chadhs21:04:05

that’s shorthand to make it easier yes: so the long form that you demo’d is what i want. thank you!

👍 4
ajs10:05:17

If you'd like to see a bare-bones approach to React directly from clojurescript, check out @weavejester Brutha library for tips