r/Clojure • u/dustingetz • May 24 '20
We did it reddit
https://twitter.com/ChromeDevTools/status/12636066540981207078
u/didibus May 24 '20
What do custom formatter do for ClojureScript?
13
u/lucywang000 May 25 '20 edited May 25 '20
People use console.log to print things when debugging js in web applications
console.log(["a", "b", "c"])Or in cljs:
(.log js/console [:a :b :c])But on its own chrome devtools console doesn't understand clojure objects like maps/lists/vectors, so by default it would print the internal representation of the vector (a js object) which is meaningless, and a pain for cljs devs.
Then it turns out that chrome provides a plugin mechanism to allow registering "custom formatters" to pretty print your objects in your own way. So here comes our great tool cljs-devtools that makes use of this feature to make cljs dev a lot easier. And cljs-devtools has thus becomes a standard weapon in most senior cljs developer's magazine. Shadow-cljs would even automatically set it up for you if it finds cljs-devtools in your project's dependencies list.
screenshot comparison w/ and w/o custom formatters
The custom formatter feature is also used by others like immutable-js.
However this could be a potential security risk (see the links for details), thus chrome team has been thinking about remove support for custom formatters.
And for now luckily it's held back due to community feedback.
For those interested in cljs dev, also take a look at dirac from the same author of cljs-devtools. It allows you to insert browser breakpoints directly at cljs level and evaluate cljs expressions in devtools console like a breeze. The only downside is it doesn't play well with shadow-cljs last time i checked it out.
9
u/twitterInfo_bot May 24 '20
"Don't worry, folks. We backtracked on the proposal to remove Custom Formatters thanks to your overwhelming feedback! "
posted by @ChromeDevTools
media in tweet: None
1
u/cbleslie May 24 '20 edited Sep 12 '25
gaze paltry snatch mighty reach dolls spotted march fragile wrench
This post was mass deleted and anonymized with Redact
2
u/activeXray May 25 '20
Now y’all should use that same enthusiasm to bump the issue on bugzilla, so us Firefox users can get it too. https://bugzilla.mozilla.org/show_bug.cgi?id=1262914
17
u/stingraycharles May 24 '20
Just wanted to add that “we did it, Reddit!” is a reference to the time that Reddit (incorrectly) found the Boston marathon bomber, who ended up committing suicide. It’s not a positive reference at all.
Backstory here: https://www.reddit.com/r/OutOfTheLoop/comments/34oirt/what_was_the_we_did_it_reddit_incident_and_who/