Fork me on GitHub
#mount
<
2016-01-12
>
tolitius00:01:43

@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.

tolitius00:01:04

where do you need to :refer the actual function?

tolitius00:01:32

(i.e. I know it is a problem, since I see it happens sometimes, but did not pinpoint the reason yet)

tolitius01:01:50

@fappy: 0.1.9-SNAPSHOT has it public. Let me know whether it works better for you

fappy17:01:33

@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

fappy17:01:39

@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?

fappy18:01:24

@tolitius: a second question: in ClojureScript, it looks like a defstate is not actually :started until the moment someone @ deref's it --- that is, :refering 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?

tolitius19:01:01

@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

tolitius19:01:57

as to cleanup-if-dirty, you still need to :refer it for 0.1.9-SNAPSHOT?

tolitius19:01:54

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..

tolitius19:01:57

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?

tolitius19:01:07

I understand that your env is different, but it's a good start

fappy20:01:53

oh you mean with a mount clone, in order to test my env?

fappy20:01:00

haha. that means building phantomjs --> 30 min

tolitius20:01:03

right, not exactly your project, but just to rule out something env specific

tolitius20:01:27

$ 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

tolitius20:01:31

not too bad simple_smile

fappy20:01:56

yeah. just have to get phantom first

fappy20:01:20

all my project needs is node so I don't yet have phantom

tolitius20:01:59

oh.. you can just run boot test-cljs

tolitius20:01:12

or do you have get boot for that? simple_smile

tolitius20:01:22

good thing to get regardless

fappy20:01:41

that still requires phantom which is still in the process of --recurse-submodules before building from source

tolitius20:01:51

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

tolitius20:01:36

for #1: boot cljs-example

tolitius20:01:59

or "lein via figwheel"

fappy21:01:25

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)

fappy21:01:44

(going to eat first though)

tolitius21:01:37

sure, no need for phanton.. should not be that complex

fappy22:01:27

@tolitius: https://github.com/frankhenderson/mount-question is an almost minimal repo of the warning in my environment

fappy22:01:22

@tolitius: I get the warning when I do lein figwheel dev

tolitius23:01:05

@fappy thx, will look later today

fappy23:01:48

@tolitius: I think all I needed was to add (mount/in-cljc-mode) to my core namespace. The warning is gone now.

tolitius23:01:54

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

tolitius23:01:50

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

fappy23:01:58

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

tolitius23:01:10

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.

tolitius23:01:26

to refactor out of this mode is just to remove @s

fappy23:01:06

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!)

tolitius23:01:41

yea, that's definitely an interesting use case

fappy23:01:00

I'll just run in cljc mode but keep optimization at :none

tolitius23:01:01

yea would definitely help to read source maps

tolitius23:01:09

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

tolitius23:01:04

@fappy: looks like (:require [mount.core]) at the app entry should be enough. no need to run it in cljc mode

tolitius23:01:10

let me know whether it works for you

fappy23:01:18

@tolitius: yes that works for both the minimal example and my project

tolitius23:01:51

@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

fappy23:01:27

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 ?