Fork me on GitHub
#figwheel-main
<
2018-10-06
>
zakora13:10:20

I am using fighweel.main to run a ClojureScript project that has re-frame and re-frame-10x. If I start the project from the command line it works correctly, re-frame-10x gets loaded. However, if I try to run the project from emacs/CIDER, it loads ok except for re-frame-10x that is not loaded. The JS console states: > goog.require could not find: day8.re_frame_10x.preload Has anyone succeeded in running a project with re-frame-10x from emacs/CIDER?

witek13:10:55

Hi. Is there a way to start figwheel-main with http-kit instead of jetty? Sadly, Jetty is not supported by https://github.com/ptaoussanis/sente

bhauman14:10:34

@zakora_clojurians it sounds like the classpath is not the same when you start it from CIDER

zakora14:10:31

Do you have any pointer on how to fix this (if it is even possible)? I am pretty new to Clojure and emacs.

bhauman14:10:45

@witek in this case you would need to start your own http-kit server

bhauman14:10:08

running your own server will work just fine

witek14:10:24

in addition to the http-kit? or instead?

bhauman14:10:57

@witek you will run an http-kit server seperately from figwheel

🙏 4
bhauman14:10:54

@witek there is only one thing you need to do to make this work

bhauman14:10:21

your http-kit server will need to serve the compiled ClojureScript artifacts

bhauman14:10:33

and of course a landing page

witek14:10:55

of course. thank you very much

bhauman14:10:01

the figwheel server will handle websocket communication for reloads, and REPL interaction

bhauman14:10:16

without any CORs problems

witek14:10:00

Is there an elegant way to start my http-kit from figwheel-main? I mean inside the same process...

witek14:10:57

I hacked it that way: I have configured a custom :ring-handler in figwheel-main.edn. It forwards to my http-kit server. Which is started in the namespace of the figwheel ring handler. Since figwheel loads this namespace, it starts my http-kit. Works fine for me. Thank you for figwheel - I love it!

bhauman14:10:14

@witek there are several elegant ways

bhauman14:10:34

are you using Clojure Tools?

bhauman14:10:44

to start Figwheel?

bhauman14:10:59

you can use the clojure -i flag to load and run a script to require and run your server.

bhauman14:10:49

you can also put the code to start your server in a user.clj file on your classpath and then use an eval flag -e (user/start-my-server) to start it

zakora15:10:45

@bhauman thanks for the hint. Previously I put the re-frame-10x dependency in {:aliases {:figdev {:extra-deps {day8.re-frame/re-frame-10x ...}}} in deps.edn, but if I move the dependency to {:deps {day8.re-frame/re-frame-10x ...}} then it works from CIDER.

zakora15:10:33

Maybe because this dependency requires a :preloads in dev.cljs.edn?

bhauman15:10:23

this happens because when you start from CIDER your aren’t supplying the alias

bhauman15:10:54

so the dependency is not found on the classpath

zakora15:10:41

Oh, right! Thanks for info and the link, I will follow its outcome.

👍 4
andrea.crotti17:10:02

trying to move to figwheel-main, and it almost all works, but if I try to do a uberjar

andrea.crotti17:10:04

$ lein uberjar
Deleting non-target project paths [".../target%s"] is not allowed.
Check :clean-targets or override this behavior by adding metadata ->
  :clean-targets ^{:protect false} [...targets...]

andrea.crotti17:10:27

I think I understand how to fix it

bhauman17:10:30

@andrea.crotti I’ve been thinking about this and I think I have a simple solution

bhauman17:10:49

for lein users :target-dir "resources"

andrea.crotti17:10:50

but I wonder why it's building in target instead of resources like cljsbuild does?

andrea.crotti17:10:58

ah yes exactly

bhauman17:10:05

because that’s the default for figwheel-main

bhauman17:10:07

so if you are porting its best to put :target-dir "resources" in figwheel-main.edn or in the build file metadata

bhauman17:10:27

this should work I haven’t tried it yet

andrea.crotti17:10:32

yeah trying now

andrea.crotti17:10:21

ok now uberjar works

andrea.crotti17:10:49

and btw about porting I found that this resource was quite nice

andrea.crotti17:10:32

the only remaining problem is that it doesn't reload

andrea.crotti17:10:43

even though it's connected and it looks like it's reloading

andrea.crotti17:10:18

it's actually an OSS project so this is how I'm doing it

bhauman17:10:16

if you just compiled a production output you may be loading the prod code?

bhauman17:10:59

actually its probably your reload hook

bhauman17:10:19

yeah that’s the other thing that messes with folks when they port

andrea.crotti17:10:53

ahh ok I'll try thanks

bhauman17:10:20

of course check the console and confirm that things are connecting etc

andrea.crotti17:10:34

would be great to have in the figwheel-main readme at least a short list of things that changed

andrea.crotti17:10:50

to just make it easier to see what I need to do

bhauman17:10:54

yeah I just jotted down a note to do that

bhauman17:10:09

of course a lot has changed

bhauman17:10:29

I jotted down a note to write a porting guide sooner than later

andrea.crotti17:10:51

mm unfortunately this blows up

(defn ^:after-load mount-root [page]
  (re-frame/clear-subscription-cache!)
  (reagent/render [page]
                  (.getElementById js/document "app")))

andrea.crotti17:10:03

Uncaught Error: Invalid arity: 0

andrea.crotti17:10:14

I guess it expects the mount function to not take any arguments

bhauman17:10:17

as it would

bhauman17:10:38

it doesn’t know what page to mount

andrea.crotti17:10:57

mm yeah I have to restructure the code a bit somehow

andrea.crotti17:10:09

actually maybe that's the all reason why I had problems with the old figwheel 😄

andrea.crotti17:10:21

but the error was so confusing that I just tried to upgrade to fix it

andrea.crotti17:10:48

I just have to restructure the code to not need to take an argument probably

bhauman17:10:11

@andrea.crotti I’d write a different function entirely

bhauman17:10:30

that fetches the page and the calls mount-root

bhauman17:10:48

I’d name the function reload-hook

andrea.crotti17:10:02

yes sure, it's a bit tricky given how I did it with accountant, but should be feasible

andrea.crotti17:10:43

amazing it all works now

andrea.crotti17:10:46

thanks for the great work and the help @bhauman!

rpkarlsson18:10:36

Hello. I have been having an issue running Fighwheel-main using clojure 1.10.0-beta1. Autobuilds no longer runs. Running on 1.10-alpha8 seems to work. Could anyone confirm? https://github.com/rpkarlsson/figwheel-beta1-rebuild-reprod

😍 4
bhauman18:10:07

@rpkn are you using figwheel.main 0.1.9

bhauman18:10:11

yeah you are

rpkarlsson18:10:12

Yes. com.bhauman/figwheel-main {:mvn/version "0.1.9"}

bhauman18:10:17

thanks for the repro

bhauman18:10:36

I hope they didn’t screw me over 🙂

rpkarlsson18:10:31

Np. Mentioned it to @alexmiller. Will continue to dig around.

bhauman20:10:53

@rpkn Thanks for finding that

bhauman20:10:19

I think use .getMethod I think so that may be the cause

bhauman21:10:24

@rpkn well what version of Java are you using? because this work fine for me on OSX using java 1.8

bhauman21:10:03

OK this doesn’t work in Java 10