This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-10
Channels
- # alda (28)
- # announcements (7)
- # beginners (79)
- # boot (62)
- # cider (11)
- # cljsjs (12)
- # cljsrn (8)
- # clojure (111)
- # clojure-art (2)
- # clojure-austin (5)
- # clojure-conj (3)
- # clojure-dev (54)
- # clojure-japan (12)
- # clojure-russia (30)
- # clojurescript (354)
- # clojurex (5)
- # cursive (9)
- # data-science (58)
- # datomic (19)
- # editors-rus (3)
- # emacs (7)
- # events (2)
- # hoplon (5)
- # ldnclj (6)
- # lein-figwheel (14)
- # luminus (1)
- # off-topic (10)
- # om (191)
- # onyx (59)
- # re-frame (30)
- # reagent (74)
- # robots (1)
- # yada (19)
@bensu I’m looking to load another .js that is on the page. I guess I can just use DOM methods
Not really. This is a .js file that other users will load in a normal <script src=“”>, so I’d like to test that behavior
@bensu while you’re here, I’m also seeing 404: /js/cljs_deps.js
. I assume that’s something to do with :asset-path, but I’m not sure what value it should be
What libraries should I look at to build a client/server where multiple clients will be displaying a page, and then from a ‘control’ page can tell one of the clients to display a different page? Based off searching I’m thinking maybe sente for communication between client and server?
let me think about it and get back to you. I'm not sure how to do that (and I have to go to bed now)
is sublime text 2 clojurescript support still decent? like, paredit/indentation at least?
@asolovyov: something using doo is probably what you want (lein-doo is a thing :))
@martinklepsch: I made a setup where figwheel runs my tests on reload, will see how it works
I'm running Clojurescript repl on Node. Should I be able to require libraries using (:require '[ :as]) ?
I keep getting "Use of undeclared Var" messages and not sure if this is something expected
@aleksander: this is a warning telling you that there’s a var somewhere that hasn’t been declared previously
The problem in that case was (:require instead of (require. I mix it up all the time 😓 Also managed to require one lib in the repl so I now know its possible Thanks for the answer!
@jensontech: error comes from that rethinkdb file I would try again without that dependency.
@aleksander: this may help: https://twitter.com/socksy/status/659509865119903744
@martinklepsch: yeah, probably should still have it printed out somewhere nearby all the time
Is there a way to import one of the XMLHttpRequest "node polyfills" so that I can use ClojureScript libraries like cljs-http? Or should I go with the route of wrapping nodejs http? I've tried simply including them in the {:npm {:dependencies []}} and also (def XMLHttpRequest (node/require "name of polyfill")). In all cases i was still getting ReferenceError: XMLHttpRequest is not defined at [object Object].goog.net.DefaultXmlHttpFactory.createInstance (/Users/aleksander/projects/provider-poller/out/goog /net/xmlhttp.js:176:16)
Greetings. I’m a relative n00b when it comes to packaging and distributing ClojureScript libraries. I’m looking to merge khroma-tests and khroma, without shipping the khroma-tests dependencies when the library gets installed. This is the best way I can think of setting up the project: https://gist.github.com/ricardojmendez/7c196c2813785b05da89 Any comments or improvements?
I don’t want to have the devcards
dependency on the main project, since it’s used solely for the tests. Having a separate profile seems like the best way to do that.
but only because leiningen does include the :dev
profile for some tasks automatically
Ah, right. In this case it’s best to leave it explicit, since the examples won’t even work on the repl anyway - you need to be running as an extension. Thanks @thheller!
But then if they load it on a ClojureScript REPL, they’d have namespaces available that wouldn’t actually work.
Thanks for the tip on :dev
being included by default on those cases, though, I was wondering what was the rule.
Man, I’m such a pack rat. I have a hard time forgoing history for khroma-tests and just plunking the files into khroma… but the alternative is merging it with the parallel history up until now. That’ll result in an ugly commit tree.
does cljs.js have a different way to enable/disable warnings from the normal compiler options (https://github.com/clojure/clojurescript/wiki/Compiler-Options#warnings)? adding :warnings {:undeclared-var false} to the options I pass to cljs.js/compile-str seems to have no effect.
not sure how javascript interop is complicated in clojurescript @mike … I also think they are neglecting things like figwheel in their tooling comparison and hyper-focusing on IDEs
@tyler: what about safety? let's say I want to refactor my clojurescript code, how would it be easier than doing so in javascript?
Type safety is definitely a limitation in clojurescript. The question is whether it provides you with any objective benefits in practice.
@mike: From my point of view, Scala.js code is safer while Clojurescript one is much more concise. Tried Scala.js too a while ago
@mike You can compare it yourself https://github.com/ochrons/scalajs-spa-tutorial/blob/master/client/src/main/scala/spatutorial/client/components/Bootstrap.scala - Scala.js
https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/views.cljs - cljs
and the grid is of course missing more important things like maturity, adoption, deployments etc.
@mike: I’m using CIDER (Emacs) for cljs programming. I’m probably one of the few, who tried Cursive, but came back 😄
the worst part of the grid to my mind is that Scala.js gets green for 'Very good' interop; the same colour as ES6
@malch: this is cool as well https://github.com/jamesmacaulay/zelkova
Right, knew about this one for a while, didn’t have time to try it though. @richiardiandrea Thank you for reminding 😊
it is in my queue as well
@mike That’s exactly the point I was making: https://github.com/jamesmacaulay/zelkova
And well, even by their own rules we have Cursive so Cljs should be at least yellow there.
if they had a column that said “IDE”, then okay, I would agree Elm might not fit in that column. But it says “TOOLABLE"
a big part of Elm is the Elm Architecture
. which is implemented in CLJS with zelkova and re-frame.
I suppose Elm wouldn't get green on JS interop, because I don't think Elm can manipulate JS objects directly. But then again I don't get why Clojurescript has bad JS interop
this might not be accurate, I'm just trying to have the big picture, please correct me:
om ~ (react + falcor)
(reagent + (re-frame or zelkova)) (react + redux) elm
Hm. I’m trying to write a (greasemonkey-style) userscript with clojurescript. This requires a specific comment block. I used the instructions from here: https://groups.google.com/forum/?fromgroups=#!topic/clojurescript/_qViDrdu30U
However, with :advanced
the comment block is removed. :whitespace
keeps it. Isn’t @preserve supposed to preserve it?
I'm trying to set up a new clojurescript project from a lein template. I'd like to use something akin to Chestnut but more up-to-date, and include om-bootstrap and devcards. I've tried setting this up myself hodge-podging from the Chestnut and devcards templates, and so far it's a big bag of fail. Any suggestions?
@kevinmershon: unless you need to do some backend stuff, you could just go straight figwheel
@halcyon: I do need to do a backend, yes.
I was reading up on Chestnut's issues on GitHub, and apparently the dependencies are pretty outdated, and the method in which you load up the repl is redundant ever since figwheel incorporated its own repl. I'd rather do without those redundancies, but I like the project structure Chestnut provides
Chestnut is just a template to start off a basic clojurescript project with a backend based in ring
@mike I suppose I might have meant if you don’t need to write a clojure backend. Although there are plenty of SPAs that don’t require a backend
I need to write a Clojure backend.
That would certainly explain it. https://developers.google.com/closure/compiler/docs/js-for-compiler#tag-license still suggests it’s a thing, though.
I’ll try /**!
, /*!
; the issue tracker suggests the team hasn’t done that yet; but I don’t know how up-to-date the issue tracker is.
I guess what I'm looking for is: figwheel (with om), compojure, and devcards all in one lein template
kevinmershon: that’d be nice, but FWIW I’ve stopped wanting that as much after setting it up once or twice. It’s just not that hard
Also I am pretty happy about those folks working on making the projects better rather than having to maintain templates 😉
@kevinmershon: things are still newish and these things require a base of knowledge, an automatic template would just get you standing on the end of a plank
Yeah, I'm clunking around with my project config trying to make it all work together.
bhauman: It helps make it easier to demonstrate how to use things; I hope that in the long run this will make us better at helping junior folks.
man to be a junior dev exploring ClojureScript for my job, such a cool experience, you are going to ruin them for all other dev setups
Speaking of which I think I'm getting tired of hearing that people should "learn ClojureScript in order to learn some new ideas to bring back to their JavaScript environment". ClojureScript is first class and better programming language period. This is no longer a "what floats your boat" situation.
I’m gonna go drive a Lotus Elise so I can bring back some new ideas to driving my Ford Fiesta
Oh, wait, I think I might know why this isn’t working. I’m adding the javascript as a :foreign-lib
; those aren’t supposed to be affected by advanced compilation at all
@bhauman: on what venn diagram does figwheel meet Office
Apparently it works with just Closure, so there’s something about Clojurescript’s handling of foreign-libs, apparently… https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%252F**%250A%2520*%2520%2540fileoverview%250A%2520*%2520This%2520file%2520contains%2520nothing%2520but%2520a%2520comment%2520block%2520which%2520is%2520to%2520be%2520preserved%250A%2520*%2520by%2520the%2520google%2520closure%2520compiler.%2520This%2520comment%2520block%2520contains%2520a%2520comment%250A%2520*%2520block%2520which%2520is%2520necessary%2520to%2520be%2520in%2520the%2520output%2520of%2520the%2520compiled%2520javascript%250A%2520*%2520even%2520in%2520advanced%2520compilation%2520mode.%250A%2520*%252F%250A%252F**%250A%2520*%2520%2540preserve%250A%252F%252F%2520%253D%253DUserScript%253D%253D%250A%252F%252F%2520%2540description%2520xyzzy%250A%252F%252F%2520%2540name%2520crunch%250A%252F%252F%2520%253D%253D%252FUserScript%253D%253D%250A%2520*%252F
Huh, that's kinda scary. I don't even remember when was the last time I even used Office or something like that.
@colin.yates: like a new moon
It doesn’t seem to emit JS comments if I call it from Clojurescript code at least; so I’m guessing I stumbled on some internals.
dnolen: Are there any other ways to get a comment to show up in the resulting source code besides :foreign-libs
+ @preserve
?
Good times when people don’t remember good old :preamble
Is Object
by itself (not js/Object
) supposed to be valid syntax in ClojureScript?
@stuartsierra: hrm it’s just never been the case
OK, but it is valid in deftype/defrecord/reify/etc.?
Just updated all the deps for the flappy bird code. The code still works flawlessly and appears to be quicker. https://github.com/bhauman/flappy-bird-demo/commit/6a5e301a64db040486aa43369e609aac805d108c
not just cljs: sablono, react, core.async ... all of it works flawlessly and more than likely better
(defmacro reporting-failing-actions [& body]
`(let [old-report-fn# ~'clojure.test/report] ; CLJC
(binding [clojure.test/report #(do (old-report-fn# %) ; CLJC
(report-failing-actions %))]
~@body)))
What would be an easy way to make this macro bind clojure.test/report
in clojure and cljs.test/report
in clojurescript? Do I need two macros?I thought I could def
the report fn with reader conditionals but then I’m not sure how I’d properly unwind that inside the macro.
@martinklepsch: conditional reading just doesn’t cover macros
@bhauman: triggered by your tweet: so far haven't found any problems with 0.5.0, been using it for development every day since thursday. There is only one weird thing with cider and repl-api/cljs-repl, but I'm really unsure what's that, maybe my emacs setup or something... And including piggieback makes cider unable to connect to nrepl, but I'm pretty sure that's not figwheel's problem.
@bhauman: it’s working pretty well for me, it’s my primary mode of working on Om Next along with Node.js REPL + cljs.test
I made tests run in browser on every figwheel's reload, and (because we don't have many yet) that's quite nice to get feedback
@bhauman: also, I've reported before 0.5.0 that .cljc reloading is broken in figwheel for me - that is fixed
@asolovyov: great!
okay, I’m still stumped by something I see other people are dealing with in the context of upgrading to 1.7.170, seeing Exception in thread "main" java.lang.AssertionError: No ns form found in <snip>/src/deps.cljs
this is in a separate project I’m including in my cljsbuild :source-paths
. I have upgraded to lein-cljsbuild 1.1.1
when I leave that src path out, the problem disappears (of course)
wondering how to debug this, not even sure why it’s happening
@ddellacosta: this is because you have a deps.cljs file in your source tree
I see, so that’s a no-no in any case then?
I guess I have to figure out how to make that work correctly
@dnolen, so I guess I should flip the question: how can I include a separate project in the cljsbuild source-paths so I don’t have to constantly delete my built CLJS files, run lein install
on that project, etc. during development, if I have a deps.cljs file in the source path (for that project)?
is that not possible now?
@ddellacosta: I have often just added a path to the other project in my source-paths :source-paths ["src" "../my-other-project/src"]
@dnolen, I see—and in that case cljsbuild will pick up the changes? @bhauman yeah, that’s exactly how I’m doing this—the problem I guess is that there is a deps.cljs in that separate project’s source path
didn’t realize that was verboten
@ddellacosta: gotcha
I see
if there’s a better way to be able to include separate projects in the source path so that you don’t have to jump through hoops during development, I’d love to hear it
we just tried it randomly one day to see if it works, and it did, so we kept doing it
otherwise the pain of writing code, installing it, cleaning and recompiling from scratch was too much
especially if what you wrote the first time was not working…a nightmare
@ddellacosta: https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies
should that work for lein cljsbuild? I hasn’t for us in my experience, but I’ll try it again and see
@exupero and you don’t have to add the checkout dependencies explicitly to your main project’s cljsbuild config?
okay, let me try that again and see if it works
@dnolen @exupero yeah, so, as I suspected this is just the same thing all over again just with checkouts:
Exception in thread "main" java.lang.AssertionError: No ns form found in <snip>checkouts/<snip>/src/deps.cljs, compiling:(/private/var/folders/yb/qrynr_s51rvd7l9x3fqqtrfr0000gn/T/form-init4629892169254164810.clj:1:125)
this is a real step backward for development in our large project, unfortunately—back ye old clean, re-install separate project, re-build from scratch flow.
if we are not doing this the right way, would love to know—would be happy to tweak this, just not sure what else to do
ah, I see—that is the magic bit I didn’t realize. Will happily move to resources/deps.cljs
, thanks @dnolen
@dnolen would it be good for me to add that that is the standard location for that here? https://github.com/clojure/clojurescript/wiki/Dependencies
I certainly wasn’t aware, maybe should have been
@dnolen: I’m not sure what that tells me. Can you give me a pointer how to get this working? Tried multiple things but none worked. 😕
@martinklepsch: write the macro twice or once and require it into the expected places
@dnolen: should this work?
/**
* Given a cljs symbol, strip the namespace part.
*/
cljs_browser_repl.views.utils.strip_namespace = (function cljs_browser_repl$views$utils$strip_namespace(sym){
return clojure.string.join.call(null,cljs.core.drop_while.call(null,(function (p1__24688_SHARP_){
return cljs.core.re_find.call(null,/\./,p1__24688_SHARP_);
}),clojure.string.split.call(null,[cljs.core.str(sym)].join(''),/\\//,(2))));
});
cljs code:
(defn strip-namespace
"Given a cljs symbol, strip the namespace part."
[sym]
(string/join (drop-while #(re-find #"\." %) (string/split (str sym) #"\/" 2 ) ) ) )
gives a SyntaxError: expected expression, got ','
@richiardiandrea: I have no idea what I’m looking at
I defined a function with a regex, and when this function is compiled to js, it gives me a SyntaxError: expected expression, got ','
The regex is #"\."
converted to /\./
what am I doing wrong?
it is a regex literal...
In Clojure (JVM) the \
character is special inside a Regex literal.
I am escaping the dot (I want to match it exactly)
I will try in the jvm
So the string "\\."
contains one literal backslash and a dot. The regex #"\."
should match one literal dot.
I don't know if ClojureScript matches this behavior.
@kevinmershon: A more up to date alternative to the Chestnut template? I just use the Reagent template, which is much better. Ripping out the Reagent bits and replacing them with Om takes a minute or so.
I went here: https://regex101.com/#javascript and the /\./
definitely works in Javascript...
@tord I ended up restarting from figwheel after a convincing conversation with @bhauman and @halcyon
(re-find #"\." "this.is.a.thing")
works in ClojureScript (Figwheel REPL) for me.
I'm currently geeking out on how accessible this community is.
@richiardiandrea: you should also in general qualify your environment or everyone is going to get confused
no no, it is in a cljs app this one
you're right
but yes if it works in ClojureScript JVM but not ClojureScript JS it can be assumed to be a bug
and then just report it in JIRA and someone will get around to it eventually or you can take it yourself
works for @stuartsierra in the REPL so I need more investigation 😄
ok tnx and sorry for the noise
What libraries should I look at to build a client/server where multiple clients will be displaying a page, and then from a ‘control’ page can tell one of the clients to display a different page? Based off searching I’m thinking maybe sente for communication between client and server?
@richiardiandrea: It might not be the #”\.” regex, but the second one: (string/split (str sym) #"\/" 2 )
/\\//
is not a valid expression
/\\//
being the resulting JS regex
That's it. (re-seq #"\/" "this/is/a/thing") => #object[SyntaxError SyntaxError: Unexpected token ,]
should work as /\//
in javascript right?
Correct me if I’m wrong (no repl at the moment), but in cljs it should just be #”/“
and it will be escaped correctly
(re-seq #"/" "this/is/a/thing")
=> ("/" "/" "/")
it is converted by the compiler probably
The /
is not a special character in Clojure(Script) regex syntax #""
, so it should not be escaped.
I don't know why that particular error results.
because just ///
is not a JavaScript regex I assumed I needed to escape
@dnolen: The use case is basically: Bunch of TVs displaying dash boards, I want to have a page that can control what each TV is looking at.
@ddellacosta: sorry I missed your last comment earlier. Sure I would add a recommendation. resources
isn’t really a standard location it just on the classpath without being in your sources path.
@ddellacosta: in the wiki I would say “one possible location is …"
no worries. Yeah, that makes sense—will add, and maybe note your point re: why resources vs. elsewhere
Which seems like it shouldn’t be too hard, but not sure about most efficient way to design. Something controlling iframe that has the dashboard maybe?
@mocker: if you’re using sente don’t see why you need to bother - WebSockets should cover you, you can broadcast to the other clients
Dashboards are web based, but already exist. So this would be wrapping around to control them.
@mocker Using cljs to change which URL each iframe points to?
@kevinmershon: Kinda what I was thinking.
That'll work so long as you don't need to manipulate the contents of the frame
If you do, I'd suggest building a browser plugin so you can get elevated privileges in the browser
@kevinmershon: No other way to display external page besides iframe though, rigth?
That depends... If it's just html you could load it in and inject it into your cljs app using ajax. But if it has JavaScript and styles you're going to lose all that
@kevinmershon: Ok, you’ve given me some things to think about.
now I would like to know and print macro call-site location, (meta &form) is nil in my case, any ideas?
I want to print compile-time warning including file location:
(defmacro my-fn [& args]
(binding [*out* *err*]
(println (pr-str (meta &form)))))
@darwin you might have to experiment a bit here, not sure why you wouldn’t get line col information
I thought it is because my macro is expanded as a result of another macro expansion, but that is not the case, even top-level macro does not get meta info