This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-07
Channels
- # announcements (11)
- # architecture (2)
- # babashka (84)
- # beginners (226)
- # calva (7)
- # chlorine-clover (4)
- # cider (29)
- # clara (17)
- # clj-kondo (23)
- # cljs-dev (58)
- # cljsrn (60)
- # clojure (172)
- # clojure-europe (24)
- # clojure-finland (2)
- # clojure-italy (6)
- # clojure-nl (8)
- # clojure-spec (4)
- # clojure-uk (22)
- # clojurescript (44)
- # conjure (39)
- # core-async (64)
- # cursive (76)
- # data-science (15)
- # duct (3)
- # emacs (2)
- # events (5)
- # fulcro (30)
- # helix (4)
- # jackdaw (5)
- # juxt (1)
- # kaocha (1)
- # leiningen (4)
- # off-topic (9)
- # pathom (22)
- # re-frame (9)
- # reagent (33)
- # reitit (3)
- # ring (10)
- # ring-swagger (2)
- # shadow-cljs (192)
- # spacemacs (27)
- # specter (2)
- # sql (59)
- # vim (2)
Anybody have an example of building a cljs app with :optimizations :advanced that avoids externs by using cljs-oops to call a function imported from an es6 module pulled from npm?
I’m compiling my project with :bundle
target and advanced optimisations. I’m getting an error from sente usage, where the statement
(.setTimeout goog/global connect-fn backoff-ms)
is compiled so that goog/global
becomes aa
and fails on no setTimeout
. Is this something that’s supposed to “just work” with externs inference?Out of curiosity, what is goog/global
? I have never seen it before.
If it is something from the Closure library then the closure compiler should understand and not mess it up and rename all its occurences ok? Or did you perhaps mean js/myGlobalVar
?
OK, found it here https://google.github.io/closure-library/api/goog.html#global
This is something from the Closure lib so it is really weird that the compilation screws it up. Your only hope is @dnolen , @U04VDQDDY or one of the other allmighty clojurescripters. I guess it is OK that the compiler renames goog/global to aa
but the fact that it then fails to call setTimeout on it shows that the renaming has not happened everywhere. How is that possible, for a Closure library's own var, I have no idea.
Hello! Any idea if there is a way in transit-js to get it output bigdecimals in a nicer way than [TaggedValue: f,123.45]
when I (str bigdec)
it? The stringification is defined here https://github.com/cognitect/transit-js/blob/master/src/com/cognitect/transit/types.js#L43 I do not see a way to do that... 😞 Perhaps I could try to replace types.TaggedValue.prototype.toString
with something smarter...
and I'm not really sure that is supposed to work? since the type of goog.global
can't be known by Closure Compiler it perhaps can't infer that it is in fact Window
or something else
js/setTimeout
is preferred I would say. The global require stuff I'm thinking about for the next release would clean this up a bit - but effectively result in the same thing but without having to explicitly handle goog/global
references in your file.
@dnolen didn't you add a define to address this. so that it sets goog.global = window
or something?
@dnolen ok. This code is inside https://github.com/ptaoussanis/sente. I tried to add an extern, but no go, I’m probably not doing it right. My attempts were
goog.prototype.global {}
and
var goog {
global: function() {}
}
no... this has nothing to do with externs. goog.global
just isn't what you think it is and doesn't have setTimeout
. @ingesol you need to configure the closure-define so that it uses window.
ah, ok. My inferred externs already contain Window.prototype.setTimeout;
and `
var setTimeout;
right, but I like said above, this level of config over js/setTimeout
doesn't seem that meaningful
actually the closure library itself uses goog.global.setTimeout
instead of setTimeout
IIRC
ah true, if the problem here is that goog.global
is just wrong period, then @thheller suggestion is best
normally goog.global = this
will use window
as the this when the script is loaded but after webpack is done with it it won't be. so need to make sure to set it to window manually.
@dnolen @thheller Thanks, the closure-defines snippet seems to have moved me one step forward on this journey towards a successful advanced bundle build
When done, consider please updating the relevant guide(s) / pages for us others!
I wonder if the new bundling stuff means you could progressively introduce cljs into a typescript app
Dear community, greetings to all of you. I started my Clojure endeavour a while ago, mostly I was reading books, but recently first time I had an opportunity to actually try Clojurescript on the simple single page app. So far so good. Didn't thought I will need help but turns out I do. I am not going to lie my brain is getting slightly damaged, and this is what puzzles me: Goal is simple, - use WebSockets to send commands to the end-point (written in Python, I have no control of it) and get responses back. Nothing fancy. Basic code snippet:
(def socket (js/WebSocket. ""))
(def data {:command "cmd" :sequence_number 1})
(defn clj->json [ds] (.stringify js/JSON (clj->js ds)))
(.send socket (clj->json data))
In REPL works as expected, sending JSON over the WebSocket. Great. Python (end-point) can read JSON and produce dictionary. BUT In Browsers Chrome/Safari produces
#error {:message "Invalid keyword: .", :data {:type :reader-exception, :ex-kind :reader-error}} edn.cljs:420
If I do
(.send socket (pr-str (clj->json data)))
it works but end-point not able to parse JSON into Dictionary "json.load" (python function) produces the string, it is not acceptable.
I am doing something very stupid probably and solution is very obvious. Could you please point to the right direction? It is really a blocking issue to me. FYI: My desire is not to install any other libraries for WebSockets and keep it simple and minimal.@sfyire wasn't intended for that but I don't see why not. there might be some missing bits to make that work a little better - i.e. referencing local JS files - I believe we really only look at node_modules
- not super high priority since it's still my impression this is much smaller use case demographic