This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-25
Channels
- # bangalore-clj (5)
- # beginners (225)
- # boot (36)
- # cider (1)
- # clara (2)
- # cljsjs (1)
- # clojure (76)
- # clojure-belgium (1)
- # clojure-conj (1)
- # clojure-india (4)
- # clojure-italy (5)
- # clojure-korea (1)
- # clojure-russia (22)
- # clojure-spec (35)
- # clojure-uk (52)
- # clojurescript (67)
- # community-development (17)
- # core-logic (2)
- # cursive (2)
- # datascript (28)
- # datomic (44)
- # emacs (1)
- # funcool (3)
- # hoplon (14)
- # lein-figwheel (2)
- # leiningen (2)
- # luminus (3)
- # midje (3)
- # mount (2)
- # nyc (2)
- # om (54)
- # om-next (1)
- # onyx (30)
- # re-frame (57)
- # reagent (19)
- # ring-swagger (23)
- # slack-help (10)
- # spacemacs (2)
- # specter (1)
- # vim (23)
I'm trying to run lein-cljsbuild
on my project, but I'm encountering an error during the macro (clj) compilation step which implies that namespaces are getting reloaded in the wrong order. On the classpath I have files instaparse/core.cljc
depends on instaparse/gll.clj
depends on instaparse/auto_flatten_seq.cljc
. In all three of those files, I put debugging println's like so:
(println "begin my.ns")
(ns my.ns
...)
(println "loading my.ns")
and the output looks like:
Compiling ClojureScript...
begin instaparse.gll
begin instaparse.auto-flatten-seq
loading instaparse.auto-flatten-seq
loading instaparse.gll
begin instaparse.gll
loading instaparse.gll
begin instaparse.auto-flatten-seq
loading instaparse.auto-flatten-seq
begin instaparse.core
loading instaparse.core
Reloading Clojure file "/instaparse/core.cljc" failed.
clojure.lang.Compiler$CompilerException: java.lang.ClassCastException: instaparse.auto_flatten_seq.AutoFlattenSeq cannot be cast to instaparse.auto_flatten_seq.AutoFlattenSeq, compiling:(core.cljc:284:14)
Am I correct that this is bad behavior?
The reason this error is occurring is because auto-flatten-seq
is getting reloaded without gll
getting reloaded afterwards. I can reproduce that same error by executing cider-load-buffer
in my editor, in that bad order.
In comparison, running lein test
(i.e. using the regular clojure compiler) results in:
begin instaparse.core
begin instaparse.gll
begin instaparse.auto-flatten-seq
loading instaparse.auto-flatten-seq
loading instaparse.gll
loading instaparse.core
which I would expect.how can I refer to a global like js/Stripe
that does not break when the global is not defined? I want to pass it to something that will eventually run (exists? js/Stripe)
@mccraigmccraig I see, thanks. Had hoped for something in the stdlib but well...
maybe there is something - i couldn't find it at the time
couldn't find something either haha
I now went with a different API that takes a fn like #(exists? js/Stripe)
instead of just the global
asked for this post: https://www.martinklepsch.org/posts/just-in-time-script-loading-with-react-and-clojuresript.html — small guide to loading scripts when you need them using higher order components
@borkdude I find the default behavior very weird tbh
@aengelberg why are things getting reloaded while compiling? does your ns
have a :reload
flag?
@martinklepsch you could also turn js/Stripe
into a prop instead of a global. for your example [thing-that-uses-stripe {:stripe js/Stripe}]
@thheller is that meant as an improvement or different approach?
I think you usually don't want to pass complex objects as props
Yeah, I think stylistically it's nice and might be handy for testing but it felt a bit out of scope in this particular post
[js-loader {:scripts {#(exists? js/Stripe) " "}
:loading [:div "Loading..."]
:loaded [payment-form]}]
also you can probably skip the #(exists? js/Stripe)
check and just check whether "
completed loading or not
@thheller but then I end up with state vs. a simple fn? 🙂
@thheller I'm not sure I'm following about the "eval'd at the wrong time" they are only turned into components if they're actually supplied as part of some :reagent-render
fn; no? Until then they should be just vectors?
I see what you mean, yeah, didn't take that into account
Stripe will log a warning if you load it twice btw
I get this exception after updating to ClojureScript 1.9.293. Anyone know what this is about?
clojure.lang.Compiler$CompilerException: java.lang.Exception: namespace 'cljs.source-map' not found, compiling:(cljs/compiler.cljc:9:1)
java.lang.Exception: namespace 'cljs.source-map' not found
@pesterhazy probably a tooling issue, did you try lein clean
first?
Is there videoplayer, which works nicely with clojurescript?
Especially Reagent
@danielgrosse youtube and vimeo both have iframe based players which work fine with reagent
I need a self hosted player
for what platform/s ?
@thheller, I'm using boot, so there are no temp files to clean up. Any deps I should look at?
@pesterhazy have you checked boot show --pedantic
just in case?
works with .89 by the way
@martinklepsch, I get a couple of red Xs, what should I be looking for? clojurescript is not among them
Modern Browser. IE10 and higher
@pesterhazy mostly if clojurescript is among them ;D
@pesterhazy maybe try tenzing with the same versions to see if it's a more general issue with boot-cljs and recent versions of cljs, there's nothing in the issue tracker though so I'd expect things to work
is there a list of stable releases somewhere? https://github.com/clojure/clojurescript/blob/master/changes.md doesn't distinguish stable from unstable
I think releases announced on the mailinglist are considered to be stable
makes sense
@knaman you could map over the vector with a function that replaces a thing if it matches. Whatever you do you don't get around the fact that you need to traverse the entire vector
@knaman I made this a while ago which sort of goes in that direction as well: https://github.com/martinklepsch/custom-comparator-set
@martinklepsch "a thing" my new map is 99% different from the original one, is there no way to just say use this map in place of the old one
@knaman there's replace
there's a JS engine in the JVM, isn't there? Does anybody know if it runs CLJS correctly?
@gfredericks Yes, Rhino (old one) and Nashorn. Rhino can be used for repl and Cljs compiler includes tests for Nashorn, so both should work.
Ok cool, thanks
@thheller: No, no :reload
flags as far as I know, which is why I'm concerned the cljs compiler isn't doing the right thing.
@aengelberg There is a known issue that libraries listed ClojureScript namespace forms are not processed in the textual order implied by the code, but it looks like you are off in Clojure ordering with the macros.
@mfikes: Yeah, it seems like the errors I'm encountering is purely the "Clojure half" of the ClojureScript compiling process.
Does cljsbuild
do anything weird regarding loading clj/cljc files that's different from the regular Clojure compiler?
I've been using cljsbuild & cljc in the test.check codebase for a while haven't noticed anything too weird