{"_id":"@ata-project/unplugin","_rev":"2-4388bf7fee18bf32d8c0c23854cedf6c","name":"@ata-project/unplugin","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@ata-project/unplugin","version":"0.1.0","keywords":["unplugin","vite-plugin","webpack-plugin","rollup-plugin","esbuild-plugin","rspack-plugin","json-schema","ata-validator","typescript","codegen"],"author":{"name":"Mert Can Altin","email":"mertgold60@gmail.com"},"license":"MIT","_id":"@ata-project/unplugin@0.1.0","maintainers":[{"name":"mertcanaltin","email":"mertgold60@gmail.com"}],"homepage":"https://github.com/ata-core/unplugin-ata#readme","bugs":{"url":"https://github.com/ata-core/unplugin-ata/issues"},"dist":{"shasum":"d7b6bd6df667a5c4cfe18befb31f9e92576937cb","tarball":"https://registry.npmjs.org/@ata-project/unplugin/-/unplugin-0.1.0.tgz","fileCount":18,"integrity":"sha512-TthrSERXTUUuHGeppisKWn5KG4l9FqRhYUJCkOTNX8Ot6D0tRv7eG72HAXgbgp+Q+uEMzdgAv7SkMUZf9lN1JA==","signatures":[{"sig":"MEUCIBkJF2HItyZx98GxbZumNAg93IxvkkiADjUHJ6Cx1zWrAiEAlr5azOaY7hypDhuaB6e14r9lfRFMgKmJx+fm5qsxB+Y=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":26972},"main":"./src/index.js","type":"module","types":"./src/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./src/index.d.ts","default":"./src/index.js"},"./core":"./src/core.js","./vite":{"types":"./src/vite.d.ts","default":"./src/vite.js"},"./rollup":{"types":"./src/rollup.d.ts","default":"./src/rollup.js"},"./rspack":{"types":"./src/rspack.d.ts","default":"./src/rspack.js"},"./esbuild":{"types":"./src/esbuild.d.ts","default":"./src/esbuild.js"},"./webpack":{"types":"./src/webpack.d.ts","default":"./src/webpack.js"},"./rolldown":{"types":"./src/rolldown.d.ts","default":"./src/rolldown.js"}},"gitHead":"e57895f02a93c5eaf26e46f1d6f6ee4815f99cc4","scripts":{"test":"node --test test/*.test.js"},"_npmUser":{"name":"mertcanaltin","email":"mertgold60@gmail.com"},"repository":{"url":"git+https://github.com/ata-core/unplugin-ata.git","type":"git"},"_npmVersion":"11.19.0","description":"Compile JSON, JS and TS schema files to ata-validator standalone modules at build time, in Vite, Webpack, Rollup, Rolldown, esbuild and Rspack.","directories":{},"_nodeVersion":"25.2.1","dependencies":{"jiti":"^2.7.0","unplugin":"^3.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^7.3.2","rollup":"^4.60.0","esbuild":"^0.28.0","webpack":"^5.105.0","rolldown":"^1.2.8","typescript":"^5.9.3","@rspack/core":"^1.7.0","ata-validator":"^1.15.0"},"peerDependencies":{"ata-validator":">=1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/unplugin_0.1.0_1789233388919_0.17354279715138632","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"_id":"@ata-project/unplugin@0.1.1","bugs":{"url":"https://github.com/ata-core/unplugin-ata/issues"},"dist":{"shasum":"9d7d7c43c5ff068ab6abfd581ca065cdab8eb40a","tarball":"https://registry.npmjs.org/@ata-project/unplugin/-/unplugin-0.1.1.tgz","fileCount":18,"integrity":"sha512-mB+8iO+/kkpIgHZNixppP18QTaQ31z0vhEifeL/pXnQhWkzP7Rdamqq57cQtDih0JoCpoLccGoeH0AefZJKUHA==","signatures":[{"sig":"MEQCIGtsWylvFC5EIS8U/Gueoneg9IUO/QHOS9NJNPsfHqlgAiA3mTFc6TmiYgfLrbBVMbmmTQxKMlncxugOD2Ew9VrfCg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCWJyhyskYRyIea0kajv0+uUlAVi2LoJhqVIE8KWe4UgQIgZTuPnhX6xuq7Jg/32BGHSXsLb4eaBxnuZ0JBAC7vKM0="}],"unpackedSize":27276},"main":"./src/index.js","name":"@ata-project/unplugin","type":"module","types":"./src/index.d.ts","author":{"name":"Mert Can Altin","email":"mertgold60@gmail.com"},"engines":{"node":">=18.0.0"},"exports":{".":{"types":"./src/index.d.ts","default":"./src/index.js"},"./core":"./src/core.js","./vite":{"types":"./src/vite.d.ts","default":"./src/vite.js"},"./rollup":{"types":"./src/rollup.d.ts","default":"./src/rollup.js"},"./rspack":{"types":"./src/rspack.d.ts","default":"./src/rspack.js"},"./esbuild":{"types":"./src/esbuild.d.ts","default":"./src/esbuild.js"},"./webpack":{"types":"./src/webpack.d.ts","default":"./src/webpack.js"},"./rolldown":{"types":"./src/rolldown.d.ts","default":"./src/rolldown.js"},"./package.json":"./package.json"},"gitHead":"c250d8405c768c5716f703ebeea3b61ac6eafd2a","license":"MIT","scripts":{"test":"node --test test/*.test.js"},"version":"0.1.1","_npmUser":{"name":"mertcanaltin","email":"mertgold60@gmail.com"},"homepage":"https://github.com/ata-core/unplugin-ata#readme","keywords":["unplugin","vite-plugin","webpack-plugin","rollup-plugin","esbuild-plugin","rspack-plugin","json-schema","ata-validator","typescript","codegen"],"repository":{"url":"git+https://github.com/ata-core/unplugin-ata.git","type":"git"},"_npmVersion":"11.19.0","description":"Compile JSON, JS and TS schema files to ata-validator standalone modules at build time, in Vite, Webpack, Rollup, Rolldown, esbuild and Rspack.","directories":{},"maintainers":[{"name":"mertcanaltin","email":"mertgold60@gmail.com"}],"_nodeVersion":"25.2.1","dependencies":{"jiti":"^2.7.0","unplugin":"^3.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^7.3.2","rollup":"^4.60.0","esbuild":"^0.28.0","webpack":"^5.105.0","rolldown":"^1.2.8","typescript":"^5.9.3","@rspack/core":"^1.7.0","ata-validator":"^1.25.0"},"peerDependencies":{"ata-validator":">=1.0.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/unplugin_0.1.1_1789637595372_0.22838502868666266"}}},"time":{"created":"2026-09-12T17:16:28.701Z","modified":"2026-09-17T09:33:15.666Z","0.1.0":"2026-09-12T17:16:29.043Z","0.1.1":"2026-09-17T09:33:15.447Z"},"bugs":{"url":"https://github.com/ata-core/unplugin-ata/issues"},"author":{"name":"Mert Can Altin","email":"mertgold60@gmail.com"},"license":"MIT","homepage":"https://github.com/ata-core/unplugin-ata#readme","keywords":["unplugin","vite-plugin","webpack-plugin","rollup-plugin","esbuild-plugin","rspack-plugin","json-schema","ata-validator","typescript","codegen"],"repository":{"url":"git+https://github.com/ata-core/unplugin-ata.git","type":"git"},"description":"Compile JSON, JS and TS schema files to ata-validator standalone modules at build time, in Vite, Webpack, Rollup, Rolldown, esbuild and Rspack.","maintainers":[{"name":"mertcanaltin","email":"mertgold60@gmail.com"}],"readme":"# @ata-project/unplugin\n\nCompiles JSON Schema files into self-contained [ata-validator](https://ata-validator.com) modules at build time, with TypeScript declarations, in Vite, Webpack, Rollup, Rolldown, esbuild and Rspack. One plugin, built on [unplugin](https://github.com/unjs/unplugin).\n\nThe generated module imports nothing. A small schema compiles to about 1.4 KB gzipped and a ten-field one to about 4.8 KB, full error detail included; the module exports `validate`, `isValid` and the inferred type, and runs anywhere plain JavaScript runs.\n\nSchemas can be authored as `.json`, `.js` or `.ts`.\n\n## Install\n\n```bash\nnpm install --save-dev @ata-project/unplugin ata-validator\n```\n\n`ata-validator` is a peer dependency and is only used at build time.\n\n## Setup\n\nVite:\n\n```ts\n// vite.config.ts\nimport ata from '@ata-project/unplugin/vite'\n\nexport default {\n  plugins: [ata({ schemas: 'src/**/*.schema.json' })],\n}\n```\n\nWebpack:\n\n```js\n// webpack.config.js\nconst ata = require('@ata-project/unplugin/webpack')\n\nmodule.exports = {\n  plugins: [ata({ schemas: 'src/**/*.schema.json' })],\n}\n```\n\nRollup:\n\n```js\n// rollup.config.js\nimport ata from '@ata-project/unplugin/rollup'\n\nexport default {\n  // Rollup has no project root; tell the plugin where the globs start.\n  plugins: [ata({ schemas: 'src/**/*.schema.json', root: process.cwd() })],\n}\n```\n\nesbuild:\n\n```js\nimport { build } from 'esbuild'\nimport ata from '@ata-project/unplugin/esbuild'\n\nawait build({\n  entryPoints: ['src/main.ts'],\n  bundle: true,\n  plugins: [ata({ schemas: 'src/**/*.schema.json' })],\n})\n```\n\nRspack:\n\n```js\n// rspack.config.js\nconst ata = require('@ata-project/unplugin/rspack')\n\nmodule.exports = {\n  plugins: [ata({ schemas: 'src/**/*.schema.json' })],\n}\n```\n\nRolldown:\n\n```js\n// rolldown.config.js\nimport ata from '@ata-project/unplugin/rolldown'\n\nexport default {\n  plugins: [ata({ schemas: 'src/**/*.schema.json', root: process.cwd() })],\n}\n```\n\nNext.js uses Webpack, so the Webpack entry goes into `next.config.js`:\n\n```js\nconst ata = require('@ata-project/unplugin/webpack')\n\nmodule.exports = {\n  webpack(config) {\n    config.plugins.push(ata({ schemas: 'schemas/**/*.schema.json' }))\n    return config\n  },\n}\n```\n\nTurbopack has no plugin interface this could attach to. Run the compile as a\nstep before the build instead: `ata build 'schemas/**/*.schema.json'` from\nata-validator's CLI, or the `compile()` function below in a script.\n\n## The `.schema.json` convention\n\nName a schema `user.schema.json` and import a typed validator by its name:\n\n```ts\nimport validate, { type User, isValid } from './user.schema'\n\nconst r = validate(input)\nif (r.valid) {\n  // input matched the schema\n}\nif (isValid(input)) {\n  input.id // narrowed to User\n}\n```\n\nThe plugin writes `user.schema.js` and `user.schema.d.ts` next to the schema.\nThe default export is the `validate` function; `validate`, `isValid` and the\ninferred type are also named exports. The type name comes from the schema's\n`title`, then its `$id`, then the file name.\n\nAdd the generated files to `.gitignore`:\n\n```\n*.schema.js\n*.schema.d.ts\n```\n\nOther sources (`.json` without the `.schema` suffix, `.js`, `.ts`) produce\n`<name>.validator.mjs` and `<name>.validator.d.mts`.\n\n## Options\n\n| Option | Default | Description |\n|---|---|---|\n| `schemas` | `**/*.schema.json` | Glob or globs, relative to the root. `node_modules` is skipped. |\n| `outDir` | next to each schema | Directory for generated files, mirroring the source layout. |\n| `format` | `'esm'` | `'esm'` or `'cjs'`. |\n| `abortEarly` | `false` | Emit the smaller validator that stops at the first failure. |\n| `types` | `true` | Emit a `.d.ts` next to each validator. |\n| `nameFromFile` | file name in PascalCase | Type name for schemas without `title` or `$id`. |\n| `root` | from the bundler | Where the globs resolve from. Vite's root, Webpack's and Rspack's `context` and esbuild's `absWorkingDir` are read; Rollup and Rolldown need it passed. |\n| `alias` | Vite's `resolve.alias` | Import aliases inside `.ts` schema files. tsconfig `paths` work without configuration. |\n\n## How it works\n\nOutput goes to disk, not to virtual modules. That is what makes the plugin\nidentical across bundlers and what lets TypeScript see the generated\ndeclarations without any bundler-specific type plumbing.\n\nSchemas compile on build start. On a schema change, Vite recompiles through\nits HMR hook and Webpack, Rspack, Rollup and Rolldown through `watchChange`.\nesbuild has no watch hook, so under `esbuild --watch` a schema edit alone does\nnot trigger a rebuild; the next build start compiles it.\n\n`.ts` schemas load through [jiti](https://github.com/unjs/jiti). A schema\nmodule exports the schema as `default` or as a named `schema`.\n\nA schema the standalone compiler cannot represent is reported with a warning\nand skipped; the ata-validator runtime API still validates it.\n\n## Programmatic use\n\n```js\nimport { compile } from '@ata-project/unplugin'\n\nconst { files, results } = await compile({ schemas: 'schemas/**/*.json', root: process.cwd() })\n```\n\n## Tests\n\n`npm test` compiles the same entry with Vite, Webpack, Rollup, Rolldown,\nesbuild and Rspack, imports each bundle and runs the validator it contains.\n\n## Package name\n\nThe package is `@ata-project/unplugin`; the plugin registers itself in the\nbundler as `unplugin-ata`, which is the name in log lines and in\n`plugin.name`. The unscoped name is not available on npm.\n\n## Relation to ata-vite\n\n`ata-vite` is this plugin's Vite entry with the old name. It keeps working;\nnew projects can use either.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}