{"id":25257,"library":"esbuild-ajv","title":"esbuild-ajv","description":"esbuild plugin (v0.0.1, pre-1.0.0) to pre-compile Ajv JSON schemas at build time for faster runtime, CSP compliance, and smaller bundles. Pre-compilation avoids dynamic code generation (Function constructor), enabling use in environments with strict `unsafe-eval` CSP. Requires esbuild for building and Ajv v8 for schema compilation. Differentiates from runtime-only Ajv usage by moving compilation overhead to build step.","status":"active","version":"0.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/srax47/esbuild-ajv","tags":["javascript","ajv","esbuild","validation","validator","jsonschema","typescript"],"install":[{"cmd":"npm install esbuild-ajv","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-ajv","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-ajv","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for schema compilation and validation","package":"ajv","optional":false}],"imports":[{"note":"Default export; package is ESM-only. Use import statement.","wrong":"const AjvPlugin = require('esbuild-ajv')","symbol":"AjvPlugin","correct":"import AjvPlugin from 'esbuild-ajv'"},{"note":"TypeScript type export for plugin options.","symbol":"PluginOptions","correct":"import AjvPlugin, { PluginOptions } from 'esbuild-ajv'"},{"note":"Precompiled modules export a named export `validator`, not default.","wrong":"import validator from './some.ajv.json'","symbol":"validator","correct":"import { validator } from './some.ajv.json'"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport AjvPlugin from 'esbuild-ajv';\n\nawait esbuild.build({\n  entryPoints: ['src/index.ts'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [\n    AjvPlugin({\n      extraKeywords: [/* custom keyword definitions */],\n      ajvOptions: { coerceTypes: true, useDefaults: true },\n    }),\n  ],\n});","lang":"typescript","description":"Registers esbuild-ajv plugin in an esbuild build, passing Ajv options and extra keywords."},"warnings":[{"fix":"Lock version to exact; review changelog before upgrading.","message":"Pre-1.0.0 version: API may change without major semver bump.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Ensure project uses `ajv@^8.0.0`.","message":"Ajv v8 is peer dependency; Ajv v7 is not supported.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use `.ajv.json` extension for schema files to be precompiled.","message":"Plugin modifies esbuild resolve to treat `.ajv.json` imports specially; non-standard file extension.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install -D esbuild-ajv ajv`.","cause":"esbuild-ajv not installed or not in node_modules.","error":"Cannot find module 'esbuild-ajv'"},{"fix":"Add `AjvPlugin()` to esbuild `plugins` array.","cause":"esbuild-ajv plugin not applied or esbuild cannot handle `.ajv.json` imports without plugin.","error":"Module parse failed: Unexpected token (1:0) - file: .../.ajv.json"},{"fix":"Use `import AjvPlugin from 'esbuild-ajv'` instead of `require`.","cause":"Trying to use `require` with ESM-only package.","error":"require() of ES Module esbuild-ajv not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}