Skip to main content

Installation

@versionzero/schema is distributed as raw ESM with no build step, and runs on Node.js 19+ or any modern browser. The same package serves both; only the set of built-in schemas and value processors varies by platform.

Node​

npm install --save @versionzero/schema
import { Schema, SchemaResolver } from '@versionzero/schema';

The Node entry registers the universal core plus a Node-only library: the buffer schema and filesystem/IO processors such as $file, $directory, $readable, $writable, $executable, $reachable, and the base64 helpers.

Browsers​

The library works directly in the browser as ESM — no bundler or build step required. From a CDN, import the pre-built single-file bundle. This is one HTTP request (~39 KB gzipped) rather than one per module in the import graph:

<script type="module">
import { Schema, SchemaResolver } from
'https://cdn.jsdelivr.net/npm/@versionzero/schema/dist/schema.browser.mjs';
</script>

Alternatively, let a bundling CDN resolve the package's browser export condition for you. jsDelivr's /+esm flavor and esm.sh both serve the same bundle:

import { Schema, SchemaResolver } from 'https://cdn.jsdelivr.net/npm/@versionzero/schema/+esm';

When installed via npm and consumed through a bundler, the bare '@versionzero/schema' specifier resolves the same browser condition automatically.

caution

Do not import the raw .../src/index.js entry over a CDN. It has no build step, so the module graph fans out to roughly two hundred individual requests. Use the bundle paths above instead.

Platform differences​

The browser bundle contains only the universal core; the Node-only buffer schema and filesystem/IO processors are excluded, since they depend on APIs that are unavailable in the browser. Schemas that avoid those built-ins behave identically on both platforms.