tolitius / mount

managing Clojure and ClojureScript app state since (reset)
Eclipse Public License 1.0
1.22k stars 88 forks source link

Make it self-host compatible #79

Closed arichiardi closed 6 years ago

arichiardi commented 7 years ago

I have been poking around a bit and tried including 0.1.12-SNAPSHOT in lumo. It fails with:

#error {:message Could not parse ns form mount.core$macros in file mount/core.cljc, :data {:tag :cljs/analysis-error}, :cause #error {:message Invalid :refer, macro mount.tools.macro/on-error does not exist in file mount/core.cljc, :data {:tag :cljs/analysis-error}}}

According to Portable Macro Musing there should be a different cljc file for self-host to work fine, and I will try to refactor things a bit. I don't know if and when of course, but this is my favorite library for state management so I have to make it functional in lumo :smile:

I opened this issue just for tracking.

Thanks a lot!

arichiardi commented 7 years ago

The immensely helpful @mfikes, who I cannot thank enough, suggested me to check https://github.com/cgrand/macrovich, which would add a dependency, it is true, but would also allow porting without refactoring stuff.

The problem is that in self-host everything goes in a :cljs reader conditional, not in a :clj. The README explains this better than me :smile:

Thoughts?

tolitius commented 7 years ago

ah.. you meant "bootstrapped ClojureScript", I did not pick up on it in the slack channel. I have a very limited experience with it.

I looked at it when adding ClojureScript support: wanted to see whether I can still rely on ns api within bootstrapped ClojureScript, but then just decided to hide the state behind the IDeref protocol to avoid relying on vars, which actually resulted in some nice properties (lazy system start, watchers, etc.)

However I need to get upto speed with self hosted cljs to understand the problem better. I am all for you doing the work :) and I'll help where I can.

As far as the dependency goes, I looked at macrovich, it looks like it has 4 macros. Depending on what we need (do we need all 4?) we could simply bring it in (with a reference of course) to src/mount/tools/macro.cljc.

We can discuss in more details in a #mount slack channel

arichiardi commented 7 years ago

Ok sounds good, I will put this in my TODO list and jump on the #mount channel when I'll start working on it.

arichiardi commented 7 years ago

Found a very good example and wanted to keep it here for future reference.

arichiardi commented 6 years ago

Supported in #97!