Every change here answers one question: where does cereale currently fail
without saying so?
**Vite 8 / Vitest 4 drop decorators silently.** Both transform with oxc,
which does not implement the standard decorator transform and does not
report that. `vitest` prints "0 test" beside a bare SyntaxError, and
`vite build` reports success while emitting a bundle that throws on first
import. Ship the plugin that fixes it as `cereale/vite`, transforming with
esbuild and falling back to tsc — cereale depends on neither. The library's
own suite now runs through it, so it is exercised by every test.
**Legacy decorators died opaquely.** With `experimentalDecorators: true`,
still the default in most existing TypeScript projects, decorators are
invoked as (prototype, "name") and cereale raised "TypeError: Cannot convert
undefined or null to object". All decorators now resolve metadata through
one checkpoint that names the tsconfig setting instead, and reject
application to a method, getter or accessor field.
**Values JSON cannot carry were emptied.** A populated Map serialized to
{}, a Uint8Array to index-keyed noise, a bigint straight through so the
caller's own JSON.stringify threw somewhere unrelated. All now raise
JsonMappingError naming the property path and both ways out. Covers what a
@JsonSerialize serializer returns, sync or async. Circular-reference and
depth errors name the path too.
Also fixed: defineRule on a subclass with no decorators of its own wrote
the rule into its base class, because the base's metadata object is
inherited through the static prototype chain and `??=` found it non-nullish.
The README's toolchain table (tsc, esbuild, swc ✅, oxc ❌) is now executed
by a test rather than asserted, and the positioning leads with
class-validator + class-transformer, the stack cereale actually replaces,
rather than Zod, which it deliberately is not.
193 -> 249 tests.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SAcqrz3FcadkYr3xG32CjK
80 lines
2.4 KiB
JSON
80 lines
2.4 KiB
JSON
{
|
|
"name": "cereale",
|
|
"version": "0.3.0",
|
|
"description": "Strongly typed JSON mapping and validation for TypeScript classes — validated domain objects, not validated data. A zero-dependency replacement for class-validator + class-transformer, on TC39 standard decorators.",
|
|
"type": "module",
|
|
"main": "./dist/cjs/index.js",
|
|
"module": "./dist/esm/index.js",
|
|
"types": "./dist/esm/index.d.ts",
|
|
"exports": {
|
|
".": {
|
|
"types": "./dist/esm/index.d.ts",
|
|
"import": "./dist/esm/index.js",
|
|
"require": "./dist/cjs/index.js"
|
|
},
|
|
"./vite": {
|
|
"types": "./dist/esm/vite.d.ts",
|
|
"import": "./dist/esm/vite.js",
|
|
"require": "./dist/cjs/vite.js"
|
|
}
|
|
},
|
|
"sideEffects": [
|
|
"./dist/esm/metadata.js",
|
|
"./dist/cjs/metadata.js"
|
|
],
|
|
"files": [
|
|
"dist"
|
|
],
|
|
"scripts": {
|
|
"build": "rm -rf dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
|
|
"build:docs": "esbuild src/index.ts --bundle --format=iife --global-name=Cereale --minify --tsconfig=tsconfig.json --outfile=docs/cereale.js",
|
|
"demo": "node --no-warnings=ExperimentalWarning --loader ts-node/esm src/example.ts",
|
|
"type-check": "tsc --noEmit",
|
|
"test": "vitest run",
|
|
"test:watch": "vitest",
|
|
"test:coverage": "vitest run --coverage",
|
|
"lint": "eslint .",
|
|
"lint:fix": "eslint . --fix",
|
|
"verify": "npm run type-check && npm run lint && npm run test && npm run build",
|
|
"prepublishOnly": "npm run verify"
|
|
},
|
|
"engines": {
|
|
"node": ">=20.0.0"
|
|
},
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/Avalon-Vanguard/cereale.git"
|
|
},
|
|
"keywords": [
|
|
"json",
|
|
"validation",
|
|
"decorators",
|
|
"standard-decorators",
|
|
"typescript",
|
|
"dto",
|
|
"serialization",
|
|
"class-validator",
|
|
"class-transformer",
|
|
"class-validator-alternative"
|
|
],
|
|
"author": "Avalon Vanguard",
|
|
"license": "MIT",
|
|
"bugs": {
|
|
"url": "https://github.com/Avalon-Vanguard/cereale/issues"
|
|
},
|
|
"homepage": "https://github.com/Avalon-Vanguard/cereale#readme",
|
|
"devDependencies": {
|
|
"@eslint/js": "^10.0.1",
|
|
"@swc/core": "^1.15.47",
|
|
"@types/node": "^25.6.0",
|
|
"@vitest/coverage-v8": "^4.1.4",
|
|
"esbuild": "^0.25.0",
|
|
"eslint": "^10.2.1",
|
|
"globals": "^17.5.0",
|
|
"ts-node": "^10.9.2",
|
|
"typescript": "^6.0.2",
|
|
"typescript-eslint": "^8.58.2",
|
|
"vitest": "^4.1.4"
|
|
}
|
|
}
|