This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-22
Channels
- # announcements (2)
- # asami (123)
- # aws (17)
- # babashka (77)
- # babashka-sci-dev (23)
- # beginners (48)
- # biff (6)
- # calva (35)
- # cider (16)
- # clj-on-windows (1)
- # clj-yaml (19)
- # clojure (36)
- # clojure-europe (78)
- # clojure-nl (5)
- # clojure-norway (8)
- # clojure-poland (3)
- # clojure-uk (16)
- # clojurescript (17)
- # cursive (6)
- # datahike (3)
- # datalevin (26)
- # duct (7)
- # emacs (41)
- # events (2)
- # fulcro (7)
- # graphql (5)
- # honeysql (13)
- # juxt (3)
- # kaocha (7)
- # lsp (5)
- # malli (12)
- # off-topic (14)
- # pathom (3)
- # portal (1)
- # rdf (9)
- # reitit (3)
- # remote-jobs (2)
- # shadow-cljs (37)
- # spacemacs (5)
- # tools-build (1)
- # tools-deps (20)
- # xtdb (2)
Given a shadow-cljs.edn with :deps set to true, and a deps.edn with an :aliases of :shadow-cljs with the :extra dep of shadow and the main opt set to ["-m" "shadow.cljs.devtools.cli"] i would expect running the command line script clj -M:shadow-cljs pom
to produce a pom (or do anything) instead i get "Unknown action" which is also what i get if i replace "pom" with "help" or "info", meanwhile "watch app" seems to work.
i wonder if my shadow version is somehow ancient...
nope its fairly recent 2.19.4.
i would also be fine creating a release build another way, maybe i should just use the clojure shadow library directly?
can you explain your intent? pom
is a task by the shadow-cljs
cli command, which you do not use? however you can ask clj
to generate a pom file for you, since it is in charge of generating the classpath? -Spom
I believe?
help, info are all things provided by the shadow-cljs
command, which runs in node and doesn't execute java for those
note that you can just continue using the shadow-cljs
command? it'll just call clj for you. you only lose features by going with clj
@U05224H0W thanks thheller.
I'm following the instructions as outlined here in the user guide.
https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn
> Example shadow-cljs.edn
with :cljs alias
>
{:deps {:aliases [:cljs]}
> :builds ...}
> Example deps.edn
> {:paths [...]
> :deps {...}
> :aliases
> {:cljs
> {:extra-deps {thheller/shadow-cljs {:mvn/version <latest>}}}}
> Running with clj
directly.
> {:paths [...]
> :deps {...}
> :aliases
> {:shadow-cljs
> {:extra-deps {thheller/shadow-cljs {:mvn/version <latest>}}
> :main-opts ["-m" "shadow.cljs.devtools.cli"]}}}
> clj -A:shadow-cljs watch app
a pom has nothing to do with creating a release build, i didn't mean to imply it did.
Build the following command fails:
> clj -A:shadow-cljs pom
And reports Unknown action
As where
> clj -A:shadow-cljs watch app
Correctly watches the app. Similarly,
> clj -A:shadow-cljs release app
fails with "unknown action"
just like pom, which is why i pointed out that more "actions" then the one i wanted to run were failing. The readme implies this should work.
If i just use shadow-cljs i get a very different complaint about missing devtools:
shadow-cljs release app
shadow-cljs - config: /home/drewverlee/Centriq/centriq-web/frontend/shadow-cljs.edn
shadow-cljs - starting via "clojure"
Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
Full report at:
/tmp/clojure-5691110849954872601.edn
My best guess this is because shadow doesn't know about binaryage/devtools because it's a hidden behind a deps.edn aliase as an extra dep. But that guess doesn't seem great because the path is shadow/cljs/devtools/cli and nothing about binaryage.
My only other thought is that my package.json has shadow as a devDependency as well, though thats what i feel i have done in all my projects and i don't recall running into this.Yea, if i add shadow-cljs as a dep (not behind an alias) to my deps.edn then i can run shadow-cljs release
and add the thheller/shadow-cljs
dependency to your deps.edn
:cljs
alias (or :shadow-cljs
, or whatever alias you want)
if you do not use the shadow-cljs command I think you must use clj -M:shadow-cljs release app
?
> My best guess this is because shadow doesn't know about binaryage/devtools because it's a hidden behind a deps.edn aliase as an extra dep.
or is your intent really to run everything via clj
and no longer use the shadow-cljs
command
i'm running some different combinations to see if i can answer my own question...
I understand now, the shadow-cljs.edn :deps :aliases are picked up when you run shadow-cljs at the command line, and so the deps.edn aliases by the same name as the one i gave shadow-cljs.edn shouldn't have a main-opt that calls out to shadow command line as well. That makes sense.
@U05224H0W
For my own education, i wrote up a short explanation of how i understand the topic now that i have had a chance to review it. If you like, i can try to clean it up more and and it could be used in the docs, or not 🙂 The following is pulled from a markdown file, so the formatting is a tad off:
# 3.2.2. integration with deps.edn and clj tool
Shadow can pull dependencies from deps.edn and Shadow can be called from the clj tool. In the section below will break down both.
## Integration with deps.edn
In order to tell Shadow that you want to use a deps.edn you have to add the
:deps
key to your shadow-cljs.edn. The :deps
value is going to Shadow where
to look for the theller/shadow-cljs dependency in your deps.edn.
If you want to place that in your deps.edn :deps
directly then set your shadow-cljs.edn :deps
to true
Which looks like this:
shadow-cljs.edn
{:deps true}
deps.edn
{:deps {theller/shadow-cljs ...}}
Now when you run
bash
shadow-cljs some-shadow-action
the command line tool will find theller/shadow-cljs in the deps.edn through the shadow-cljs.edn file. If you want to move the shadow depency under a deps.edn :aliases, then you will have to tell shadow
about that aliase (or aliases) that you want to use when the shadow is invoked. You do this by changing the deps.edn :deps
value to a list of keywords that shadow will use to look up in the deps.edn and use there extra-deps from. for example
shadow-cljs.edn
{:deps {:aliases [:shadow-cljs]} }
deps.edn
{:aliases {:shadow-cljs {:extra-deps {theller/shadow-cljs ...}} }
Here shadow finds theller/shadow-cljs through the :shadow-cljs
keyword, but you can use any :keyword as long as it matches.
## Having the clj command line call through to Shadow
If for some reason you want to use the clj
command line tool to call out to Shadow, you will need to tell the clj command line how to do that by updating your deps.edn to have an alias with a :main-opts
and a value of exactly ["--main" "shadow.cljs.devtools.cli"]
. "--main"
is a function that takes the string representation of the clojure namespace that has a -main function that you want to pass arguments from the command line to. A full example might look like this:
shadow-cljs.edn
{:deps {:aliases [:shadow-cljs]} }
deps.edn
{:aliases {:shadow-cljs {:extra-deps {theller/shadow-cljs ...}
:main-opts ["--main" "shadow.cljs.devtools.cli"]}}
bash
clj -M:shadow-cljs pom
Of course, clj -M can pass through arguments to any namespace with a main function. Shadow isn't special in this regard.clj -M:shadow-cljs pom
this won't work so doesn't make for a good example in the last section
> the command line tool will find theller/shadow-cljs in the deps.edn through the shadow-cljs.edn file.
this isn't entirely accurate. it won't find anything. the clj
tool constructs the classpath with shadow-cljs in it, when the process it started it can then be loaded
> clj -M:shadow-cljs pom
this won't work so doesn't make for a good example in the last section
Oh you right (big surprise 🙂 ) Why does clj -M:shadow-cljs watch app
work then? I guess the main function of shadow-cljs.devtools.cli doesn't take the same arguments as the command line then? as shadow-cljs pom
would work right?
as I said yesterday. some commands are provided by the shadow-cljs
node script and never execute any java to do that
all build related commands require clojure, so they launch java and are available via shadow.cljs.devtools.cli
I'm back, with hopefully just one more question and I'll be out of your hair.
Currently, Shadow is importing a dep (using :esm
target) like this:
import * as esm_import$node_fetch from "node-fetch";
How can I get it to do
import esm_import$node_fetch from "node-fetch";
(:require ["node-fetch$default" :as node-fetch])
, see translation table provided here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages
Thank you! Sorry for not seeing that!