Fork me on GitHub
#shadow-cljs
<
2024-05-02
>
weavejester17:05:50

Hi folks! I'm trying to figure out what I'm doing wrong with ShadowCLJS. I'm getting a cryptic eval error with no stacktrace trying to compile a minimal ClojureScript file:

(ns ring.example.chat.client)

(defn on-load [_]
  (js/console.log "Hello World"))

(defn init []
  (.addEventListener js/window on-load))
With a shadow-cljs.edn that looks like:
{:deps true
 :builds
 {:client {:target :browser
           :output-dir "target/assets/public/js"
           :asset-path "/js"
           :modules {:main {:init-fn ring.example.chat.client/init}}}}}
Does anyone happen to have any ideas what might be causing this? Without a stack trace or any further information on what the error actually is, I'm hitting a wall. Edit: Found the issue! It was just a typo - I missed out the "load" event name on the event listener! And of course I notice that the moment I post! However, I would like to know if there's a way of getting more detail error messages? Like something that would tell me that there's a problem at a particular line, rather than just "there's an error somewhere". I've tried --debug to turn on source mapping, but it doesn't appear to register in Firefox.

erwinrooijakkers18:05:39

How do I convert the following javascript code to clojurescript?

const origins = ["foo", "bar"];
sysend.proxy(...origins);
I tried using shadow-cljs (after npm i sysend)
(ns core
 (:require
  [sysend])

(def origins = ["foo" "bar"]
(apply .proxy sysend origins)
but this fails during (advanced) compilation with (Parse error. ‘)’ expected), when I use sysend.proxy there’s no error, but then the resulting web page does not work because sysend cannot be found