Is there a good way to develop shadow-cljs locally and use in other projects? Like lein install
, except if you want to use it the recommended way (npm)?
I just lein install
the recommended way still just uses the installed version in .m2
so that has nothing to do with it
what do you intend to do? another way is just putting the shadow-cljs src/main
into the source paths of your project
if you intend on working on it while working on a project I'd definitely recommend just adding the source path to the project
I do this frequently. all projects in ~/code
so just :source-paths ["src/main" "../shadow-cljs/src/main"]
. while keeping the normal shadow-cljs dependency to get all other transitive dependencies and stuff
works fine with project.clj or deps.edn as well
I'll give that a shot, thanks!
I'm playing with monorepo multiproject multibuild settings and I'm getting a fresh error. I'm not sure where I went wrong
with deps.edn
alias:
:dev-cljs
{:extra-deps {thheller/shadow-cljs {:mvn/version "2.11.22"}
...
:main-opts ["-m" "shadow.cljs.devtools.cli" "watch" "ui"]}
and shadow-cljs.edn
build:
{:ui {:target :browser
:output-dir "projects/ui/public/js"
:asset-path "projects/ui/js"
:module-hash-names false
:modules {:ui {:init-fn ui.main/init!
:preloads [devtools.preload
day8.re-frame-10x.preload]}}
:dev {:compiler-options {:infer-externs :auto
:closure-defines
{re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}
:devtools {:repl-pprint true
:preloads [shadow.remote.runtime.cljs.browser]
:http-root "projects/ui/public"
:http-port 8280}}}
When i load the app in the browser, I get "is the watch for this app running?". I only changed paths to move the location of shadow-cljs.edn
up a couple of directories. Any help appreciated.@jasonhlogic first of all your :asset-path
looks incorrect. likely that should just be /js
?
the error you get is when the files you are loading were not produced by the running shadow-cljs instance
so likely if you changed some paths or so you have some older files still somewhere that are not used instead of the new output
or you jsut haven't started the watch? don't know which command you run
I changed the :assset-path
to "/js", but I still get the same error. My command is:
clojure -M:defaults:ui:dev-cljs
where defaults
is a set of override-deps
to version-lock libraries shared across projects and ui
is:
{:extra-deps {ui/ui {:local/root "projects/ui"}}}
which adds the project-level deps.edn
not a clue how that works but it doesn't matter for shadow-cljs
you are opening http://localhost:8280 I presume?
that serves the files from <project>/projects/ui/public
Confirmed.
Also correct.
and you are including <script src="/js/ui.js">
in the HTML
do you maybe have two instances of shadow-cljs running?
Yes, this app ran before I changed the paths
simple test. shutdown shadow-cljs and open the http://localhost:8280
if you still get a reply then find out from where
Only one instance running, and these resuts are confirmed by another developer
could be a service worker if you have one
I shut down the instance and the browser says it can't connect
ok
then I'm out of ideas. there really isn't much that goes into this. shadow-cljs places the files in the :output-dir
and the :http-root
serves them
but especially if you move some files or change directory names or so
it is easy to miss one place and is still using an old file from some other directory
yes, let me go clean those out.
you can also remove :preloads [shadow.remote.runtime.cljs.browser]
. that has been the default for a while now.
but that doesn't affect anything regarding this
happy to clean out old opts 🙂
i found it. i changed the build name to 'ui' but did not update the name of the js file the index page loads. Thank you very much for your responses. I'm sorry to have taken your time with my config error.
the build name doesn't affect this. the :modules
key does.
duly noted and thanks again