Skip to content

clojurewasm/Kiso

Repository files navigation

Kiso

CI npm kiso npm su license GitHub Sponsors

A ClojureScript-to-JavaScript compiler written in TypeScript. Zero dependencies.

Kiso (基礎) — foundation in Japanese.

Package Description Size
@clojurewasm/kiso Compiler + runtime ~146 KB
@clojurewasm/su Component framework ~21 KB

Live Showcase — interactive demos with source code and compiled JS output.

Quick Start

npm install @clojurewasm/kiso @clojurewasm/su
npm install -D vite

vite.config.js:

import { cljs } from '@clojurewasm/kiso/vite';
export default { plugins: [cljs()] };

src/main.cljs:

(ns my.app
  (:require [su.core :as su :refer [defc defstyle]]))

(defstyle app-styles
  [:.counter {:display "flex" :gap "8px" :align-items "center"}])

(defc my-counter
  {:style [app-styles]}
  []
  (let [n (atom 0)]
    [:div.counter
     [:button {:on-click (fn [_] (swap! n dec))} "-"]
     [:span (str @n)]
     [:button {:on-click (fn [_] (swap! n inc))} "+"]]))

(su/mount (js/document.getElementById "app") [::my-counter])
npx vite

What Compiles to What?

(defn greet [name]           ;; → export let greet = function greet(name) {
  (str "Hello, " name "!"))  ;;     return str("Hello, ", name, "!");  };

(ns my.app                   ;; → import * as u from './util.js';
  (:require [my.util :as u]))

(.toUpperCase "hello")       ;; → "hello".toUpperCase()
(.-length "hello")           ;; → "hello".length
(js/console.log "hi")        ;; → console.log("hi")

[1 2 3]                      ;; → vector(1, 2, 3)
{:a 1}                       ;; → hashMap(keyword("a"), 1)

Compiler API

import { compile } from '@clojurewasm/kiso/compiler';
const { code } = compile('(defn add [a b] (+ a b))');
npx kiso compile src/ --out-dir dist/ --source-map

Documentation

See docs/ for the full guide, API reference, and cookbook.

Examples

  • Task Manager — full app with components, context, and styling

Development

npm install && npm run build
npm test                     # 1500+ vitest + Playwright E2E
npm run typecheck

License

MIT