JOLT docs v0.1.0 Apps Install

Libraries and imports

Project files are real ES modules, so you can use import to pull in other project files and packages from the web.

Project files

import { formatMoney } from "./lib/format.js";
import * as sheets from "../sheets.js";

Relative imports resolve inside the project. Circular imports between project files aren't supported.

Bare names

JOLT resolves a bare name such as import x from "name" in this order:

  1. "imports" in jolt.json. It works like an import map. Keys are names, or prefixes that end in /, and values are URLs or project files.
    "imports": {
      "react": "https://esm.sh/react@18.3.1",
      "lodash/": "https://esm.sh/lodash-es@4/",
      "util": "vendor/util.js"
    }
  2. "van" or "vanjs-core": the copy of VanJS (1.6) that JOLT ships, so there's nothing to download and it works offline.
  3. Anything else loads from esm.sh. import dayjs from "dayjs@1.11.13" loads https://esm.sh/dayjs@1.11.13.

Always include a version. A name without one gets the latest release, which can change under you, and the console warns about it.

While you build, the first package you load from esm.sh, or from any other site, asks you to trust that site. Once the app is approved (from JAM, a URL or a document), its packages load without asking, and its approval screen lists them so people can have them reviewed. Pin exact versions: a reviewer will flag a package that can change under the app. See Security.

No build step

JOLT runs your files as they are, without compiling them, so JSX and TypeScript don't work. For JSX-like markup, use htm:

import { h, render } from "preact@10.24.3";
import htm from "htm@3";
const html = htm.bind(h);

render(html`<h1>Hello from ${jolt.host}</h1>`, jolt.root);

A VanJS example

import van from "van";
const { button, span } = van.tags;

export function autoRun() {
  const count = van.state(0);
  van.add(jolt.root, button({ onclick: () => count.val++ }, "Clicked "), span(count), " times");
}

Classic scripts

For a library that only ships as a global script (UMD), use await jolt.loadScript(url), or a <script src> tag in the entry page.