Fork me on GitHub
#figwheel-main
<
2018-09-17
>
mike_ananev08:09:27

Hello! I would like to use Figwheel Main, but can't find any docs, how to connect to REPL started by Figwheel Main from Emacs/Cursive? Is there any guides how to open nREPL port from REPL started by Figwheel Main?

stathissideris09:09:32

I’m a bit confused about configuration, and specifically what should be in the map and what should be in the metadata of the map

stathissideris09:09:45

is the map the config that’s passed to clojurescript?

stathissideris09:09:15

is that documented somewhere?

jduhamel10:09:20

@mike1452 How are you setting up your project? Lein? or clj? or boot?

jduhamel10:09:57

for clj I followed the tutorial in figwheel-main and just used Cider-jack-in-cljs and it worked.

mike_ananev11:09:06

@jduhamel Hi! I'm using Clj CLI + Spacemacs. Where did you find such tutorial? Here? https://cider.readthedocs.io/en/latest/clojurescript/

bhauman11:09:43

but yes only ClojureScript options are in the body of the map

bhauman11:09:52

and figwheel options are in the metadata

bhauman11:09:52

but perhaps I could make that more explicit

stathissideris11:09:53

@bhauman thanks, but I’m mainly wondering about where I can find information about the options that go into the map

stathissideris11:09:33

I did find the documentation on the figwheel options (very complete documentation btw, I’m impressed!)

stathissideris11:09:51

but what are “ClojureScript options” 🙂

stathissideris11:09:08

I suppose that would be on the clojurescript website somewhere

bhauman11:09:06

@stathissideris its linked to on the create a build page

bhauman11:09:28

but I’m sure if you search for Clojurescript compiler options it will come right up

mike_ananev11:09:20

@bhauman Hello, Bruce! Is there any tutorial, how to connect to REPL from Cursive, which run by Figwheel Main?

bhauman11:09:29

not yet but its pretty straight forward

bhauman11:09:54

start a repl of some kind in cursive

mike_ananev11:09:54

I use Clojure CLI

bhauman11:09:13

so you will want to start a REPL in cursive

bhauman11:09:31

you will then use the scripting api to start figwheel

mike_ananev11:09:41

@bhauman Thanks. Now a bit more clearer. But, when I run (figwheel.main.api/cljs-repl "dev") it hangs my REPL in Cursive and Chrome console tells me "WebSocket connection to '<ws://localhost:3449/figwheel-ws/dev>' failed:"

bhauman12:09:43

@mike1452 that error is wrong

bhauman12:09:58

that error is for figwheel-sidecar

bhauman12:09:05

so something is wrong

mike_ananev12:09:22

@bhauman I always used lein-figwheel and it works very straightforward. Now, I'm trying to migrate my configs for Figwheel Main and I think I mixed some configuration for both (lein-figwheel and Figwheel Main). I'm trying to achieve next workflow: 1. Run REPL using clojure CLI from terminal with Rebel support 2. Run Figwheel Main and switch REPL from CLJ to CLJS mode 3. Connect to REPL from Cursive or Spacemacs using remote connection 4. have fun with coding CLJS and FigWheel and eval sexp from IDE, not terminal It would be nice to have such guide

kwladyka12:09:26

I did it and then moved my shadow-cljs code into it

kwladyka12:09:37

It wasn’t easy because of npm deps, but I learned new things about webpack solution

stathissideris12:09:24

@bhauman thanks, and sorry, I hadn’t seen the link! I think I was just missing the name for it (“compiler options”)

👍 4
bhauman20:09:29

@zane this is kindof a bug in figwheel right now

bhauman15:09:43

@zane I looked into the asyc loading problem, and it seems that I solved it long ago and forgot about it

bhauman15:09:44

so if a you are calling a main function and its not available, it would be interesting to trace when it’s getting called compared to when the file is actually loading

zane15:09:35

I see. Okay.

bhauman20:09:16

I think this happens because when figwheel is loading it takes over the loading of dependencies at that point

bhauman20:09:36

and dependency loading becomes async and not sync as usual

bhauman20:09:14

I’m planning on fixing this

bhauman20:09:48

but its only a problem in when figwheel is included

bhauman20:09:54

hmmm I could probably fix this with a setTimeout 0 since everything is synchronous

tmarble21:09:02

@bhauman i've made a little progress in debugging my lein fig;test issue: By using -pc and looking at the source I found the reason my :output-dir changed in my client's code, but not in the template code: It's because in the template code example the :dev profile has :resource-paths ["target"] which causes should-add-temp-dir? to be false in https://github.com/bhauman/figwheel-main/blob/master/src/figwheel/main.cljc#L559 By adding (in my client project.clj) :resource-paths ["target"] now :output-dir/:output-to are the expected [Figwheel] Compiling build test to "target/public/cljs-out/test-main.js"

tmarble21:09:19

The next problem is that while I mimic what the template does by creating a test HTML file in resources/public/test.html when running the test (using the example in test.cljs.edn of :open-url "http://[[server-hostname]]:[[server-port]]/test.html") the actual URL is not found?

tmarble21:09:48

The symptom is that the test hangs at:

Launching Javascript environment with script:  ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" "--headless" "--disable-gpu" "--repl" :open-url]
Environment output being logged to: target/public/cljs-out/test/js-environment.log
And a the process is still running:
tmarble@tmarble 43 :) ps -ef | grep headless | grep -v -E '(Helper|grep)'
  502 97428 97424   0  2:23PM ttys002    0:00.98 /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --headless --disable-gpu --repl 
tmarble@tmarble 44 :) 

tmarble21:09:34

And trying to load in a normal browser tab shows: Figwheel Server: Resource not found Keep on figwheelin' yep

tmarble21:09:24

OMG I fixed the this last problem by completely commenting out... (from the client project.clj)

;; Avoid contamination of AOT artifacts (e.g. during uberjar) vs dev artifacst
  :target-path "target/%s/"

tmarble21:09:24

I can't tell you how SWEET it is to see this!

Ran 7 tests containing 15 assertions.
0 failures, 0 errors.
:figwheel.main.testing/success

dpsutton21:09:10

getting coworker up connecting to clj -A:fig:build and he's not sure which port to direct cursive at. does anyone know?