Fork me on GitHub

Can I run a cljs repl on target :npm-module ? Also, If I run shadow-cljs watch :code, get server + nrepl port, connect to it (in cursive, ,via port), run (shadow/repl :code) I get No available JS runtime. Any not sure how to procede. Here is my shadow-cljs.end

{:source-paths ["src"]
   [[binaryage/devtools "1.0.5"]]

    {:target :npm-module
     :output-dir  "node_modules/shadow-cljs"
     :entries [gbo.mycljs]}}}


:npm-module can in theory have a REPL but it depends on how and where you are including the code. if another tools processes it too much it won't work. eg. webpack can work but also can break horribly đŸ˜›


for it to load you need to set a proper :runtime :browser or :runtime :node in the build config


and then include the devtools client ns from JS so if (process.env.NODE_ENV === "development") { require("shadow-cljs/shadow.cljs.devtools.client.browser") } or so


@thheller any tips on hacking shadow-cljs? I'm feeling bad only asking/reporting issues and I want to know how could I try to fix them too đŸ™‚


thats kind of too general. what do you intend to work on? its just a clojure project like any other clojure project đŸ˜›


I usually add the shadow-cljs src/main path to a project I'm working on. ie. keep the regular dependency and then just override it with local sources. then just poke at it from the REPL.


similar to working on shadow-cljs directly


Yes, I think the idea of adding src/main path could work đŸ™‚. My problem is with react-native builds, somehow I see no stacktrace at all (only the munged function name). I was thinking if I could debug it and at least know what's wrong


define no stacktrace at all. like what is the error?


The stacktrace appears, but no file (not even the JS one) or line number


this is not an error from shadow-cljs and nothing you do to shadow-cljs will change this error message?


It's not an error from shadow-cljs - it's just that when I use shadow-cljs with react native, and an error occurs on my code, I don't see the ClojureScript nor the Javascript (compiled) file, regardless of source-maps is disabled or enabled...


So I've been thinking if I could debug this issue somehow


hmm yeah dunno what your plan is. so can't provide tips. but there is nothing in shadow-cljs producing this stacktrace format. that is all in react-native/metro


maybe you can just try/catch this error in your code somewhere so you can get to it before metro mangles it?


Yeah, that's what I did: I did a (try (my-code) (catch :default e) (println (-stack e)), and indeed the filename and row are missing


oh well I just remembered that metro didn't support merging input source maps a very long time ago. maybe it still doesn't? I don't really keep up to date with what react-native is doing. maybe something in that changed so that you now get no trace at all rather than a trace back to the JS?

Joshua Smock10:04:02

Is there a way to get the current build state from a channel or some other async mechanism when running a build using (devtools.api/watch target {:autobuild false}) and (devtools.api/watch-compile! target)? At the moment I’m using the build history coming from the server instance ref (`(get @(:state-ref (:build-history @devtools.server.runtime/instance-ref)) target)`) but if it’s possible to get it via a channel that would be nicer. I tried to use the :channels :output channel coming from the worker state ref but subscribing to that seemed to cause some issues


what do you intend to do with this state? makes it easier to give suggestions on how to get it đŸ˜›

Joshua Smock13:04:16

I need to know what the latest status that isn’t :compiling is so I can see if the build succeeded or failed programmatically

Joshua Smock18:04:04

I want to know if a build has succeeded or failed when run in watch mode, and I need to query for the status programmatically. The way described at the start works but I saw there are also async channels, so I wonder if I should use the method described there or if there is another way


it would really help to know WHERE you want to know it? like what kind of tool? the info is all available but without knowing a WHERE I cannot give a suggestions of which method to use


do you want to know it on the client side? do you want to know it in the JVM running shadow-cljs? do you want to know it over nrepl?

Joshua Smock18:04:52

In the JVM, with a running server using the devtools server


so you are running it in embedded mode? via a user.clj or so? or is that one started just via shadow-cljs server or shadow-cljs watch ..?

Joshua Smock18:04:52

I guess so, I'm running it by calling devtools.server/start! and then api/watch :target-name


ok, (sys-bus/sub (:system-bus @shadow.cljs.devtools.server.runtime/instance-ref) :shadow.cljs.model/worker-broadcast your-channel)


sys-bus being shadow.cljs.devtools.server.system-bus


your-channel being a core.async channel you create and read from. or close when done


:shadow.cljs.model/worker-broadcast listens to all build workers


[:shadow.cljs.model/worker-output build-id] instead would just be the output for the specified build


messages are the same

Joshua Smock18:04:31

Great, thanks!