A re-frame application designed to … well, that part is up to you.
shadow-cljsre-frame-10x/: project config files.clj-kondo/: lint config and cache files (cache files are not tracked; see
.gitignore)dev/: source files compiled only with the dev profile
user.cljs: symbols for use during development in the
ClojureScript REPLresources/public/: SPA root directory;
dev / prod profile depends on the most recent build
index.html: SPA home page
div:
<div id="app"></div>
js/compiled/: compiled CLJS (shadow-cljs)
.gitignoresrc/subterranea/: SPA source files (ClojureScript,
re-frame)
core.cljs: contains the SPA entry point, init.github/workflows/: contains the
github actions pipelines.
test.yaml: Pipeline for testing.Use your preferred editor or IDE that supports Clojure/ClojureScript development. See Clojure tools for some popular options.
subterranea project root directory clj-kondo --lint "$(npx shadow-cljs classpath)"
Browser caching should be disabled when developer tools are open to prevent interference with
shadow-cljs hot reloading.
Custom formatters must be enabled in the browser before CLJS DevTools can display ClojureScript data in the console in a more readable way.
F12
or Ctrl-Shift-I; macOS: ⌘-Option-I)? or F1; macOS: ? or Fn+F1)Preferences in the navigation menu on the left, if it is not already selectedNetwork heading, enable the Disable cache (while DevTools is open) optionConsole heading, enable the Enable custom formatters optionF12 or
Ctrl-Shift-I; macOS: ⌘-Option-I)F1)Advanced settings heading, enable the Disable HTTP Cache (when toolbox is open)
optionUnfortunately, Firefox does not yet support custom formatters in their devtools. For updates, follow the enhancement request in their bug tracker: 1262914 - Add support for Custom Formatters in devtools.
Start a temporary local web server, build the app with the dev profile, and serve the app,
browser test runner and karma test runner with hot reload:
npm install
npx shadow-cljs watch app
Please be patient; it may take over 20 seconds to see any output, and over 40 seconds to complete.
When [:app] Build completed appears in the output, browse to
http://localhost:8280/.
shadow-cljs will automatically push ClojureScript code
changes to your browser on save. To prevent a few common issues, see
Hot Reload in ClojureScript: Things to avoid.
Opening the app in your browser starts a ClojureScript browser REPL, to which you may now connect.
Connect to the browser REPL:
M-x cider-jack-in-cljs
See
Shadow CLJS User’s Guide: Emacs/CIDER
for more information. Note that the mentioned .dir-locals.el file has already
been created for you.
See the re-frame-template README for Calva instuctions. See also https://calva.io for Calva documentation.
See
Shadow CLJS User’s Guide: Editor Integration.
Note that npm run watch runs npx shadow-cljs watch for you, and that this project’s running build ids is
app, browser-test, karma-test, or the keywords :app, :browser-test, :karma-test in a Clojure context.
Alternatively, search the web for info on connecting to a shadow-cljs ClojureScript browser REPL
from your editor and configuration.
For example, in Vim / Neovim with fireplace.vim
.cljs file in the project to activate fireplace.vimPiggieback command with this project’s running build id, :app:
:Piggieback :app
shadow-cljs nREPL:
lein repl :connect localhost:8777
The REPL prompt, shadow.user=>, indicates that is a Clojure REPL, not ClojureScript.
:app:
(shadow.cljs.devtools.api/nrepl-select :app)
The REPL prompt changes to cljs.user=>, indicating that this is now a ClojureScript REPL.
user.cljs for symbols that are immediately accessible in the REPL
without needing to require.shadow-cljs ActionsSee a list of shadow-cljs CLI
actions:
npx shadow-cljs --help
Please be patient; it may take over 10 seconds to see any output. Also note that some actions shown may not actually be supported, outputting “Unknown action.” when run.
Run a shadow-cljs action on this project’s build id (without the colon, just app):
npx shadow-cljs <action> app
The debug? variable in config.cljs defaults to true in
dev builds, and false in prod builds.
Use debug? for logging or other tasks that should run only on dev builds:
(ns subterranea.example
(:require [subterranea.config :as config])
(when config/debug?
(println "This message will appear in the browser console only on dev builds."))
Build the app with the prod profile:
npm install
npm run release
Please be patient; it may take over 15 seconds to see any output, and over 30 seconds to complete.
The resources/public/js/compiled directory is created, containing the compiled app.js and
manifest.edn files.