Fork me on GitHub
#shadow-cljs
<
2018-08-19
>
richiardiandrea04:08:09

uhm, no....the side effects must be somewhere else...these defmethods are confusing...I will confirm later if it really works 😄

richiardiandrea04:08:49

I guess this is correct? :devtools {:preloads [testing.with-diff-reporter]}

richiardiandrea04:08:25

the full entry is:

{:target :node-test
                 :output-to ".cljs/tests.js"
                 :ns-regexp ".*-test"
                 :autorun true
                 :devtools {:preloads [testing.with-diff-reporter]}
                 :release {:compiler-options {:optimizations :simple
                                              :variable-renaming :off
                                              :property-renaming :off
                                              :pretty-print true
                                              :source-map true}
                           :autorun false}}

richiardiandrea04:08:51

I made sure and a normal require works...I am overriding the cljs.test multimethods, are those required before :preloads or after?

thheller07:08:45

@richiardiandrea :dev {:preloads [...]} currently. forgot that should be in :devtools. will fix later

👍 4
thheller07:08:33

if you want to mess with cljs.test options however I suggest copying https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/node.cljs and adjust whatever you need and your ns via :runner-ns. its main fn will be called when running the test script

richiardiandrea17:08:09

Will try with preloads just to see what happens, the resort to that. Not to write a runner is convenient 😄

wilkerlucio12:08:55

hello, I just did a big bump on shadow from 2.4.10 to 2.6.1 and now getting these:

wilkerlucio12:08:57

RuntimeException java.io.EOFException
	com.cognitect.transit.impl.ReaderFactory$ReaderImpl.read (ReaderFactory.java:114)
	cognitect.transit/read (transit.clj:319)
	cognitect.transit/read (transit.clj:315)
	shadow.build.cache/read-cache (cache.clj:49)
	shadow.build.cache/read-cache (cache.clj:33)
	shadow.build.classpath/find-jar-resources/fn--10051 (classpath.clj:565)
	shadow.build.classpath/find-jar-resources (classpath.clj:564)
	shadow.build.classpath/find-jar-resources (classpath.clj:553)
	shadow.build.classpath/find-resources (classpath.clj:623)
	shadow.build.classpath/find-resources (classpath.clj:621)
	shadow.build.classpath/index-path* (classpath.clj:843)
	shadow.build.classpath/index-path* (classpath.clj:840)
Caused by:
EOFException
	com.cognitect.transit.impl.JsonParser.parse (JsonParser.java:44)
	com.cognitect.transit.impl.ReaderFactory$ReaderImpl.read (ReaderFactory.java:112)
	cognitect.transit/read (transit.clj:319)
Exception in thread "main" java.lang.NoSuchMethodError: com.cognitect.transit.TransitFactory.writer(Lcom/cognitect/transit/TransitFactory$Format;Ljava/io/OutputStream;Ljava/util/Map;Lcom/cognitect/transit/WriteHandler;Ljava/util/function/Function;)Lcom/cognitect/transit/Writer;
	at cognitect.transit$writer.invokeStatic(transit.clj:157)
	at cognitect.transit$writer.invoke(transit.clj:139)
	at shadow.build.cache$write_stream.invokeStatic(cache.clj:9)
	at shadow.build.cache$write_stream.invoke(cache.clj:8)

wilkerlucio12:08:15

any ideas what might be that?

wilkerlucio12:08:12

fixed by manually adding transit-java dep on latest

thheller14:08:34

what the heck?

thheller14:08:21

is this with plain shadow-cljs or lein/deps?

thheller14:08:39

shadow-cljs depends on transit-clj which depends on transit-java so it should be there regardless?

wilkerlucio15:08:49

@thheller plain shadow-cljs in this case

wilkerlucio15:08:02

maybe some other dep of mine was overriding the transit version?

thheller16:08:58

hmm shadow-cljs is added as the very first dep to avoid such issues

ClashTheBunny18:08:58

Is there a dep-tree option to Shadow?

thheller18:08:18

there was in 2.5 but its gone in 2.6. will be coming back soon.

thheller18:08:39

in the meantime you can try shadow-cljs pom and mvn dependency:tree if you have maven installed

urbanslug19:08:56

Anyone know how to fix cannot infer externs for https://github.com/Day8/re-frame-template/blob/master/src/leiningen/new/re_frame/src/cljs/routes.cljs#L18 Seems to break the entire app because I set up navigation before mounting components

thheller20:08:24

@urbanslug (fn [^js event] ...)

urbanslug20:08:22

thanks a ton

thheller20:08:56

@urbanslug but isn't the token coming from a closure router usually? that shouldn't require externs. are you sure thats the problem?

urbanslug20:08:00

No I'm not sure

urbanslug20:08:08

I can't figure out routing lol

wilkerlucio20:08:04

@thheller would be hard to support local deps (like deps :local/root) on shadow deps? I have been in mane cases were it would be very nice to use that

thheller20:08:29

well you can just add the source path manually

👍 4
thheller20:08:44

just keep the deps as normal but also add the source-path

thheller20:08:57

the files on the source path will be used over the jar

thheller20:08:24

I need to figure out some tools.deps stuff before I switch back to that

thheller20:08:55

eventually I want to use it but the issues in 2.5 sort of got out of hand

urbanslug21:08:24

Have you used accountant? From the readme on accountant this seems like it should be possible

(defn hook-browser-navigation! []
  (doto (History.)
    (gevents/listen
     EventType/NAVIGATE
     (fn [event] (secretary/dispatch! (.-token event))))
    (.setEnabled true)))


(defn setup-routing!
  []
  (accountant/configure-navigation!
   {:nav-handler  #(hook-browser-navigation!)
    :path-exists? (fn [path] (secretary/locate-route path))}))

urbanslug21:08:27

but calls to accountant/navigate don't dispatch the routes

thheller21:08:42

no I have not used accountant

urbanslug21:08:10

weird how little literature there is on naviation with goog.Histroy for cljs

thheller21:08:41

whats your issue? routing is not that hard. sometimes seems libraries just make it harder

urbanslug21:08:44

hmm I want to transact the app state when links are clicked so that I can change views

urbanslug21:08:19

and also have back forward in the browser

urbanslug21:08:34

so I have two things on my urls click handlers and hrefs

urbanslug21:08:58

I could transact app-state in click handlers but they won't update the url bar

urbanslug21:08:18

and they spread state changing functions all over

urbanslug21:08:49

My routes defined secretary.core/defroute have funcitons transact the app state

urbanslug21:08:07

these fns don't seem to get triggered when the page is refreshed

thheller21:08:30

https://github.com/venantius/accountant looking at the docs it seems you are setting :nav-handler incorrectly

thheller21:08:10

calling the hook-... fn should only be done once on init

urbanslug21:08:39

hmmm I can't see that anywhere in the code

urbanslug21:08:44

I mean the readme

thheller21:08:02

(accountant/configure-navigation! {:nav-handler (fn [path] ...) :path-exists? (fn [path] ...)})

urbanslug21:08:05

you mean setup-routing! in my case

thheller21:08:07

(fn [path]
  (secretary/dispatch! path))

thheller21:08:26

thats the :nav-handler you are supposed to use I guess

urbanslug21:08:05

that doesn't preserve history from what I can see

urbanslug21:08:15

unless my assets are stale

urbanslug21:08:37

I'll clean eveything and try again

thheller21:08:04

what does preserve history mean to you?

urbanslug21:08:29

hmmm yeah it changes the url bar that's for sure

urbanslug21:08:41

I mean umm render the previous view

urbanslug21:08:57

Say I have two routes:

thheller21:08:49

the user presses "back" and the hook fires to trigger the secretary/dispatch!

thheller21:08:56

that how it goes from what I can see?

urbanslug21:08:28

(defroute root-path "/" [] (swap! app-state assoc :view :index))

(defroute map-path "/posts" [] (swap! app-state assoc :view :posts))

urbanslug21:08:30

so if I start at / and click a link for posts that runs :on-click #(accountant/navigate! "/posts")

urbanslug21:08:37

it loads posts yes

urbanslug21:08:16

but if I press back the url bar will update witout the app-state change ties to the route. Even when I refresh it still ignores the contents of the url bar

thheller21:08:33

sorry I don't know enough about any of theses libs to make a suggestion

thheller21:08:46

seems to me that you might just miss some call on startup?

urbanslug21:08:57

let me move my call to setup-routing! to my init so that websocket stuff doesn't affect it and see

urbanslug21:08:15

I appreciate the help 😄

thheller21:08:23

adding a few js/console.log calls never hurts 😉

urbanslug21:08:01

haha I've done that already

urbanslug21:08:21

I think the issue is that I don't quite get what I'm trying to make it do so I can't tell what's failing

urbanslug21:08:42

I should just use reframe and let it handle everything for me