Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Add support for pausing/resuming a CLJS REPL #73
(Originally proposed in #28, which couldn't be applied due to the 0.2.0 rewrite landing.)
Should be pretty easy, and make using piggieback a lot easier, i.e. make it less necessary to have two nREPL sessions going in a lot of cases (one Clojure, the other piggiebacked CLJS).
This idea is interesting, I have another idea in the pipeline, a
This would give cljs tooling a very simple way of using the connection if needed and it would have all the information it needs available (including a way to easily eval in the js env client).
I already mentioned my reservations about this in the #cider slack but let me repeat it here so it doesn't get lost. The problem with
In shadow-cljs these can all run in parallel and you can "select" which REPL to talk to at any time.
I suggested to use
The broader problem however is that ClojureScript is not like Clojure and maybe we should re-think some assumptions about the REPL. One issue is that the Read runs in a different runtime than Eval/Print. For the Browser REPL it is very possible (and common) that the user reloads the Browser which means all state that might have been accumulated is lost. The compiler-env however is still around so the compiler thinks state exists when it doesn't.
You also can't Read inside Eval since JS doesn't have a blocking streaming stdin (or stdin at all in the case of the Browser).
And since there are different runtimes for each build most of the tooling is in a weird situation. You might be editing
There is also this weird and common issue that a REPL might actually have multiple runtimes connected. Say you have the
This went way off-topic so I'll stop here.
PS: I'm absolutely not a fan of abusing reader conditionals for this, that just seems like a hack gone too far. The client knows if it wants to eval CLJS or CLJ. It should tell this to the nrepl middleware via either different ops or extra attributes in the message.
Re-reading this last post multiple times. It makes a lot of sense to me to try to come up with a cljs-specific nREPL mini-protocol. It could be handled by its own middleware for achieving isolation and could be initially behind feature flag so that we do not break the existing behavior.
For me all the above makes sense as I have directly experienced all of the problems above (especially the namespace not compiled one!).
I will see if I can come up with some simple stuff that brings together ideas spread in there issues.
I'm not a believer in a mini protocol, it's coupled and specific and would require an every growing set of operations. Almost everything that needs to be done can be done with a clojure library with
I do think suspend and resume are good ideas and contrary to the post above you can resume because you are keeping track of the session ids.