This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-24
Channels
- # aws-lambda (1)
- # beginners (99)
- # boot (46)
- # cider (8)
- # cljs-dev (20)
- # cljsrn (37)
- # clojure (189)
- # clojure-dev (22)
- # clojure-dusseldorf (28)
- # clojure-italy (1)
- # clojure-russia (28)
- # clojure-spec (10)
- # clojure-uk (33)
- # clojurebridge (1)
- # clojurescript (64)
- # core-matrix (2)
- # css (3)
- # cursive (3)
- # datascript (34)
- # datomic (101)
- # defnpodcast (2)
- # dirac (5)
- # events (1)
- # funcool (3)
- # ldnclj (1)
- # lumo (11)
- # mount (1)
- # off-topic (95)
- # pedestal (2)
- # perun (10)
- # re-frame (3)
- # reagent (6)
- # ring-swagger (4)
- # specter (102)
- # test-check (1)
- # untangled (1)
- # vim (8)
- # yada (17)
@dominicm Thanks but it still cannot require it somehow
I'm trying to deploy a small CLJS program on a "nano" AWS instance (lightsail, to be precise) with only 512MB RAM. lein cljsbuild once min
fails, with out-of-memory. Is this expected? Anything I can tweak, or should I just pay a few bucks for a bigger instance?
:optimizations :none
may help.
Clojurescript build's aren't cheap...
In small cenarios, it may help
https://anmonteiro.com/2017/02/compiling-clojurescript-projects-without-the-jvm/
But in a big project, JVM was more efficient(mem/cpu) than "nodevm"
I've had some success tweaking -Xms
and -Xmx
settings on the JVM running lein. For circleci we're using JAVA_OPTS: "-Xms512m -Xmx2048m"
Build it on CI server or somewhere else and deploy just the resulted JS to the nano instance.
@deg building ClojureScript often takes a lot of RAM - the typical thing is to have a build machine of some kind that just copies the compiled assets to S3 or whatever
Hmm, ok. Are there any good scripts or tools to help drive this process, or should I just roll my own? (My current flow was nice and simple, just a short script starting with a git pull. I was hoping to stay simple at first).
@deg you can also copy those assets from your own machine if you want to keep it super simple of course
Yup, thanks. I'll do that. I was just trying to avoid the slippery slope of tool-writing. @dnolen
@deg to explain a bit more, advanced compilation is really memory intensive 1gb of RAM at a minimum usually if you don’t want it to to OOM or take forever
My simple "reagent+re-frame" cljs compiles on a atom+2Gb
with gitlab, docker and some other stuff.. 1Gb should be ok.
Any suggestions on http libs that works with environments that only has js/fetch
instead of xhr (eg. node, React Native)?
@souenzzo : how long does it take to compile? My cljs setup is so slow that I can't use my recent 15" MBP; and am ssh-ing into a server with 32GB of RAM to compile.
@qqq how often are you doing a full recompile (with a clean), I've done tons of CLJS development on a MBP, and compilation is super snappy with simple optimizations and incremental compiliation
@tbaldridge: I never do "clean"; I occasionally do "rm -rf" I'm building with :optimizations none and incremental compilation.
I also used figwheel so the JVM was always loaded, maybe that's the difference
as in, on my most recent project we had about 300 cljs files and my compilation times were about 700ms
@qqq By default, ClojureScript compilation is serial, but you can enable parallel compilation via a compiler flag: https://clojurescript.org/reference/compiler-options#parallel-build
And that's "so slow I need to run it on a 8 core machine with 32GB"?
@qqq if your namespaces are pretty small parallel compilation may have little or no impact
parallel build was implemented mostly for larger projects which were seeing >1 min build times
The new :npm-deps
mechanism does not yet support modules which don't map to packages (like 'react-dom/server'), right?
@deas right. For that case you need to create a shim JS file exporting those
@anmonteiro Shiming by creating foreign libs using node-inputs
, right? Does that mix with :npm-deps
?
Yeah, like in the end of https://clojurescript.org/guides/javascript-modules
They should mix. If something doesn't work please report back
@anmonteiro Ok, thanks!
@mitchelkuijpers ^^ this might be of interest to you 🙂
What would be the faster lookup mechanism in CLJS for a tight 8 way branch? A map lookup? Like (defn mk-lookup [v1 v2 v3 v4 v5 v6 v7 v8] {1 v1, 2 v2, 3 v3, 4 v4, 5 v5, 6 v6, 7 v7, 8 v8})
? Or would a case statement be faster? Or something else?
Yeah, I think I'm winning the switch
. It's just a super simple automata transition rule lookup, so it's a pretty tight loop.
right case
becomes switch
if the values are either all numbers, strings, or keywords (maybe also symbols, can’t remember)
Hey Everyone, I need to work with a foreign lib that returns native JS promises … what’s the most idiomatic way to deal with this
right now my code looks some like:
(defn callback []
(.then
(.signinRedirectCallback (js/Oidc.UserManager.))
(fn [user] (println "success! for " (-> user .-profile .-email)))))
@tankthinks I’d use threading, like
(-> (.signinRedirectCallback (js/Oidc.UserManager.))
(.then (fn [user] (println "success! for " (-> user .-profile .-email)))))
thanks @grav, that makes sense since promises always return promises i could add the (.catch ...)
in the thread
@dominicm thnx for the heads up! This will definitely work ^^
I notice that *warn-on-infer*
doesn't take user-defined externs (specified via :externs on opts) into account when using cljs.build.api/watch
with *compiler*
bound to an existing env; is that expected? If so, I take it I should be calling add-externs-sources
myself when creating the env?