Fork me on GitHub
#shadow-cljs
<
2018-09-02
>
priornix12:09:09

Hi, trying out shadow-cljs, looks neat

priornix12:09:26

I managed to compile with shadow-cljs watch app and then run node target/app.js. Next, on another window, I ran shadow-cljs cljs-repl app, but I can't load the cljs namespace?

thheller12:09:01

> I can't load the cljs namespace

thheller12:09:06

what does that mean? what are you doing?

priornix12:09:29

shadow-cljs - connected to server
[1:1]~cljs.user=> (+ 3 3)
[2:1]~cljs.user=> (require '[myapp.core :as mc])

priornix12:09:42

[3:1]~cljs.user=> mc
nil

priornix12:09:59

I'm trying to load and eval the cljs app

priornix12:09:23

Yes (+ 3 3) returned 6

thheller12:09:37

mc is not valid. :as does not create a local variable

thheller12:09:40

just a namespace alias

thheller12:09:43

mc/your-thing

thheller12:09:02

that :as works as a variable is an exception for JS namespaces only

priornix12:09:53

Hmm, well, calling the namespace doesn't work, let me show you

priornix12:09:34

[7:1]~cljs.user=> (myapp.core/main)
<eval>:1
myapp.core.main.call(null)
                    ^
TypeError: Cannot read property 'call' of undefined

thheller12:09:58

what is the code?

thheller12:09:14

first gotta prove that the code exists 😉

priornix12:09:24

Sure, let me hack out the code for you 🙂

priornix12:09:30

Just playing around with it

priornix12:09:57

Great work, @thheller was using lumo before this

priornix12:09:26

But didn't really do much work on lumo anyway let me start on a minimal code and send you the output

priornix12:09:58

(ns myapp.core)

(defn test1 []
  (println "test1"))

(defn main! []
  (println "entry"))

priornix12:09:37

shadow-cljs - connected to server
[1:1]~cljs.user=> (+ 3 3)
6
[1:1]~cljs.user=> (require '[myapp.core])
nil
[1:1]~cljs.user=> myapp.core/main)
nil
[1:1]~cljs.user=> (myapp.core/main)
<eval>:1
myapp.core.main.call(null)
                ^

TypeError: Cannot read property 'call' of undefined

thheller12:09:02

you called it main!

priornix12:09:35

Thanks @thheller I need a new pair of eyes!

priornix13:09:42

Just a quick question, I am reading through the user guide. What's the difference between cljs-repl and node-repl?

priornix13:09:13

So far, I noticed that println results appear in node-repl not in cljs-repl

thheller13:09:40

node-repl is standalone and not specific to any build

thheller13:09:56

cljs-repl is part if your build, started and managed by you

thheller13:09:13

if you just care about the REPL use node-repl

thheller13:09:21

node-repl output is currently only going to where the node-repl was started

priornix13:09:41

Hmm. The output was appearing in the node-repl window just now. Don't know what I did, but it's not appearing inside node-repl window now. cljs-repl works though

priornix13:09:21

Restarted shadow-cljs watch and it works now

priornix13:09:23

I think it could be a bug. Because when I quit node-repl and restarted it, the output disappeared

priornix13:09:58

Let me try to reproduce it again

thheller13:09:07

node-repl isn't stopped if you leave it

thheller13:09:21

you only resume it when you connect again

priornix13:09:25

I see, well, let me see if I can recreate this issue

priornix13:09:48

Because when I quit and resumed node-repl the output disappeared completely

thheller13:09:54

there is not really anything to reproduce. its a known issue. just didn't get to it yet

thheller13:09:06

yes like I said. the output goes to the process that started it.

priornix13:09:08

So it's a known issue, got it

thheller13:09:12

if you start node-repl and leave it

priornix13:09:13

Understood now

thheller13:09:24

the process that started it is gone. so no more output

priornix13:09:28

Right, got it

thheller13:09:39

I'm undecided whether leaving it should kill the REPL

thheller13:09:02

you can run shadow-cljs clj-repl (shadow/stop-worker :node-repl) to stop it

thheller13:09:10

and then run the node-repl again

thheller13:09:29

or run the (shadow/node-repl) from the clj-repl

priornix13:09:59

Thanks for the help

priornix13:09:29

So the workaround that you mentioned kills the REPL

priornix13:09:43

Is there a way to check how many builds are running

priornix13:09:01

if there's only 1, just kill node-repl when leaving it

thheller13:09:10

not as part of the public API currently no

priornix13:09:14

What are the use cases where node-repl is preferred to cljs-repl?

thheller13:09:54

don't know about preferred because that is up to you

thheller13:09:16

node-repl is recommended if you just want to explore at the repl

thheller13:09:34

cljs-repl is recommended if you have an actual running application that you just want to poke into

thheller13:09:53

since you control the node process there you can more easily interact with it

priornix13:09:16

And in node-repl you can re-direct the output to REPL

priornix13:09:09

Need me to update https://github.com/thheller/shadow-cljs/issues/373 with this example, where the output ends up in the wrong place?

thheller16:09:00

@priornix please do. might miss something otherwise

flyboarder17:09:00

@thheller so I blew away the .m2 and .boot directories and sure enough, I can no longer compile 😢

flyboarder17:09:44

I did look into the properties of the app object, it seemed to be correct (confirmed with source) but did not exists when I tried to access them

flyboarder17:09:03

so I cleared the folders and assumed it was caching something

flyboarder17:09:27

now I am getting

thheller17:09:51

so you are using boot

thheller17:09:56

and I cannot control how boot resolves dependencies

thheller17:09:12

therefore you must ensure that everything is correct yourself

thheller17:09:26

the above error means that you are using an incompatible closure-compiler version

thheller17:09:35

and most likely an incompatible clojurescript version

thheller17:09:03

it hsould be clojurescript 1.10.339

flyboarder17:09:03

ok, but where when compiling using shadow as a lib can I specify those things?

thheller17:09:21

I don't understand that question

thheller17:09:46

you mean if you use shadow-cljs directly without boot?

flyboarder17:09:05

let me find the line I am invoking

thheller17:09:42

I don't know anything about boot. I presume there is a command to show your dependencies

thheller17:09:49

run that and look at which cljs version gets picked

flyboarder17:09:19

The dependencies are handled by boot already

thheller17:09:23

that is completely irrelevant to the problem

thheller17:09:32

yes and boot is messing them up

thheller17:09:56

look at nothing else but the dependency graph that is used to invoke whatever command you are using

flyboarder17:09:31

I see what you mean, it throws an error currently

thheller17:09:34

please note that just specifying the deps like in shadow-cljs is not the same thing

flyboarder17:09:38

boot show -p

flyboarder17:09:50

in that repo is throwing an error

flyboarder17:09:03

clojure.lang.Symbol cannot be cast to java.lang.Number

flyboarder17:09:15

I’ll check the dependencies list for a typo

thheller17:09:21

I presume thats a boot error?

flyboarder17:09:32

I believe so

flyboarder17:09:42

@thheller line 109 [org.clojure/clojurescript “1.10.339”]

thheller17:09:27

I see that but I don't see thheller/shadow-cljs?

flyboarder17:09:50

that comes from the boot pod

flyboarder17:09:02

[[thheller/shadow-cljs "2.6.4"]]

flyboarder17:09:06

is the version I am using

thheller17:09:28

then show me the deps that the pod uses

thheller17:09:35

everything else is pretty irrelevant

thheller17:09:58

can you run a REPL inside the pod?

flyboarder17:09:10

I dont know if there is an easy way to grab that

flyboarder17:09:19

I dont think so

thheller17:09:27

can you run the shadow-cljs server?

thheller17:09:14

I see a start-server!

flyboarder17:09:19

this is how I build the pod environment

thheller17:09:28

run the shadow-cljs server and then use shadow-cljs clj-repl command

thheller17:09:42

and run ( "cljs/core.cljs")

flyboarder17:09:41

I get an error when connecting to the repl

flyboarder17:09:43

ClassNotFoundException shadow.cljs.devtools.cli java.net.URLClassLoader.findClass (URLClassLoader.java:381)

thheller17:09:55

your boot setup is seriously frustrating. I'm afraid I can't help you. If you run into the same issue running the compile without boot I'm happy to look further but I can't look into how boot works.

flyboarder17:09:01

and nothing happens after the resource func

thheller17:09:08

in your readme it says boot shadow/server

thheller17:09:23

if you run that I presume it starts the shadow-cljs server yes?

flyboarder17:09:38

that works just fine

thheller18:09:07

and then running shadow-cljs clj-repl doesn't work?

thheller18:09:22

please paste everything not just one line

thheller18:09:53

why is that version 2.4.22?

flyboarder18:09:25

I imagine the global npm version I have is different than the dependency boot is pulling in

flyboarder18:09:36

I can update it

thheller18:09:54

the global version isn't used if you have it installed in your project

thheller18:09:31

ah wait ... I guess thats boot nonsense again of not actually keeping the files in node_modules/... but someplace else

flyboarder18:09:50

boot dosent pollute the project dir

thheller18:09:53

ok then the global version is used

thheller18:09:23

ok in your boot stuff make sure that the shadow.cljs.devtools.cli namespace is required

thheller18:09:43

I think its just not loaded due to boot starting the server not shadow-cljs

flyboarder18:09:41

I can print from the shadow-cljs repl I think

thheller18:09:53

please don't try to skip problems

thheller18:09:57

one at a time

flyboarder18:09:19

I’ll add the extra ns

flyboarder18:09:48

ok, ns added starting server…..

thheller18:09:49

cljs 1.9.946 ends up on the classpath BEFORE 1.10.339

thheller18:09:57

I presume that the same thing happens for the closure compiler

thheller18:09:10

thus you end up with conflicting classes which can't be loaded properly

flyboarder18:09:52

so this is really a classpath conflict

thheller18:09:10

it always was. there is no other explanation 😉

flyboarder18:09:21

yeah I guess so hahaha 😛

thheller18:09:36

I have seen that error plenty of times and it always was caused by an old clojurescript version

thheller18:09:44

or rather an old closure-compiler version

thheller18:09:11

thats why the shadow-cljs command does a few extra tweaks to ensure that old versions don't get loaded

flyboarder18:09:48

kk, thanks for your help on this, I need more coffee

flyboarder19:09:05

some progress….

thheller19:09:53

( "cljs/user.cljs") is probably the easiest way to verify if the version is correct