-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev support - shadow-powered dev repl
Add :dev profile to deps, and shadow-cljs config to build the code and serve a page with it. The entrypoint is `dev/development.cljs`. See Readme. This makes it easy to interactively develop and test SCI configs.
- Loading branch information
Showing
7 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,6 @@ | |
.cpcache | ||
cljs-test-runner-out | ||
node_modules | ||
www/js/ | ||
.calva/ | ||
.portal/ |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
(ns development | ||
"Entry point for code loaded by shadow-cljs" | ||
(:require | ||
[sci.core :as sci] | ||
[sci.configs.fulcro.fulcro :as fulcro-config])) | ||
|
||
;; Necessary to avoid the error 'Attempting to call unbound fn: #'clojure.core/*print-fn*' | ||
;; when calling `println` inside the evaluated code | ||
(enable-console-print!) | ||
(sci/alter-var-root sci/print-fn (constantly *print-fn*)) | ||
(sci/alter-var-root sci/print-err-fn (constantly *print-err-fn*)) | ||
|
||
(def full-ctx (doto (sci/init {}) | ||
(sci/merge-opts fulcro-config/config))) | ||
|
||
(defn init [] | ||
(println "Init run")) | ||
|
||
(defn reload [] | ||
(println "Reload run")) | ||
|
||
(comment | ||
(sci/eval-string* (sci/init {}) "(+ 1 2)") | ||
|
||
(sci/eval-string* full-ctx " | ||
(ns test1 | ||
(:require | ||
[com.fulcrologic.fulcro.algorithms.denormalize :as fdn] | ||
[com.fulcrologic.fulcro.application :as app] | ||
[com.fulcrologic.fulcro.components :as comp :refer [defsc]] | ||
[com.fulcrologic.fulcro.dom :as dom])) | ||
(defsc Root [this props] (dom/h3 \"Hello from Fulcro!\")) | ||
(defn build-ui-tree [] | ||
(let [client-db (comp/get-initial-state Root {})] | ||
(fdn/db->tree (comp/get-query Root client-db) client-db client-db))) | ||
(comp/with-parent-context (app/fulcro-app) | ||
(dom/render-to-str ((comp/factory Root) (build-ui-tree)))) | ||
") | ||
,) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"devDependencies": { | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
"react-dom": "^18.2.0", | ||
"shadow-cljs": "2.25.5" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{:deps {:aliases [:test :dev]} | ||
:nrepl {:port 9000} | ||
:dev-http {8081 "www"} | ||
:builds {:dev {:target :browser | ||
:output-dir "www/js/dev" | ||
:asset-path "/js/dev" | ||
:modules {:dev {:init-fn development/init}} | ||
:devtools {:after-load development/reload}}}} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>SCI dev</title> | ||
<meta charset="UTF-8" /> | ||
</head> | ||
<body> | ||
<h1>SCI dev playground for shadow-cljs</h1> | ||
<p>Run shadow and connect to its nrepl at port 9000. Then eval code in <code>development.cljs</code>.</p> | ||
<div id="app"></div> | ||
<script src="js/dev/dev.js" type="text/javascript"></script> | ||
</body> | ||
</html> |