figwheel 2018-08-03

@manuel has joined the channel

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

oh nevermind, dependency issue. Solved.

@manuel has left the channel

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?

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.

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

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