@ata-project/unplugin 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Compiles 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).
4
4
 
5
- The generated module imports nothing. A typical schema compiles to about 1 KB gzipped, exports `validate`, `isValid` and the inferred type, and runs anywhere plain JavaScript runs.
5
+ The 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.
6
6
 
7
7
  Schemas can be authored as `.json`, `.js` or `.ts`.
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ata-project/unplugin",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Compile JSON, JS and TS schema files to ata-validator standalone modules at build time, in Vite, Webpack, Rollup, Rolldown, esbuild and Rspack.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -33,7 +33,8 @@
33
33
  "types": "./src/rspack.d.ts",
34
34
  "default": "./src/rspack.js"
35
35
  },
36
- "./core": "./src/core.js"
36
+ "./core": "./src/core.js",
37
+ "./package.json": "./package.json"
37
38
  },
38
39
  "files": [
39
40
  "src/"
@@ -75,7 +76,7 @@
75
76
  },
76
77
  "devDependencies": {
77
78
  "@rspack/core": "^1.7.0",
78
- "ata-validator": "^1.15.0",
79
+ "ata-validator": "^1.25.0",
79
80
  "esbuild": "^0.28.0",
80
81
  "rolldown": "^1.2.8",
81
82
  "rollup": "^4.60.0",
package/src/core.js CHANGED
@@ -270,11 +270,13 @@ async function compileOne(schemaFile, options, root, api, logger, fresh = false)
270
270
  let outSrc = validatorSrc
271
271
  let defaultRewritten = false
272
272
  if (isSchemaConvention(schemaFile) && options.format !== 'cjs') {
273
- // toStandaloneModule emits `export default { validate, isValid };`.
273
+ // toStandaloneModule emits `export default { validate, isValid, schemaHash };`
274
+ // (schemaHash since ata-validator 1.25.0; earlier versions emit fewer names).
274
275
  // For the .schema convention we make the default the validate function so
275
- // `import validate from './x.schema'` works. Named exports stay intact.
276
+ // `import validate from './x.schema'` works. Named exports stay intact, so
277
+ // anything else in that object list is still importable by name.
276
278
  const replaced = outSrc.replace(
277
- /^export default \{\s*validate(?:\s*,\s*isValid)?\s*\};?\s*$/m,
279
+ /^export default \{\s*validate(?:\s*,\s*[A-Za-z_$][A-Za-z0-9_$]*)*\s*,?\s*\};?\s*$/m,
278
280
  'export default validate;',
279
281
  )
280
282
  if (replaced !== outSrc) {