Fork me on GitHub
#figwheel-main
<
2018-11-09
>
sofra00:11:18

Hi, can anyone explain to me what function sidecar plays in the figwheel workflow? should I be using it?

plexus00:11:24

if you're using figwheel-main then you *do not* need sidecar

plexus00:11:58

sidecar is what you used before figwheel-main, if you wanted to use figwheel as a library, rather than through lein-figwheel

👍 4
sofra00:11:46

@plexus thank you! that is useful to know 🙂

mkvlr12:11:26

is there a way to turn off :hot-reload-cljs at runtime via the repl?

andrea.crotti14:11:13

anyone using figwheel-main and integrant together?

shaun-mahood16:11:38

@andrea.crotti Yes, it works great - use the script API to start figwheel as part of your integrant startup.

andrea.crotti16:11:59

great, the only problem I have is that for some reason if I have both figwheel and jetty, only figwheel runs

andrea.crotti16:11:04

if I only have jetty jetty works fine

andrea.crotti16:11:06

(defmethod ig/init-key :server/figwheel
  [_ {:keys [build] :as opts}]
  (figwheel/start build))

(defmethod ig/init-key :server/jetty
  [_ {:keys [port]}]
  (jetty/run-jetty (wrap-reload #'api/app)
                   {:join? false
                    :port port}))

(defmethod ig/halt-key! :server/jetty
  [_ server]
  (.stop server))

(def config
  {;;:server/garden {:builds ["screen"]}
   :server/figwheel {:build "elo"}
   :server/jetty {:port 3335}
   })

(defn -main
  [& args]
  (reset! system (ig/init config)))

andrea.crotti16:11:18

quite a simple config so far

andrea.crotti16:11:33

am I doing something silly @shaun-mahood?

shaun-mahood16:11:39

I think your figwheel config needs the equivalent of :join false? - I’ll see if I can find the reference quickly

andrea.crotti16:11:50

yeah weird because on another project I use at work we don't have any other option and it still works fine

andrea.crotti16:11:56

but yeah I suspected it was something like that

shaun-mahood16:11:16

:mode :serve, then you can start the figwheel-repl from your repl. If you are still having trouble at the end of the day let me know and I’ll get some example code together this weekend or Monday, I’m in meetings all day today. :(

andrea.crotti16:11:42

mm no sadly still doesn't work, I'm trying to actually get it working on a personal project, to then fix something related on my real project 😄

andrea.crotti16:11:57

this is the PR in case you can see something silly https://github.com/AndreaCrotti/elo/pull/90

andrea.crotti16:11:21

but should not integrant run things by default in detached mode so to say?

andrea.crotti16:11:43

(maybe that's a question for another channel though)

bhauman17:11:42

@andrea.crotti you should be able to pass :`join? false` in the :ring-server-options https://figwheel.org/config-options#ring-server-options

bhauman17:11:56

also an error might be getting thrown if there is a jetty conflict

andrea.crotti17:11:11

mm not sure I tried but I don't see any difference

andrea.crotti17:11:24

I think it's an issue with integrant config not figwheel to be fair

bhauman17:11:48

cool just wanted to make you aware that that was an option

andrea.crotti17:11:50

it simply doesn't even call the function to start jetty

bhauman17:11:15

that would happen if it blocks though

andrea.crotti17:11:57

yes sure, I have this config now

{:watch-dirs ["src/cljs" "src/cljc"]
 :css-dirs ["resources/public/css"]
 :open-url false
 :auto-testing true
 :log-level :debug
 :target-dir "resources"
 :mode :serve
 :ring-server-options {:join? false}}

bhauman17:11:58

@ghopper @raymcdermott I haven’t been able to reproduce the figwheel.core warning with the new clojurescript

bhauman17:11:48

@andrea.crotti test to see if code that happens after figwheel starts is executed

bhauman17:11:58

like right after

bhauman17:11:46

@ghopper @raymcdermott perhaps you are using a different clojurescript as well

andrea.crotti17:11:46

so yeah definitively blocking

bhauman17:11:04

OK let me look at the code real quick

bhauman17:11:51

@andrea.crotti Hmmm I’d make sure that those build options are actually getting to figwheel

bhauman17:11:02

I mean the figwheel options

andrea.crotti17:11:24

ah good point I'll check

andrea.crotti17:11:33

I get a validation error when they are wrong

andrea.crotti17:11:38

so they should be right?

bhauman17:11:26

perhaps pass the figwheel build options directly to start as the first option

bhauman17:11:20

it should actually just work though

bhauman17:11:40

without :mode :serve

bhauman17:11:25

also make sure you are using figwheel.main.api/start as well

andrea.crotti17:11:19

ah yes I tried also without :mode :serve and the PR is here, https://github.com/AndreaCrotti/elo/pull/90

andrea.crotti17:11:27

it gets stuck here

andrea.crotti17:11:30

Nov 09, 2018 5:44:23 PM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
Unable to detect a system Terminal, you must not launch the Rebel readline
from an intermediate process.
If you are using `lein` you may need to use `lein trampoline`.
JavaScript environment will not launch automatically when :open-url is false

andrea.crotti17:11:41

that warning is not the problem right? I've seen it many times before

bhauman17:11:07

@andrea.crotti that is a problem because it is trying to start a REPL

bhauman17:11:26

and it does start a repl and blocks

bhauman17:11:31

so yes you do need :mode :serve

bhauman17:11:45

I have to read my own docs

bhauman17:11:52

I have an idea

bhauman17:11:20

try starting figwheel from the REPL

andrea.crotti17:11:25

mm :mode :serve doesn't make a differnce

bhauman17:11:05

so from a clojure REPL try (figwheel.main.api/start "dev")

bhauman17:11:41

and see if it blocks

bhauman17:11:37

Oops (figwheel.main.api/start {:mode :serve} "dev")

bhauman17:11:44

and you can also do (figwheel.main.api/start {:mode :serve :pprint-config true} "dev")

bhauman17:11:02

do see the config that you end up with

andrea.crotti17:11:15

elo.api=> (figwheel.main.api/start {:mode :serve} "elo")
[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid \(ツ)/

ExceptionInfo ClojureScript Namespace elo.dev was not found on the classpath.  clojure.core/ex-info (core.clj:4739)

andrea.crotti17:11:22

same thing without {:mode :serve} works

andrea.crotti17:11:58

does it somehow assumes something about the name dev?

bhauman17:11:58

well it’s probably just that a needed file isn’t on the classpath

andrea.crotti17:11:15

ahh ok I get it now

andrea.crotti17:11:52

so now it stopped blocking

elo.api=> (figwheel.main.api/start {:mode :serve} "elo")
[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid \(ツ)/
[Figwheel:WARNING] Attempting to dynamically add "target" to classpath!
[Figwheel:WARNING] Target directory "target" is not on the classpath
[Figwheel:WARNING] Please fix this by adding "target" to your classpath
 I.E.
 For Clojure CLI Tools in your deps.edn file:
    ensure "target" is in your :paths key

 For Leiningen in your project.clj:
   add it to the :resource-paths key
[Figwheel:SEVERE] java.lang.AssertionError: Assert failed: Should have at least one build input!
(not-empty build-inputs)
[Figwheel] Starting Server at 
Opening URL 
nil
elo.api=>
after I coimmented out ;; :main elo.dev from my elo.cljs.edn

andrea.crotti17:11:00

so getting closer 😄

bhauman17:11:57

just make sure that you add your src classpath before you start the REPL

bhauman17:11:56

oh now I see the error

bhauman17:11:01

thats strange

bhauman17:11:20

I think its caused by the lack of a :main ?

andrea.crotti18:11:38

well I put main back, and I require dev now

elo.api=> (require 'elo.dev)
nil
elo.api=> (require '[figwheel.main.api :as figwheel])
nil
elo.api=> (figwheel.main.api/start {:mode :serve} "elo")
[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid \(ツ)/

ExceptionInfo ClojureScript Namespace elo.dev was not found on the classpath.  clojure.core/ex-info (core.clj:4739)
elo.api=>

andrea.crotti18:11:48

how can it not be in the classpath if I also just required it?

andrea.crotti18:11:01

ah damn clojrescript not clojure 😄

andrea.crotti18:11:05

ok makes sense then

andrea.crotti18:11:48

ok then I'll sort it out, problem for future me

andrea.crotti18:11:55

thanks a lot in the meanwhile

bhauman18:11:44

sorry for all the complexity