Fork me on GitHub
#shadow-cljs
<
2022-05-27
>
rayat18:05:35

How can I get a REPL JS Runtime connection if my stack looks like ( shadow cljs ➡️ `webpack` ➡️ `storybook web app` ) ?

thheller18:05:18

just need to manually require("./path-to-output/shadow.cljs.devtools.client.browser") in the JS somewhere

thheller18:05:24

assuming you are using :target :npm-module

thheller18:05:42

no guarantee the REPL works at all though, better just use shadow-cljs browser-repl without webpack or storybook

rayat18:05:48

1. Thanks so much for the rapid response, let alone for like single-handedly making shadow-cljs lol. 2. Going to try your first option, as it is :npm-module. 3. I apologize, but I am unsure what your suggestion means with "better just use ... without webpack or storybook", could you clarify?

thheller18:05:47

do you specifically need a repl into the storybook? or do you just want a repl?

rayat18:05:32

I suspect the latter, I think? Still new to clj/s, but I mainly want REPL-powered IDE language features

thheller18:05:18

then browser-repl is enough

1
👀 1
lilactown18:05:59

basically when you jack in, you'll pick the browser REPL option which will open a new window that all your REPLing will run in

lilactown18:05:10

outside of the built storybook site

lilactown18:05:49

the downside is you might not have all of the namespaces loaded that are in the storybook build by default, but you can eval them manually to get your tooling to pick it up

rayat21:05:44

Reporting that I got it working via both the browser REPL + "with storybook", in the sense that for the latter: 1. It doesn't "connect" to the browser devtools console, all eval results print to the storybook watcher Thanks so much, you two. Now ( maybe related? ) would you have any tips, @U05224H0W for getting binaryage/cljs-devtools (or similar) custom formatting working within the storybook page/console? I tried reading around the shadow docs, and I don't know the difference between binaryage's cljs-devtools / devtools libs nor if the references to them matter for the shadow -> webpack -> storybook flow. I imagine it'd be a similar task to above, where I'd have to require the right module?

thheller21:05:40

the problem is that :npm-module builds don't have a clear entry point. so there is no place for shadow-cljs to enforce loading of certain namespaces

thheller21:05:59

so somewhere on the JS side of things you need to require the proper namespaces

thheller21:05:34

so somewhere require("./path-to-cljs-output/devtools.preload.js")

thheller21:05:05

and if you want to try a REPL require("./path-to-cljs-output/shadow.cljs.devtools.client.browser.js")

thheller21:05:08

where I cannot tell you

thheller21:05:22

I believe there are config files in storybook you can use for that

rayat21:05:25

Ah, I think we have good entry points for that. So, it's the preload file you listed, and not something like the binaryage/cljs-devtools https://github.com/binaryage/cljs-devtools/blob/master/docs/installation.md#install-it-manually? And this is to get custom formatting working, right?

rayat21:05:30

Thanks again for the quick response

rayat21:05:08

Trying my listed approach I get NOT installing CLJS DevTools 1.0.6 under advanced build. See . But I'm running shadow-cljs watch :stories, with these shadow configs:

:stories {:compiler-options {:optimizations :simple}
                    :devtools   {:console-support true
                                 :enabled  true
                                 :preloads [binaryage/cljs-devtools]}
                    :entries    [amperity.storybook.core]
                    :output-dir "out"
                    :target     :npm-module}

thheller21:05:41

it may not be detecting the storybook output

thheller21:05:59

you can try to require(".../shadow.cljs.devtools.client.console") instead

thheller21:05:25

sort of my own trimmed down version of cljs-devtools. thats too noisy for me so I made something less invasive 😉

rayat22:05:38

Hm... any clue why it thinks it's in advanced mode?

thheller05:06:12

no idea sorry