Fork me on GitHub
#figwheel
<
2018-08-03
>
manuel07:08:04

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

manuel08:08:13

oh nevermind, dependency issue. Solved.

mikerod18:08:12

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?

mikerod18:08:31

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.

mikerod18:08:19

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

mikerod18:08:49

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