This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-14
Channels
wow - and I thought that clojure build errors could be indecipherable: https://www.refheap.com/106544 anyone got a clue what could cause this?
Using clojurescript 0.0-3308 and clojure 1.7.0
or should I be asking this stuff in a different channel
I’d like to use an external React component in a ClojureScript project. It’s an ES6 module that’s been transpiled to UMD. Can anyone offer suggestions on how to generate externs? This is the component: https://github.com/orgsync/react-list/
@lucien.knechtli: are you requiring korma.core
in a cljs file?
No, I use it on the server
The cljs file is basically torn from the default reagent lein template, except I replaced secretary with bidi
@lucien.knechtli: is cider-nrepl pulling an outdated version of tools.reader? https://www.reddit.com/r/Clojure/comments/3295j6/clojurescript_003196_and_cidernrepl/
Oh.. If that's the case, is there any way to resolve it other than getting rid of cider-nrepl?
Disregard that, I'll try what is recommended in the thread
yay! i'm getting errors that make sense now!
Thanks
Any tips on FRP(-like) libs that play nicely with Reagent? https://www.reddit.com/r/Clojure/comments/3d87vt/clean_concise_frp_lib_integration_for_reagent/
@dkvasnicka: re-frame and zelkova are your two obvious options. Hoplon (not reagent) is also FRP.
What is the correct way of using the google clojure stuff? I am trying to go through the Secretary stuff but am coming against this error: WARNING: Use of undeclared Var xyz.routes/History at line 7 xyz/routes.cljs
I am trying to do something like this: (defn hook-browser-navigation! [] (doto (History.) (events/listen EventType/NAVIGATE (fn [event] (secretary/dispatch! (.-token event)))) (.setEnabled true)))
do you have (:import [goog.history History])
?
I have tried a number of different variations, I have (:import [goog.history]) which doesn't complain when loading the namespace form
So this is basically what my ns looks like (ns sagsbehandler.routes (:require [secretary.core :as secretary :refer-macros [defroute]] [goog.events :as events] [goog.history.EventType :as EventType]) (:import [goog.history])) (History.)
And I get an error with ExceptionInfo #<TypeError: undefined is not a function> clojure.core/ex-info (core.clj:4403)
You saw the example here? https://github.com/gf3/secretary#example-with-googhistory
The include macros thing doesn't work for me at least, so I have to change the imports to (:require [secretary.core :as secretary :refer-macros [defroute]] [goog.events :as events] [goog.history.EventType :as EventType]) (:import goog.History)
we use (:import [goog.history History]) and it’s fine
@casperc: your :import
is still not right, (:import [goog History])
is probably what you want
Yeah that one doesn't complain, but (History.) is still giving the error: ExceptionInfo #<TypeError: undefined is not a function> clojure.core/ex-info (core.clj:4403)
examine the generated source, you should see a goog.require(“goog.History”)
at the top of the file.
@dnolen: Right
The Source looks like this:
goog.provide('sagsbehandler.routes');
goog.require('cljs.core');
goog.require('goog.History');
goog.require('goog.history.EventType');
goog.require('goog.events');
goog.require('secretary.core');
(new goog.History());
//# sourceMappingURL=routes.js.map
That works fine, and I just tried calling it when loading a page and it does it to work fine there.
Hi, what’s the forward looking way to include a pure JS lib in a clojurescript project? CLJSJS still a good option? Or is there a something little bit less ceremonious?
@arnaudsj: I can’t think of anything less ceremonious than CLJSJS, you completely avoid manual configuration
@dnolen: I meant that the lib in question does not exist in the CLJSJS repo, so it appear I need to write an extern file for it (or am I wrong?)
@casperc: so something is wrong with your assumptions. I would enable stop on breakpoints in your browser to see what is actually happening. I would disable source maps for this.
@arnaudsj: the first thing you should determine if Closure does not have the functionality of the library you are interested in.
@dnolen: I am looking at https://github.com/jstat/jstat which is neat stats library, and I don’t think I have seen this in Clojure land (incanter does have some of the things I want, but I did not think incanter could be brought into CLJS land)
@casperc: does this working code help? https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/core.cljs No wait. My Slack session has just caught up and I can see a LOT of discussion since you asked. So ignore this.
@dnolen: ok, let me give it a shot then, if I am successful i will send a PR. Thanks!
How do you create a uuid in clojurescript ? I'm getting (random-ui id) var not found errors in figwheel/0.0-3211
@dnolen: So I am pretty sure it is a REPL problem. I am pausing on all exceptions in the browser and it doesn't break. But I tried defining the funtion to print the History object and it is actually printing it while throwing the exception in the REPL.
It does seem like it, because everything else seems to work, but I'll give it a go in a clojurescript REPL and make a bug report fir figwheel if it ends up being the problem
I would create a sample reagent project using the lein template and compare my core.cljs with their core.cljs.
cljsinfo is doing an amazing job documenting exactly when things are added or removed.
And, if you are interested in helping verify patches: http://dev.clojure.org/jira/secure/IssueNavigator.jspa?mode=hide&requestId=10707
is there a recommended best practice for adding “vendor” js libraries to a project? (e.g. foundation.js, jquery, etc)?
I’m transitioning from a prototype I did several months ago to a piece of a luminus project, and I haven’t made all the mental mappings yet.
fwiw I’m porting over a page template from liftweb, so I’m hoping to avoid rewriting it completely on this pass.
@curtosis: I use this to work with some JS libraries that I wrapped myself. Allows me to keep them in git. https://github.com/LonoCloud/lein-voom
hmm… I suspect it’s the wrapping bit that I need more than the artifact bit… I already have a local repository in my git project for those two 3rd-party java libraries that aren’t online. lein-voom seems to solve that problem, differently?
@curtosis: Yeah it allows me to treat my git repos like clojars, at least that's how I'm using it.
so I think I need something kind of like this: https://github.com/clojure/clojurescript/wiki/Packaging-Foreign-Dependencies with the caveat that right now I don’t actually need to access them from . I just need the foundation calls in the page template to work. cljsifcation to come later
@curtosis: I used this to help me get started generating the externs. It's not perfect, but it helped. http://www.dotnetwise.com/Code/Externs/index.html
do I even need the externs, though? I think at this point all I’m trying to do is get bog-standard js libraries copied over into the resources/public/js directory controlled by cljsbuild.
Those would have to be closure compatible though.
If it's not referenced, what is it being used for? I got by without externs at first, but once I tried to do advanced compilation I had to generate some. Otherwise the Closure compiler gets cranky.
in the simplest case, the page template loads up foundation.alert.js, and calls $.foundation() to bind to the alert box onClick.
another way to think about it is that this is (currently) a ring app that includes JavaScript. The
side comes later.
so the question could be better framed as "how do I include static js resources for html pages served by ring"
@dnolen: right... I think luminus hijacks the default resources/js directory for cljsbuild. But thinking about it now I don't see why I can't use a different directory for the static (non-closured) stuff.
@roberto: there’s one of those in the default luminus template (route/resources “/“)
that is presumably mapped somewhere to resources/public
?
this is less helpful than I'd hoped: http://www.luminusweb.net/docs/routes.md#static_resources
>By default, any resources located under the resources/public directory will be available to the clients. This is handled by the compojure.route/resources handler found in the <app>.handler namespace:
yeah... that's the mapping I'm not clear on, though. where the "/" -> "resources/public" mapping is stored. I can work around it, but I'd like to know where the magic is.
The luminus docs also says it :
By default, any resources located under the resources/public directory will be available to the clients. This is handled by the compojure.route/resources handler found in the <app>.handler namespace:
ok, sure. I guess it could be clearer, since to properly make all those connections you have to know that:
a) resources/route
has a default :root
parameter
b) that path is relative to resources/
and, specifially wrt luminus, that
c) resources/public/js
is managed (and cleared) by the cljsbuild
process
definitely re-thinking my choice to start from luminus rather than building it up library-by-library. 🍸
but yes, dropping things into a resources/public/vendor directory worked like a charm. thanks for the many pointers leading me there.
:clean-targets ^{:protect false} ["resources/public/js"]
:cljsbuild
{:builds
{:app
{:source-paths ["src-cljs"]
:compiler
{:output-dir "resources/public/js/out"
:externs ["react/externs/react.js"]
:optimizations :none
:output-to "resources/public/js/app.js"
:pretty-print true}}}} ...
I'm not too far in, so I'm still considering a ground-up, one-library-at-a-time rebuild.
@tonsky: "In ClojureScript #datascript/DB handler is installed by default, just use … ” really? That sounds strange to me. Is datascript/DB something that’s explicitly handled in CLJS?
Ah, ok. I misread then
Reformulated: > In ClojureScript #datascript/DB handler is installed globally when using DataScript, so read-string just works:
hi all - do the optimisations make any difference to run-time performance for ClojureScript or is it just about filesizing/combining? Objective or anecdotal experience is fine 😉
Yes, advanced is faster
It’s strange, but almost always when I measure it’s about ~2 times faster under advanced
OK, two out of two for faster - thanks!
I also remember @dnolen mentioned that that’s mostly thanks to CLJS compiler optimizations, not because of Google Closure
No, gclosure under advanced mode does more than just minimization. It does inlining as well as several other algebraic code transforms.
In certain pathological cases it can be dramatically faster. It's about 6x faster than identical code when running Enlive in cljs.
thanks @luke
In an intense HTML canvas project I was hacking on a few months back, advanced made the difference between sadness and 30fps
Ok, shameless self-promotion: DataScript now has a Tips & Tricks wiki page https://github.com/tonsky/datascript/wiki/Tips-&-tricks
inlining does matter at all, and a lot advanced inlining is hurtful because callsites become megamorphic
previously JavaScriptCore and Firefox didn’t do property caching so the namespace pattern hurt you, but far as I can tell this hasn’t been the case in a long time
this said :static-fns
and :optimize-constants
don’t kick in until :advanced
because they interact badly with REPL driven development
just clarifying that the real ClojureScript perf optimizations are handled by ClojureScript not Closure.
@dnolen then how come I have observed 2-6x perf increases between :simple and :advanced?
yeah, that stuff should probably be documented at some point. I need to sit down with you at some point (prior to the next release of the CLJS book) and get a brain dump on that kind of thing.
@dnolen: yoyo! any suggestions on how to compare qualifiers? i only compared major and minor and got bitten by the qualifier part. alpha versions of 1.7.0 wont work with cljs but beta will. I can compare strings by mapping them to numbers same way maven does, but that will add a few lines more and Alan Kay would not be happy about that 😉
@annapawlicka: I think we should just assume the known qualifiers that have been used, “alpha”, “beta”, “RCN"
cool, that’s only 3 instead of 7
Hey there, sort of a beginner question here. We (company I work for) are transitioning over to CLJS/Om. Looks like the standard Chestnut app boilerplate calls (sh "lein" "less" "auto")
inside the start-less
function, meaning it never kills off the child lein processes and they build up over time. NBD to kill
them but I am wondering
1. if any of you have experienced this before and there is a generally-accepted solution
2. if any of you are aware of a relatively clean way to check if the lein less auto
process is already running before invoking it again (iow not accepting the output of ps
and testing a regexp against the string returned from the sh
function)
Sorry if this is old/newbish/etc, I wasn't able to figure this out by googling but assumed it must be a relatively common thing in CLJS dev environments