This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-08
Channels
- # admin-announcements (1)
- # arachne (3)
- # beginners (17)
- # boot (36)
- # bristol-clojurians (1)
- # cider (4)
- # clara (10)
- # cljsjs (11)
- # cljsrn (20)
- # clojure (134)
- # clojure-austin (2)
- # clojure-boston (1)
- # clojure-czech (1)
- # clojure-greece (128)
- # clojure-norway (1)
- # clojure-romania (1)
- # clojure-russia (17)
- # clojure-spec (106)
- # clojure-sweden (1)
- # clojure-taiwan (1)
- # clojure-uk (41)
- # clojurescript (122)
- # component (4)
- # cursive (1)
- # datomic (34)
- # editors (57)
- # emacs (12)
- # events (5)
- # hoplon (18)
- # instaparse (1)
- # jobs (9)
- # keechma (9)
- # lein-figwheel (3)
- # luminus (1)
- # om (47)
- # onyx (31)
- # proton (2)
- # re-frame (7)
- # reagent (3)
- # rethinkdb (1)
- # specter (25)
- # sql (2)
- # untangled (21)
- # yada (1)
is there a good way to debug in production (i.e. everything works in figwheel, but foreign libs cannot be found when doing advanced optimization)
FYI: some early testing with 1.9.93 have issue in Chrome devtools with seeing cljs source & (js-debugger)
doesn't breakpoint whereas 1.9.89 is fine. Using dirac on Canary/Unstable so I'm yet to confirm this is an issue in plain devtools
@blance: so that sounds like an externs issue? Are you familiar with the challenges around externs and advanced compilation? If not, see: https://github.com/cljsjs/packages/wiki/Creating-Externs
This is no way a solution, but the code generated by :advanced
compilation becomes slightly easier to understand when you use this setting:
:pseudo-names true
https://github.com/clojure/clojurescript/wiki/Compiler-Options#pseudo-names
also use :pretty-print true
Remember to remove both options when you have solved the problem.
Which data transformation library is most popular in ClojureScript development? Not interested in Clojure. • Spectre - https://github.com/nathanmarz/specter • Instar - https://github.com/boxed/Instar • balagan - https://github.com/clojurewerkz/balagan • Other Which one do you use, and why not one of the other ones? Spectre looks good but it only works for me on Clojure and not ClojureScript. Even though it says it's for both. Haven't tried the rest.
@jjunior130: Since you ask: I use cljs's core and datascript. I'm very picky with pulling in dependencies into my cljs code. I only have datascript, rum and nothing else. I'd probably not use specter in cljs (even though I love it in clj) because it's a pretty large dependency and has been growing a bunch.
@rauh: thanks for datascript. I'm gonna study it. Edit: sorry for sharing, meant to reply, assumed share button was reply button, clicked it before reading, share button should like like https://cdn3.iconfinder.com/data/icons/glypho-free/64/share-128.png
PSA: In case you have React :key
warnings frequently, the new React v15.2 gives much nicer error messages about them.
@denisj please confirm it in plain devtools, in case of Dirac issue I could look into that
@rauh: when you say "large dependency" — isn't that a non-issue with advanced builds because of dead code elimination?
@martinklepsch: DCE isn't as magic as I thought. A lot of code will still end up in your build even if you don't use it. Depends on the library's code of course. Simple functions will get DCE, but many libraries are more than simple fns.
In my example I had garden and datascript somewhere required (BUT never used/called). It was still all there even with advanced builds. I wouldn't blindly rely on DCE, better double check.
I see. Guess I should integrate my boot task to gzip and show sizes into our production build pipeline :
@martinklepsch: I did that recently in my build script and I log (simple spit
) the size after every advanced compile: https://gist.github.com/rauhs/2a02e5e04b5bd4e4b4b5
made this a while ago but adding an option to log the sizes is neat, also brotli 👍
@rauh: lol forgot the link: https://github.com/martinklepsch/boot-gzip
@jjunior130: happy to help in #C0FVDQLQ5 channel with whatever issues you ran into using specter in clojurescript
but there are many library anti-patterns that will defeat it - that includes top level data structures
@ethangracer: no we do not support that and unlikely to
I didn't mean to say "simple vs complex fns" but "simple fns" vs "non-fns (such as top level data structures)".
For anyone interested, this talk on BuckleScript (OCaml -> JS) is pretty good. https://www.youtube.com/watch?v=8GNUh1TYfo8
@dnolen: is there any performance benefit of using named functions over anonymous ones?
e.g. will extracting #()
out of React component's render function reduce any execution overhead (like redefining the same #()
on each render)?
(rum/defc yo []
(text-input {:on-click #(...)}))
==>
(defn on-click ...)
(rum/defc yo []
(text-input {:on-click on-click}))
but even the finest grain user generated event handlers aren’t going to fire more than a couple hundred times a second
internally we try to avoid closures but I can’t remember ever seeing that be the bottleneck in any application level event handling code I wrote
Hi, I like to use window.msCrypto
but the advanced compiler minifies msCrypto
. I already wrote an externs file but it doesn’t work. Should externs work for window
?
my code: (let [crypto (or js/window.crypto js/window.msCrypto))
the minified version: var a,b=window.crypto;a=r(b)?b:window.qm;
, the externs:
var window = {
"msCrypto": {}
};
@misha: I think one problem with #(…) is that it will make many “automatic” implementations of shouldComponentUpdate trigger unnecessary re-renders
did anybody see that tweet of a little snippet of elisp for making emacs to consider keywords as one word when in evil mode?
@johanatan: https://timothypratley.blogspot.com/2014/08/clojure-friendly-word-definitions-in.html that?
@codonnell: yep, that's it!
if I want to make a js class … is it legit to use defn + specify! on the prototype, or am I relying on impl details?
@hueyp: have you had a look at this document: https://github.com/clojure/clojurescript/wiki/Working-with-Javascript-classes
Is there a way to not load/access forign-libs from global? The big JS project I have has some kind of script loader, which I would use to load the compiled cljs->js code. However, it would do closure around it to avoid exporting anything to global. Thus my cljs code won't be able to do (.func js/some-libs)
cuz none of the foreign libs will live under js/
@hueyp: deftype
would be the most idiomatic depending on the stuff you need
@anmonteiro: thinking of a case where I want to ‘inherit’ a third party prototype (not sure the right word) … but I agree ya, deftype works for that 🙂
Advice needed please: I'm trying to recover the name of a function being passed around, with
(meta (var the-function))
...which works in a cljs REPL, but when compiling, I get the error message java.lang.AssertionError: Assert failed: (ana/ast? sym)
Any way around this?vars are only supported at compile time in clojurescript. you might be able to demunge the name of the fn instance
In one of my project I was able to retrieve var’s meta in macros and bake it into cljs sources as data, I used it in test environment with dev builds, but I don’t see a reason why it should not work under :advanced builds as well
here: https://github.com/binaryage/dirac/blob/master/src/automation/dirac/automation.clj#L41
and I fetch the function name in cljs code here: https://github.com/binaryage/dirac/blob/master/src/automation/dirac/automation.cljs#L222
suppose I have a map with certain keys and a vector of special keys. what's the best way to duplicate every k/v in the map with the new special keys mapped to the respective values. so, like rename-keys
but keeping the old as well as the new. I'm thinking (merge old (rename-keys old new))
where new is a mapping from the old keys to the new 'special' keys mentioned in my initial vector above. [not the best performance since the 'merge' will be throwing away a lot of duplicated values].
[oh, i suppose I could remove all non-special keys from old
before passing it to rename-keys
to eliminate the perf issue i mentioned with merge
above]
Hey all! This is probably a n00b question, but I have a function which transforms milliseconds since epoch to an #inst
:
(defn ms-inst
"Convert milleseconds to an #inst (inverse of `inst-ms`)"
[msecs]
#?(:clj (java.util.Date. ^{:tag ~'long} msecs)
:cljs (js/Date. msecs)))
I feel like this is some built-in I've overlooked...actually to back up one level and ask my original motivation for the above: does anyone know of any clojure[script] code which automatically adds "-webkit-xxx" attrs for any standard attrs where there is overlap?
[can't imagine that every person out there would want to implement this for themselves]
@xcthulhu, there aren’t any time functions built into clojure.core
. But you can use cljs-time
and clj-time
to wrap the Joda Time library. That could be overkill if that’s the only timestamp manipulation you need.
@akiva: That may have once been true, but now inst-ms
is in clojure.core
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6666
https://cljs.github.io/api/cljs.core/inst-ms
And here you can see the developers rolling their own inverse, which I found odd: https://github.com/clojure/clojure/blob/master/src/clj/clojure/spec.clj#L1610 https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/spec.cljc#L444
@akiva: It looks like functionality from clj(s)-time
is creeping in to Clojure 1.9 btw https://github.com/clojure/clojure/blob/master/src/clj/clojure/instant.clj
Actually, looks like the clojure.instant
namespace has been available for awhile. [cue The More You Know jingle]
Does anyone know why I get myname_space is not defined
when doing simple compilation, while advanced don't have this error?
this is what I came up with (if anyone sees room for improvements):
(defn wk [styles]
(let [attrs [:flex :flex-flow :align-items :align-self]
mapping (zipmap attrs (map (fn [a] (keyword (str "-webkit-" (name a)))) attrs))]
(merge styles (rename-keys (select-keys styles attrs) mapping))))
@jr @darwin Thanks for the ideas/pointers; I'm concluding it's too bothersome to recover the function name, so I re-designed the abstraction to not need it.
@denisj: I can confirm a bug in plain devtools, they don’t load sourcemaps on first load sometimes, you have to refresh the page second time to make it work (my experience)
well, wait, in my case, the cljs file is not even listed in the files panel on the left
if you have reproducible project, you can try to bisect clojurescript commits between 1.9.89 and 1.9.93
So you are confirming you also don't see cljs source but in your case not event the files are listed in left sources pane.
@denisj now when I think about it more, my case was a different bug, it was devtools not recognizing there is a source map associated with a js file, so files panel didn’t even show the cljs file(s)