This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-14
Channels
- # announcements (2)
- # babashka (7)
- # beginners (20)
- # calva (2)
- # clj-kondo (7)
- # clojure (31)
- # clojure-australia (3)
- # clojure-dev (10)
- # clojure-europe (7)
- # clojurescript (13)
- # conjure (1)
- # cursive (27)
- # datomic (168)
- # events (3)
- # fulcro (2)
- # garden (3)
- # honeysql (2)
- # jobs (1)
- # joker (1)
- # lsp (52)
- # releases (1)
- # shadow-cljs (11)
- # slack-help (4)
- # spacemacs (22)
- # sql (1)
I have a use case where I want to ^:export
some variables for JS consumption - the build in shadow is :npm-module
. To clean things up I wanted to do export a cljs var within a macro, but I'm struggling to find a way to do so - attaching the metadata to the resulting cljs var doesn't get shadow to include the var in the module.exports. I can goog.exportSymbol manually in the macro code, but I do I also need the JS var in the module.exports object. Is this a known limitation or is there a way to get this working?
@danvingo what did you do in the macro? shadow collects the data from the analyzer meta data so if you did it correct it should just work
the background context is I'm trying to create some react storybook stories - which in the newer versions are just functions that are exported. Here's the code:
(defmacro make-story2 [nm body]
`(defn ^:export ~nm []
(reagent.core/as-element ~body)))
I've also tried:
(defmacro make-story2 [nm body]
`(do
(defn ~nm []
(reagent.core/as-element ~body))
(alter-meta! (var ~nm) assoc :export true)))
ahhhh I found the magic incantation 🙂
(defmacro make-story2 [nm body]
`(defn ~nm
{:export true} []
(reagent.core/as-element ~body)))