This project code provides a Clojurescript REPL for Quickjs via weasel.
Quickjs is a lightweight javascript engine with low memory footprint.
Clojurescript code compiled in advanced mode can be turned into standalone executables via Quickjs's qjsc
.
Your app can use awesome cljs libraries like core.async, clojure.spec, pathom and datascript without any problem. React should be possible with a custom renderer, like: https://github.com/doodlewind/react-ssd1306
A REPL is handly to develop such apps. The easiest way to create a REPL env for Clojurescript is to leverage weasel. However, Quickjs doesn't support Websocket out of the box. Wiring up a websocket client via C api is undesired. Fortunately, there's a python wrapper for Quickjs.
This project makes use of that python wrapper together with websockets
library to implement the weasel client and edn_format
for edn transport.
Python's functionality can be easily exposed to the embeded Quickjs therefore we have straightforward Python interop right in Cljs.
The Python ecosystem is huge. Have fun!
Note: you must choose with either with standalone executable or python access. Not both.
- start weasel server, usually from your editor or manually with:
(cider.piggieback/cljs-repl (weasel.repl.websocket/repl-env :ip "0.0.0.0" :port 9001))
- compile your cljs project with
:target :none
, can be as simple as this:clj -M -m cljs.main --target none -c your-project.core
- take note of the compiled js files' base path which is the directory containing
base.js
(usuallytarget/out/goog/
. You need absolute path for this. Update thebase_path
var in the provided filequickjs_cljs.py
) - DO NOT start weasel client in your clojurescript code (as seen in weasel's documentation) - that is for websocket-powered javascript environments
- once you see that weasel is waiting for client (
<< started Weasel server on ws://127.0.0.1:9001 >><< waiting for client to connect ...
, run the provided python:python quickjs_cljs.py
todo: