This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-25
Channels
- # babashka (65)
- # beginners (34)
- # biff (18)
- # calva (8)
- # clara (22)
- # clj-kondo (32)
- # clojure (24)
- # clojure-bay-area (4)
- # clojure-europe (135)
- # clojure-nl (3)
- # clojure-norway (9)
- # clojure-uk (1)
- # clojurescript (11)
- # clojutre (1)
- # core-async (8)
- # cursive (3)
- # datomic (31)
- # emacs (5)
- # fulcro (6)
- # graalvm (5)
- # graphql (3)
- # honeysql (1)
- # introduce-yourself (9)
- # kaocha (1)
- # lsp (65)
- # meander (5)
- # nbb (7)
- # nrepl (2)
- # off-topic (44)
- # rum (3)
- # shadow-cljs (23)
- # specter (1)
- # tools-deps (6)
- # vim (3)
- # xtdb (30)
I declare my deps in deps.edn and I am trying to build with tools.build, when I call (shadow/release :main)
in my build.clj I get "The required namespace is not available...", the being the first dependency required by my code, defined in the :deps
key of my deps.edn. When I copy paste that dependency under :replace-deps of the :shadow-cljs alias then I get the same error with the next one (meaning that dependency is now visible to shadow/release).
My question would be if that is expected? Is there a way to tell shadow-cljs to use the deps from deps.edn :deps key like it does during development?
> My question would be if that is expected?
Yes. You are using tools.build with :replace-deps
, so the Clojure CLI will build a classpath with only the defined deps, and then you use Shadow’s API within the same JVM, so Shadow will have the same classpath.
You probably need to adjust your classpath and make sure that all ClojureScript deps are on the classpath as well, or spawn a sub-process from your build.clj
to call Shadow with its own classpath.
Initially I was not using :replace-deps I just added it to test if it will find the dependency that way
:shadow-cljs
{:paths ["src/main"]
:extra-deps {thheller/shadow-cljs {:mvn/version "2.20.2"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}
all the deps are in the :deps key
How are you using build.clj
? Using clojure -T:build
?
clojure -T:shadow-cljs:build
How is your :build
alias defined?
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.8.3" :git/sha "0d20256"}}
:ns-default build}
Not sure if -T
will ignore the root-level :deps
. In general, you should not use :deps
in your aliases, but :extra-deps
or :replace-deps
. Normally, tools are meant to run in a classpath that is different from your project’s, so they use :replace-deps
. In your case, can you try using :extra-deps
in both your :build
and :shadow-cljs
aliases?
I see you have that in :shadow-cljs
already
See the docs for -T
: https://clojure.org/reference/deps_and_cli#_running_a_tool
> When running a tool, the project’s :deps
and :paths
are not used.
yeah will try, I didn't think too much about this one in :build, I took inspiration from https://github.com/metosin/packaging-clojure-examples/blob/master/deps-uberjar/deps.edn#L17
I think in your case you don’t want to use -T
, as this is meant for standalone tools with their own classpath.
Instead, if you use :extra-deps
in the :build
alias, you should be able to use the -X
switch to run your build functions, with a classpath built from your project’s :deps
and all extra deps from additional aliases.
You might need to add :extra-paths ["."]
so that your build.clj
in on the classpath.
Note that:
> Tools declared with an alias can also be executed with -T, just as they can be executed with -X. The only difference is that -T implies {:replace-deps {}, :replace-paths ["."]}
, so the project deps/paths will not be included, by default.
yep thanks
running with -X solved my issue
So I assume what's missing is the possibility to pass a basis to shadow/release
I understand it this way: The shadow-API is meant to be used on a preconfigured classpath, and the standalone version will follow shadow-cljs.edn
to deps.edn
(when configured) and builds the basis
yeah, tools.build doesn't use the project classpath but CLJS compilation (and therefore shadow-cljs) require access to the full project classpath
Is there a way to disable shadow-cljs automatically calling 'npm install...' commands if one does not want that behaviour ?
Thanks @U05224H0W 👍 🙂