Fork me on GitHub

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.


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.


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?


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


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


Nevermind, got it working! 😁


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"})) )


@pupeno: Maybe you can help with You mention some of this stuff on screencast about ninja tools


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


@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.


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


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


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


{: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}}


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


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.


@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


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


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


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


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


@eggsyntax: Have you tried Canary?


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


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


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


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.


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


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


@eggsyntax: Another more drastic option is reset Chrome to factory settings (defaults)


@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! 😉


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


Sorry, typo, s/localhost/localstorage/


@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


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...


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


@eggsyntax: thanks for looking into this


@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.


@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 and the figwheel client looks for its comm websocket at localhost:3449


@bhauman: seems plausible. Thanks simple_smile


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


@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...


@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


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!