@fappy, interesting. I noticed that recently some of the circle builds randomly fail due to cljs tests complaining about cleanup-if-dirty
, but then they get rebuilt, and the problem goes away. might have to do with an order things get compiled / referenced.
where do you need to :refer
the actual function?
(i.e. I know it is a problem, since I see it happens sometimes, but did not pinpoint the reason yet)
@fappy: 0.1.9-SNAPSHOT
has it public. Let me know whether it works better for you
@tolitius: it works as long as I :refer [cleanup-if-dirty]
... I suppose it's because I'm in ClojureScript and the defstate
macro expansion refers to cleanup-if-dirty
@tolitius: perhaps if defstate
is the only one who uses cleanup-if-dirty
then it can be a local let-fn
inside the macro expansion and cljs users would not need to :refer
it in addition to defstate
?
@tolitius: a second question: in ClojureScript, it looks like a defstate is not actually :start
ed until the moment someone @ deref's it --- that is, :refer
ing it is not enough to :start
a dependency.... Is this as-designed (the start-up order for everything will be the same) or is this an unexpected difference from pure Clojure?
@fappy the rational for derefing is here: https://github.com/tolitius/mount/blob/master/doc/clojurescript.md#managing-state-in-clojurescript (long story short, in cljs :advanced
you can't rely on several Clojure namespace API) but if you are not planing to use :advanced
to start with, you don't have to go into cljc
mode
as to cleanup-if-dirty
, you still need to :refer
it for 0.1.9-SNAPSHOT
?
since we already have several cljs projects that use mount (+ the mount cljs example app: https://github.com/tolitius/mount/tree/master/dev/cljs/app) and they do not need to require it..
can you run boot test-cljs
or lein do clean, doo phantom test once
(whichever you prefer) from the mount root and see if it passes for you?
I understand that your env is different, but it's a good start
oh you mean with a mount clone, in order to test my env?
haha. that means building phantomjs --> 30 min
right, not exactly your project, but just to rule out something env specific
sure ok
$ time lein do clean, doo phantom test once 0.1.9-SNAPSHOT
;; =============================================================
;; Testing with Phantom:
Testing mount.test.fun-with-values
Testing mount.test.private-fun
Testing mount.test.parts
Testing mount.test.cleanup-dirty-states
Testing mount.test.stop-except
Testing mount.test.start-without
Testing mount.test.start-with
Testing mount.test.suspend-resume
Ran 9 tests containing 71 assertions.
0 failures, 0 errors.
12.66s user 1.16s system 142% cpu 9.704 total
not too bad :simple_smile:
yeah. just have to get phantom first
all my project needs is node so I don't yet have phantom
oh.. you can just run boot test-cljs
or do you have get boot
for that? :simple_smile:
good thing to get regardless
that still requires phantom which is still in the process of --recurse-submodules
before building from source
if it is a problem, there are a couple of other things to try:
1. You can run a cljs example app, and see if it works for you (it does not have :require
cleanup-if-dirty
)
2. You can give me something to checkout and try, if that is ok, of course
for #1: boot cljs-example
or "lein via figwheel"
may have to give you something since phantom build from source failed on my machine. (it didn't think libQt5Bootstrap.a
was compatible when searching for libQt5Bootstrap.a
)
(going to eat first though)
sure, no need for phanton.. should not be that complex
@tolitius: https://github.com/frankhenderson/mount-question is an almost minimal repo of the warning in my environment
@tolitius: I get the warning when I do lein figwheel dev
@fappy thx, will look later today
@tolitius: I think all I needed was to add (mount/in-cljc-mode)
to my core namespace. The warning is gone now.
you'll definitely need it, if you are going as far as ClojureScript production deploys, since then you'll use :advanced
compilation optimization level, which would mangle all the namespaces
glad it works, and that is probably why we have not seen it before since, so far everyone I know using mount on cljs do run it cljc mode. I would still like to understand the reason though.. :simple_smile:
Well... this will just be a server-side app. In cases where I don't care about disk usage, I won't have to use :advanced
... there will be no downloading of my generated js
I see.. if you don't mind to run in this mode for now, that would be good. I'll try to piece together the reason.
to refactor out of this mode is just to remove @
s
ok thanks. (I still have to learn how to use the generated source-map to make sense of the mangled names in a stack trace. I think the browser does it for everyone else but my use case doesn't include a browser!)
yea, that's definitely an interesting use case
I'll just run in cljc
mode but keep optimization at :none
yea would definitely help to read source maps
yea.. that's definitely not your env or anything on your side:
boot.user=> (start-repl)
cljs.user=> (require-macros '[mount.core :refer [defstate]])
nil
cljs.user=> (defstate a :start 42)
clojure.lang.ExceptionInfo: Unable to resolve var: cleanup-if-dirty in this context at line 1 <cljs repl> {:file "<cljs repl>", :line 1, :column 1, :tag :cljs/analysis-error}
cljs.user=>
cljs.user=> (require '[mount.core :as mount])
nil
cljs.user=> (mount/in-cljc-mode)
:cljc
cljs.user=> (defstate a :start 42)
#'cljs.user/a
cljs.user=> a
#object[mount.core.DerefableState]
cljs.user=> @a
42
@fappy: looks like (:require [mount.core])
at the app entry should be enough. no need to run it in cljc
mode
let me know whether it works for you
@tolitius: yes that works for both the minimal example and my project
@fappy: cool. I am not a cljs guru, so the best way to tackle this needs some research :simple_smile: but I think it's not unreasonable to "require" at the app entry for now, as long as it is documented
what do you mean by app entry
? I put the :require
in the ns which gave the warning.... Do you mean put it in my core ns ?