Fork me on GitHub

For development purposes I think it would be great if the serversideprops function emitted to nextjs would interface with the local nrepl process and invokes the jvm based version of the server side props function. Because it's nice to at least have repl based development for the server side part


I next-cljs to add basic Remix support (page & loader, can easily add action .etc), but will needs to move away from :npm-module target as it's quite deprecated

😎 1

:npm-module is not deprecated. it'll stay as is. just seems like the newer :esm should be used given that all remix/next examples use ESM code


agree esm is the way to go, just that current :esm requires exports to be pre-defined which I think is a bit verbose, would be great to have per-fn :export like in :npm-module as it fits nicely with remix/next page files as they needs certain exports. I will try using custom target to see how it go thinking-face

carlos antonio neira bustos13:05:33

I'm using re-frame-http-fx but I don't seem to find where to sent the Content-Type header on the request, according to the docs using request-format to json-response should do it, but checking the request it still appears as Content-Type: application/x-www-form-urlencoded;charset=utf-8


The code in this realworld implementation should provide answers:

👍 1
carlos antonio neira bustos14:05:27

I tried :headers {"Content-Type" "application/json" }


Hello! I wonder if there is a lib already that allows adding <clojureScript></sclojureScript> or <script type="text/clojurescript"> tags directly to HTML?


Borkdude just keeps creating :star-struck:

Quentin Le Guennec18:05:30

Hello, I got an exception trying to print a clojurescript value with either js/console.log or info from timbre, which I cannot easily debug. Is this a known issue and is there an easy way to get around it? Any clue would help.


I haven't stumbled upon such issues before. If you can't figure it out, try creating a minimal reproducible example. Apart from letting other people try to figure out what's going on, it may improve your own understanding as well.

Quentin Le Guennec18:05:28

Ok, I will try to do that.

Quentin Le Guennec18:05:47

Forgot to mention, it only happens in a production build, not in dev.


Ah, fun stuff. Probably forgotten externs somewhere.

Quentin Le Guennec18:05:45

eh I really don't know how I could debug this. I can't print it, I can't postmortem it either since it's a production build and I can't connect cider to it. It sounds like an extern issue somewhere, but shadow-cljs isn't giving me any warning.


well, what is the exception?


There are instances where none of the build tools help. E.g. when you do stuff like (let [x (first ^js some-js-array)] ...).


externs issues are easy to confirm by just using shadow-cljs release app --pseudo-names


if the error disappears it is externs related


if you still get the error, it should be much more legible as well

Quentin Le Guennec18:05:20

@U05224H0W well hmm... it happens in a fulcro error handler so it recursively throws, so the error is a maximum stack size exceded


You can set a breakpoint there in your browser.


best way to debug is most definitely with pseudo names


well, if it still happens at least. if its gone it gets harder 😉

Quentin Le Guennec18:05:24

--pseudo-names doesn't fix the issue. Can I then assume it's not a extern issue?


no, just the code should be easier to debug


but it does rule out some externs issues yes. just not all.


I think I still need some help with this kind of function:

(defn obj->clj [obj]
  (if (.isObject js/goog obj)
    (-> (fn [result key]
          (let [v (goog.object/get obj key)]
            (if (= "function" (goog/typeOf v))
              (assoc result key (obj->clj v)))))
        (reduce {} ^js/Array (.getKeys goog/object obj)))
Even after importing (:require [goog] [goog.object] in my namespace, when I evaluate (obj->clj js/navigator) I just get :repl/exception back, and I'm not sure how to progress. Moreover, I'm not sure why I can use both js/goog suggesting that goog is a global object, and goog/typeOf, suggesting that goog is a namespace.


This seems to do something:

(ns my.ns (:require [goog :as g] [goog.object :as o]))

(defn obj->clj
  ([obj] (obj->clj obj #{}))
  ([obj seen]
   (if (and obj (g/isObject obj)
            (not (contains? seen obj)))
     (-> (fn [acc k]
           (let [v (o/get obj k)]
             (if (= "function" (g/typeOf v))
               (assoc acc k (obj->clj v (conj seen obj))))))
         (reduce {} (o/getKeys obj)))
probably not exactly what you want... one problem is that js/navigator is self-referencing (so I introduced a seen set). Anyhow HTH 🙂

timothypratley23:05:21 explains usage of goog.object FWIW my guess is that if you us the js/goog style with advanced compilation it will fail, as the name would get munged... but I haven't tested that. The reason it "works" at all is just because they happen to overlap in your environment, but you shouldn't rely on that IMO.


You might also find the cljs-bean library interesting


Thank you very much @U06S1EJPL! In the meantime I had hardcoded a depth limit to avoid the self-reference, but your solution is better! I'll check cljs-bean 🙏

😎 1