0

I added a new dependency to my Clojurescript app, and I want to know if I can run a function, maybe something like (restart-figwheel) to restart Figwheel. I read you have to restart Figwheel to detect new dependencies.

Brandon Olivier
  • 578
  • 5
  • 16

1 Answers1

2

At this time, I don't think you can do this. You need to quit your current figwheel session and restart in order to pick up new dependencies added to your :dependencies in your project.clj file. In fact, the figwheel docs also recommend running lein clean before you restart figwheel to be sure you don't end up with some old code.

I think this functionality is on the roadmap, but is not a high priority. There is considerable complexity in being able to have this functionality work reliably - especially if you add in the complexity of different repl environments (such as using piggyback, and cider with figwheel).

Note that this limitaiton is just with :dependency items in the project.clj. You can add :require lines in your cljs files dynamically and have them picked up (asusming the library is already in the dependencies list of course).

I suspect part of the compicaiton is ensuring the classpath is updated and that all processes already running which use the classpath are somehow updated and making sure all loaded classes are reloaded in case the dependency changes the dependencies of those loaded classes to keep things consistent.

Tim X
  • 4,158
  • 1
  • 20
  • 26
  • I see. I guess I'll just write an elisp function to do it automatically for me after I use clj-refactor to add a dependency. – Brandon Olivier Mar 19 '17 at 03:56
  • You could write an elisp function which quits the cider connections and then starts them again, but as this only takes a couple of key strokes already, it isn't buying you much. The killer is the load time and an elisp funciton won't help that. 90% time, you only need to reload project.clj when you add new libs, which typically happens at the start and is rare later on unless your adding a completely new bit of functionality. You won't want to use it when you refactor (ns ..) of course as figwheel will handle that. – Tim X Mar 19 '17 at 07:24