figwheel

general discussion about figwheel, specific discussions in #figwheel-main and #lein-figwheel
manuel 2018-08-03T07:57:04.000115Z

Hi everybody, I have a problem configuring figwheel-main in my project. Is this the right channel to ask questions? 🙂

manuel 2018-08-03T08:24:13.000210Z

oh nevermind, dependency issue. Solved.

2018-08-03T18:39:12.000077Z

Recently I ran into a situation with figwheel-sidecar where I had a macro in a ns like:

clj
(ns foo.mac)
(def a "hello")
(defmacro foo [] @(resolve 'a))
and a cljs file like
clj
(ns foo.bar (:require-macros [foo.mac :as f]))

(defn on-js-reload []
  (f/foo))
and it throws an NPE when compile the CLJS. The reason is that (resolve 'a) returns nil, and that is because the bound *ns* during macroexpansion in the foo.mac ns is bound to cljs.user, not the ns foo.mac. Anyone have any thoughts on that?

2018-08-03T18:39:31.000186Z

In general, I’m not sure it is “safe” to use resolve at macroexpansion time during CLJS compilation, but I also don’t have any reason to believe it isn’t safe.

2018-08-03T18:41:19.000304Z

I’m wondering if figwheel should be setting up the CLJS compiler environment to have the *ns* bound to the CLJ ns being analyzed - not even sure that fixes it though

2018-08-03T18:42:49.000384Z

In figwheel-sidecar.utils/compiler-env I see that it has (cljs.env/default-compiler-env build-options) called, which is where the *ns* gets eventually gets it’s default of cljs.main from I believe