Fork me on GitHub

I’d like to automate cljs/figwheel-main/webpack a little better using deps. 1. Using a fig alias I can jack-in with Figwheel Main and compile. 2. With another alias I can then start a figwheel main repl that is connected to the editor. Between (1) and (2) I want to run webpack at least once. It looks like I can get access at this point by adding a :post-build-hooks vector in figwheel-main.edn. I feel it should be possible to supply a clojure function there which shells out to call webpack.


:post-build-hooks wants a namespaced function to call. However I can’t get this to resolve correctly - e.g. if I give it [user/foo] it can’t resolve namespace user. It would be simple if I understood how the classpath was defined when the :post-build-hooks functions are resolved. This might be a figwheel-main issue, but it may also be a Calva defined classpath. Does anybody have an idea how to put functions on the classpath at that point?


OK - answering my own question - I guess the classpath there is the one built by Calva Jack-in which is echoed in the terminal.


Now is there a way to add source paths to that?


Calva does not build any classpaths. That will be done by Leiningen or the clojure CLI tool, depending on which one you use. If you define a profile (lein) or an alias (clj) then you can select these at Calva Jack-in and the command line will be built such that it invokes the profile/alias. I tried to explain the Jack-in feature a bit here:


Sorry - I was thinking out loud there. Yes I agree, but Calva does build the CLI command line and passes it dependencies to go on the classpath using clojure -Sdeps. Maybe this output will clarify the problem I’m trying to solve - I can’t see how to get ‘user’ on the classpath. I have :post-build-hooks [user/foo]in figwheel-main.edn. user/foo is a placeholder for a function that will run webpack. I see this:

> Executing task: clojure -Sdeps '{:deps {nrepl {:mvn/version "0.8.2"} cider/cider-nrepl {:mvn/version "0.23.0"} clj-kondo {:mvn/version "2020.04.05"} cider/piggieback {:mvn/version "0.4.2"}}}' -A:fig:dev <

WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
2021-01-30 00:21:41.178:INFO::main: Logging initialized @3750ms to org.eclipse.jetty.util.log.StdErrLog
[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid \(ツ)/
[Figwheel:WARNING] Compile Exception: Could not locate user__init.class, user.clj or user.cljc on classpath.  
post-build-hook-fn: There was an exception while requiring the namespace 'user while trying to load the var 'user/foo


There’s probably a simpler way to tackle this 🙂


I’m not sure I am following. But I get this to work. 1. Create a directory env as a sibling to src 2. Put a file user.clj there with (ns user) and (defn foo [arg] (println "Hello world, args: " arg)) 3. Add "env" to :extra-paths of the alias I am using 4. Add user/foo to :post-build-hooks


I also see that you are using the alias :fig which I think often contains :main-opts . If so that will not chime with jack-in, unless those opts start the nrepl server. Try without selecting that alias. (Even if this should be unrelated to the problem with finding user/foo.)


[email protected], Stupidly I’d tried that earlier but with source-paths rather than extra-paths. With extra-paths It no longer barfs about the user namespace, but I’m not seeing the println anywhere. And fair point - my fig alias is now misnamed as its :main-opts moved elsewhere.


You’re welcome. I’m glad I got to try that out and learn a bit about these settings. As for the printout. Don’t recall where I found them. Maybe in the Jack-in terminal? Maybe in the (wrongly named) Output channel Calva Connection Log


Don’t spend time on this - but I tried all those. No errors, but nothing in any log as far as I can see.


Haha, try to stop me. 😃 But not right now, working for food time.


Just picked up on this again when I saw that missing Hello World suddenly appear at startup. So the println is working now and outputting to the REPL buffer after the build as it should. 🙂


When I get some time I’ll see if I can get it to do something sensible with the npx webpack call.

calva 1

Wow, @eric.uitbeijerse It is a pleasure to try to contribute to Clojure success, because the community is so welcoming, helpful, and interested in helping each other succeed. It makes me happy to hear that we Calva peeps are following the example. Thanks for sharing that!


Just reported two printing related issues. It would be nice to get them fixed. 🙏


Quick question for Vs code and Calva users. How do you stop evaluating when your functions enters an infinite loop?


What OS you on?

Hagenek20:01:58  [9:07 PM] Tried Ctrl-Alt-C Ctrl-Alt-D, but that does not seem to do the trick. (Should stop evaluations). (edited)


How about: Ctrl+Shift+P -> Calva: Interrupt Running Evaluations ?


(I'm on Ubuntu/Gnome & Ctrl+Alt+D is show desktop)


It might be that there is a sluggishness in the system, that it actually interrupts it but text keeps coming into the REPL


I will stop it and wait and see if it stops coming text in the REPL after a while


Yes, sluggishness. If you are printing from that loop that will not stop until the print queue use empty.


There's a command for that. Iirc somethng like Interrupt running evaluation


I need a good story for customization; can't do well w/o my nitty gritty keyboard behaviors. a) I'm thinking: Calva to expose pretty much all it can (mirrored doc map, paredit fns, etc) in it's public API. That's the way to allow people to customize to their workflows. We can tag: "API subject to change" and things can break from time to time. That RH "never break API" is not the mother lode of good things, there are cases like here. b) Maintain a series of patches applied on releases from time to time. c) A setting flag "Calva: Natural mode" (killSpace, backspaceNoFormat) but the rabbit hole may be deep here.


Probably a) with a well thought API is a good plan.

replied to a thread:

Wonderful. And super extra great that you both contributed to Calva’s shiny Review section at the marketplace. ❤️ As for who to thank: A lot of people! @bozhidar and his CIDER team comes to mind, of course, since Calvados is distilled from Cider. And now lately we are sourcing the power of #lsp and, by that proxy, also #clj-kondo which brings in all the many hours of hacking and supporting put in by @borkdude, @ericdallo and @snoe to serve the Calva users.

❤️ 2
clojure-lsp 2
calva 3
clj-kondo 1
cider 2
hyper-clap 1