Fork me on GitHub
#shadow-cljs
<
2019-10-31
>
mattly04:10:41

I'm trying to use the new shadow-inspect feature and getting this:

mattly04:10:39

that was from preloads, if I just require it in my root namespace, I get The required namespace "shadow.remote.runtime.browser" is not available, it was required by "xxxxx/main.cljs".

mattly04:10:56

and from the repl:

thheller07:10:01

@mattly that is all still undergoing massive changes. the namespace was moved to shadow.remote.runtime.cljs.browser

👍 4
thheller08:10:03

@mattly also note the shadow-cljs - server version: 2.8.52. so you are still an old version. need to update deps.edn when using that

mattly14:10:33

Huh, I didn’t realize shadow-cljs.server didn’t get updated along with the cli, it’s not in my does

heefoo12:10:35

@thheller does shadow-cljs work with Conjure ?

thheller12:10:10

no clue, I use Cursive

heefoo12:10:36

I am trying to connect to the socket repl without any luck

Olical12:10:38

I'm going to try and get it working over lunch, I just need to know how to swap from the Clojure context into the ClojureScript one from within the prepl socket.

thheller12:10:15

you can't switch it in prepl. prepl doesn't allow that. thats why I added this? https://github.com/thheller/shadow-cljs/issues/508#issuecomment-535866881

Olical12:10:08

Sure, sorry, I think I worded that really poorly. I was under the impression when you connect to that prepl it isn't a ClojureScript environment but that was 2nd hand information, I'll try it for myself.

Olical12:10:02

Thank you for adding prepl support in the first place! I'll try to get Conjure + shadow-cljs prepl documented somewhere, I just have 0 / negative free time right now.

heefoo13:10:42

From what i understand they should be able to work out of the box, yet i get Error from :frontend java.io.IOException: Stream closed

Olical13:10:46

Ah, interesting, let me have a go. If I get it working I'll add a link / guide here https://github.com/Olical/conjure/wiki

Olical13:10:51

Gimmie 20 minutes

heefoo13:10:44

🙂 thanks, the stream closed error is pretty generic, i wasnt sure if it is helpfull

Olical13:10:29

That just means the socket is kicking you off just after you connect which could be because node / your browser isn't running / ready to evaluate JavaScript on the behalf of shadow-cljs... I think...

Olical13:10:32

Building a demo repo

Olical13:10:43

While I eat katsu curry 😅

😄 4
thheller13:10:56

I can change it so it doesn't kick you off but instead waits for a runtime? if that makes sense

thheller13:10:11

it sends out {:tag :err :msg "No available JS runtimes!"} currently before kicking

Olical13:10:34

Hmm that could be pretty neat :thinking_face: might help in scenarios where you refresh the browser or something? Would it be able to hook you up to the new environment?

Olical13:10:51

If not, no worries. With Conjure you just hit one key combo and it'll reconnect whatever it can anyway.

Olical13:10:17

(`<localleader>cu` or :ConjureUp)

thheller13:10:27

> Ah I understand what you mean now, thanks for the explanation! I would argue you go for the first environment and maybe disconnect the prepl if there's nothing there, that way the client will know it's reconnecting to a new environment.

thheller13:10:29

your words 😛

Olical13:10:46

lol, sounds good then, thanks past me!

heefoo13:10:46

@U38J3881W with (`<localleader>cu` or :ConjureUp) i get disconnected immediately

Olical13:10:15

Yep, trying to repro and investigate now, I've been putting off investigating for a while.

Olical13:10:53

Hmm, sorry to bother you @thheller, I'm just trying to netcat into a prepl I started, I'm using npx shadow-cljs node-repl with what I think is some super basic config

{:builds
 {:demo
  {:target :node-script
   :modules {:main {:init-fn conjure-demo.main/init}}}}
 :prepl {:demo 36751}}
It starts up okay but I get the no runtimes error. If you think I'm just configuring / starting it wrong I'll go dig through docs now. If you think this looks okay then maaaaybe something is wrong?

Olical13:10:13

(not even using Conjure right now, just trying to netcat into the port)

thheller13:10:28

you used node-repl. that isn't related to :demo in any way

Olical13:10:45

🙃 I'm a shadow-cljs noob and I should've really learned earlier. I'll dig the docs.

thheller13:10:49

:prepl {:node-repl 36751}

thheller13:10:02

that should do it

Olical13:10:24

Oh so node-repl is like a built in "build"

Olical13:10:42

That's cool

Olical13:10:01

But I guess I could watch demo or something too.

Olical13:10:08

Hmm, no output from the netcat but a big ol' blob of EDN in the shadow-cljs stdio

Olical13:10:22

[:repl-unknown {:type :repl/session-start, :id "67bcbfa5-55...

thheller13:10:50

try browser-repl .. I think node-repl is missing some things

Olical13:10:58

Ah, interesting!

heefoo13:10:26

I am trying browser-repl the last 10 minutes and getting stacktraces

heefoo13:10:10

` [:app] Build completed. (405 files, 1 compiled, 0 warnings, 6.62s) 32 Exception in thread "Clojure Connection repl 1" clojure.lang.ExceptionInfo: failed compiling file:out/clojure/browser/event.cljs {:file #object[java.io.File 0x72769185 "out/clojure/browser/event.cljs"], :cloj 33 ure.error/phase :compilation} `

Olical13:10:14

I might know what that is and might be able to patch it in shadow for you, hang on.

thheller13:10:52

$ nc localhost 12345
(js/console.log "foo")
{:tag :ret :ns cljs.user :form "(js/console.log \"foo\")" :ms 1 :val nil}

Olical13:10:02

Yeah, so :val is coming back as data, it needs to be a string.

Olical13:10:18

That's the Clojure contract and I think something I patched in ClojureScript.

Olical13:10:42

It needs to be a string because you can't parse some things that came from another environment, such as records and reader conditionals. So you can pr-str it in the eval environment but then you need to turn it into a string to make sure the prepl data is parseable in ANY environment. Then the prepl client can decide to keep treating the response as just a string or it can try to parse it in whatever way it deems correct.

Olical13:10:03

So yeah, don't provide data as data in a prepl payload from an env because the string serialisation doesn't always match up on the other end.

thheller13:10:08

i'll fix that

Olical13:10:34

I can patch it if you don't have time but yeah, small nuance that I know of. I should really write up a "prepl spec" that I've inferred since it isn't documented.

Olical13:10:48

I've been patching Clojure and ClojureScript to bring both of their prepl implementations inline with each other 😬

Olical13:10:46

https://github.com/Olical/conjure-shadow-cljs-example demo repo is here for when it returns strings 😄

Olical13:10:48

Oh the other thing to check: When an exception is caught it should return the data in :val as a string (output of Throwable->map I think?) then set :exception to true on the top level of the message.

Olical13:10:22

I have a patch going into the next ClojureScript version which sets this :exception flag.

Olical13:10:45

And one into the next Clojure version which allows reader conditionals (ClojureScript already has them).

heefoo13:10:41

should i open an issue somewhere ?

heefoo13:10:00

just to keep track when/if the problem has ben solved ?

Olical13:11:35

https://oli.me.uk/clojure-prepl-for-tool-authors/ for future reference, I've written up how prepls should respond / work

thheller12:10:32

meaning each build gets its own prepl port

mattly14:10:33

Huh, I didn’t realize shadow-cljs.server didn’t get updated along with the cli, it’s not in my does

bcaccinolo16:10:57

Hi, how can I require a package with shadow-cljs ? Like this fs = require('fs');

thheller16:10:50

(ns (:require ["fs" :as fs]))

bcaccinolo16:10:50

thanks ! 🙂

mazin17:10:29

Have a question about node_module resolution https://github.com/thheller/shadow-cljs/issues/547 as a concrete example, im currently using the package react-bootstrap. when building with the :browser target, the build fails because react-bootstrap has the dependency @restart/hooks, which we dont find since we arent traversing child node_modules directories. what is the correct way to handle this? do i install @restart/hooks in the parent node_modules directory? if so, are upgrades of sub dependencies like @restart/hooks expected to be handled manually?

Filipe Silva19:10:04

package manager hoisting (pulling nested packages to the toplevel) is considered an implementation detail

Filipe Silva19:10:37

different package managers handle hoisting differently

Filipe Silva19:10:41

some don't hoist at all

Filipe Silva19:10:09

I think I've seen cases with yarn where the resolution for a conflict was to hoist neither

thheller20:10:11

@mazin you install @restart/hooks in the same package.json where you installed react-bootstrap

thheller20:10:45

basically you manually resolve the conflict. that saves you from including the same package twice. thats the whole reason it doesn't look into nested folders

mazin21:10:22

ok thanks, that makes sense. what's the reason for avoiding looking into nested folders for packages that only appear once in the entire project, nested or otherwise? if the main motivation is to avoid including duplicate packages, seems ok to recurse nested folders and include packages that are only found once

thheller21:10:51

never heard of a case where something is installed nested without conflicts?

mazin22:10:00

nevermind, believe i misunderstood. thanks!