Fork me on GitHub
#shadow-cljs
<
2019-02-02
>
kana01:02:56

Hello. I'm trying to use shadow-cljs with Calva, and there is no progress. I can connect to repl via shadow-cljs cljs-repl frontend, but Calva says Failed starting cljs repl for shadow-cljs build: :frontend. Is the build running and conected? Shadow works in lein mode, so I added [cider/cider-nrepl "0.20.0"] into project.clj, then I added it into shadow-cljs.edn, no effect. Can someone help me?

lilactown05:02:58

@kana what steps are you taking when you try to connect to Shadow-cljs via Calva?

jaide05:02:14

What’s the best way to have code that only runs in development mode? In figwheel-main I configured an extra env/dev source path.

jaide07:02:15

Nevermind, able to achieve it with the :dev and :release configs. Shadow-cljs is amazing!

thheller09:02:39

you can't change the classpath in build configs?

jaide14:02:37

Was able to change the :main with the :dev and :release.

thheller09:02:42

@richiardiandrea can you name some of the npm libs you use in your azure builds or other node builds? I'm working on the one-file bundler thing and need examples of libs people actually use

richiardiandrea15:02:35

Sure, Bunyan, node-postgres, @azure/cosmos, ajv, request...just by memory

thheller09:02:17

need to test this a bit

thheller09:02:49

I know that this won't work with all node libs but if webpack can do it so should we 😉

kana10:02:05

@lilactown 1. install shadow via lein 2. add shadow-cljs.edn

{:lein true
 :builds {:frontend ...}}
3. add [cider/cider-nrepl "0.20.0"] to lein (not shadow-cljs) deps 4. start shadow
lein run -m shadow.cljs.devtools.cli watch frontend
5. trying start repl
lein run -m shadow.cljs.devtools.cli cljs-repl frontend
6. trying to connect via Calva 7. getting
This looks like a shadow-cljs coding session.
Failed starting cljs repl for shadow-cljs build: :frontend. Is the build running and conected?

thheller10:02:43

@kana do not do this

thheller10:02:53

do not launch using lein. that is pointless.

thheller10:02:03

just run shadow-cljs watch frontend and shadow-cljs cljs-repl frontend

thheller10:02:15

it will use lein internally when appropriate

kana10:02:17

but shadow-cljs just runs lein

thheller10:02:29

not exactly

thheller10:02:39

it will use lein to run the watch that is correct

kana10:02:49

okay, but it doesn't work too

thheller10:02:03

but if a "server-mode" process is running (eg. the watch) then it won't run lein and instead connect to the server process

thheller10:02:37

so cljs-repl will not run through lein but instead connect to the previous watch

thheller10:02:58

did you wait for watch to start fully before running cljs-repl?

thheller10:02:23

lein run -m shadow.cljs.devtools.cli cljs-repl frontend this will NEVER work when launched through lein

kana10:02:41

Yes. As I say, cljs-repl frontend fully works from cli

kana10:02:35

$ npm run shadow-cljs watch frontend
...
# another terminal
$ npm run shadow-cljs cljs-repl frontend

> waifoo@ shadow-cljs /Users/kana/Development/waifoo
> shadow-cljs "cljs-repl" ":frontend"

shadow-cljs - config: /Users/kana/Development/waifoo/shadow-cljs.edn  cli version: 2.7.24  node: v10.6.0
shadow-cljs - connected to server
[1:1]~cljs.user=> js/document
#object[HTMLDocument [object HTMLDocument]]
[1:1]~cljs.user=>

kana10:02:22

But Calva returns the same in "Calva says"

This looks like a shadow-cljs coding session.
Failed starting cljs repl for shadow-cljs build: :frontend. Is the build running and conected?

thheller10:02:17

did you use calva connect?

kana10:02:19

I just trying to connect to cljs repl separately from clj repl, by "Attach ClojureScript repl" command, but when I am trying to connect to clj repl, it always successfully connected to cljs repl

kana10:02:12

Thanks a lot, you are saved a lot of my time!

kana13:02:46

There was only one rebuild after cljs change (in log), but there were two reloads in browser

{:lein true
 :builds {:frontend
          {:output-dir "resources/public/js"
           :target :browser
           :modules {:main {:entries [waifoo.client]}}
           :asset-path "js"
           :devtools {:watch-dir "resources/public/css"}}}}
css folder didn't has changes

thheller13:02:18

I'm not sure what you mean with "two reloads"

thheller13:02:28

the :watch-dir is incorrect and should be resources/public

thheller14:02:37

:asset-path should also be /js

thheller14:02:59

also prefer absolute paths, will save you later

thheller14:02:05

(but that doesn't affect live-reload in any way)

kana14:02:07

after any change in cljs, the module will be launched in the browser twice

thheller14:02:39

what does that mean to you?

thheller14:02:46

is a function executed twice?

thheller14:02:12

by default shadow-cljs doesn't run anything and only reloads you code

kana14:02:21

okay, I have a tolplevel code in module

thheller14:02:25

do you have any hooks configured?

kana14:02:25

(defonce x (atom 0))
(println "RELOADING" (swap! x inc))

kana14:02:35

at first run we will se "RELOADING 1"

kana14:02:00

after every single change we will see "RELOADING 2" and "RELOADING 3" after second

thheller14:02:30

what is a "change" to you? assuming editing it in an editor?

thheller14:02:49

a simple touch src/your/file.cljs triggers 2 reloads?

kana14:02:40

it doesn't trigger any reloads

thheller14:02:24

it should. are you sure you touched the correct file?

thheller14:02:45

just trying to rule out your editor doing stuff that could trigger the second reload

kana14:02:14

sorry, it triggers only 1 reload

kana14:02:29

does it mean, that it is something with editor

kana14:02:38

oh, maybe parinfer

thheller14:02:41

very likely yes

thheller14:02:02

the live-reload code is pretty fast so it just probably gets triggered twice

thheller14:02:19

eg. you save the file, then run some on-save hook which saves it again