aboutsummaryrefslogtreecommitdiffstats
path: root/src/user.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/user.clj')
-rw-r--r--src/user.clj28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/user.clj b/src/user.clj
new file mode 100644
index 0000000..9419d04
--- /dev/null
+++ b/src/user.clj
@@ -0,0 +1,28 @@
+(ns user) ; Must be ".clj" file, Clojure doesn't auto-load user.cljc
+
+; lazy load dev stuff - for faster REPL startup and cleaner dev classpath
+(def start-electric-server! (delay @(requiring-resolve 'hyperfiddle.electric-jetty-server/start-server!)))
+(def shadow-start! (delay @(requiring-resolve 'shadow.cljs.devtools.server/start!)))
+(def shadow-watch (delay @(requiring-resolve 'shadow.cljs.devtools.api/watch)))
+
+(def electric-server-config
+ {:host "0.0.0.0", :port 8080, :resources-path "resources/public"})
+
+(defn main [& args]
+ (println "Starting Electric compiler and server...")
+ (@shadow-start!) ; serves index.html as well
+ (@shadow-watch :dev) ; depends on shadow server
+ (def server (@start-electric-server! electric-server-config))
+ (comment (.stop server)))
+
+; Userland Electric code is lazy loaded by the shadow build due to usage of
+; :require-macros in all Electric source files.
+; WARNING: make sure your REPL and shadow-cljs are sharing the same JVM!
+
+(comment
+ (main) ; Electric Clojure(JVM) REPL entrypoint
+ (hyperfiddle.rcf/enable!) ; turn on RCF after all transitive deps have loaded
+ (shadow.cljs.devtools.api/repl :dev) ; shadow server hosts the cljs repl
+ ; connect a second REPL instance to it
+ ; (DO NOT REUSE JVM REPL it will fail weirdly)
+ (type 1)) \ No newline at end of file