Fork me on GitHub
#shadow-cljs
<
2019-08-07
>
Chris13:08:05

@thheller Is there an issue around anonymous functions in CLJS/shadow-cljs? When I execute (fn [foo] foo) it returns the following stack trace:

Chris13:08:11

SyntaxError: Unexpected token .
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
    at 
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$browser$handle_message ()
    at 
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] ()
    at WebSocket.<anonymous> ()

Chris13:08:08

However, calling (fn foo-fn [foo] foo) seems to work as expected

thheller13:08:04

nothing that I know of but I'll look into it

thheller16:08:16

there is indeed something buggy going on. wonder why that happens though

thheller16:08:32

it is trying to eval (function cljs$user$cljs.user.cljs(foo){\r\nreturn foo;\r\n}) which is invalid JS

thheller17:08:59

fixed in 2.8.45. was only causes by anon-fns defined directly in the REPL, not nested ones. guess thats why nobody complained about that before

Chris18:08:30

Nice, thanks for fixing so quickly! Really appreciate it - I"ll verify it shortly

denik14:08:49

running into this on the command line.. ideas?

shadow-cljs release app
shadow-cljs - config: /Users/den/Dropbox/dev/code/zeal/shadow-cljs.edn  cli version: 2.8.42  node: v8.11.1
shadow-cljs - connected to server
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:381).
shadow.cljs.devtools.cli

neupsh15:08:23

what version of java are you using?

thheller16:08:22

@U050CJFRU how did you start the server? if you are starting the server in a custom embedded way and intent on using the command line you need to require shadow.cljs.devtools.cli wherever you start the server

denik07:08:16

@thheller ah! 💡💡💡. I started it embedded but wanted to build from the command line. Ended up building from the REPL (embedded as well) so it all worked out in the end. good to know, thanks!

andrewzhurov15:08:30

Short: Is there a way to supply additional :dependencies for a build? as with clj's :extra-deps Long: In a shadow-cljs project, I'm having two build aliases, which are being used as

shadow-cljs watch local
shadow-cljs release prod
I'm using re-frisk as a dependency, How would I include re-frisk as dependency only for :local build? i.e. not include it in :prod

neupsh15:08:10

are you looking to add dev dependencies?

neupsh15:08:47

I use something like below:

{:builds
 :dependencies [[re-frisk "version"]]
 {:local
  {:target :browser
   :devtools {:preloads [[re-frisk.preload]]}}
   :dev {:extra-paths ["src/test" "src/dev" "src/workspaces"]
         :extra-deps {
                        nubank/workspaces {:mvn/version "1.0.9"},
                        binaryage/devtools {:mvn/version "0.9.10"}
                        day8.re-frame/re-frame-10x {:mvn/version "0.4.1"}
                        day8.re-frame/tracing {:mvn/version "0.5.1"}
                        }
                 }

  :prod
  {:target :browser}}
 }

neupsh15:08:55

I also use deps.edn to define that :dev like:

{:paths [...]
 :deps {;actual deps here
            }
:aliases {:dev {:extra-paths [...]
                        :extra-deps {...}
              }
}
` and in shadow-cljs.edn :
{:deps {:aliases [:dev]}
 :builds {:local ...}} 
...
}

neupsh15:08:15

instead of dependencies in the shadow-cljs.edn file

andrewzhurov19:08:33

yea, I am curious how to have a dependency in the run-time of a build, cool that we've got this smart inference of deps-in-use https://shadow-cljs.github.io/docs/UsersGuide.html#_clojure_script

thheller16:08:13

@brownmoose3q it doesn't matter if re-frisk is on the classpath or not. it is only included in a build if the build uses it. its presence on the classpath is not relevant

andrewzhurov19:08:52

a neat feature, eases dev's life 👍

andrewzhurov19:08:52

ha.. My mind was seeking for the solution, ability to supply an extra dep, filtering other approaches The spot in the doc about inferring deps-in-use jumps in your eyes straight away. 🙂 https://shadow-cljs.github.io/docs/UsersGuide.html#_clojure_script

thheller16:08:44

:preloads are only used in development builds so it automatically won't be included in the release build

Daniel Leong20:08:29

Is there a way to get compile warnings/errors via nrepl? With figwheel when I use the load-file op it responds with err messages (ex: {'id': '874b6a4f-5419-4acc-3f82-bdca8708ac7d', 'session': 'acf389b9-51cb-4231-8499-1a9ee17fa53d', 'err': 'WARNING: No such namespace: str, could not locate str.cljs, str.cljc, or JavaScript source providing "str" at line 24 /path/to/file.cljs^@'}) but shadow-cljs just responds with a {'status': ['done'] ...} message

thheller20:08:47

errors are reported to whereever the watch was started. did you maybe not start the watch via nrepl in the first place?

Daniel Leong20:08:45

Ah, no I usually start the watch via cli and connect to nrepl via vim/fireplace

Daniel Leong20:08:59

I tried starting the watch over nrepl by evaluating the (shadow/watch :app) API but load-file still just returns ['done']

Daniel Leong20:08:31

I used shadow-cljs start to start a background server, if that makes a difference

Daniel Leong20:08:16

To be clear, the CLI (if I do shadow-cljs watch :app) and the webpage (via the HUD/overlay) both report the errors just fine, but I was hoping to also get them via the nrepl connection for displaying in Vim

thheller20:08:29

please open an issue. too tired to look into it now. could be that load-file errors just aren't properly forwarded to all places

Daniel Leong20:08:55

Will do, thanks!