r/Clojure • u/thheller • Oct 24 '19
Introducing shadow-cljs Inspect
https://clojureverse.org/t/introducing-shadow-cljs-inspect/50123
u/straightOuttaCrypto Oct 24 '19
I'm curious about shadow-cljs but basically don't understand if I can (and should) use it. I'm on the Emacs/CIDER side of the pond and doing Clojure/Clojurescript using reframe and figwheel (so backend in Clojure, front end in ClojureScript inside a browser).
Can I somehow integrate shadow-cljs in my workflow and what would I gain?
7
u/thheller Oct 24 '19
You'd basically replace figwheel with shadow-cljs for building your ClojureScript. You'd gain things like Inspect and the npm integration while still keeping all the hot-reload and REPL related things.
shadow-cljs works a bit differently though so it may take a bit of time getting used to the differences.
You can keep your current setup and just add shadow-cljs separately to try it out. This should require very little to no code changes, kinda depends on how much you "customized" your build setup.
1
u/CapableWeb Oct 26 '19
You can keep your current setup and just add shadow-cljs separately to try it out
Interesting! One of the reasons why I myself haven't even looked into shadow-cljs yet is because it looks like you need to adopt it wholesale, otherwise you wouldn't have any use of it (another reason is that we don't really use npm libraries in our cljs project).
I quickly scanned the GitHub project/website/blog for some more information on how to include it separately, but couldn't find anything.
Do you have any pointers to more information on this?
1
u/thheller Oct 26 '19
I'm not sure what you mean by "adopt it wholesale"? It will run happily alongside
leinordeps.ednor integrated with them.I tried to document things as best I can ... I can't really add to that, only maybe repeat it here. If you have any specific question I'm happy to answer but I don't know anything about what you are doing so there are no "generic" instructions I can give.
Maybe try a sample template or the quickstart to get a feel for how things work?
10
u/danielneal2 Oct 24 '19 edited Oct 24 '19
Just want to say thanks for making this - as a mainly ClojureScript / React Native dev at the moment, I'd been eyeing REBL with envy, as I go around accidentally printing my re-frame db to the console, struggling to navigate complex nested datastructures, sticking printlns everywhere. This worked straight away when I tried it - just added the :preload in to my shadow-cljs.edn and there it was on localhost:9630. Navigating the full re-frame database worked super fast thanks to the lazy/minimal approach to sending info of the wire. A giant leap forward for debugging cljs apps, and a great job!
1
u/CapableWeb Oct 26 '19
Not sure how helpful this will be, but I'm developing a ClojureScript application where the app-db tends to be a huge monster to inspect as well.
What I ended up doing, was implementing my own inspect view that can be enabled by either setting a value in localStorage or by keyboard shortcuts (entering the Konami code anywhere). Once enabled, the Inspect view is a drawer that covers 30% of the screen by default but when hovering, covers the full screen. In the inspect view, I print out the
app-dbwith(-> cljs.pprint/pprint with-out-str)+ a selector that can be inputted in a text input. Also adding a button to copy/paste the currently selected slice of the state from/into the app-db.While it's great to be able to have shadow-cljs inspect available on a different port while in dev, I've found it super helpful in understanding bugs related to the state in production, as we ship the application with our custom inspect view still available in production.
4
u/1xltP3mgkiF9 Oct 24 '19
Amazing :). Do you consider adding some support for extending the views e.g. with some visualizations?