Is there a way to do this already? Maybe at least with robert-hooke? If the best option is to add a feature to lein-cljsbuild, it should probably be more general than just *assert*. E.g., work for any dynamic var, including user-defined vars.
Unfortunately, I can't think of any decent way to do this, even with robert.hooke. The compiler runs in a subproject (via eval-in-project) and thus I don't think any hooks set up in the Leiningen process itself would be executed.
I think to solve this problem in the general case it's worth starting a conversation about whether dynamic vars should ever be used to configure the compiler. It seems like all it does is make it harder to configure things -- even without lein-cljsbuild, the cljsc command can't even change the settings that are in dynamic vars. I think the best approach would be to always make things configurable via the compiler options map.
I don't know enough about lein plugins and the cljs compiler to really understand the issues here. eval-in-project involves evaling a form, right? Why can't the form be wrapped in (binding [*my-var* some-value] ...)?
(binding [*my-var* some-value] ...)
Okay, I was confused about the *assert* Var before. I thought it was one of the options that the ClojureScript compiler exposed as a dynamic Var for controlling compilation, but it's actually just the regular old clojure.core/*assert* that it's looking at. That changes my opinion a little bit, such that I'm in favor of supporting it in lein-cljsbuild.
Your description is pretty much the long and short of it. The binding form would end up in the cljsbuild support JAR that lein-cljsbuild depends on for its internal functionality. I guess we'd add a :assert option to the :build map, and pass that down to determine the value for *assert*.
I'll add this in the next release.
Add an :assert option that sets *assert* during compilation.