This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-18
Channels
- # aleph (7)
- # announcements (11)
- # beginners (186)
- # calva (17)
- # cider (26)
- # clj-kondo (4)
- # cljdoc (12)
- # cljs-dev (3)
- # clojars (1)
- # clojure (105)
- # clojure-berlin (1)
- # clojure-chicago (1)
- # clojure-dev (34)
- # clojure-europe (3)
- # clojure-italy (4)
- # clojure-nl (27)
- # clojure-russia (19)
- # clojure-uk (25)
- # clojuredesign-podcast (4)
- # clojurescript (54)
- # cursive (6)
- # data-science (1)
- # datascript (11)
- # datomic (5)
- # emacs (3)
- # events (2)
- # fulcro (13)
- # graalvm (5)
- # jobs (15)
- # leiningen (7)
- # luminus (3)
- # melbourne (1)
- # nrepl (1)
- # nyc (2)
- # onyx (4)
- # pathom (6)
- # pedestal (18)
- # re-frame (19)
- # reagent (10)
- # shadow-cljs (27)
- # spacemacs (32)
- # sql (11)
- # tools-deps (35)
- # vim (50)
@dnolen I created a minimal example with the bug here: https://github.com/talgiat/cljs-spec-bug. Can’t open a bug in cljs jira (don’t have permission to do so).
you can file bugs without an account here: https://clojure.atlassian.net/servicedesk/customer/portal/1
they'll go into the triage queue and we'll turn them into a ticket
Is there a good way to turn a DOMRect object into map, without having to list all the attributes?
thanks @alexmiller reference is SUPPORT-25 (https://clojure.atlassian.net/servicedesk/customer/portal/1/SUPPORT-25)
I'm trying to use the :global-exports
feature of foreign-libs and having trouble in this case:
:provides ["@foo/bar"]
:global-exports '{@foo/bar Bar}
because @foo/bar
is not a valid symbol of course and if I put a string instead, that gives me an error 'sym is required'. I'd guess this is a bug, but please let me know if there's something I'm missing. thanksSo I think I found a bug in the compiler, and made a fix that works for me - but unsure it is the right way to fix:
https://github.com/jamesmintram/clojurescript/commit/e70e5159d2c58e53d0dfdf89f386722ed110c586
My app.js had the following in it:
document.write('<script src="target\public\cljs-out\common/goog/deps.js"></script>');
document.write('<script src="target\public\cljs-out\common/cljs_deps.js"></script>');
document.write('<script>if (typeof goog == "undefined") console.warn("ClojureScript could not load :main, did you forget to specify :asset-path?");</script>');
document.write('<script>goog.require("figwheel.core");</script>');
document.write('<script>goog.require("figwheel.main");</script>');
document.write('<script>goog.require("figwheel.repl.preload");</script>');
document.write('<script>goog.require("devtools.preload");</script>');
document.write('<script>goog.require("figwheel.main.css_reload");</script>');
the .cljs.edn file had the following setting: :output-dir "target\\public\\cljs-out\\common"
(this is on Windows)
I'll add that deps.edn made it super easy to download local copies of figwheel and clojurescript + tweak/add debug statements as required.
I’m looking for help on JS interop, specifically making sure that things also work under advanced compilation. I have found several things at play here, but I don’t understand what each of them do and when/which to use:
- ^js
type hints
- goog.object
- cljs.oops
- mfikes new bean
library
Is there any documentation that ties this all together? Also, when I find certain things not working, how do I approach debugging this? I’m sprinkling ^js
throughout my code atm, and that seems to improve things, but I don’t know if that’s the right way to go.
(I don’t think it really matters, but this is a shadow-cljs based react-native clojurescript project)
usually the first question asked when this stuff happens is for you to give an actual problem statement. are things currently not working under advanced compilation?
https://clojurescript.org/reference/compiler-options#pseudo-names and this can help with reading the advanced output
Sure, I’ll give a concrete example, but I’m really looking for general principles more than solutions to specific problems. Like: can I use normal JS interop at all safely? E.g. some react native component calls my callback with a JS object as a parameter and I use normal JS interop notation to access it. Is that OK? Must I include ^js
? Is that sufficient? Specifically as an example:
(defn cell [^js details]
(let [item (.-item details)
...))
(defn Staff [styles]
[:> rn/View styles
[:> rn/FlatList
{:data ^js @view-model
:extra-data ^js @cursor-info
:key-extractor (fn [item _] (str (.-measureNumber item)))
:horizontal true
:Cell-renderer-component ViewOverflow
:List-header-component #(r/as-element [header])
:List-footer-component #(r/as-element [footer])
:Item-separator-component #(r/as-element [separator %])
:render-item #(r/as-element [cell %])}]])
in this case (.-item details)
that will result in details.item
in the code. the closure compiler may decide to rename this to something shorter. the ^js
hint will cause externs to be added that will prevent the renaming of the .item
property (which you need for JS interop)
Can I infer from that that normally I don’t need to use something like bean
or cljs.oops
or goog.object
directly?
Is there tooling that can warn me about missing ^js
type hints? I have run shadow-cljs check
but that doesn’t catch everything.
Ahh now I read that again it starts to make sense, last time I read it, it didn’t yet 🙂
So as an example, it says:
153 | :key-extractor (fn [item _] (str (.-measureNumber item)))
---------------------------------------------^----------------------------------
Cannot infer target type in expression (. item -measureNumber)
-
I change that to:
:key-extractor (fn [^js item _] (str (.-measureNumber item)))
That seems to fix the warning.well the warnings aren't 100% accurate so you may get warnings and add typehints when they aren't actually needed
And cljs-bean
is then probably more like a convenience thing to simplify destructuring JS objects and things like that?
(sorry to have mislead earlier. I'm learning new stuff. thanks @stefan.van.den.oord)
Thanks @thheller, extremely insightful and helpful as always. I’ll keep the donation on Patreon active for a while longer 😛
Hello! Trying to run cljs tests either directly with phantom ....js either thru lein doo there is same error ReferenceError: Can't find variable: Map
I find out many things about it in internet, but all of them are not with clojure. What shoud I do?
I find a lot of examples how to add polyfils , but all of them are in js/ts/etc. How and where I can do it in cljs project?
but maybe there is another way for headlesstesting cljs from command line for CI? not unworked phantom, but maybe another V8 source? And not node either