Fork me on GitHub
#practicalli
<
2023-04-30
>
James Amberger13:04:01

I am afraid I still don't really get how to use clj. for instance I see that I can run a cljs/node repl with the practicalli deps.edn

practicalli-johnny14:04:37

If using Clojure (rather than ClojureScript), then portal and rebel readline will automatically start with the following command

clojure -M:repl/reloaded
Portal will listen to all evaluations carried out over nREPL (e.g. a connected editor like Emacs CIDER, VSCode, Calva, Nvim Conjure, etc) Or use tap> around an expression to send that to Portal There is also a mulog publisher, so an event is sent to Portal too
(mulog/log ::meaningful-event-name :meaningful-key "some value, e.g. from a function call or local name" :more-keys "and values")

James Amberger13:04:27

but what if I want to load portal and rebel-readline too, all from the cli invocation

James Amberger13:04:19

Hmm maybe I figured it out?

clj -M:repl/cljs:repl/reloaded

practicalli-johnny14:04:34

I haven't tried the reloaded workflow with ClojureScript yet, only with Clojure. Note: rebel-readline for Cljs reqiured a Java version that contains Nashorn (usually Java 14 or earlier) The inspect/portal-web alias if using fighweel-main or cljs-build, or :inspect/portal-node if using shadow-cljs may be more appropriate

clojure -M:inspect/portal-web:repl/cljs
Note that clj wrapper should not be used with rebel-readline as clj calls the rlwrap readline program which may interfere with rebel readline

practicalli-johnny14:04:32

The reloaded workflow might do something, but I assume everything will be connected to a Clojure repl rather than a ClojureScript repl. Given that a ClojureScript repl is often launched from a Clojure REPL, then there may still be some use. Happy to help explore this aspect if you have a particular project or tooling in mind.

James Amberger20:04:59

seems you've saved a lot of people a lot of work

James Amberger20:04:16

a lot to explore

practicalli-johnny09:05:03

I believe the :repl/rebel-cljs alias only works with Java 8, as it uses libraries that were removed in newer Java versions. I'm experimenting with additional libraries to understand which is needed for Java 11 and Java 17

practicalli-johnny12:05:13

I have this rather monsterous alias working for Java 11, although it will not work on newer versions of Java where the Nashorn JavaScript engine was removed - even if the openjdk nashorn library is added as a dependency

:repl/nrepl-figwheel
  {:extra-deps
   {org.clojure/clojurescript {:mvn/version "1.9.946"}
    nrepl/nrepl {:mvn/version "0.8.3"}
    cider/cider-nrepl         {:mvn/version "0.30.0"}
    cider/piggieback {:mvn/version "0.5.3"}
    org.slf4j/slf4j-nop {:mvn/version "1.7.30"}
    ;; org.openjdk.nashorn/nashorn-core {:mvn/version "15.4"}
    jakarta.xml.bind/jakarta.xml.bind-api {:mvn/version "2.3.2"}
    cljs-tooling/cljs-tooling {:mvn/version "0.3.1"}
    com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
    com.bhauman/figwheel-main {:mvn/version "0.2.17"}}
   :extra-paths ["target" "test"]
   :main-opts
   ["-m" "nrepl.cmdline"
    "--middleware" "[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"
    "--interactive"
    "-f" "rebel-readline.cljs.main/-main"]}

practicalli-johnny12:05:10

So for now, the simplest way to have Rebel Readline with ClojureScript, with Figwheel as the build tool, is to use the https://github.com/bhauman/figwheel-main-template and then launch a REPL using the aliases the project creates.

practicalli-johnny12:05:06

I havent tried with Shadow-cljs yet, its lower down on my todo list as its going to require quite a bit of reading of the shadow-cljs user guide

James Amberger21:04:57

Hmm. clojure -M:repl/rebel-cljs complains that Could not locate rebel_readline_cljs/main__init.class, rebel_readline_cljs/main.clj or rebel_readline_cljs/main.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.

James Amberger21:04:31

Is that because my java version is >15?

practicalli-johnny21:04:25

I have been trying that alias out myself and am also getting the same issues. I have tried using Java 11 and adding a separate Nashorn dependency with Java 17, but haven't had any luck as yet

practicalli-johnny22:04:09

To have a rebel readline with ClojureScript, the easiest way is to create a project with https://github.com/bhauman/figwheel-main-template

practicalli-johnny22:04:13

Portal for ClojureScript seems to need to call a main but so does figwheel, so that's something I need to look into.

practicalli-johnny22:04:56

The ClojureScript version of rebel needs Nashorn which is no longer in Java. Maybe Java 8 is required to make rebel readline for ClojureScript I'll take another look tomorrow