figwheel-main

figwheel-main http://figwheel.org
EmmanuelOga 2020-02-06T04:18:10.085700Z

Ok, the solutions I think I found.... 1) I still don't know, but I saw when cider launches a repl it uses nrepl-cmdline which seems to be saving the port a file on the root of the project (.nrepl-port) https://github.com/nrepl/nrepl/blob/be37e0ebd13c2d341bf6a7bcd5735da45b78f909/src/clojure/nrepl/cmdline.clj#L403-L413

EmmanuelOga 2020-02-06T04:18:49.086100Z

2) I thin figwheel launches a single nREPL server, the cmds to cljs or clj are "redirected" through the use of the piggieback middleware, so I shouldn't try to run two nREPLS

EmmanuelOga 2020-02-06T04:18:58.086300Z

3) is basically answered by 2).. 🙂

EmmanuelOga 2020-02-06T04:20:51.086700Z

founds this project that solved the cider-jack-in-clj&cljs debacle for me: https://github.com/EmmanuelOga/deps-cider-cljs-reagent

EmmanuelOga 2020-02-06T04:21:33.087100Z

the "secret sauce" seems to be the config on .dir-locals.el, which customize the way cider launches the repl: https://github.com/EmmanuelOga/deps-cider-cljs-reagent/blob/master/.dir-locals.el

EmmanuelOga 2020-02-06T04:22:47.087500Z

it instructs cider to use the -A:cider alias cmd, and in deps.edn there's a corresponding alias that enables figwheel. There's also config to automatically select a repl of figwheel-main type and the dev build.

EmmanuelOga 2020-02-06T04:23:09.087700Z

sigh, that was a lot to write. Hopefully it will help someone, maybe not 🙂

pyrmont 2020-02-06T05:43:33.088500Z

You should put this on a blog (or just a Gist)! It's useful information.

EmmanuelOga 2020-02-06T08:20:40.088700Z

ah, good point, will do 🙂

aisamu 2020-02-06T12:18:15.088900Z

> how do you do that with figwheel? Just like you'd do in a regular, non-figwheel project. Figwheel doesn't come with nrepl baked-in:

$ clj -Acider -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.6.0"}}}' -m nrepl.cmdline
...
nREPL server started on port 49712 on host localhost - <nrepl://localhost:49712>
...
[Figwheel] Starting Server at <http://localhost:9500>
[Figwheel] Starting REPL
Then we can connect to the nrepl with a client. (cider is a client, but so is this other command line tool)
$ clojure -Sdeps '{:deps {reply {:mvn/version "0.4.3"}}}' -m reply.main --attach localhost:49712
REPL-y 0.4.3, nREPL 0.6.0
...
user=&gt; (require '[figwheel.main.api :as fig])
nil
user=&gt; (fig/start "dev")
Prompt will show when REPL connects to evaluation environment (i.e. a REPL hosting webpage)
Figwheel Main Controls:
          (figwheel.main/stop-builds id ...)  ;; stops Figwheel autobuilder for ids
          ...
user=&gt; 
(i.e. where we were with `-A:figwheel` or `clojure -m figwheel.main -b dev -r`, but using nrepl)
Note that it'll also complain of other missing pieces (e.g. piggieback middleware for CLJS support). Either you add them to the project, to your user profile, or use the jack-in-* commands (which add those for you)

EmmanuelOga 2020-02-06T18:52:41.089100Z

thx! took me a while but I figured out cider jack in was running the repl cmd line

EmmanuelOga 2020-02-06T18:52:47.089300Z

clojure -A:cider -Sdeps '{:deps {nrepl {:mvn/version ""0.6.0""} cider/piggieback {:mvn/version ""0.4.2""} cider/cider-nrepl {:mvn/version ""0.23.0""}}}' -m nrepl.cmdline --middleware '[""cider.nrepl/cider-middleware"", ""cider.piggieback/wrap-cljs-repl""]'

1👍