This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-08-05
Channels
- # announcements (7)
- # babashka (9)
- # beginners (47)
- # calva (28)
- # clj-kondo (17)
- # clj-otel (20)
- # clojure (193)
- # clojure-brasil (1)
- # clojure-europe (43)
- # clojure-norway (12)
- # clojure-uk (6)
- # clojurescript (18)
- # datalevin (15)
- # figwheel-main (3)
- # honeysql (3)
- # hyperfiddle (44)
- # introduce-yourself (2)
- # java (10)
- # lsp (19)
- # malli (9)
- # meander (4)
- # off-topic (14)
- # polylith (48)
- # re-frame (21)
- # releases (3)
- # shadow-cljs (6)
- # tools-deps (29)
- # yamlscript (3)
what's the equivalent of (Something. x y z)
or (new Something x y z)
using js-interop
or oops
to avoid externs ? Neither library gives an example.
> to avoid externs I haven't had to deal with externs in around... five years now? Despite heavily using interop. But I've been using only shadow-cljs throughout all this time, so no clue whether the vanilla compiler changes anything here.
(.construct js/Reflect something args)
appears to work
But also, there should be no need for something special in any of the libraries to support (X.)
.
When you write things like (.method x)
, that .method
gets and calls a property, but the name of the property might be changed due to advanced optimizations. So the "get" part can fail due to the names mismatch.
But with (X.)
, you cannot achieve that mismatch at all. Using X
means that you already have a reference to X
, there's no "get" part here - it has been done during the import of whatever you're using.
As for the global things like js/Reflect
- IIRC, automatic externs have been working with js/*
stuff for ages.
Or does plain (js/Reflect. ...)
not work for you?
I would assume that it actually does work.
With modern tools, there's barely any need to think about externs. Maybe throw in ^js
here and there when you mix both JS interop and CLJS functions, as in (-> (.getItems some-object-from-js-import) (first) (.-name))
.
Can anyone tell me why this command is failing? clj -M --main cljs.main --asset-path cljs --target browser --output-dir web/cljs --compile metalist.core
I have a static html file in dir web
and I'm loading the target js myself with .
It doesn't like me setting
--asset-path
, although at some point it was fine with this argument. It also always launches a browser, despite my omitting the --repl
and --serve
options, but it does always compile if I omit the --asset-path
option, although the asset then 404s as expected.
Error message reads "Expected script or -, got flag --asset-path instead",
To add to the confusion, the http://clojurescript.org homepage says the latest version is 1.12 but this seems to be wrong o_O
> It doesn't like me setting --asset-path
, although at some point it was fine with this argument
Hmm. Are you sure?
If it was indeed not failing with that arg, are you certain it was respected?
--help
doesn't list that option.
According to the whole Git history, it has never been an explicit CLI option.
But it is a compile option which can be specified via EDN fed into --compile-opts
or -co
.
> To add to the confusion, the http://clojurescript.org homepage says the latest version is 1.12 but this seems to be wrong o_O Yeah, it has been brought up before. There is a 1.12 release, but it hasn't been published as a jar.
Haven't checked but this command should work:
clj -M --main cljs.main -co '{:asset-path "cljs"}' --target browser --output-dir web/cljs --compile metalist.core