ClojureScript compiled to ES modules, bundled by Vite.
Clojurific is a fork of ClojureScript
by Whimsical. Its :module-format :esm compiles every
namespace to an ES module and leaves bundling, minification, npm packages and
TypeScript to Vite, without the Google Closure Compiler. It includes a Vite
plugin, hot reloading and an nREPL server evaluating in the browser. See
ESM.md for usage, design and known gaps. The classic compiler
(cljs.main, cljs.build.api) is still there and needs the Closure Compiler,
see Dependencies.
It's based on ClojureScript's master after the 1.12.145 release; see
CHANGELOG.md for where it forked and what it changed. It keeps ClojureScript's
namespaces (cljs.core, cljs.analyzer, …), so libraries written for
ClojureScript work unchanged. Its own are cljf.*: the ES module build
(cljf.esm) and the extensions to ClojureScript (cljf.x).
Status: experimental.
Versions are 0.<minor>.<release>: <minor> is the ClojureScript 1.x release
it's compatible with (12 for 1.12.x), <release> counts Clojurific's releases,
starting from 1.
npm create clojurific@latest
scaffolds a Vite project (Vanilla, Reagent or UIx), installs it and starts the dev server. It needs Node.js 20 and Java 17 or later, and offers to download Java when there's none.
Vite replaces shadow-cljs' build and dev server: npm install -D clojurific vite,
then move shadow-cljs.edn over:
:source-paths and :dependencies go to deps.edn's :paths and :deps.
The Vite plugin resolves it with the cljf launcher, the Clojure CLI isn't needed.:compiler-options (:closure-defines, :warnings-as-errors, …)
go to cljs.edn, the plugin's config, or its compilerOptions.
:dev/:release settings are the :dev and :release profiles.:modules' :init-fn becomes a script in index.html
(<script type="module" src="/src/my/app.cljs"></script>), whose namespace
calls its init fn at the top level. :output-dir is the plugin's outputDir,
:dev-http is Vite's dev server.:npm-interop :shadow to keep shadow-cljs' bindings of CommonJS packages
(["pkg" :as x] is module.exports).// vite.config.mjs
import cljs from 'clojurific/vite';
export default {
plugins: [cljs({ config: 'cljs.edn', outputDir: 'target/cljs',
compilerOptions: { 'npm-interop': ':shadow' } })],
};
In the code, ^:dev/before-load / ^:dev/after-load, shadow.resource and
symbol requires of npm packages work as they are. shadow.cljs.modern's
defclass is cljf.x's, shadow.lazy is cljf.esm.lazy, and
lazily loaded namespaces are :main entries split by the bundler instead of
:modules. :test builds become a :test-runner. See ESM.md for
the details and the known gaps.
Clojure deps.edn, from Clojars:
com.whimsical/clojurific {:mvn/version "0.12.4"}
npm, with the cljf launcher, which
needs Java but not the Clojure CLI: npm install clojurific.
Stock ClojureScript (org.clojure/clojurescript) has the same namespaces, so
it mustn't be on the classpath too: cljf.esm fails at startup, naming both,
when it is. Exclude it from the library that brings it in with
:exclusions [org.clojure/clojurescript], or from the whole dependency tree
with the empty project in no-clojurescript/:
:override-deps {org.clojure/clojurescript {:git/url "https://github.com/WhimsicalCode/clojurific"
:git/sha "…"
:deps/root "no-clojurescript"}}
Please point all of your questions and feedback to the #clojurific Slack channel.
Bug and features requests can be opened as issues in GitHub repo.
Clojurific is licensed under Eclipse Public License 1.0 (https://opensource.org/license/epl-1-0/), same as ClojureScript.
Copyright © Whimsical, Inc. Copyright © Rich Hickey
Can you improve this documentation? These fine people already did:
David Nolen, dnolen, davidnolen, Kaspars Dancis, Alex Miller, Devin Walters & FogusEdit 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 |