figwheel

general discussion about figwheel, specific discussions in #figwheel-main and #lein-figwheel
rplevy 2018-09-07T04:01:00.000100Z

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.

rplevy 2018-09-07T04:14:34.000100Z

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.

rplevy 2018-09-07T04:21:53.000100Z

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.

2018-09-07T08:51:48.000100Z

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.

2018-09-07T09:56:54.000100Z

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?

bhauman 2018-09-07T10:16:27.000100Z

https://figwheel.org/docs/scripting_api.html

bhauman 2018-09-07T10:18:34.000100Z

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

2018-09-07T10:20:51.000100Z

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

bhauman 2018-09-07T10:22:07.000200Z

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

bhauman 2018-09-07T10:23:37.000100Z

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

2018-09-07T10:26:13.000100Z

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?

2018-09-07T12:18:46.000100Z

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?

2018-09-07T12:21:28.000100Z

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?