Fork me on GitHub
#shadow-cljs
<
2021-03-12
>
isak20:03:15

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)?

thheller20:03:14

I just lein install

4
thheller20:03:42

the recommended way still just uses the installed version in .m2 so that has nothing to do with it

4
thheller20:03:14

what do you intend to do? another way is just putting the shadow-cljs src/main into the source paths of your project

isak04:03:22

Sounds good if lein install works. Just checking if I can solve one of the problems with inspect that I noticed earlier (where taps don't work if you do them too quickly on a page load)

thheller08:03:02

if you intend on working on it while working on a project I'd definitely recommend just adding the source path to the project

thheller08:03:48

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

thheller08:03:55

works fine with project.clj or deps.edn as well

isak22:03:42

I'll give that a shot, thanks!

Jason21:03:11

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.ednbuild:
{: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.

thheller21:03:34

@jasonhlogic first of all your :asset-path looks incorrect. likely that should just be /js?

thheller21:03:58

the error you get is when the files you are loading were not produced by the running shadow-cljs instance

thheller21:03:23

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

thheller21:03:29

or you jsut haven't started the watch? don't know which command you run

Jason21:03:18

I changed the :assset-pathto "/js", but I still get the same error. My command is:

clojure -M:defaults:ui:dev-cljs
where defaultsis 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

thheller21:03:54

not a clue how that works but it doesn't matter for shadow-cljs

thheller21:03:05

you are opening http://localhost:8280 I presume?

thheller21:03:48

that serves the files from <project>/projects/ui/public

Jason21:03:53

Confirmed.

Jason21:03:21

Also correct.

thheller21:03:23

and you are including <script src="/js/ui.js"> in the HTML

thheller21:03:52

do you maybe have two instances of shadow-cljs running?

Jason21:03:34

Yes, this app ran before I changed the paths

thheller22:03:19

simple test. shutdown shadow-cljs and open the http://localhost:8280

thheller22:03:35

if you still get a reply then find out from where

Jason22:03:35

Only one instance running, and these resuts are confirmed by another developer

thheller22:03:57

could be a service worker if you have one

Jason22:03:41

I shut down the instance and the browser says it can't connect

thheller22:03:42

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

thheller22:03:55

but especially if you move some files or change directory names or so

thheller22:03:13

it is easy to miss one place and is still using an old file from some other directory

Jason22:03:41

yes, let me go clean those out.

thheller22:03:03

you can also remove :preloads [shadow.remote.runtime.cljs.browser]. that has been the default for a while now.

thheller22:03:13

but that doesn't affect anything regarding this

Jason22:03:20

happy to clean out old opts 🙂

Jason22:03:17

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.

thheller22:03:53

the build name doesn't affect this. the :modules key does.

Jason22:03:53

duly noted and thanks again