Fork me on GitHub
#lein-figwheel
<
2015-12-30
>
rcoedo10:12:37

Hi! I’m trying to build a small example application with ring + reagent. I use figwheel to develop but I’m having trouble to run it inside the lein repl.

rcoedo10:12:09

I’m using figwheel-sidecar (even though I’m not sure what is it used for!). Recently I moved my cljsbuild configuration to separate profiles and now it stopped working.

rcoedo10:12:39

I’ve read that figwheel-sidecar can’t read the merged configuration and that I should move it to a figwheel.edn file. Am I right?

rcoedo10:12:22

However, I don’t know what is the file format and I can’t find an example of this kind of configuration

rcoedo10:12:48

If anyone can help me on this one I’ll be very grateful!

rcoedo11:12:25

Nevermind, got it working! 😁

simax9912:12:30

Apologies if this is the wrong channel to ask this question but here goes anyway. I'm trying to use bidi for client side routing and pushy so I can have urls without the #/ in them and of course I'm using Figwheel. This is my scenario: I have a project that comprises a ClojureScript front end and a Clojure backend. I'm using IntelliJ/Cursive as my dev environment and have set up a Cursive REPL that runs the ClojureScript using Figwheel. Works great. I use re-frame for the front end UI stuff and the usual http to call the Clojure backend API to fetch data (which runs on localhost:3030). Also, works great. Now I've introduced pushy and bidi. So, if I have a href in the client with a URL like 'localhost:3449/about' and I click on it re-frame dispatches to an event handler and I now see the /about page. Perfect! However if I type localhost:3449/about into the Chrome address bar I instantly get "Page not found". Then I realised that the the front and back ends are running on different ports so of course localhost:3449/about is not found so I tried running both on the same port but I get port is already in use. I'm lost, how do get this stuff to work? My server side routing is shown below: (defroutes app-routes (GET "/" [] (file-response "index.html" {:root "public"})) (context "/api" [] (GET "/auth-token" [] (build-auth-token)) (ANY "/departments" [] (departments)) (ANY "/departments/:id" [id] (department id)) (ANY "/department/:id" [id] (department id)) (ANY "/employees" [] (employees)) (ANY "/employee/:id" [id] (employee id)) (ANY "/holidays" [] (holidays)) ;(route/not-found "Not Found") ) (ANY "*" [] (file-response "index.html" {:root "public"})) )

simax9912:12:30

@pupeno: Maybe you can help with https://clojurians.slack.com/archives/lein-figwheel/p1451477190000399 You mention some of this stuff on screencast about ninja tools

simax9912:12:12

@eggsyntax: FYI I use Chrome/Figwheel/Mac all the time w/out any issues.

sventechie12:12:34

@simax99: do you have Chrome extensions installed? I'm getting the same behavior where switching tabs causes figwheel to stop refreshing when changes happen. I have to manually refresh the page to make it work again.

simax9912:12:26

Yes lots of them. What should I do to test?

simax9913:12:31

Oh, just realised. I’m using Canary. Give me a little while and I’ll try with Chrome standard.

simax9913:12:01

No, Figwheel working perfectly in standard Chrome as well. Maybe it is one of the extensions you have loaded.

crocket14:12:12

{:id "dev"
 :source-paths ["src/cljs" "src/bin"]
 :figwheel true
 :compiler {:main to-utf8-unix.core
            :output-to "target/server_dev/to-utf8-unix.js"
            :output-dir "target/server_dev"
            :target :nodejs
            :optimizations :none
            :source-map true}}

crocket14:12:28

Why can I not remove :main from :compiler when I use figwheel?

crocket14:12:02

If :main is set to a namespace that doesn't include every other namespace included in :source-paths, I don't have full access to all namespaces in all :source-paths.

wilkerlucio15:12:13

@crocket: it's normal in Clojure/ClojureScript, it's just that you didn't loaded that namespace, the namespaces are loaded as you ask. however you can at anytime use (require 'my.namespace) to load a namespace that's not loaded yet

crocket15:12:57

I just hope it was possible to make figwheel reload every namespace in source paths. REPL testing happens everywhere.

crocket15:12:00

Why does figwheel need :main? Or, is it google closure that needs :main on nodejs?

eggsyntax15:12:19

@simax99: Cool, thanks, good to have at least one concrete data point.

eggsyntax15:12:49

@simax99: @sventechie Opening it in chrome in an incognito tab, with all extensions disabled, I still see the problem.

simax9915:12:28

@eggsyntax: Have you tried Canary?

eggsyntax15:12:09

I should note also that, on cljs pages, I get the following error, which reappears every time I save a .cljs file:

eggsyntax15:12:36

Despite some research & experimentation, I’ve been completely unable to track that one down.

eggsyntax15:12:36

Haven’t tried Canary, but possibly later today. Why do you think that might solve it?

eggsyntax15:12:28

Hmm, interesting, don’t remember whether I tried shutting that off (it was a while ago that I was researching this). Gotta afk, but will try that later. I am fairly sure that I’ve set localhost as an exception to all cookie blocking.

eggsyntax16:12:48

Yeah, I’ve got that setting unchecked. Probably one of the earlier things I checked, although I don’t recall specifically doing so.

simax9916:12:06

@eggsyntax: No idea if canary will help or not. Pure guess. I’m no Chrome expert but its worth a try.

simax9916:12:50

@eggsyntax: Another more drastic option is reset Chrome to factory settings (defaults) http://www.howtogeek.com/171924/how-to-reset-your-web-browser-to-its-default-settings/

eggsyntax17:12:18

@simax99: doing Canary works like a charm. Thanks, good suggestion. Doesn’t identify the problem, really — different Chromium build? Absence of extensions? Disconnection from my Chrome syncing? Not a clue — but my primary investment is in having an effective working env for figwheel, and I like the Chrome dev tools better than Safari’s. @bhauman: sorry I can’t track it down further at the moment, but here’s a reasonable workaround if anyone else encounters this issue. @sventechie also of interest to you, I expect. Bonus: pretty gold dock icon! 😉

eggsyntax17:12:18

I’ll note that the localhost errors have vanished in Canary too, related or not.

eggsyntax17:12:32

Sorry, typo, s/localhost/localstorage/

simax9917:12:30

@eggsyntax: Glad it worked. But as you say it doesn’t really explain the problem. Possibly something to do with your Chrome config. But what? Maybe you’ll find out one day.simple_smile

eggsyntax17:12:02

Yeah, at some point I’ll probably be annoyed enough — and have enough spare time — to track it down. I agree it's probably my Chrome config, one way or another...

bhauman18:12:09

@eggsyntax: it looks like I need to do some error handling around accessing localStorage

bhauman18:12:54

@eggsyntax: thanks for looking into this

bhauman18:12:41

@simax99 if you simply load your app from your server everything should work just fine. The figwheel client will communicate over the websocket but you do not need to use the figwheel server to load your application.

bhauman18:12:28

@grav: the :js-client-host isn't the default because loading your code from your application server should be the default. Fighweel is set up for this default. IE. you load your app at localhostapp.dev:3000 and the figwheel client looks for its comm websocket at localhost:3449

eggsyntax18:12:34

@bhauman: seems plausible. Thanks simple_smile

bhauman18:12:12

@eggsyntax: according to the error you posted it is the most likely cause.

eggsyntax19:12:47

@bhauman: Ah, here’s some confirmation. Looking back, I first started seeing that error in November — turned out George & I had gotten further out of sync than we realized, we were on a tight schedule getting ready to present at the Conj, and so a bunch of dependency updates happened at the same time in our project, without having time to track down the new localStorage error (since it wasn’t yet clear that it was causing problems w/ figwheel). One of the updated dependencies was figwheel, 0.3.9 -> 0.5.0-SNAPSHOT, and I see that would have introduced lein-figwheel commit 2553d825, which introduced the code you just pointed to which tries to hit localStorage. I wonder why the localStorage call even throws an error. It’s not a problem that’s other folks are reporting, I take it? So that maybe points back to something screwy in my Chrome config/profile/install as the reason the error gets thrown in the first place...

bhauman19:12:33

@eggsyntax: that confirms it thanks! No other reports, so yeah there must be something in your setup or program that is triggering this safety feature

eggsyntax19:12:10

Cool, feel free to deprioritize or wontfix, since the problem’s ultimately on my end (although I imagine I’m probably not the only one who’ll ever encounter it). Or I’d be happy to attempt a patch & PR if you want to tell me what you want figwheel to do in that case, and/or test a patch if you write one. Thanks!