Fork me on GitHub
#shadow-cljs
<
2017-11-17
>
mhuebert00:11:38

oh nevermind. I had forgotten that I had added a devtools server to one of my other builds šŸ™‚

mhuebert00:11:05

seeing the list of HTTP servers in the logs and being able to click on them is nice. (one is a test build, the other an ordinary :browser build)

cmal04:11:39

FileNotFoundException target/shadow-node-repl.js (No such file or directory) java.io.FileInputStream.open0 (FileInputStream.java:-2) when I tried to start shadow-cljs node-repl

cmal06:11:09

Another question: I add :nrepl {:port 8202} to my shadow-cljs.edn, but it tells me failed to require macro-ns "cljs.repl", it was required by "cljs.repl" when I shadow-cljs watch app

thheller06:11:53

@cmal ah doh. should be fixed in [email protected]. I bumped the closure compiler version yesterday but cljs.closure (used by cljs.repl) is not compatible with that.

cmal07:11:40

both are the same problem?

cmal07:11:25

Hi, @thheller. shadow-cljs watch app works now.

cmal07:11:34

user> (shadow.cljs.devtools.api/nrepl-select :d3-cljs)
To quit, type: :repl/quit
[:selected :d3-cljs]
cljs.user> (defn hello [who]
  (str "Hello, " who "!")
  "ret value")
There is no connected JS runtime.
cljs.user> (cemerick.piggieback/cljs-repl :d3-cljs)
There is no connected JS runtime.
cljs.user> (shadow.cljs.devtools.api/nrepl-select :d3-cljs)
There is no connected JS runtime.
cljs.user> 

cmal07:11:14

I use Emacs and follows the instructions on github repo, but the repl seems not work.

thheller07:11:44

There is no connected JS runtime. means that you need to open the app in the browser

cmal07:11:00

I use cider in Emacs

cmal07:11:06

and cider-connect to 8202

thheller07:11:20

`user> (shadow.cljs.devtools.api/nrepl-select :d3-cljs)
`

thheller07:11:42

notice the user>. you were in a CLJ REPL

thheller07:11:53

nrepl-select causes it to switch to a CLJS REPL

thheller07:11:02

cljs.user> (defn hello [who]
  (str "Hello, " who "!")
  "ret value")
There is no connected JS runtime.

cmal07:11:12

and then I go into a cljs.user> repl

thheller07:11:20

this then fails because there is no JS ā€œhostā€ connected

thheller07:11:28

ie. in a :browser build you need to open it

cmal07:11:47

I am in a :node-library build

thheller07:11:56

in :node-library you need to run node

thheller07:11:19

or use node-repl directly, that launches a node process for you

cmal07:11:50

you mean shadow-cljs node-repl or node-repl in Emacs?

cmal07:11:33

There is no connected JS runtime. [:node-repl] Configuring build. [:node-repl] Compiling ... [:node-repl] Build completed. (39 files, 19 compiled, 0 warnings, 10.58s) JS runtime connected.

thheller07:11:34

unfortunately you need to launch shadow-cljs node-repl outside of emacs

cmal07:11:38

it works

thheller07:11:52

but you can then (shadow.cljs.devtools.api/nrepl-select :node-repl) in emacs

cmal07:11:01

JS runtime connected.
cljs.user>  (defn hello [who]
  (str "Hello, " who "!")
  "ret value")
There is no connected JS runtime.
cljs.user> 

cmal07:11:24

`cljs.user> (shadow.cljs.devtools.api/nrepl-select :node-repl) There is no connected JS runtime.`

thheller07:11:57

note the cljs.user> prompt. you are already in a CLJS REPL. nrepl-select ONLY works in CLJ REPLs

thheller07:11:05

type :repl/quit to get back to a CLJ REPL

cmal07:11:37

cljs.user> :repl/quit
:repl/quit
user> (shadow.cljs.devtools.api/nrepl-select :node-repl)
To quit, type: :repl/quit
[:selected :node-repl]
cljs.user>  (defn hello [who]
  (str "Hello, " who "!")
  "ret value")
#'cljs.user/hello
cljs.user> 

cmal07:11:07

Thanks a lot. @thheller šŸ˜¢ '

thheller07:11:24

Iā€™ll change that behaviour so that you can only nrepl-select when the runtime is already connected

thheller07:11:28

too confusing otherwise

cmal07:11:25

Thanks. simple_smile

cmal07:11:47

Are there any examples for building tests of :node-library project in shadow-cljs?

thheller08:11:08

what do you mean by tests?

cmal08:11:36

I want to write test like in lein test using cljs.test

cmal08:11:48

like deftest and then run-tests

cmal08:11:09

for a node library

thheller08:11:55

(ns demo.app-test
  (:require [cljs.test :refer (deftest is)]))

(deftest some-demo-test
  (is (= 1 2)))

thheller08:11:18

put that in test/demo/app_test.cljs, add :source-paths ["src" "test"]

thheller08:11:23

shadow-cljs test

cmal08:11:31

Thanks !

thheller08:11:02

that command needs a lot of work though

thheller08:11:19

its only a proof of concept at the moment

mitchelkuijpers09:11:50

@thheller the advanced compilation change sounds great

mitchelkuijpers09:11:43

Btw we are also interested in running the tests, that is the only problem we have now, because currently we use lein doo

Jon16:11:33

shadow-cljs depends on babel... which is unexpected

Jon16:11:06

Noticed that since we have unstable network in China...

Jon16:11:09

=>> yarn
yarn install v1.3.2
[1/4] šŸ”  Resolving packages...
[2/4] šŸšš  Fetching packages...
info There appears to be trouble with your network connection. Retrying...

Jon16:11:08

[2/4] šŸšš  Fetching packages...
verbose 27.931 Performing "GET" request to "".
[################################################] 188/189

jgdavey20:11:49

Started using shadow-cljs last night. I wish I would have found it sooner! I can suddenly use npm deps that wouldnā€™t work with :npm-deps!

jgdavey20:11:16

One question: is there programmatic access to the Java apis? Iā€™m curious if I can keep the watcher/builder in the same JVM instance as my applicationā€™s REPL (clojure).

thheller20:11:57

yes there is but it has pretty steep dependency requirements

thheller20:11:06

so you need to be running clojure 1.9

thheller20:11:28

beyond that shadow-cljs compile app is the same as calling (shadow.cljs.devtools.api/compile :app)

thheller20:11:11

the (shadow.cljs.devtools.server/start!) fn starts the embedded server

jgdavey20:11:13

Okay, interesting.

thheller20:11:25

stop! does the shutdown

jgdavey20:11:01

I wonder if that would work as a boot task (which can use instantiate separate instances/versions of Clojure through the ā€œpodā€ abstraction)

thheller20:11:11

I do recommend running it standalone though since its much more optimized that way

thheller20:11:55

I do not recommend boot at all. they do a bunch of stuff that really get in the way, ie. caching doesnā€™t work.

jgdavey20:11:56

Okay, gotcha

thheller20:11:42

but I donā€™t know much about boot so maybe you can figure it out so it works properly

thheller20:11:10

everything I tried just didnā€™t seem like a good fit at all

jgdavey20:11:41

Yeah, Iā€™m sure that boot could be used, but if its optimized for cli usage, that seems like the place to start

thheller20:11:52

@jiyinyiyong yes it uses babel-core to transpile ES6 in node_modules.

jgdavey20:11:25

Iā€™m wanting to minimize friction on a team of folks who are used to lein repl and then a (start) command that does everything, including figwheel

thheller20:11:27

yeah you can do that if you like, just not recommended.

jgdavey20:11:15

Cool. Thanks for your help!