Fork me on GitHub

klipse really is something special - it’s fun to play around with these examples and eg set the fizzbuzz one to go to 20 instead of 10, etc 🙂


i’ve been continuing to use a lot for perf investigations, will eventually write a blogpost 🙂 gained a 20% perf improvement in my app today by optimizing a particular function [called in a tight loop] using klipse interactively +


(there’s probably a more elegant solution that still causes the same perf benefit, but is the diff fwiw)


hello folks - having a small issue with reduce-kv here


does not seem to like lazy sequences


(reduce-kv #(into %1 {%2 %3}) {} i-am-a-lazy-sequence) throws No protocol method IKVReduce.-kv-reduce defined for type cljs.core/LazySeq:


@michael.heuberger Right, reduce-kv takes an associative collection, not a lazy sequence.

Alex Miller (Clojure team)02:10:36

I think it works with a seq of entries in Clojure (not at a computer to check though)


@csm didn’t know about that, will try it. this is an electron app so I’ll see how it fits, tks


Hello guys, i’m trying to port a simple lib from Clojure to ClojureScript and I’m stuck with this question: how do i replace float?? thanks!


ok, i did my homework and here is my solution, in javascript:

function isFloat(n){
    return Number(n) === n && n % 1 !== 0;
that i translated to:
(defn float? [n]
  (and (== (js/Number n) n)
       (not (== (mod n 1) 0))))
do you think this can work? should i use identical? instead of ==?


strictly speaking all numbers in js are floats


Hi guys, I’m giving a shot in cljs, and I thought I could do this from anywhere: (require '[cljs.nodejs :as node]) but it didnt work. I’m using planck as a repl


I thought cljs.nodejs could be required


@mping The inability to require cljs.nodejs in Planck is because Planck is based on JavaScriptCore, not Node. (If you were to try to evaluate (js* "require”), which that namespace does, the evaluation will fail because JavaScriptCore does not define this function; it is specific to Node.) What are you trying to do?


@mfikes I’m trying to load a node lib


I’m doing a electron app with cljs and the requires are not working so I figure I go and try on a repl


@mping You mean a lib from NPM?


I’m guessing I’m missing some understanding of how this works


@mping ClojureScript doesn’t directly support NPM dependencies. It does support CommonJS FWIW: it does this via Google Closure. Planck doesn’t use Google Closure. But you could try to treat the lib as a foreign lib and simply use Node’s require, as you are doing (I don’t have any experience with that). But, to do that, you need to be in a Node JavaScript environment.


in my app I tried to do that but it didnt work; I’ based on this code:


I tried to hook the main.clj to require a node lib but I’m missing something in the process


but I’m quite new to this


@mping I have no experience with targeting Electron with ClojureScript. (All I can say is: what you are trying won't work in Planck.)


thanks, at least I wont try it anymore 😄


@mping: have a look at This is my (slightly outdated) template for creating a electron project which uses ClojureScript.

Adam Munoz12:10:49

Hello I have a js file (library.js) compatible with closure. I'm using figwheel which uses cljsbuild and in project.clj I have included the :libs option with the path to my library.js However it is completely being ignored when I build or launch the repl. Even if I intentionally write a wrong path to library.js I don't get any errors. So I'm suspecting that I'm not putting the :libs file in the right place

Adam Munoz12:10:54

:cljsbuild {:builds

              [{:id "dev"
                :source-paths ["src"]

                :figwheel {:on-jsload "sdk-2.core/on-js-reload"
                           :open-urls [""]}

                :compiler {:main sdk-2.core
                           :asset-path "js/compiled/out"
                           :libs ["path/to/library.js"]
                           :output-to "resources/public/js/compiled/sdk_2.js"
                           :output-dir "resources/public/js/compiled/out"}}

               {:id "min"
                :source-paths ["src"]
                :compiler {:output-to "resources/public/js/compiled/sdk_2.js"
                           :main sdk-2.core
                           :libs ["path/to/library.js"]
                           :pretty-print false}}]}


@rohit thanks I’ll have a look


@adammunoz usually i prefer to go with cljsjs libs - is it possible in your case?

Adam Munoz12:10:49

@rafaelzlisboa It's a custom library that I've written in closure


@mping: could you elaborate/repeat what you're trying to do?


@martinklepsch hi, you’re the author! cool! I’m trying to require a npm package to use it in the main process


What is the package and how are you trying to load it in your app? @mping


I think I got something working, I added it in resources/package.json and required it through js/require


Hi. Has anyone successfully used chartist? I included the CLJSJS package, I can load chartist no problem. The graphs look ugly and I thought it may be the CSS. But now I find no way to load the chartist CSS at all. /me feels stupid


@ska so the CSS may be in the jar and you need to include that in your page in one way or another


@martinklepsch Yeah, the CSS in the JAR. It is the "one way or another" part that I don't grok. Also, while boot extracts the minified JS from the JAR it does not seem to do that for the CSS. At least, I can not find the CSS underneath ~/.boot


The deps.cljs in the JAR also only mention the JS files. But I don't know if that is relevant.


Manually downloading the CSS and adding to my app fixes the ugly graph.


Is this ring middleware the common way of loading CSS files from CLJSJS JARs?


@ska sorry for the slow response, yes Juho's middleware should help with this


also if you know the path of the file you can get/serve it via io/resource


the middleware does that in a more generic way


if you look at the implementation you can probably see whats done in ring-cljsjs


Currently looking into the newer boot-sass by Deraen and then importing the style sheet in my SCSS file.


Oh, and no worries about slow responses. Thanks for any responses in the first place. 🙂


I always forget that this wiki page exists, dang


@juhoteperi, thanks. That's where I found the link to the less4clj and sass4clj hint. Would you be able to suggest one of the approaches to me?


If you already use sass then that's good approach


That's what I use myself


OK, will try then. Am currently still on boot-sass-0.2.1. Will changing that to 0.3.0 give me the latest version from your new project?


Thanks. Will come back with results...


Hm, I could silence the compiler by removing the (inline) part from the example on the wiki page. That was for less anyway. But my webapp still does not find the CSS file.


Inline is for less


Hmm.. sass has different logic. Try leaving .css out of import path.


Latest sass4clj should check for css file and inline the contents


If you have .css on import path it will write the regular css @import


Maybe I'll have to add a route to my ring app?


So, my app.css now has a new line at the beginning: @import url(chartist/common/chartist.min.css); But my ring app does not serve anything under that path.


But there shouldn't be that line in app.css


it should be replaced by the contents of chartist.min.css


What is the line in your scss file?


@import "chartist/common/chartist.min.css"; is my first line in my app.scss


Try @import "cljsjs/common/chartist.min";


Compile exception: Error: File to import not found or unreadable: chartist/common/chartist.min


Hang on, will try your edit


had do edit again, after I checked chartist build.booit


hi, I'm trying to use modular compilation, and although non of my modules have a dependency on react, nevertheless cljs_base.js includes react -- can I make it only include cljs without removing react etc from my project.clj deps vector ?


File to import not found or unreadable: cljsjs/chartist/common/chartist.min


Oh, next edit compiles


Works!! Thanks a lot, @juhoteperi


I'll update the wiki page with some Sass specific instructions


Too much magic going on underneath. I think, I am getting too old for this. 😉


Yes, there is some magic here but the css import logic in sass4clj should be the same as in libsass/ruby sass


@juhoteperi That looks better. I think, adding a hint how to get at the correct path (look into JAR, find asset, copy path, add package, whatever) would have been very helpful for me.


FWIW @ska it seems to work the easy way for me with just including the CDN versions of the chartist JS and CSS, in the html, in dev. Which obviously won't work for advanced compilation, but maybe the lazy easy solution is just to do that and then slap the externs from cljsjs in before compiling or something?


@gowder @ska It is also possible to just use JS from Cljsjs and then CSS from CDN, then you don't need to use sass/less compiler to embed css or middleware the serve them


@gowder that will work but you'll have extra HTTP requests


@gowder, thanks for your hint. I do not think, I can go for any CDN package, as I have to ship a fully self-contained JAR. And I always like to keep dev and prod environments as similar as possible.


sensible enough 🙂


Once I found out that the missing CSS file was actually my problem (by adding it manually and seeing that it works), it was easy to find the wikipage. The page is a bit intimidating to a newcomer. Thus, when @dearen said, that going for the SASS way would be good, I had my decision on that. The next problem was that I pasted the less example to my sass and expected it to work. Stupid, I know; this has been improved by the latest edit. The only remaining problem would have been to find the correct filename. There is now a paragraph in the wiki page, too. So, I guess the next newcomer to this problem will have a good chance of finding the pieces. 🙂


The Sass way was not documented yet as I just released sass4clj version which supports this like a week ago, so you happened to be the first one to try this 🙂


What I am trying to say is: 'good job, thanks' 🙂


Has anyone used I’m getting Cannot read property 'childNodes' of null when using the patched MDL.js


is it possible to configure the reader use by the clojurescript compiler?


in say project.clj


i don’t see an option but i may have overlooked something.


What’s react.js actually doing in all the CLJS wrappers? It seems like we don’t use its diffing capabilties but instead cljs equality semantics. React’s lifecycle hooks seem simple enough to implement. Additionally there are plenty of issues talking to react, e.g. making proper react elements on the server side and pushing around props in js objects. Am I overlooking something?


@denik: Part of the reasoning I've heard in previous discussions has been so that it enables us to take advantage of the wider react ecosystem and performance improvements made on react. It's a similar reasoning as for the rest of the interop/hosting story, I think. It's definitely not the only approach though, I believe Hoplon has it's own vdom implementation (though you might want to check that).


just curious: is core.logic boostrap-cljs compatible? (i have a fuzzy understanding of what that means and how a library achieves compatibility, am doing some reading to try to solve that)