Last active
January 27, 2022 05:27
-
-
Save pyrmont/73d10c74d14f26772fd276c38ee3490d to your computer and use it in GitHub Desktop.
Figwheel setup with Conjure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:deps {org.clojure/clojure {:mvn/version "1.10.1"} | |
org.clojure/clojurescript {:mvn/version "1.10.597"}} | |
:paths ["src" "resources"] | |
:aliases {:fig {:extra-deps | |
{com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"} | |
com.bhauman/figwheel-main {:mvn/version "0.2.4"}} | |
:extra-paths ["target" "test"]} | |
:build {:main-opts ["-m" "figwheel.main" "-b" "dev" "-r"]} | |
:min {:main-opts ["-m" "figwheel.main" "-O" "advanced" "-bo" "dev"]} | |
:release {:main-opts ["-m" "figwheel.main" "-bo" "release"]} | |
:remote {:main-opts ["-m" "figwheel.main" "-b" "remote" "-r"]} | |
:nrepl {:extra-deps | |
{nrepl/nrepl {:mvn/version "0.7.0"} | |
cider/piggieback {:mvn/version "0.4.2"} | |
cider/cider-nrepl {:mvn/version "0.24.0"}} | |
:main-opts ["-m" "figwheel.nrepl" "-b" "remote"]}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns figwheel.nrepl | |
(:require [clojure.java.io :as io] | |
[clojure.string :as string] | |
[figwheel.main.api :as fig] | |
[nrepl.server :as server])) | |
(def port-file ".nrepl-port") | |
(def nrepl-port 7888) | |
(defonce nrepl-server (atom nil)) | |
(defn nrepl-handler [] | |
(require 'cider.nrepl) | |
(ns-resolve 'cider.nrepl 'cider-nrepl-handler)) | |
(defn start-nrepl-server! [] | |
(reset! nrepl-server | |
(server/start-server :port nrepl-port | |
:handler (nrepl-handler))) | |
(println "CIDER nREPL server started on port" nrepl-port) | |
(spit port-file nrepl-port)) | |
(defn stop-nrepl-server! [] | |
(when (not (nil? @nrepl-server)) | |
(server/stop-server @nrepl-server) | |
(println "CIDER nREPL server on port" nrepl-port "stopped") | |
(reset! nrepl-server nil) | |
(io/delete-file port-file true))) | |
(defn parse-command-args [args] | |
(if (nil? args) | |
{} | |
(->> args | |
(reduce (fn [as a] | |
(if (string/starts-with? a "-") | |
(conj as a true) | |
(conj (pop as) a))) | |
[]) | |
(apply hash-map)))) | |
(defn -main [& args] | |
(let [switches (parse-command-args args) | |
build (switches "-b")] | |
(start-nrepl-server!) | |
(-> (new java.io.File port-file) (.deleteOnExit)) | |
(fig/start {:rebel-readline false :mode :serve} build) | |
(fig/cljs-repl build))) |
@thiru Sorry to have taken so long to respond. Are you able to share more of the file you're running to set everything up? I wasn't able to get things to work but I suspect I didn't have all the pieces set up the way you do.
Hey there, sorry for the late response as well. I didn't have a public repo with what I outlined. I just opened up a private repo that doesn't use Conjure yet but it has the rebel-readline bit, which is the problem anyway:
https://github.com/thiru/fileworthy2/blob/master/dev/user.clj
Note if you remove the (System/exit 0)
call it hangs.
Hey @thiru that file seems to have been deleted?
Oops, I'm not sure why I put a link to a private repo! Maybe this repo will help @EdwardIII?
@thiru Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had the same problem with Rebel-readline not exiting correctly. What worked for me was calling
(System/exit 0)
after starting rebel. E.g. here's what it roughly looks like in my main: