:js-runtime)shadow-cljs can use Bun instead of Node.js for running compiled output.
This is opt-in per build via the :js-runtime config key.
| Target | Supported |
|----------------+--------------|
| :node-test | Yes |
| :node-script | Yes |
| :esm | No (not yet) |
| :browser | N/A |
Add :js-runtime :bun to a build in shadow-cljs.edn:
{:builds
{:test
{:target :node-test
:output-to "out/test.js"
:js-runtime :bun}
:my-script
{:target :node-script
:main my.app/main
:output-to "out/script.js"
:js-runtime :bun}}}
When omitted, the default is :node (unchanged behavior).
With :autorun true on a :node-test build, tests run under bun run <file> instead of node <file>.
A watched build with :js-runtime gets a managed process: shadow-cljs starts
it when a compile succeeds, and every REPL evaluates in it however it selected
the build — (shadow/repl :id), an editor's nrepl-select (CIDER, Calva,
Cursive), the console REPL or shadow/cljs-eval.
(shadow/watch :my-script) ;; compiles, then starts Bun
(shadow/repl :my-script) ;; evaluates in it
:node-script does
unless :devtools {:enabled false}. A :node-test does only with
:ui-driven true; otherwise it runs its tests and exits, so no process is
started for it. node-repl gets none: it pipes in its own process.:main
that calls process.exit — is started again by the next compile (save a
file), not by itself. A build that stops being managed loses its process.
A config edit, or a process that hangs after connecting, needs the watch
restarted..shadow-cljs/shadow-managed-runtime-<build-id>.log. Each run appends after
a --- bun runtime started --- line, so an earlier run's crash stays
readable. Before each start, a log past 1 MB is set aside as <log>.1;
one long-running chatty process can still grow it.:main that handles SIGTERM would otherwise linger.The managed process is stopped automatically when the worker shuts down.
Pass :js-runtime in the options map:
(shadow/node-repl {:js-runtime :bun})
Pass --js-runtime to any CLI command:
# standalone REPL with Bun
shadow-cljs node-repl --js-runtime bun
# watch a build with Bun
shadow-cljs watch my-build --js-runtime bun
# compile/release with Bun
shadow-cljs compile my-build --js-runtime bun
shadow-cljs release my-build --js-runtime bun
The CLI flag overrides :js-runtime in shadow-cljs.edn. It only takes
effect for node-family targets (:node-script, :node-test); on other
targets it is ignored with a warning.
PATH:js-runtime accepts :node or :bun. Any other value will produce an error
at build time or when starting a REPL.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |