lynaghk / cljx

Write a portable codebase targeting Clojure/ClojureScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is is possible to make this faster?

samedhi opened this issue · comments

This isn't so much a problem, but just a open ended question. Adding the cljx hook to my project adds about 4-5 seconds to my "lein test" task.

Don't get me wrong, I appreciate what cljx is doing for me. I was just wondering if there was some way (documented or otherwise) to get cljx to either:

  1. Just run a lot faster
  2. Only run if the source (cljx) file is newer than the derived (clj or cljs) file
  3. Do something else to achieve the same effect.

(2) is the most obvious first step; a patch to implement that should be pretty straightforward, a good first contribution from anyone interested. ;-)

Nothing in the "stack" cljx is using (i.e. sjacket), or anything cljx itself is doing with it has seen much of any optimization AFAIK, so there's surely some gains to be made. TBH, optimizations are going to be on the back burner for me until certain key features are complete (esp. loading of required namespaces written in cljx). If anyone wants to dig into that though, feel free.

I don't really know how :hooks or nrepl middelware really work. Does cljx spin up a second jvm when it runs, or is it running "inside" another jvm process. Basically, am I paying the cost of having a jvm spun up or is it just running within another lein task?

Yes, the loading thing would be awesome. Currently I write in cljx, watch it compile, and then switch over to the generated clj file and load that using Ctrl-c Ctrl-k.

If you're using nREPL, then I strongly suggest using the cljx middleware (see the README). As long as your nREPL client (nrepl.el?) is sending the filename as it should for eval and load-file operations, the middleware will perform the cljx preprocessing automatically, and way faster. If you're using cljx once, then that should be running within Leiningen's process.