-
-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal for Dirac integration via shadow.remote #636
Comments
Just for record. Dirac 1.6.0 added support for REPL via This might be good enough solution for now. |
@darwin A big 👍 for being able to see cljs variables in the variables list panel, really helpful when debugging! I find it's not possible to eval cljs code when paused in a breakpoint - I guess it's an intrinsic limitation of the "loopback" mode?
|
I'm not 100% sure but I would say that it is not intrinsic limitation. When page is stopped on a breakpoint dirac uses special debugger api for evaluating expressions in the context of the page. Maybe I just need to enable some flag to allow async code as well. I noticed that there is relative new support in devtools console for top-level await expressions. Maybe I would need to do something similar. |
Thanks @darwin . I just found your doc page https://github.com/binaryage/dirac/blob/master/docs/about-repls.md and it's really great read about the design of dirac and clojure repls as well. |
@darwin IIUC this doesn't seem to be able to work. What's more shadow-cljs server sends ping requests to the client and in a breakpoint the client is not able to respond with a pong, so the server would disconnect the client. |
Good points. Let's move the discussion to dirac issues. |
Let me know if there is still any interest in this. Closing due to lack of activity. |
I looked at the remote.md doc, studied its code and briefly glanced over shadow-cljs code.
I'd like to propose a possible way how to make Dirac play with Shadow.
Initial assumptions:
shadow.remote
relay running.dirac-tool
is ashadow.remote
tool connecting to the relay.Typical Dirac workflow:
dirac
in a new terminal sesssiondirac
launches Chrome with Dirac DevTools, it also starts playground project in the backgrounddirac
JVM processdirac-tool
dirac-tool
will attempt connection to the relay and list available runtimes supporting cljs compilationdirac :ls
This is an example output from
dirac :ls
with figwheel-main "ClojureScript compiler" present, it is selected as indicated by->
, btw.dirac/f270d0e8.1
is the default compiler provided by dirac, also addedshadow/build1
as an example.dirac :switch
, assume he switched to some shadow runtime (e.g.dirac :switch "shadow/build1"
).8.1. it will get processed by dirac nREPL middleware, which will see that shadow runtime is selected, instead of calling own cljs compiler or figwheel's compiler (in-process), it will perform compilation over the wire via
shadow.remote
api.8.2. it will get back compiled js code or some error (java stack trace)
8.3. it will send the js code for evaluation into the browser (it will be handled by Dirac DevTools and "dirac runtime" as usual)
Please note: Dirac nREPL and Dirac Agent are running in a separate process (of
dirac
) and are not in any way interfering with the initial shadow-cljs setup.dirac-tool
needs following services from (supported) runtimes::list-cljs-compiler-runtimes
:compile-with-cljs-compiler-runtime
:shadow-bridge
List CLJS Compiler Runtimes
This is a message for relay? Or it could be a broadcast and each runtime supporting
:compile-with-cljs-compiler-runtime
can answer independently?In the first case it could look like this:
These runtimes would be presented in
dirac :ls
asCompile with CLJS Compiler Runtime
Dirac needs to pass in the cljs code text and also optional
:locals
and maybe other compiler-env settings, this should be passed through to cljs.analyzer/analyze.Dirac expectes compiler js code text back with source mapping info - or alternatively some error info which should be presented to the user.
Shadow Bridge
Dirac sends a command as plain text. And shadow cljs will interpret it on its side. Potentially returning some output.
A note on stdout/err feedback. Dirac has currently infrastructure to stream back stdout/err produced during compilation (or other operations) back to DevTools console. It would be nice to support this as well. So for example
:compile-with-cljs-compiler-runtime
could trigger multiple reponses some of them could be just reporting printed output back.@thheller If you agree with this concept, I would propose following steps:
shadow.remote
)The text was updated successfully, but these errors were encountered: