This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-24
Channels
- # announcements (5)
- # aws (5)
- # aws-lambda (6)
- # babashka (6)
- # beginners (48)
- # calva (54)
- # clj-commons (12)
- # clj-kondo (39)
- # cljfx (3)
- # cljs-dev (11)
- # clojure (91)
- # clojure-europe (25)
- # clojure-uk (3)
- # clojurescript (16)
- # cursive (2)
- # data-oriented-programming (6)
- # datomic (8)
- # emacs (10)
- # events (3)
- # fulcro (2)
- # functionalprogramming (2)
- # graalvm (4)
- # graphql (2)
- # helix (1)
- # honeysql (4)
- # jobs (1)
- # malli (4)
- # nextjournal (21)
- # off-topic (5)
- # other-languages (4)
- # overtone (3)
- # reitit (17)
- # releases (2)
- # rewrite-clj (6)
- # ring (6)
- # shadow-cljs (37)
I'm trying to control which :npm-deps
are provided using deps.cljs
for diferent versions of a library in a monorepo. Setting up a structure like this:
foo_lib
├-src
| └-core.cljs
| └-...
├-v1
| └-deps.edn
| └-deps.cljs
├-v2
| └-deps.edn
| └-deps.cljs
And in those deps.edn files
:paths ["." "../src"]
This gives me a deprecation warning because the path is outside the project. Anyone see some other layout I can use? (I'm ready to solve it via documentation and telling consumer which npm dependency to install for different versions of the library API, but want to also check what options I have.)this is what local deps are for
The library is consumed through local deps. Is the suggestion here that I can somehow use local deps in the library to get the shared src directory on the classpath?
You also said > Or one deps.edn at the root https://clojurians.slack.com/archives/C03S1L9DN/p1645713410040839 I think I am missing something there, because I struggle to make sense of it.
you can possibly use one deps.edn at the root, then different aliases to pull different subsets of the subdirs and only work from there (but this probably fights with tooling)
my/src {:local/root ".."}
etc
or one deps.edn at the root
I'm trying to create a macro that creates a var 'default in the ns in which it's used without requiring 'default to be passed as a first argument. I've expressed the idea in the following snippet of code:
(defmacro defpage
[{:keys [title component decorators arg-types]}]
(let [ns (:ns &env)
ns-name (:name ns)
meta (:meta ns)
var-name (with-meta (symbol (str ns-name) "default") meta)]
`(do
(let [x# (with-meta '~var-name (merge {:export true} ~meta))]
(def x#
#js {:title ~title
:component (factory->class ~component)
:decorators (into-array ~decorators)})))))
However when using the macro it creates a var in the macro ns instead of the ns where it's used. In clojure I would probably use in-ns for this. Do you have an idea how to make it work with Clojurescript?Looks like you're overcomplicating things. You can just emit a regular def
form without having to generate symbols or altering the namespace. This should work:
(defmacro defpage
[{:keys [title component decorators]}]
`(def ~(vary-meta 'default assoc :export true)
(cljs.core/js-obj
:title ~title
:component (factory->class ~component)
:decorators (into-array ~decorators))))
Can't use #js
because it's expanded during reading and not macro expansion. And Clojure itself doesn't have a #js
reader.
Though I'm not entirely sure why ^:export
is not usable and instead vary-meta
has to be used.
Thank you so much!!
https://replit.com/@eccentric-j/Node-Babashka-With-Redefs-Examples#src/cli/core.cljs here's a demo of nbb using the latest version of promesa which includes an async version of with-redefs perfect for mocking out api requests while testing in a live repl