tooling around single file clojurescript programs running on node or the browser.
runclj ./rotate_the_logs.cljs
transparently converts a single clojurescript file into a temporary shadow-cljs project in .shadow-cljs/
.
get the dependencies:
- bash
- python3
- java
- node
- npm
then:
git clone https://github.com/nathants/runclj
sudo mv runclj/bin/* runclj/bin/.shadow-cljs /usr/local/bin
- hello.cljs - node hello world
- shell.cljs - node with subprocess, user prompts, and core.async
- server.cljs - node express server
- client.cljs - client app with material ui (demo)
- macros.cljs - node hello world with macros
runclj program.cljs
declare clojure and npm dependencies with meta-data at the start of the file.
#!/usr/bin/env runclj
^{:runclj {:npm [[express "4.16.3"]]
:deps [[prismatic/schema "1.1.3"]]}}
(ns main
(:require [schema.core :as schema :include-macros true]))
run the program.
runclj program.cljs
-
runclj-watch examples/client.cljs
-
open browser to
localhost:8000
-
edit
client.cljs
and browser auto reloads -
optionally connect to repl on
localhost:3333
runclj examples/server.cljs
runclj-tar program.cljs | ssh server tar xf -
then either install runclj
and run normally runclj program.cljs
or run manually:
-
browser:
cd .shadow-cljs/program.cljs/public && python3 -m http.server
-
server:
cd .shadow-cljs/program.cljs/ && node public/main.js
if your project grows too large for a single file, copy the generated shadow-cljs project and continue working on that directly.
-
runclj program.cljs
-
cp -r .shadow-cljs/program.cljs program
alternatively lift and shift to a project template like aws-gocljs.