This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-04
Channels
- # aleph (4)
- # bangalore-clj (1)
- # beginners (89)
- # boot (16)
- # braveandtrue (4)
- # cider (1)
- # cljs-dev (6)
- # cljsrn (90)
- # clojure (132)
- # clojure-austin (1)
- # clojure-dusseldorf (4)
- # clojure-italy (12)
- # clojure-portugal (2)
- # clojure-spec (13)
- # clojure-uk (41)
- # clojurescript (142)
- # code-reviews (19)
- # conf-proposals (1)
- # datascript (6)
- # datomic (7)
- # graphql (12)
- # jobs-discuss (3)
- # keechma (23)
- # leiningen (3)
- # lumo (22)
- # off-topic (7)
- # om (21)
- # onyx (8)
- # parinfer (46)
- # pedestal (3)
- # perun (3)
- # re-frame (10)
- # reagent (30)
- # ring (1)
- # rum (2)
- # spacemacs (1)
- # sql (2)
- # testing (17)
- # yada (32)
so how do I debug a (reagent-based) site that spits out a js error in production but works perfectly in development mode? (app.js:1352 Uncaught TypeError: b.Xh is not a function)
@kaosko try to set :optimizations :whitespace
to :compiler
https://github.com/emezeske/lein-cljsbuild#basic-configuration
thanks @lukas.rychtecky , looks like it's a missing extern causing it
question for everyone: I know this has been solved in many ways (elegant or not), and there’s paid solutions like Mixpanel, etc, etc but it’s probably worth asking: has anyone come up with an elegant, hassle-free approach to record analytics automagically from a mostly pure ClojureScript React app? (browser or React Native Cljs should not make much of a difference)
I would like to record as much data as possible without having to diff the whole state at every transition/transaction/swap! etc
I might be asking for impossible magic 🙂 I have done the diff-ing way and it created some performance problems (not critical but noticeable)
the “efficient” way is to simply sprinkle event calls everywhere… which always ends up a hassle to maintain and you always miss something important
basically I’m looking for a library-ish type thing that would do it “well”… aka I’m trying to avoid re-inventing the wheel if it exists already
@raspasov - well I'd think re-frame's interceptor concept would be as close to automagical as you can get - see for example how they do undo: https://github.com/Day8/re-frame-undo
What is the best way to create externs for something like react-bootstrap-typeahead
? I was looking for some modules at
, but it seems rather complicated. Could it be generated, or do I need to have some knowledge about the module I write externs for? Thanks!
@pawel.kapala not to use react-bootstrap-typeahead
😄 If you use Reagent, you can try to replace typeahead from Re-com.
@lukas.rychtecky yep, I considered re-com, but as the disclaimer says it might not work properly in all browsers, so I went with support here. Thanks for the tip though!
@pawel.kapala I see. I’ve tried to create externs, but I failed (none of given workflow worked) thus I’ve changed UI component to similar one with externs.
generation depends on the lib, there should be a link to one, but in my experience you always need a manual retouch
I actually find the fact that there isn't an existing web assembly project for clojurescript (that I know of) to be rather surprising as many major sites are already struggling with performance issues with javascript. If elm or clojurescript could compile to web assembly and javascript it would provide a nice stop gap while letting bigger apps theoretically run more effectively. In other words if anyone is serious about clojurescript or elm taking on javascript wasm is s good strategy to have.
@liminal18 you realize the current major use case of WA is to port C++ games into the browser right 🙂
In JVM Clojure, I tend to put a bunch of repl convenience functions in user.clj. I would like to do the same in cljs, and have the file not be included in production builds. I'm using lein and the figwheel repl. Have you guys set up something like this?
How do I make sure the functions in the file are automatically available when I start my repl?
@curlyfry you can have files without namespaces and they will be set to cljs.user
- this should work but it’s not a heavily tested feature.
@dnolen did not know, but that does make the c to wasm projects a bit more understandable. Was just thinking if a wasm version of a language could make dom updates and other things faster it would make sites written in it more desirable. Anyways good point. Keep up the good work :)
@liminal18 ClojureScript is a GCed language
Ok so basically WA is meant for games and other apps where garbage collection kicking in would cause frame rate drops etc.
Not to up on the ins and ous of gc so I will not comment although that does make me wonder how the haskell WA project will handle it.
Hmm, can't seem to get the files without namespaces feature to work. Figwheel reacts to changes in the file so it seems that it's loaded OK. I don't have access to the function in the file in the REPL though.
@dnolen It does have that feature, but it requires a namespace! 🙂 > Figwheel will not load or reload files that haven't been required by your application. If you want to force a file to be loaded when it changes add the follwoing meta-data the namespace declaration of the file:
@curlyfry ah right, maybe try calling the file cljs/user.cljs
and make figwheel load cljs.user
ns?
@curlyfry agreed, I just don’t think anyone has requested it before so hasn’t been a priority
Putting (ns ^:figwheel-always cljs.user)
at the top of the file works for now anyways
Has anyone any advice for on AWS lambda?
I tried but I am running against a couple of issues. The one is that the artifact is huge (> 20 MB, same code with JS is 9 MB). I was thinking of :advanced
, did not get far but also did not try that hard. The second problem is bigger. Basically functionally the same code in CLJS fills up the lambda's memory and the lambda gets even killed 😱
@richiardiandrea : I'm running CLJ on lambda, and it's working fine; also you can increase mem limits (which iirc, also increases cpu proportionally) if your cljs is too large
for clojure ,I used this tutorial: https://aws.amazon.com/blogs/compute/clojure/
I tried bumping to 128 - 256 - 512 - 1024, memory usage follows and peaks and AWS kills the lambda
https://www.youtube.com/watch?v=GINI0T8FPD4 <-- was also a great talk on clojure on aws lambda
@richiardiandrea : what does your cljs code do?
@richiardiandrea how do you get a 20MB js file? how much code do you have? 🙂
cljs is a requirement so no 😉
(ns logpoc.core
(:require [cljs.pprint :as pprint]
[cljs-lambda.macros :refer-macros [deflambda]]
[cljs-lambda.context :as context]
[cljs-lambda.local :as local]))
(def bunyan (js/require "bunyan"))
(def log (.createLogger bunyan #js {:name "bunyan-lambda-cljs"}))
(deflambda ^:export bunyan-lambda-cljs [event ctx]
(js/console.time "bunyan-lambda-cljs")
(.info log "AWSrequestID =" (:aws-request-id ctx))
(.info log "functionName =" (:function-name ctx))
(.info log "invokedFunctionArn =" (:function-arn ctx))
(.info log "remainingTimeInMillis =" (context/msecs-remaining ctx))
(dotimes [i 1000]
(.info log #js {:index i} "Time: now" (.toISOString (js/Date.))))
(js/console.timeEnd "bunyan-lambda-cljs"))
that's all it does
logging lib for js.., probably something not obvious is going on
I have :optimizations :simple
now
does any of the logging make sync network calls? doing it 1000 times could blowup the exec time
yes that is the point of my POC 😄
funny thing is that it does not happen with straight JS
no it is writing to stdout
hi all, i've updated my reagent to 0.8.0.beta and i get this error now: No such namespace: react, could not locate react.cljs, react.cljc, or Closure namespace "react"
I must say I’m amused that a logging library named “bunyan” is absurdly large
but that is not even the problem...I am really scared about memory consumption
@richiardiandrea cljs.pprint
is pretty huge and you don’t use it. maybe you can remove that
@richiardiandrea : if you don't mind, please document how you cut the size down for aws lambda; there's alot that may be useful
I think I just need to work out the :advanced
magic. I found @thheller's shadow-cljs check
an awesomely amazing tool for that. Example:
------ WARNING #45 -------------------------------------------------------------
File: ~/.m2/repository/funcool/promesa/1.6.0/promesa-1.6.0.jar!/promesa/impl/promise.cljc:162:20
--------------------------------------------------------------------------------
158 | p)))
159 |
160 | (defn rejected
161 | [v]
162 | #?(:cljs (.reject Promise v)
--------------------------^-----------------------------------------------------
Property reject never defined on Promise
--------------------------------------------------------------------------------
163 | :clj (let [p (CompletableFuture.)]
164 | (.completeExceptionally p v)
165 | p)))
166 |
167 | #?(:clj
--------------------------------------------------------------------------------
@liminal18 if you really wanted to get some clojure code running in WA today, I think you would have to use ferret[1] and compile the transpiled C-source using emscripten or WA toolchain. By default the code would be using reference counting instead of GC, so you would have to be careful about not creating cycles in your data structures.
thank you @thheller, i've successfully upgraded my react native project to 0.47, re-agent, re-frame, fighweel, clojurescript and clojure
I think I just need to work out the :advanced
magic. I found @thheller's shadow-cljs check
an awesomely amazing tool for that. Example:
------ WARNING #45 -------------------------------------------------------------
File: ~/.m2/repository/funcool/promesa/1.6.0/promesa-1.6.0.jar!/promesa/impl/promise.cljc:162:20
--------------------------------------------------------------------------------
158 | p)))
159 |
160 | (defn rejected
161 | [v]
162 | #?(:cljs (.reject Promise v)
--------------------------^-----------------------------------------------------
Property reject never defined on Promise
--------------------------------------------------------------------------------
163 | :clj (let [p (CompletableFuture.)]
164 | (.completeExceptionally p v)
165 | p)))
166 |
167 | #?(:clj
--------------------------------------------------------------------------------
hello, I'm trying to use the new npm load stuff, but I'm unable to use the library
trying to add this on my project: https://github.com/JedWatson/react-codemirror
my compiler options have:
:install-deps true
:npm-deps {:react-codemirror "1.0.0"}
and in my code I'm doing: (:require [react-codemirror :as code-mirror])
different from the example on the news article, the thing I want to access is at the root of the project, it exports a class
but seems like cljs is handling the code-mirror
as a namespace only (it doesn't fail to require, but trying to eval just code-mirror
gives me nil)
I had tried to use as ["react-codemirror" :as code-mirror]
too, but this gets me this error: java.lang.AssertionError: Assert failed: cljs.analyzer/foreign-dep? expected symbol got "react-codemirror" (symbol? dep)
any though on how to handle this case?
looking
@wilkerlucio works for me with current master
I'm using with the build 1.9.854
there might be a bug that was fixed in the meantime
how you did the require? string or symbol? and to use it, just eval the name on as
?
just trying to get the full info, so I can try myself 🙂
(ns foo.core
(:require react
react-dom
react-codemirror))
and then how you access it, just react-codemirror
?
(println "react-codemirror:" react-codemirror)
cool, thanks, I'll try to use master here
react-codemirror: #object[Function]
@wilkerlucio let me know if you run into any issues
sure, did you know if there are known issues regarding npm deps + figwheel?
not that I know of
put something together that I can try
and I’ll look at it
not a repo, a single build.clj
+ source file should be enough to repro
ok, I'll going to try inside my current setup (with figwheel), if that doens't work I'll try standalone
@anmonteiro working on master 😉
@anmonteiro now I'm having issue to require a namepace that needs to be a string, on this case: (:require ["codemirror/mode/clojure/clojure"])
got that analyzer error: java.lang.AssertionError: Assert failed: cljs.analyzer/foreign-dep? expected symbol got "codemirror/mode/clojure/clojure" (symbol? dep)
@wilkerlucio I can repro
looking into it
@wilkerlucio https://github.com/codemirror/CodeMirror/blob/master/mode/clojure/clojure.js#L9-L17
Juho has some pending work trying to fix those cases
ok, this is the same thing as this right? https://dev.clojure.org/jira/browse/CLJS-1777
in any case, thanks for looking that up
might be
I just asked Juho that in #cljs-dev
Hi! Is it possible to create a macro in Found it https://cljs.github.io/api/cljs.core/defmacro.clj
that uses the js
namespace?