jit
AOT

Generation and tree shaking

Export grouped objects or standalone functions without shipping the compiler.

const selected = JIT.validator(UserSchema).get("is", "parse");

export const User = JIT.compile(UserSchema, {
  is: selected.is,
  parse: selected.parse,
});

export const User_is = selected.is;

Grouped declarations generate one object import:

import { User } from "@jit/generated";
User.is(input);

Standalone declarations keep their exact exported name:

import { User_is } from "@jit/generated";

Generated modules contain no import from jit and declare sideEffects: false. Only selected operations and their required low-level helpers are emitted. This matters most in browser bundles: importing one validator cannot retain schema builders, codecs, queries or the runtime compiler.

Manifest and plan files make the retained surface reviewable. Bindings that cannot be serialized, such as arbitrary callbacks, are skipped with a reason instead of being miscompiled.

Grouped versus standalone

Grouped objects are ergonomic domain modules. Standalone exports are finer tree-shaking units. If one route needs only is, importing a grouped object that also declares parse/stringify can retain those siblings depending on how the object is consumed.

export const User_is = selected.is; // narrowest unit
export const User = JIT.compile(UserSchema, {
  is: selected.is,
  parse: selected.parse,
});

Generated output

A project-local output writes ESM index.js plus matching declarations for standard relative imports. Output below node_modules writes ESM, CJS, an exports map and sideEffects: false for package-style imports. Optional subpath modules let route bundles import one declaration file without evaluating the root barrel.

// Local output
import { User } from "./generated/jit/index.js";

// node_modules/@jit/generated output
import { User } from "@jit/generated";

Helper retention

Operation-specific helpers are emitted only when needed. A validator that does not parse cannot retain JITValidationError; a query that touches id and score cannot retain an unrelated string dictionary; a standalone is cannot retain codec or mapper infrastructure.

Callback-free JIT.watch functions can also be exported standalone or as a JIT.compile extra. Their generated module retains only the keyed diff loop; stateful JIT.watchedList instances remain runtime-owned. See watched lists.

Proof, not assumption

The repository bundles generated fixtures through esbuild and asserts that unused exports/helper classes disappear. Applications should also inspect their actual Vite/Next/Webpack output because grouping and re-export barrels can alter tree-shaking boundaries.

On this page