Fork me on GitHub
#figwheel
<
2018-09-07
>
rplevy04:09:00

I've been trying to do something, and not entirely sure why it wouldn't work. I want to run start-figwheel and cljs-repl in my user.clj for when the repl loads. When I do this it just hangs forever (or until it reaches the timeout I've set in repl-settings.) In contrast, if I only run start-figwheel in user.clj then I can manually run cljs-repl without problems. Perhaps interestingly, if I run cljs-repl in user.clj in a future/thread it doesn't do the hanging thing, but since it's in a background thread I can't actually use it.

rplevy04:09:34

the best I've come up with is

(ns user
  (:require [figwheel-sidecar.repl-api :as figwheel]))

(defn start []
  (figwheel/start-figwheel!)
  (figwheel/cljs-repl))
So the process is lein repl and then (start), but I wonder why it's not possible to just run lein repl somehow and have the start happen.

rplevy04:09:53

Aha I think I just figured it out: In dev profile

:main user
In user.clj:
(ns user
  (:require [figwheel-sidecar.repl-api :as figwheel]))

(defn start []
  (figwheel/start-figwheel!)
  (figwheel/cljs-repl))

(defn -main []
  (start))
And then run lein run instead of lein repl.

jcr08:09:48

I have almost exactly the same question (I think). I want to start figwheel from inside my project repl, i.e. I don't want to use lein run -m figwheel.main, I don't need its static file server or anything like that. All I want is to launch my repl as usual (jvm repl, for my server), connect to it from CIDER, and then launch a cljs repl. I don't want reload-on-save behavior also, I just need the usual repl-driven workflow. I would think it has to be the most common setup, but weirdly enough, I can't find anything about how to do that on the figwheel's site.

jcr09:09:54

https://figwheel.org/docs/create_a_build.html#configuring-a-build -- why this strange syntax? It seems very confusing to me to be honest. Why isn't it possible to have just one figwheel.edn file with {:dev {:main my-ns.core, :hot-reload false} ...}, etc?

bhauman10:09:34

@just_crashed use the scripting api so that you can start figwheel from the repl

jcr10:09:51

@bhauman yep, I was going through the docs and started reading that page literally just now. Looks like I need piggieback now...

bhauman10:09:07

the metadata syntax is so that you can read the file to obtain compiler options unencumbered with figwheel options, this is precisely so that you can use the build file with the -co option in cljs.main

bhauman10:09:37

and there are other times when you want to read the file and to get the compiler options only

jcr10:09:13

For those who don't use cljs.main, is it possible to specify the same things in figwheel-main.edn? Looks like it's used only to set the default, global figwheel options, so the answer is no, right?

jcr12:09:46

1. I have :hot-reload-cljs false in my build config, but the cljs is still recompiled when files are changed. I have to call (figwheel.main/stop-builds "dev") manually from the repl. Why is this? Did I misunderstand the purpose of :hot-load-cljs?

jcr12:09:28

2. How do I prevent figwheel's http server from starting? Also, what's the supposed way to integrate figwheel output with my server? Is setting :output-to/:output-dir to resources/public enough? Is it the right way to do it or is there a better way?