This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-23
Channels
- # aws-lambda (5)
- # beginners (212)
- # boot (3)
- # cider (130)
- # cljs-dev (24)
- # clojars (2)
- # clojure (287)
- # clojure-dusseldorf (23)
- # clojure-italy (11)
- # clojure-russia (10)
- # clojure-spec (9)
- # clojure-uk (45)
- # clojurescript (59)
- # core-async (1)
- # cursive (13)
- # datascript (1)
- # datomic (46)
- # emacs (12)
- # events (9)
- # fulcro (196)
- # graphql (3)
- # hoplon (79)
- # jobs (5)
- # jobs-discuss (7)
- # jobs-rus (2)
- # keechma (26)
- # keyboards (9)
- # leiningen (2)
- # luminus (9)
- # off-topic (20)
- # om-next (1)
- # onyx (15)
- # re-frame (16)
- # reagent (18)
- # reitit (1)
- # remote-jobs (2)
- # rum (3)
- # shadow-cljs (13)
- # sql (135)
- # unrepl (46)
- # vim (1)
- # yada (23)
does anyone use spyscope with clojurescript? even though I’ve added it to dependencies, the compiler can’t find it when I require spyscope.core
. generally what debugging libraries do people like to use? i’m just using lots of prints
Check out https://github.com/binaryage/cljs-devtools for debugging
@lee.justin.m that reminds me somewhat of https://github.com/vvvvalvalval/scope-capture
I’ve used scope-capture some and have liked it. I used it a pretty basic level, but it was helpful to me for capturing locals environments at runtime
In the CLJS via figwheel
+ cider
+ piggieback
repl I am getting an “analysis error” “at line 1" with really no information when trying to expand a macro:
---- Could not Analyze <cljs form> line:1 column:1 ----
this same thing used to work. Not sure what changed. That part is somewhat irrelevant to my question though.
My question is, what can be done to troubleshoot something like this?The cljs repl analysis happening here seems opaque and it doesn’t give stacktraces or anything
I'm having trouble making a re-frame app run my init
function when I load the page. How can I tell it what it should run first?
who calls the function?
the point of :export
is that something can now call it from the outside - I use a script tag in my shell html that calls the init to start the webapp
(after all the scripts are loaded of course)
and yes, not calling init from the top level of the ns is good - for example that makes testing more straightforward
hello all, what do you use in :optimizations
to do not give problems with external js libraries?
@conan: Happy to help over in the #re-frame channel
Any tip how to remove the duplication from
(AWS.Credentials.
(ggo/get creds "AccessKeyId")
(ggo/get creds "SecretAccessKey")
(ggo/get creds "SessionToken"))
? I tried (apply new AWS.Credentials
(map
#(ggo/get creds %)
["AccessKeyId" "SecretAccessKey" "SessionToken"]))
but apply new
evidently does not work 😞right, apply doesn't work with constructors or methods
you can use a macro though
Yeah, that is always a valid answer in clojure(script) 🙂 Thanks!
(defmacro make-creds [& sources] `(AWS.Credentials. ~@(map (partial ggo/get creds) sources))
or maybe the ggo/get has to happen in the cljs at runtime, which means constructing it differently
(defmacro make-creds [creds & sources] `(AWS.Credentials. ~@(map #(list 'ggo/get creds %) sources)))
Can anyone point me to an example of code that uses the cljs API (and specifically cljs.analyzer.api/analyze-file
) to produce javascript from a cljs file?
Thanks @thheller! But is there no way to get JS out as a string without using the filesystem?
what are you trying to do? compiling one file won't work since it will require a few others to also be available
I want to be able to take any cljs
file on my classpath and obtain the corresponding javascript as a string (to serve as a web response, most likely)
This weekend I very quickly got to the point where I had
(with-core-cljs nil (fn []
(analyze-file "us/quartyard/wat.cljs")
(println(all-ns)) ;; prints essentially what I expect.
(now what???)))
But then I spent all day trying to figure out how to get the AST back out of the compiler state so that I could call emit
on it. Couldn't figure it out. The API docs are pretty sparse.But analyze
expects a single form, while my namespace consists of a series of forms that should (I think?) all be incorporated into the same JS script.
There's no way to populate the compiler state and then extract the various analyzer results from it to emit the JS for each piece?
not sure what the actual API is but you'd usually open a tools.reader instance, read one, analyze, emit, repeat
And then use some other mechanism to emit the JS for the core
namespace (which any other script will have to rely on)?
things are slightly more complicated since everything has to be loaded on the client side in order
That's fine, as long as I can find a way to serve a copy of cljs.core so that the browser can load it
I should be able to gather all the dependency cljs
files and then analyze
/`emit` them all, concatenating all emissions into a single JS file, right?
@escherize For your particular example array?
🙂
No problem. That's the precondition used for checked aget
, FWIW. https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L445
now I have another one, I need to check that #js [1 2 3] === #js [1 2 3]
.
I know it’s not js/==
.
ERROR in (get-works) (zzz/api_test.js:86:46)
expected: (js/== n #js [1 2 3])
actual: #object[ReferenceError ReferenceError: Can't find variable: _EQ__EQ_]
@escherize goog.array/equals
might fit the bill
^ and ~ 2 orders of magnitude perf boost https://gist.github.com/mfikes/2199d662d89626d26ffde1917acbbf9e