JSON Schema Artifact Bundler

2.0.3 · active · verified Tue Apr 21

json-schema-artifact is a utility designed to bundle and optimize JSON Schemas, facilitating their use in development and production environments. Currently at version 2.0.3, this project shows active development with recent patch releases in the v2 series. Its release cadence appears to follow common open-source practices, with updates occurring as needed to introduce features, fix bugs, and align with evolving JSON Schema specifications. Key differentiators include robust support for multiple configuration formats (ESM, JSON, YAML, TypeScript) via `defineConfig`, built-in optimization options such as minification and dereferencing, and an integrated localization system that supports `t('key')` syntax for dynamic content. It also features a watch mode for development and provides direct integration recommendations for VSCode's schema validation, making it a comprehensive solution for managing complex JSON Schema ecosystems.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to configure json-schema-artifact using an ESM file, bundling a main schema, including localized content, applying optimizations like minification and dereferencing, and setting up watch paths for development.

import { defineConfig } from "json-schema-artifact";
import path from "path";

export default defineConfig([
  {
    input: {
      file: path.resolve(process.cwd(), "src/main-schema.json"),
      locales: {
        en: path.resolve(process.cwd(), "locales/en.yaml"),
        fr: path.resolve(process.cwd(), "locales/fr.yaml")
      }
    },
    output: {
      dir: path.resolve(process.cwd(), "dist"),
      optimize: {
        minify: true,
        dereference: "flatten"
      },
      filename: "bundled-schema-[locale].json"
    },
    watch: [path.resolve(process.cwd(), "src"), path.resolve(process.cwd(), "locales")]
  }
]);

// To run this:
// 1. Save as json-schema-artifact.mjs in your project root.
// 2. Ensure 'src/main-schema.json', 'locales/en.yaml', 'locales/fr.yaml' exist.
// 3. Run: npx json-schema-artifact

view raw JSON →