This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-12
Channels
- # aleph (10)
- # beginners (79)
- # boot (81)
- # chestnut (3)
- # cider (9)
- # cljs-dev (336)
- # cljsrn (17)
- # clojure (121)
- # clojure-boston (1)
- # clojure-italy (4)
- # clojure-nl (1)
- # clojure-russia (218)
- # clojure-spec (32)
- # clojure-uk (98)
- # clojurescript (109)
- # cloverage (1)
- # core-async (5)
- # cursive (17)
- # datascript (15)
- # datomic (38)
- # editors (4)
- # emacs (6)
- # graphql (1)
- # hoplon (140)
- # instaparse (1)
- # jobs (2)
- # klipse (1)
- # leiningen (4)
- # lumo (2)
- # mount (103)
- # off-topic (3)
- # om (8)
- # onyx (19)
- # parinfer (32)
- # pedestal (3)
- # precept (32)
- # re-frame (33)
- # reagent (24)
- # remote-jobs (11)
- # rum (1)
- # spacemacs (1)
- # specter (37)
- # unrepl (4)
- # untangled (43)
- # vim (11)
Does anyone have experience working with reagent and generating large tables? I'm having trouble with reagent just dying trying to render 1000+ rows which seems like it shouldn't happen. Sometimes it's even dying on just 100 rows, although not every time.
@tjscollins https://danielcompton.net/2016/04/04/speeding-up-clojure-sorting-by-100x was my experience tracking down a slow render
You can use Chrome devtools to record a CPU profile to see where the time is being spent (sorting and preparing the list, or rendering to the DOM)
@danielcompton Thanks. Had never used the profiler before. The problem turned out to be access-lint checking the DOM as it re-rendered. Disabling it fixed the problem. Something about the react re-renders the dom must not play nice with it.
Guys, when interacting with REPL with clojurescript node.js, how can I prevent program from exiting on error?
What techniques do you use for cache-busting your clojurescript web app? I’m particularly interested in how to invalidate the cache for app.js
, but also html and css would be nice.
I use https://github.com/thheller/shadow-cljs/wiki/ClojureScript-for-the-browser#module-hash-names
Hmm, i'm getting an error i dont understand and googeling is not making it more clear:
No protocol method ISwap.-swap! defined for type cljs.core/PersistentArrayMap
It comes from this code:
(defn mark-as-done [todo-item]
(if (= (:done todo-item) "active")
(swap! (assoc todo-item :done "done") todo-item)
(swap! (assoc todo-item :done "active") todo-item)))
a todo-item is {:id "1", :title "test", :done "active"}
I have a r/atom with db results todos, i have an onclick handler that calls the mark-as-done to update the state of the one todo item
@wilkerlucio missed this yesterday you don’t need to bother with :advanced
to get some big speed boosts - just use :static-fns true
@dnolen thanks, I'll do that 🙂
I've just packaged (w/Uberjar) and deployed my cljs app for the first time. When running the deployed app one of the 3rd pary JS libs isn't found, all the others seem to be fine. I've opened the packaged jar file and see the JS lib in the right place. Any suggestions on how to troubleshoot this?
@dealy deploying a cljs app generally means :advanced
compilation, you won’t have separate files (unless using code splits)
@dealy hrm if you haven’t tried this before then it may be bumpy for a little bit - it’s generally important to try :advanced
early and often
@dealy a minor detail is that people often put the production JS on a CDN & enable gzipping
@dealy if you’re in a jam, then :simple
works, though your clients will download a larger payload
I'd love to know this too! Right now I'm manually incrementing a version on my script tag src's query string and disabling the browser's cache completely during development........ I wonder if there's some kinda tooling for generating the html file that requests my script using a unique id for each build....
https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules
(defn play-game []
(let [
matrix-size (re-frame/subscribe [:matrix-size])
matrix-cells (re-frame/subscribe [:matrix-cells])
user-selection-matrix (re-frame/subscribe [:user-selection-matrix])
]
(r/create-class
@yediFor anybody interested in helping out with JS interop docs: https://github.com/clojure/clojurescript-site/pull/95 . the original is the interop-ref branch at https://github.com/mobileink/clojurescript-site/tree/interop-ref . This is a very rough draft (and I’ve got more material to add), but at the least it functions as a list of stuff that needs to be covered. Not sure what the best way to pitch in is, I guess a note on this channel or you can DM me.
What’s the interop story for deftype? If I construct a value from a deftype, can I pass it to a fn in a Javascript library and expect hunkydoriness? More specifically, I’m looking at expressing ES6 classes (with extend) in cljs. I’ve found code on the web showing how to do this in earlier JS syntax, but it’s pretty hairy (to me). How close is deftype to supporting this sort of thing? Note that I’m willing to hack up a deftype variant if need be, I’ve done that sort of thing before. But I’m a little shaky on the JS side of things, not sure if it would make sense.
making definition of ES6 classes easier might happen - but I doubt it will have anything to do with deftype
ClojureScript can handle mixed codebases if you want to make a ES6 class just make a ES6 class
for what it's worth, ES6 classes are just syntactic sugar on top of the existing JS prototype model
I have almost no clojure background (just joined this slack yesterday), but I've done JS a long time, and I would say that unless you absolutely need to use the prototype (i.e. for extreme performance), just stick to factory functions that return objects
I particularly look forward to trying it out on Node in lieu of my current strategy (which is adding JS libraries manually, referring them globally, and then hating myself)
@henrik there’s fixes for that also forthcoming in the next release - there’ll be a separate post about that next week
@dnolen is that referring to making it easier to import JS libraries via a CLJS build process
hm how large is a minimal hello world om.next application after :advanced compilation supposed to be
I get 500kB app and the only thing I use is om.dom and compassus (and core om of couse)
@roklenarcic do you have (enable-console-print!)
somewhere in your code?
that accounts for at least 90KB
I do!
Is there some way to make it dev only?
The options I use for min build are :static-fns true :closure-defines {goog.DEBUG false} :optimizations :advanced :pretty-print false
(when ^boolean goog/DEBUG
(enable-console-print!))
and add {:closure-defines '{goog.DEBUG false}}
to your compiler optionsyou may also want to throw :elide-asserts true
in there
btw is typehinting needed a lot?
might not be needed in this case
you don’t need to think about type hinting no
and in ClojureScript the only thing that matters is boolean
anyway
@roklenarcic you can use something like https://github.com/danvk/source-map-explorer to see what’s in your bundle
provided you generate source maps
though foreign libraries won’t show up in there
does {goog.DEBUG false} needs to be qoted?
and React+React-DOM accounts for like 130KB?
yeah I know, but I use very little of it
if you’re using Lein or something then things are implicitly quoted
> I use very little of it there’s no DCE on foreign libraries
they’re simply prepended to the generated bundle. So you’re getting it all
related haha: https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules
will look into it
after I added material-ui, my rather trivial app is at 1.1MB
250kb zipped
this may be a dumb question: what's the benefit of babel?
depends what you use it for, it can be used to write es7 code that gets transpiled to es5, or it can just be used to turn jsx into js react understands
all this compiling and packaging work is rather confusing for a java/clojure developer TBH 😄
Say all, with the latest cljs build, post clojure/spec
-> clojure.spec.alpha
split I'm requiring [clojure.spec.alpha :as s]
in my source. Am I correct that I should now be looking for :clojure.spec.alpha/invalid
as a result of (s/conform)
on both JVM and JS platforms, rather than :cljs.spec/invalid
on JS?
@timgilbert no in ClojureScript we’re just ns aliasing for you but the namespaces are not changed, nor values
Ok, cool. Just curious, is that likely to get normalized once clojure.spec comes out of alpha? Not the biggest deal but it would be nice to have fewer reader conditionals in the code
(Er, "normalized" meaning "same value on both platforms")
Cool. Would a ticket be helpful, or is that premature?
Ok, cool. Thanks!
how do i check if a var is a function? this is what i tried:
app:cljs.user=> (type t)
#object[Function "function Function() { [native code] }"]
could be a fun side project
@timgilbert For portability, I’d consider (= ::s/invalid (s/conform int? "a"))
the features of the last post is mostly thanks to the hard work of @anmonteiro & @juhoteperi
Oh great idea @mfikes, thanks
does someone have any “best practice” for deploying app with two versions, one compiled with all advanced optimizations and one with just simple optimizations? So, if any bugs happens you can ask people (customers, field team, whoever has access to env) to open “debug” version so you can get better idea if this due to advanced compilation or actual bug.
also, do you package source maps for “production” build?
pretty much what is your “debuggability” story for production builds
with the new string requires, if I do something like (in Node):
(ns foo.core
(:require ["fs" :as fs]))
...do I use it like (fs/readFileSync ,,,)
or (.readFileSync fs ,,,)
(or I guess (fs.readFileSync ,,,)
)?or.. all of them!
@rgdelato all of those work 🙂