Fork me on GitHub
#bootstrapped-cljs
<
2020-06-11
mfikes14:06:48

@sfyire Your test-macro is being defined and being used in the same namespace. (What you are seeing here would occur with regular ClojureScript as well, FWIW.)

phronmophobic15:06:34

@mfikes,this is exactly what I was looking for! Thanks!

phronmophobic15:06:18

is it possible to include macros in AOT compilation?

phronmophobic15:06:34

i’m compiling with :aot-cache set to true and calling cljs.js/load-analysis-cache! at runtime for every .*cache.json file produced. this has dramatically sped up page load times and seems to make eval work for everything except macros.

phronmophobic16:06:47

after loading the AOT cache and trying to call a macro that intended to be loaded from cache, I get the following error:

{:error
 #error {:message "Could not eval ",
         :data {:tag :cljs/analysis-error},
         :cause #error {:message nil,
                        :data {:clojure.error/source nil,
                               :clojure.error/line 1,
                               :clojure.error/column 1,
                               :clojure.error/phase
                               :compilation},
                        :cause #error {
                                       :message "Cannot read property 'findInternedVar' of null at line 1 ",
                                       :data {
                                              :file nil,
                                              :line 1,
                                              :column 1,
                                              :tag
                                              :cljs/analysis-error},
                                       :cause #object[TypeError TypeError : Cannot read property 'findInternedVar' of null]}}}}

mfikes16:06:56

@sfyire While :aot-cache won't affect anything related to self-host (it is really for JVM ClojureScript), you can indeed conceptually AoT compile macro namespaces. You have to roll your own way of doing that. Planck does this https://blog.fikesfarm.com/posts/2016-02-03-planck-macros-aot.html The high-level idea is that you can use a build-time self-hosted compiler to compile macros namespaces down to JavaScript. Also Replete does this as well, all in the name of fast loading. So, you can look at Plank and Replete as inspiration on how to do this. There might be other examples out there as well.

phronmophobic16:06:48

I’ll check it out. thanks for the help and your work on clojurescript 🙂