Fork me on GitHub
#vim
<
2018-09-18
>
rgm16:09:11

I’m hoping someone can help me understand a bit of the piggieback docs with respect to setting up through fireplace and accommodating foreign libs:

rgm16:09:13

> When using Piggieback to enable a browser REPL: the ClojureScript compiler defaults to putting compilation output in out, which is probably not where your ring app is serving resources from (resources, target/classes/public, etc). Either configure your ring app to serve resources from out, or pass a cljs-repl :output-dir option so that a reasonable correspondence is established.

rgm16:09:07

so at the repl I’m manually instantiating an nrepl, spitting out .nrepl-port OK, evaluating fine through fireplace as long as it’s CLJ

rgm16:09:52

I’m using figwheel, and starting that up OK via (figwheel.main.api/start "dev") (using a dev.cljs.edn at my project root)

rgm16:09:37

browser’s working at this point

rgm16:09:02

next, in vim :Piggieback (figwheel.main.api/repl-env "dev") succeeds

rgm16:09:35

and I can eval (js/alert "WHATUP?") and see it in the browser

rgm16:09:47

now the twist:

rgm16:09:58

I’m using reagent, but React is coming in through a foreign-lib (using the clojurescript-webpack setup on http://clojurescript.org) and so I’m excluding from the reagent dep, ie. reagent {:mvn/version "0.8.1" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server cljsjs/create-react-class]}

rgm16:09:33

and if my vim buffer is in a namespace that requires reagent, the Fireplace eval blows up with clojure.lang.ExceptionInfo: No such namespace: react, could not locate react.cljs, react.cljc, or JavaScript source providing "react" in file file:/Users/rgm/.m2/repository/reagent/reagent/0.8.1/reagent-0.8.1.jar!/reagent/core.cljs {:tag :cljs/analysis-error} (and long stacktrace follows)

rgm16:09:25

note that figwheel’s clojurescript compile is picking up the foreign-lib react just fine (evidence: the browser app works, and using a cljs-repl outside vim can eval within namespaces and the browser picks up the results, eg. if I do a re-frame dispatch I see the UI change appropriately)

rgm16:09:51

it just seems like Piggieback doesn’t know about the foreign libs, so I’m wondering if it doesn’t know to look at target/public/cljs-out/dev for build products

rgm16:09:33

So, finally, my actual distilled question (apologies):

rgm16:09:31

Can I configure piggieback somehow to look at Figwheel’s build dir target/public/cljs-out/dev, or is it better to change Figwheel to put the build products where piggieback seems to require them to be? (ie. out/)

rgm16:09:29

(btw huge thanks to whoever wrote this guide to vim in the figwheel-main repo docs: https://github.com/bhauman/figwheel-main/blob/master/docs/docs/vim.md)

❤️ 4
thiru21:09:11

That was me thanks! 🙂

thiru21:09:42

Hope everything else worked out for you. I'm pretty new to Clojure as well so haven't come across the issue you were having

thiru21:09:07

bhauman is pretty active here in slack so you may want to ping him on #figwheel-main