This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-04
Channels
- # aws (3)
- # beginners (63)
- # boot (10)
- # cljs-dev (14)
- # cljsrn (10)
- # clojars (4)
- # clojure (132)
- # clojure-nl (4)
- # clojure-spec (3)
- # clojure-uk (1)
- # clojurescript (206)
- # css (3)
- # datascript (5)
- # lein-figwheel (1)
- # leiningen (1)
- # off-topic (48)
- # re-frame (18)
- # reagent (29)
- # specter (4)
- # untangled (1)
- # yada (1)
How to get into graphs in clojurescript?
I'm using ubergraph to describe some control structures of my system and in the moment, I plot from repl with uber/viz-graph
.
I want to put it in a "admin pannel" in clojurescript. But I didn't find:
- how to/what format use to export graph (with metadata) from back to JSON/EDN/transit
- how to plot it in clojurescript. There is some stuff on cljsjs but each lib has it own input format for graphs...
@souenzzo depends a lot on your needs. If you're happy with something generic looking and aren't sweating the details, then just hit up cjsjs and search for "chart"
if you want to make something more bespoke, I've had an OK time wrapping the lower level utilities of d3 to calculate things like scaling x/y positions and then rolling my own SVG elements with attributes
or, to put it another way, there is no "standard chart library" that works for everyone in javascript, so there isn't one in cljs either, so there is no "standard chart input format" either 😞 - although there certainly are some efforts to do so, such as d3 and https://vega.github.io/
Clojurescript on Windows users. Please vote on this. https://dev.clojure.org/jira/browse/CLJS-2036
It looks like a compile bug associated with the :preloads feature. Stops us from using the more recent stable releases of CLJS.
@olivergeorge we have a very small number of contributing devs on Windows machines, happy to see that one fixed but you’ll probably have to provide a patch yourself. Pretty sure this is likely a file system issue, that’s been most of our problems on Windows.
Pretty set on clojurescript at the moment, but does anyone here have any experience/views on ScalaJS?
Hi, can someone give me advice as to the best way to give a sizable financial contribution towards clojurescript development? I don't see any info on this in the github page or the http://clojurescript.org site.
@qqq :thumbsup: I'm reachable at <mailto:[email protected]|[email protected]> if @dnolen or anyone else wants to get in touch
@drcode : if you are throwing $$$ at clj/cljs, another project worth looking at is: https://github.com/clojure-emacs/cider ; they have detailed "funding" page at the bottom [disclaimer: I use cider; I am not a dev of cider. I would benefit indirectly (via improved dev tools) but not directly (i.e. cider does not pay me.) ]
I'd also advocate throwing money at figwheel. Not sure if Bruce is soliciting, but he's providing an important service to the community IMO
What's the simplest way to turn CLJS into JS? I'm trying to reproduce a bug, and I'd like to avoid a whole project setup if possible.
@peeja that's one of the first examples in the clojurescript quickstart https://github.com/clojure/clojurescript/wiki/Quick-Start
just requires cljs.jar
@noisesmith Ha! I think I clicked every link on the wiki but that one. Thanks!
this is also easy: http://app.klipse.tech/
It looks like when you take the value of a dotted interop form, say .aJSMethod
, ClojureScript emits simply .aJSMethod
So (println .aJSMethod)
emits cljs.core.println.call(null,.aJSMethod)
, which is invalid JS
I'm not sure what to make of this: when I put it into http://app.klipse.tech/, I get an analysis error, but also output.
printing a dot method, unassociated with any object or anything, I don't think would be expected to work.
Right, it shouldn't do anything useful, but it should break the build process correctly.
the answer I expect to see there is that .aJsMethod isn't a valid form
garbage in, garbage out
clojure and clojurescript do a lot of silly things instead of outright rejecting inputs
in a lot of contexts
spec may change this in the long run...
But there are probably a billion ways to cause a js parser error. Do we catch all of them?
I doubt we catch any of them - explicitly at least
see, this is why using cljs.jar make sense - you can say that with a specific version of clojurescript we get this specific output...
@pedroteixeira did you ever solve your issue with running lein cljsbuild once hello
once you cloned the om repo. I am still not able to figure out this clojure.lang.ExceptionInfo: Invalid :refer, macro cljs.pprint/deftype does not exist in file examples/hello/out/cljs/pprint.cljs {:tag :cljs/analysis-error}
exception.
For context, here's the bug surfacing in another issue, which is what led me down this rabbit hole: https://github.com/funcool/promesa/issues/48
Now, granted, Promesa's macro acrobatics here may not be completely thought out, but it shouldn't be able to emit invalid JS
$ cat src/repro/repro.cljs
(ns repro.repro)
(println .fooBar)
$ rlwrap java -jar cljs.jar
Clojure 1.8.0
+user=> (require 'cljs.build.api)
nil
+user=> (cljs.build.api/build "src" {:output-to "out/main.js"})
nil
+user=>
$ cat out/repro/repro.js
// Compiled by ClojureScript 1.9.562 {}
goog.provide('repro.repro');
goog.require('cljs.core');
cljs.core.println.call(null,.fooBar);
@peeja I'm going to take a wager that the cljs devs disagree with you, and that it's handy to reject invalid input, but there is no priority in cljs or clj dev to make erroneous output impossible
I could be wrong though, but I've seen similar responses to various other clojure / clojurescript behaviors when given erroneous input
"it does something invalid for this input" "that input wasn't valid so it's not a priority to fix it"
it's a conversation I've had more than once with clojure devs
Explicitly de-prioritizing error messages for problems that are obvious to the complier and non-obvious to the user is a great way to tank a language.
but is it obvious to the compiler?
does cljs have the infrastructure to recognize valid vs. invalid js forms?
Sure it's obvious. It does something special with (.aJSMethod (js-obj))
. It doesn't do that with (foo .aJSMethod)
. Somewhere in the compiler there's already logic that says what to emit for that form, and that logic is incorrect.
if there is a finite amt of time, it sounds more like they prioritize other things more, and the explicit deprioritization -> tanking argument may be a lot
The analyzer already knows that that symbol can't be evaluated there. So why does it emit anything?
I bet it's related to the fact that (js/console.log ...)
works
which is totally invalid as a clojure form
but works (accidentally?)
@peeja cljs doesn't assume a closed world where it knows what exists and what things mean in the output code
it happily outputs things it knows nothing about
atomically, (after macroexpand) there are a finite number or patterns to match interop forms against and it's not one of them @john i believe
they are probably implemented by some other lib somewhere...
all the time, yeah
usage of external libs
@peeja sure - but the compiler happily passes things through as is. I'm not objecting to the very idea of validating the compiler's output, but cljs has no such infrastructure or functionality right now.
I'm not talking about what should be, but what is there.
it's got near zero validation in place
@peeja as I said, pretty much any usage of a lib that isn't part of js
it just passes through all your references
only sometimes
eg. js/consolre.log - the clojure language says that shouldn't work, but because it's passed through it works
but we have evidence that they are
I've never seen reason to beleive they aren't
I can emit calls to libraries that cljs.jar knows nothing about
by putting them in the code
yes, that's true
type .aJSmethod
in the repl and it'll pass right though to the JS site, with an error coming from JS land.
@john https://cljs.github.io/api/syntax/dot (x .y) doesn't match any of those patterns
oh, otherwise they get converted, right
@nikki I believe @peeja was saying that a (.x y) form was causing the erroneous output, when .x doesn't exist.
When the compiler compiles (.aJSMethod something)
, it does become something.aJSMethod()
, but the compiler's not just blindly passing the characters .aJSMethod
through between something
and ()
. It understands the JS it's constructing there.
@nikki What I'm trying to say is that there's no other examples of passthrough, so I don't understand why that appears to be the fallback
+user=> (macroexpand '(println .fooBar))
(println .fooBar)
fwiwIf that were correct, you'd expect to see passthrough happen in other cases, producing correct output
Which is why I think there must be a branch of the logic which already addresses this case, the only case where passthrough happens, which could throw an error, but instead says "ah, screw it" and emits the bad JS instead
So I'd understand more if it was looking for a var called .aJSMethod
in the current namespace.
Have looked into the guts of the analyzer and checked out what it is attempting to do with dot prefixed forms?
on another topic: other than http://thi.ng and kovasb gamma, do y'all know some neat paradigms / libs for webgl on cljs?
http://regl.party is data-oriented enough that it can be used from JS interop from cljs pretty well
@peeja might want to bring it up in #cljs-dev. Like we've been saying, CLJS doesn't have a general policy of cleaning all garbage on the way in, which, as @noisesmith mentioned, may be improved on with spec in the future, but it couldn't hurt to ask them.
Right, I understand that, my assertion is that I don't think this actually needs to be cleaned on the way in so much as handled differently where it's already handled. But I'll dig deeper.
Frankly, I don't see the issue. The error is one level later. At compile time of the JS code. If this was a runtime error... I'd understand.
where is the most thorough explanation of js interop? i'm having to translate stuff like app.$.foo.bar(baz)
or Polymer.dom(document).querySelector("#foo .bar")
, and it's mostly trial and error. the explanations i've found online tend to treat only the simplest cases.
also is there some resource that has listed all the cljs react wrappers and what they are about
@rauh When I my CLJS compiles fine but I get a JS syntax error after I deploy my node app to the server because a library macro did something funny with a symbol, that's pretty obscure. I've already lost a lot of time on it.
I feel like never emitting illegal JS (but certainly sometimes emitting legal JS that doesn't run) is a perfectly reasonable line to draw for a JS compiler.
@mobileink is this insufficient? http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/
for chained expressions like you share, the thing I use that isn't in that guide (as far as I saw) is -> which makes literal translations from examples easier
(-> app (.-$) (.foo) (.bar baz))
- the hard part is knowing when something is a property or method (.- vs. .)
and since js makes no such distinction, that requires either trial and error, console examination, or reading docs
but i find it assumes a little more js-fu than i have. e.g. sometimes js/foo.bar
works, and sometimes it doesn't. looking for a little more hand-holding, i guess. 😉
js/foo.bar
is sugar, and I don't really like it personally, it can always be replaced with (.bar js/foo)
separate issue: i've run into trouble with dashes and underscores. i understand aget and aset deal with this; what's best practice? always use aset/aget?
dashes should only come up for things defined for and by cljs itself, which shouldn't be accessed via aget / aset usually
mind you this is all in the context of interop. my cljs must play nice with a js "object".
@dominicm if you want to interact with goog.object
at run-time, just use the symbol goog.object
in your syntax-quoted form
well, so what happens is that if your macro returns a syntax-quoted form, all the symbols in that form will be prefixed with the namespace in which the macro is expanded
should work how you want as long you expand it in a cljs namespace where goog.object is aliased to go
@adamvh That approach seems a little magical & prone to unexpected errors. I probably won't take that approach, but thanks anyway.
yeah, i think it's probably best to write macros that aren't couple to, like, expected namespaces in which they should be evaluated
An interesting reason this may not work in some situations (it does for me, but that's an aside), is if you're requiring, e.g. cljsjs.react in your macro namespace. You must add it to a cljs namespace of some kind. That's not terrible, but it does create an implicit coupling.
Can anyone help with a regex & run-all-tests? I'm trying to build up a regex and pass to cljs.test/run-all-tests. Here's the code:
(let [rgx (re-pattern (str "example" ".*"))]
(cljs.test/run-all-tests rgx))
=> clojure.lang.ExceptionInfo: clojure.lang.Symbol cannot be cast to java.util.regex.Pattern
So it looks like the run-all-tests macro isn't using the runtime value, but the symbol? Any suggestions to pass a dynamic regex to run-all-tests?
Looks like, since run-all-tests is a macro, it is taking rgx as a symbol instead of taking its value, I suggest solving this by using a macro yourself
(I tested your case locally and found the same problem)
For example doing the let in the macro and then taking the value of the regexp inside the syntax-quote
cljs.user=> (let [rgx (re-pattern (str "example" ".*"))] #_=> `(cljs.test/run-all-tests ~rgx)) (cljs.test/run-all-tests #"example.*")