Fork me on GitHub
#clojurescript
<
2018-10-31
>
deliciousowl08:10:45

How useable is Clojurescript on nodejs? last time I checked (long time ago), it was still experimental

rarous08:10:26

#lumo is viable node.js citizen

deliciousowl08:10:14

So if I want to make a simple cross-platform SaSS, i wouldnt get too many headaches? :) I'm kind of disillusioned with other languages outside of clj at the moment

cjohansen09:10:59

I’m using cljs on node as we speak, pretty happy with it. did have some compilation issues with cljsjs packages, but the development experience is ace

cjohansen09:10:17

I use figwheel and CIDER 👌

henrik09:10:37

I use #shadow-cljs. No problems running on Node, including using external (Node) libs.

orestis10:10:36

Do you get a live REPL experience with production systems with node? Similar to how you can open a socket server for Clojure and start redefining things on the fly?

valtteri11:10:20

Lumo comes with OOB socket-repl. Maybe it could be used? Assuming you’d run your production build with Lumo.

orestis12:10:28

That wouldn’t fly 🙂

thheller11:10:53

no. you could maybe create something similar with self-hosted CLJS but nothing like that exists as far as I'm aware

manuel11:10:18

hi guys, is it possible to build (via lein cljsbuild or a similar tool) a ClojureScript app with the output versioned? Kind of like Hugo does when you run it with serve:

<link rel="stylesheet" href="//localhost:1313/scss/style.min.aab96fff16f8025de8731d75970e04e0e4f02aaf4760749519be55d86efe0a6d.css">

mfikes12:10:15

@manuel There is a new feature on master, which I'm not familiar with, but sounds similar to what you describe: https://dev.clojure.org/jira/browse/CLJS-2903 Perhaps it is worth trying.

manuel12:10:10

thank you!

Logan Powell12:10:51

Why is `(clj->js <map with string keys>) turning just one of the string keys into a keyword? It's weird... only happens for strings with no spaces 😞

mfikes12:10:16

@loganpowell All of the keys are actually strings. Do js-keys on your result and you will see the truth.

mfikes12:10:12

You are simply seeing an artifact of printing, where it can't display keys with spaces as keywords

Logan Powell12:10:15

ah, ok, but when I js/console.log, I still get the keywords in there

mfikes12:10:17

Consider that #js {"a b" 1, :c 3} gets compiled to {"a b": 1, "c": 3}

Logan Powell12:10:47

ok, so I shouldn't worry about it?

Logan Powell12:10:57

this is for json interop

mfikes12:10:59

Perhaps your console log infrastructure is doing a similar thing to what ClojureScript does when using prn

Logan Powell12:10:26

ok, thank you!

Logan Powell12:10:07

The thing is, I will be returning the result to the user and if the keywords are sent over as anything but strings, the user may not know that they're not supposed to be strings

Logan Powell12:10:45

Sorry for the drag. I'll see what I can do with this

mfikes13:10:47

I’m not following the above, but the JSON.stringify result seems to illustrate how all the keys are rendered as strings in JSON.

mfikes13:10:21

From ClojureScript’s perspective, it can read and write certain keys as ClojureScript keywords in the JavaScript tagged literal format

cljs.user=> #js {:a 1 "b" 2 "c d" 3 "e/f" 4}
#js {:a 1, :b 2, "c d" 3, "e/f" 4}

Logan Powell13:10:21

I'm probably over-reacting... I'm creating a library that exposes a JavaScript API and arguments are translated to and from JS/CLJS. I am just worried that - since the JS args I'll be returning will have inconsistent key formats - that the user might get confused

Logan Powell13:10:05

I'm playing around with the returned object in a browser console and accessing either format works with the ["access an object key"] syntax, but of course - since there are spaces in those keys that are getting returned as strings with spaces - the user can't use the .accessor notation that is allowed for the ones that aren't

mfikes13:10:06

Right. The same thing would occur if your key happened to make it an invalid JavaScript identifier, right? As in "a-b"

Logan Powell13:10:50

you mean that the user would have to use object["a-b"]?

Logan Powell13:10:31

TBH, I abandoned JS for Clojure(Script) because I hated it

mfikes13:10:50

I’m not a JavaScript programmer, but I assume so. Otherwise object.a-b would essentially mean object.a - b

Logan Powell13:10:54

I just want to ensure that - if I return some args that happen to have nothing but single word keys - that the user won't set up any wrappers/functions that use the dot notation

mfikes13:10:56

I bet you need to avoid all of the strings in (js-keys js-reserved)

Logan Powell13:10:52

Perhaps I should just send it over js/JSON.stringifyed...

Logan Powell13:10:48

but it's a library, and the purpose of this particular response is to provide example arguments to the function

Logan Powell13:10:06

at least I know I'm not going crazy, so thank you very much for that 😄 I suppose I'll just have to make do

Logan Powell13:10:57

I can feel the yak shavers in my hand

lilactown15:10:55

I’m using extend-protocol to implement a protocol for a bunch of types

lilactown15:10:12

one of the JS types I need to apply it to is a Symbol

lilactown15:10:21

is there any docs on how to do that?

lilactown15:10:43

I’d like to avoid a catch-all object implementation if possiblee

thheller15:10:16

(extend-type js/Symbol ...) should do it

thheller15:10:00

@loganpowell {foo: "bar"} is identical to {"foo":"bar"} as far as JS is concerned. it just happens to print JS objects without quotes (when it can). no such thing as keywords in JS

lilactown15:10:15

ah, for some reason I recalled that extending js/<Type> was a no-no

thheller15:10:55

it can be tricky in some cases but Symbol should be fine

lilactown15:10:54

:thinking_face: it seems to break

lilactown15:10:26

I’m using it to try and detect React’s Fragment element, which is a symbol under the hood. extending the type looks like it causes the internal check to fail in React

lilactown15:10:40

React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object

lilactown15:10:12

logging it shows that the symbol ends up boxed, which is probably why

lilactown15:10:35

goog.typeOf(Symbol()) is “symbol” but it looks like I can’t use that in extend-protocol

Sasha18:10:10

does anybody know how to translate it into clojurescript?

const img = new Image()
img.onload = () =>
			/somecode/

Dustin Getz18:10:16

From a cljc file I want to use clojure.core.match/match from CLJ and /match* from CLJS, what is the best way to do this? Hard to abstract over because "can't take value of a macro" and match is variable arity

justinlee19:10:24

@alexandra.lysenko something like (let [img (new js/Image)] (set! (.-onload img (fn [] ...))))

cjohansen19:10:16

@dustingetz create a small wrapper-function in reader conditionals

mfikes20:10:10

ClojureScript master is currently in good shape for release, with no more changes planned. If we can't find any bugs in it, it may be the one that ships.

🎉 12
miikka08:11:40

Giving it a go. Everything's compiling fine but I'm getting "Maximum call stack exceeded" errors from specter's use of subvec. Those didn't happen in 1.10.339.

miikka09:11:20

Okay, it's a bug in Specter and it has been fixed in Specter's master.

Roman Liutikov12:11:07

@U04VDQDDY Just tried it on my project, looks like some project namespaces are missing on classpath. Doesn’t happen with 1.10.339 :thinking_face:

mfikes12:11:01

@U0FR82FU1 Would need a minimal repro; ClojureScript doesn't form the classpath but perhaps something regressed with consuming it?

Roman Liutikov12:11:36

yeah, unfortunately it’s a closed source. let me see, maybe I can share something in DM

Roman Liutikov13:11:31

@U04VDQDDY ok, that was NPM dep and the problem was with changed default value :npm-deps compiler option 😐

mfikes13:11:45

Ahh, cool.

Roman Liutikov13:11:33

In our case we have NPM deps declared in package.json + :npm-deps true which was default

dnolen23:10:41

Yes please