| Framework | Works | What it takes |
|---|---|---|
| Angular 21 | ✓ | Flip the scaffolded experimentalDecorators to false — Angular does not need it |
| React, Vue, Svelte… | ✓ | Any Vite 8 app — add the plugin below |
| Bun | ✓ | Nothing |
Node + tsc | ✓ | Just the flag |
| Next.js 16 | ~ | Not inline — keep models in a package compiled by tsc |
| NestJS 11 | ~ | Not inline — its DI needs emitDecoratorMetadata; same precompiled route |
+ Each of these was set up and run before it was written down. + FRAMEWORKS.md + has the full recipe for every one, including the two that need the precompiled route. +
+import { defineConfig } from 'vite';
diff --git a/docs/meta.js b/docs/meta.js
index 752d437..e7ae56a 100644
--- a/docs/meta.js
+++ b/docs/meta.js
@@ -1,5 +1,5 @@
// Generated by scripts/build-docs.mjs — do not edit.
window.CEREALE_META = {
- "version": "0.3.0",
+ "version": "0.4.0",
"node": ">=20.0.0"
};
diff --git a/package.json b/package.json
index 6fb0ce8..a4d34f8 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "cereale",
- "version": "0.3.0",
+ "version": "0.4.0",
"description": "Strongly typed JSON mapping and validation for TypeScript classes \u2014 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",
@@ -16,21 +16,29 @@
"types": "./dist/esm/vite.d.ts",
"import": "./dist/esm/vite.js",
"require": "./dist/cjs/vite.js"
+ },
+ "./min": {
+ "types": "./dist/esm/index.d.ts",
+ "default": "./dist/cereale.min.js"
}
},
"sideEffects": [
+ "./dist/esm/index.js",
"./dist/esm/metadata.js",
- "./dist/cjs/metadata.js"
+ "./dist/cereale.min.js",
+ "./src/index.ts",
+ "./src/metadata.ts"
],
"files": [
"dist",
"src",
+ "FRAMEWORKS.md",
"CHANGELOG.md",
"!src/**/*.test.ts",
"!src/example.ts"
],
"scripts": {
- "build": "rm -rf dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
+ "build": "rm -rf dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && node scripts/build-bundle.mjs",
"build:docs": "node scripts/build-docs.mjs",
"demo": "node --no-warnings=ExperimentalWarning --loader ts-node/esm src/example.ts",
"type-check": "tsc --noEmit",
diff --git a/scripts/build-bundle.mjs b/scripts/build-bundle.mjs
new file mode 100644
index 0000000..6b331be
--- /dev/null
+++ b/scripts/build-bundle.mjs
@@ -0,0 +1,82 @@
+/**
+ * Flattens the ESM build into a single minified module.
+ *
+ * This is an *addition*, not a replacement. `dist/esm` stays the default `import`: it keeps
+ * readable stack traces for anyone who does not load source maps, and it is what a bundler
+ * should be handed.
+ *
+ * Where the single file does earn its place is everywhere a bundler is not involved: a
+ * `