Fork me on GitHub
Atiq Gauri03:02:03

@thheller I have created source map for this template starter project: config:

{:main {:target :node-script
                 :main app.main.core/main
                 :compiler-options {
                                   :source-map true
                                   :source-map-include-sources-content true
                                   :source-map-detail-level :all}
                 :output-to "x/main.js"}
shadow-cljs version: 2.11.15 generate file main.js works fine with your clojure function written here: here are those sourcemap: Sentry has this open source sourcemap validator: (I need sourcemap to work with I get this strange error 1. while uploaded main.js 2. while uploaded


sorry I cannot debug sentry for you. it most likely is the problem with the source-map npm lib that everything JS based uses. you already linked the problem issue.


Hi all, was hoping i could get a hand with something. I’m using reagent and I’m trying to add a class to the the form-group div if there is an input value available. something like this:

[ui/form-group {:label          "Email"
                :id             "login-email"
                :name           "email"
                :type           "email"
                :class          "(.-value ? 'some-class-here' : '')".    <------How to do this 
                :required       true
But not quite sure how this logic works. I’ve tried using something like [(when .-value? "some-class-here")] but that doesn’t seem to work either. Any help would be much appreciated.


What is ui?


In general, you store the class or the value in some reagent.core/atom with some :on-change handler and use that value to determine what you pass to :class.


Thanks for the responses @U2FRKM4TW, turns out someone else on the team had a different suggestion and we ended up going with that. I appreciate you taking the time to respond. Have a great day.

👍 1

@cap10morgan Didn’t try :target :bundle yet for webworkers, but I think it should work to build webworkers with it, if you have the :bundle-cmd doing the right thing. so no probably no need for :target :webworker in that case


Ah, OK. I’ll investigate that route. Thanks!

Fredrik Andersson11:02:48

is there pretty print alternative to println? I would like to be able to inspect clojure data in the browser console

Fredrik Andersson11:02:37

found it in cljs.pprint 🙂


I do [:pre (with-out-str (pp/pprint x))] But there is tap>, if you are using #shadow-cljs , you can see the result's pprinted and clicable at localhost:9630 There is the cljs-devtools, that when you enable custom formatters on chrome, you can do (js/console.log x) and it will show on console pprinted


If it's only for the browser console, then you should absolutely check out and

Fredrik Andersson13:02:37

ok ill look them up thanks!


Just had a very unpleasant manifestation of the Mandela effect - apparently, ^ in NPM versions means "with the same left-most non-zero digit" (not even "same major", which is confusing by itself) whereas I was adamant that it meant "the exact same version".

Yehonathan Sharvit13:02:43

What is the fastest way (in terms of CPU time) to parse a JSON string into a CLJS map where the keys are keywordized and transfomed to kebab case?


It wouldn't surprise me if e.g. Chromium and FireFox require different approaches to achieve that.

Yehonathan Sharvit14:02:26

What makes you think so @U2FRKM4TW?


Because I've seen plenty of algorithms where different implementations perform differently (sometimes drastically so) in different browsers.

Yehonathan Sharvit15:02:15

Good to know. Anyway, how would you handle it?

Yehonathan Sharvit15:02:53

Right now, I do it via (-> js/JSON.parse js->clj) and the walking recursively over all the keys


js->clj is probably the slowest thing. If you need just a subset of keys, you can simply use aget with goog.object or or some other interop library. If you need all the data, you can write your own version of js->clj that focuses on the values that can be in JSON and converts all the keys in the process, without any intermediate steps.


If you really care about performance, you should employ the scientific method to come up with the best result. And don't forget to test across all the platforms that will end up running that code.

Yehonathan Sharvit16:02:16

I need all the data

Yehonathan Sharvit16:02:42

I was hoping that there would be a lib out there that addresses this (common?) use case.


Not that common, I think. As far as I can tell from passive observations, the following cases are much more common: - Not caring about the performance - Avoiding JSON altogether (transit is a great choice) - Not converting anything - just using JS objects via interop Can you share your particular use-case that has that need that you described?

Yehonathan Sharvit18:02:34

We communicate between fronted and backend over JSON

Yehonathan Sharvit18:02:04

The payload is big in some cases. That’s why we care about perfs


And that's why we have transit. :) I understand though that sometimes JSON is more preferable. But, as I mentioned, I don't think such use-case is that frequent. In any case, an obvious solution to your problem is a function that's about 10-15 lines long.


20-30 if you add key caching.

Yehonathan Sharvit07:02:02

You mean a function that parses a JSON string or a function that parses the result of JSON.parse?


The latter.


I wouldn't implement my own JSON.parse - it's highly optimized in browsers, you just can't get on that level of performance from the JS level.


@U0L91U7A8 do you really care that it’s ClojureScript data structures or might it be enough to get something that behaves somewhat similarly like


Why does ClojureScript jar include an AOT'ed version of,, and cognitect.transit? At least, 1.10.773 one.


Ideally, these would really be shaded, but they're not


I see. Thanks!


Is this a known/intentional difference between clj and cljs:

(println (keyword 'sym)) ; clj and cljs both print :sym
(println (symbol :kw)) ; clj prints kw (as a symbol) but cljs throws an exception

;; cljs throws
var idx = name.indexOf("/");

TypeError: name.indexOf is not a function


What version of CLJS are you using?


I can reproduce it with 1.8.40 but cannot with 1.10.773.


Not a recent enough one, apparently! I updated my test runner from 3.7.0 to 3.8.0 which pulled in a more recent cljs version and now it works.

👍 1

Looks like it was using org.clojure/clojurescript {:mvn/version "1.10.520"} before.


Hmm, must have been older than that... since this also works on 1.10.520.


Should've worked even with that one, given that "CLJS-2958 - make symbol work on keywords and vars" was ostensibly shipped with 1.10.516. But it's probably not that important, given that you got it working now.


Ah, right.


Ah, thanks for finding the change!


that's a 1.10 feature in clj (and cljs)


Yeah, I realized that I needed to back off to (symbol (name kw)) anyway for Clojure 1.9 compatibility (this is for HoneySQL v2).


Thanks for the :target :bundle webworker pointers, @dnolen and @kommen. I got it working! Going to submit a PR in case it's helpful for others.


cool, curious to see what you came up with


@kommen Let me know if any of that doesn't seem right or I've left out anything important.