Fork me on GitHub
#clojurescript
<
2018-03-03
>
dnolen05:03:32

@leontalbot server side it more or less just works

dnolen05:03:27

all the challenges are client side where we want stuff to pass through Closure Compiler

miikka07:03:27

FYI: I'm planning to create a new release of Doo. If somebody has some work pending that they'd really like to get in, let me know. https://github.com/bensu/doo/issues/169

jrychter11:03:50

Hmm. Looking through all the configuration libraries out there (including one I've written myself) and it seems there is no solution for compile-time configuration. I'd like to implement static resource versioning (e.g. store CSS/JS resources under a directory that contains say the latest git short ref in the name: "/static-522af908/css/styles.css"). This is proving rather difficult, as I use server-side rendering: I'd like to know the ref at compile time for my cljc code.

jrychter11:03:47

It's something lein-git-version solves for server-side code (generates an EDN file with git information), but this isn't usable at compile-time.

andrea.crotti12:03:06

I was trying a cljsjs library (this one to be precise https://clojars.org/cljsjs/react-select)

andrea.crotti12:03:28

and in theory I only have to add it to dependencies and it should work in my Clojurescript REPL right?

andrea.crotti12:03:40

I get this error however

cljs.user> (require '[cljsjs.react-select])
#object[Error Error: goog.require could not find: cljsjs.react_select]
   figwheel$client$file_reloading$figwheel_require (jar:file:/home/andrea/.m2/repository/figwheel/figwheel/0.5.14/figwheel-0.5.14.jar!/figwheel/client/file_reloading.cljs:179:30)
nil

andrea.crotti12:03:01

I tried with the cljsjs d3 and that one works fine, so I don't think it's my project

jrychter12:03:02

I've never seen a working ClojureScript REPL, but in principle, you add to dependencies, require, and you should be fine. I've actually just added react-select to my project.

andrea.crotti12:03:58

mm yeah no it doesn't work for me strangely

andrea.crotti12:03:33

so this works for you @jrychter?

(ns your.namespace
  (:require [cljsjs.react-select]))

jrychter12:03:37

I have:

(ns ui.selector
  (:require [cljsjs.react-select]
            [rum.core :as rum]))

jrychter12:03:08

and [cljsjs/react-select "1.2.1-1"] in project.clj

Empperi12:03:09

have you restarted your repl and done a full clean?

Empperi12:03:16

it should work pretty well with figwheel

andrea.crotti12:03:29

mm wait wat now it works

jrychter12:03:50

I also tried to use it via :npm-deps, but that, like a working ClojureScript REPL and code splitting across modules, is another unicorn that I'm unable to actually touch.

Empperi12:03:54

and actually I think cljs repl works great with figwheel, you should just control it via user.clj (which is how one should do development envs anyway in my opinion)

andrea.crotti12:03:54

and yes I did a restart (but maybe not a clean)

andrea.crotti12:03:05

don't really know what I was doing wrong now it magically works 😕

Empperi12:03:28

guessing you were missing a clean and now when you recompiled it ended up added to the appropriate paths

andrea.crotti12:03:02

yes well I added D3 after this library and D3 worked before this one

andrea.crotti12:03:53

now I just have to understand how to use it from Clojurescript though, there is no autocompletion for these libraries right?

Empperi12:03:17

yeah, you read it's js documentation and adapt

andrea.crotti12:03:23

do I just have to look at the JS docs and translate accordingly? Any examples someone have handy?

jrychter12:03:40

I do (js/React.createElement js/Select (clj->js options))

andrea.crotti12:03:08

ah cool, I also have to fit it into Re-frame somehow

Empperi12:03:57

I would guess that library has callbacks

Empperi12:03:07

just bind those and do re-frame dispatches

jrychter12:03:24

I use it with Rum. Oh, you will need to write functions that convert the (strange) format of the data values that they use to ClojureScript and back. Options are JavaScript objects with value and label properties.

andrea.crotti12:03:44

yeah I was trying

(js/React.createElement
 js/Select
 (clj->js [{:value 1, :label 2}
           {:value 2, :label 3}]))

andrea.crotti12:03:47

but it doesn't like it

jrychter12:03:30

No, that will work, but please look at the docs. Choices are passed as the :options argument.

Jon15:03:19

trying to get it merged..

dnolen16:03:38

@jiyinyiyong the Quick Start is going to change dramatically for the better (it will be very, very short), we’re not going to mention other tools there, it will be clj based

dnolen16:03:10

we can mention it elsewhere though if shadow-cljs is missing

Chris Bidler17:03:55

@andrea.crotti If you’re still looking at getting d3 and cljs playing well together, perhaps you will find https://github.com/gadfly361/rid3 to be useful