Fork me on GitHub
#shadow-cljs
<
2018-02-22
>
thheller00:02:11

@richiardiandrea what do you have in mind?

thheller00:02:27

yes it has its own internal resolve mechanisms

richiardiandrea00:02:52

@thheller I wanted to ask if shadow could output the classpath so that I can use lumo šŸ™‚

thheller00:02:14

so how this works internally is that shadow-cljs itself depends on shadow-cljs-jar

thheller00:02:29

which is a standalone uberjar thats just used for resolving maven dependencies

thheller00:02:34

not much code at all

thheller00:02:56

basically reads a edn {:dependencies [[foo/bar "1.2.3"]]} map from stdin

thheller00:02:01

downloads the deps

thheller00:02:20

write everything to :cache-root/classpath.edn

thheller00:02:30

exit with 0 on success

richiardiandrea00:02:50

coool so I can use :cache-root/classpath.edn I guess

richiardiandrea00:02:29

it is in edn format, I need to convert it

richiardiandrea00:02:59

and it does not include only the build deps but also shadow deps

thheller00:02:12

well you could create something like lumo deps

thheller00:02:24

to build the classpath and such

thheller00:02:41

well you could just use tools.deps which I would recommend at this point to be honest

richiardiandrea00:02:58

yep I could, but I have already project.clj in place and I can just use lein...or use tools.deps

thheller00:02:31

clojure already has clojure -Spath which is what I assume you are asking for?

richiardiandrea00:02:45

yep that's what I am using

thheller00:02:23

so what do you need shadow-cljs for?

richiardiandrea00:02:35

well, I was just wondering šŸ˜„

thheller00:02:04

since I expect deps.edn to become standard pretty soon I'd suggest sticking with that

richiardiandrea00:02:32

it's just that it requires to use an additional tool on ci...while shadow can be provisioned through npm install but yeah...you are probably right...

thheller00:02:29

but when using shadow-cljs you'd need a shadow-cljs.edn config

thheller00:02:39

since the script itself only reads from that

richiardiandrea00:02:05

yep I am ok with that, but then the classpath has to be generated with other tooling

richiardiandrea00:02:51

no worries Thomas, just grumbling at the some many tools to provision on CI šŸ˜„

thheller00:02:23

well you could roll your own with the shadow-cljs-jar thingo

richiardiandrea00:02:35

I could definitely do that

richiardiandrea00:02:58

I like that you can export functions for :node-library, you could even add JSDoc šŸ˜„ šŸ˜„ šŸ˜„

richiardiandrea00:02:28

will see if I can PR something sooner or later but shadow-cljs has improved a lot since the last time I checked!

richiardiandrea00:02:44

@thheller you are awesome thanks for the fix!

richiardiandrea00:02:14

last question, is there a way to use ClojureScript libraries deployed through the npm mechanism at the moment?

richiardiandrea00:02:33

and is there a way to add things to the shadow-cljs tool classpath by any chance? my deps are not deployed on Maven as we prefer npm in my company at the moment...

richiardiandrea00:02:22

oh I see I can get creative with deps.edn, I will try that

thheller00:02:48

shadow-cljs can't since it loads itself via maven

richiardiandrea01:02:51

I am in a monorepo so I can have a deps.edn file that contains {:paths ["src" "../spec-cljs/src"]}

richiardiandrea01:02:05

and it will end up in shadow's classpath

richiardiandrea01:02:45

that is what I mean by "being creative" šŸ˜„

richiardiandrea01:02:38

lol other question

richiardiandrea01:02:52

when I build, I see in my dist a folder called cljs-runtime

richiardiandrea01:02:18

do I need to deploy both? how do I get a unique artifact?

thheller01:02:06

that only happens when you set :output-dir

thheller01:02:32

you can set :release {:output-to "some-other/path.js"} to only change the path for release

thheller01:02:16

if you only set :output-to you will only get that file. :output-dir during development uses an absolute path in the target/shadow-cljs directory so the cljs-runtime folder doesn't show up in the dist dir šŸ˜›

bolasblack15:02:30

Hi @thheller , I found (println "hello") will print hello in the screen I executed shadow-cljs node-repl, Is it possible to print the message in cider? (https://github.com/thheller/shadow-cljs/issues/207#issuecomment-367699962)

thheller15:02:08

Like I said it is not currently possible.

thheller15:02:51

I need to do some work around the node-repl with regards to nrepl

thheller15:02:50

and then there are two ways the output could get there. either pipe all stdout of the managed node process to the REPL

bolasblack15:02:52

Sorry, I've misunderstood you before. I thought you meant to let me open a new issue to discuss this issue šŸ˜‚

thheller15:02:09

yes thats what I meant.

thheller15:02:49

discussing it here just gets lost so a ticket is better

bolasblack15:02:17

ok, I will open a new issue later šŸ˜›

donmullen20:02:04

Iā€™m getting IllegalStateException: Can't change/establish root binding of: *cljs-warnings* with set when using the [binaryage/oops] library (https://github.com/binaryage/cljs-oops) within a shadow-clj repl. Any ideas?

thheller20:02:39

hmm never noticed that its messing with compiler bindings from a macro

donmullen20:02:13

Yeah - I pulled the library in when goog.object/set did not seem to be working to set properties of a javascript object. I believe something else is going on. My javascript interop chops are weak.

thheller20:02:20

that error in particular is a bug in shadow-cljs though. or rather was. fixed in [email protected]

donmullen20:02:32

Excellent - thanks @thheller!

wilkerlucio21:02:11

@thheller do you have any idea how hard would be to enable REPL in React Native apps? how is it currently implemented for web, websockets? having live-reload/REPL on RN would be awesome

thheller21:02:50

it might work if you import "shadow-cljs/shadow.cljs.devtools.client.browser"

thheller21:02:06

or wherever your :output-dir is

thheller21:02:39

ideally there would be a :target :react-native but I haven't done any serious RN development

thheller21:02:04

last time I tested there wasn't any way to turn of their live reloading

thheller21:02:41

I didn't go past the "hello world" experience

mathpunk21:02:45

I'm making a toy application, and to my surprise & delight I've got a user to support. My goal is for her to be able to run my server.js in node. I changed my project to use shadow-cljs, and it seems to be achieving my goal. However, I'm not sure what's going on with my tests.

mathpunk21:02:16

I successfully compiled a test file, and ran it in node. But, my specs were not found.

thheller21:02:41

which config did you use?

mathpunk21:02:48

I'll post it, one sec

mathpunk21:02:39

and, shadow compile test followed by a node invocation on what was generated

thheller21:02:56

you said "specs"? are you using cljs.test?

thheller21:02:51

are the namespaces named sherman.server-test?

mathpunk21:02:52

I doubt I have things set up 'correctly'.... I was developing by having a lein auto tach lumo process running, and I have a (cljs.test/run-tests) line at the end of each of my test files

thheller21:02:19

definitely don't need the run-tests

thheller21:02:49

you can put a (prn :foo) or so to confirm that they are getting loaded

thheller21:02:07

shadow compile test --verbose should also show them getting compiled

thheller21:02:57

what is your test namespace?

mathpunk21:02:36

This might be easiest, altho it is a push from before I was trying shadow: https://github.com/mathpunk/sherman

mathpunk21:02:04

The only thing that's changed since has been shadow-cljs.edn, and I've just commented out the cljs.test/run-tests

mathpunk21:02:10

let's see what verbose compiling does...

mathpunk21:02:04

and... it is fine. I have no idea what that previous output was

mathpunk21:02:38

ok, second question: is there a method for having tests run when I change code? I used to use CIDER as my test runner for Clojure, which I don't think is going to work easily in CLJS. On this project I had been running a lein auto tach lumo task in a separate window, but I'm not sure if there's a way of doing something similar in shadow yet

thheller21:02:13

for node not yet

mathpunk21:02:16

i guess third question is, should I remove my project.clj entirely? everything's being done by shadow now?

thheller21:02:31

you can use something like chokidar-cli

mathpunk21:02:12

oh ok, so that will watch to see if the output test file changes... great

thheller21:02:17

chokidar out/node-test.js -c 'node out/node-test.js'

mathpunk21:02:49

thanks so much! sorry about the first non-question, no clue what that was about

wilkerlucio21:02:06

thanks, I'll try that out, it is possible now to disable their auto-reload

wilkerlucio21:02:16

so we can do that and rely on the shadow one if that works šŸ™‚

wilkerlucio21:02:17

@thheller doens't work =/ the only thing I see is this message on the android console: I/ReactNativeJS: '%cDEVTOOLS: disconnected!', 'color: blue;

wilkerlucio21:02:43

code doesn't reload, and the REPL doesn't respond as well

wilkerlucio21:02:45

To quit, type: :cljs/quit
=> [:selected :app]
3
There is no connected JS runtime.

thheller21:02:23

no idea. I only ever opened the iOS emulater once

thheller21:02:29

won't have time to play with react-native for a while

thheller21:02:06

if figwheel works then it is possible for shadow-cljs as well. just might take some tweaks.

wilkerlucio21:02:42

sure, I can try to look at it, thanks for the tips

justinlee22:02:22

hey @thheller if i wanted to hack around a bit with the nrepl connection, whatā€™s the best way to experiment with shadow-cljs when building from source?

thheller22:02:36

I run lein with-profiles +cljs repl then (require 'repl) (repl/go)

thheller22:02:43

(shadow.cljs.devtools.api/watch :browser) is the test build I commonly use

thheller22:02:23

what do you want to do?

justinlee22:02:26

I want to debug the protorepl connection to see if I can make it do all the cool shit it is capable of, but I donā€™t want to bug you every single day šŸ™‚

wilkerlucio22:02:08

@thheller I see that the browser versions tries to use <script> tags to load things, that wont work on RN, I'm wondering if its easier to start from the node version, I tried that directly but seems like RN doesn't have teh crypto package, but in terms of load seems the node version is closer

thheller22:02:16

last time I checked proto-repl didn't use any nrepl-middleware but rather just evals CLJ code straight up.

thheller22:02:20

so that won't work for CLJS

justinlee22:02:35

In theory, I should be able to get function arguments to pop up as I type, get autocompletion to work, be able to jump to source, be able to get docstrings inline.

thheller22:02:50

@wilkerlucio if you use :npm-module it won't use <script>

justinlee22:02:54

It can connect via an nrepl connection. Thatā€™s how I use it.

thheller22:02:24

@lee.justin.m like I said. they do this by evaling clojure code. I think.

wilkerlucio22:02:31

humm, good to know, I'll keep reading šŸ™‚

justinlee22:02:32

My suspicious is that it just doesnā€™t even try to do the stuff that it does with the clj repl, but I really want it to. šŸ™‚

thheller22:02:09

you'll probably need to hack that on the proto-repl side

thheller22:02:47

still can't get past the blasphemy that proto-repl is written in coffeescript šŸ˜›

justinlee22:02:05

coffeescript is a nice language. too bad I donā€™t know it.

thheller22:02:31

nah its horrible. did it for 2 years before CLJS. never want to do it again

justinlee22:02:22

well okay iā€™ll futz around with the coffeescript side. partly i wanted to get some insight as to what the hell is going on with all these different repl techniques

justinlee22:02:51

it confuses the hell out of me that you can start a clj repl and then switch into a cljs-repl (like with figwheel). but then you can also connect to the same thing via a network

thheller22:02:06

usually with nrepl most of the heavy listing is done by middleware. ie. cider-nrepl.

thheller22:02:19

but proto repl just straight up evals CLJ code

justinlee22:02:23

so when you say ā€œthey do this by evaling clojure codeā€ I donā€™t really know what you mean because, you know, isnā€™t that the ā€œeā€ part of the repl?

thheller22:02:11

nrepl has two ways of doing stuff

thheller22:02:20

eval is usually just for what the user types

thheller22:02:26

and middleware handles tool related stuff

thheller22:02:30

the middleware takes care of completion for clj and cljs

thheller22:02:58

but proto-repl just sends full forms to eval

justinlee22:02:30

so, somehow in my many iterations before i landed on shadow, I was able to start protorepl and get a full feature set.

justinlee22:02:14

I think I did that by lein watch or whatever the command was and then (do (use 'figwheel-sidecar.repl-api) (start-figwheel!) (cljs-repl))

justinlee22:02:27

but maybe that was when i was doing CLJ (sorry I just canā€™t remember)

thheller22:02:59

CLJ should work just fine now

justinlee22:02:10

I really want to be able to make protorepl fully featured with cljs but I donā€™t even understand the problem. maybe after iā€™ve got a little more experience

thheller22:02:46

from briefly going over the proto-repl sources that will be a gigantic effort

thheller22:02:55

it just isn't built with CLJS in mind at all

justinlee22:02:26

is the issue that the nrepl channel is different from whatever its doing when you just fire up a normal repl?

thheller22:02:57

no. the issue is what proto-repl is doing with the REPL.

thheller22:02:44

there seems to be a gigantic discussion about this https://github.com/jasongilman/proto-repl/issues/54

justinlee22:02:59

yea iā€™ve read through that. i wanted to push it forward. maybe it isnā€™t possible.

thheller22:02:44

it is definitely possible

thheller22:02:00

but if you take a look at the completion code now

thheller22:02:19

it evals this code in the REPL. which you can also do by hand.

thheller22:02:36

this is clojure code that only gives you completions for clojure code.

thheller22:02:45

you'd need to send entirely different code for CLJS

justinlee22:02:54

itā€™s painful to think that all the juicy juicy data is sitting right there in the shadow watch process and all someone needs to do is just marshall a couple of dumb op codes back and forth to get it

thheller22:02:43

well cider-nrepl already has access to all the data I believe

thheller22:02:41

proto-repl eval works because you just send stuff and it handles the result

thheller22:02:43

that is simple

thheller22:02:50

and works the same in both languages

thheller22:02:59

the rest is entirely different

thheller22:02:15

it seems to have special code for self hosted js