This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-27
Channels
- # adventofcode (1)
- # announcements (5)
- # babashka (11)
- # beginners (41)
- # biff (16)
- # calva (2)
- # clj-together (1)
- # clojure (9)
- # clojure-austin (8)
- # clojure-doc (1)
- # clojure-europe (45)
- # clojurescript (4)
- # clr (14)
- # datomic (13)
- # figwheel (1)
- # fulcro (11)
- # introduce-yourself (2)
- # lsp (31)
- # malli (6)
- # off-topic (3)
- # releases (2)
- # reveal (8)
- # schema (1)
- # shadow-cljs (13)
- # spacemacs (10)
- # timbre (8)
- # transit (3)
- # xtdb (5)
I want to use the self-hosted clojurescript compiler in the browser to compile code that uses com.rpl.specter
. It says com.rpl.specter/select
is an undeclared var. A JS symbol com.rpl.specter.select
indeed doesn't appear in any of the js/com.rpl.specter*
files in the output of the :bootstrap
build.
In the source select
's a macro https://github.com/redplanetlabs/specter/blob/67e86806020b9d02fbca8cdb1efad3002fc81a32/src/clj/com/rpl/specter.cljc#L347-L351
My :bootstrap
build config is:
{:target :bootstrap
:output-dir "public/bootstrap"
:compiler-options {:warnings {:infer false}}
:exclude #{cljs.js}
:entries [cljs.js com.rpl.specter]}
I copied {:warnings {:infer false}}
from other examples of self-hosted cljs, without knowing what it does and whether it's necessary.
I didn't find statements that self-hosted cljs doesn't support macros. Should this work? What am I missing?
Thanks!
Addendum: It seems that certain macro syntax isn't supported by the self-hosted clojurescript clojurescript compiler. There's a PR in specter that seems to address this partly. I'll see if that gets me further. https://github.com/redplanetlabs/specter/pull/299yeah, lots of lib written in cljc do not account for self-hosted. can't comment on what exactly the problem is though
macros do work just fine but still need to be used correctly, as in the regular CLJS version
quick glance suggests that at least there is a macros.cljs
, or it written as .cljc
with the proper :require-macros
for itself
@U05224H0W When it works, the com.rpl.specter/select
macro should appear as com.rpl.specter$macros.select
in the JS source, right?
Also, when you say that macros need to be used correctly, one of the things you mean in particular is that wrapping macro definitions in #?(:clj ..)
would be wrong. While that works for Clojure and Clojure-hosted ClojureScript, it doesn't work for self-hosted Clojurescript.
and yes, macros are in special $macros
namespaces. that separation is what I mean by using it correctly. can't put macros in the com.rpl.specter
ns directly even though it might appear so
With macros in Clojure, you just use defmacro and that's it. With macros in Clojure-hosted ClojureScript, you describe the problems in https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html With macros in self-hosted ClojureScript, assuming that that's the only target you intend to support, would it be enough to just use defmacro in the .cljs file, similar to the Clojure case, where you just use defmacro in the .clj file, and that's it? Are all the shenanigans that net.cgrand.macrovich deals with and reader conditionals and so forth only necessary to support the mixed ClojureScript on Clojure target?
@U05224H0W Can this work with shadow-cljs's bootstrapped self-hosted cljs compiler?
https://github.com/cgrand/macrovich/blob/e80fb37cb795201821d0e75f73119802227e9620/src/net/cgrand/macrovich.cljc#L11
In my experiments *ns*
is always null
.