@rexezuge/contracts 1.13.0 → 1.15.0

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.
Files changed (2) hide show
  1. package/README.md +13 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -71,6 +71,19 @@ const api = createContractClient(itemsContract, { baseUrl: '' });
71
71
  const item = await api.getItem({ params: { id } }); // typed { id, name }
72
72
  ```
73
73
 
74
+ ## Bundle size: where zod comes from
75
+
76
+ The kit adds no zod to the SPA bundle: this package reads `.shape` and imports zod as types only, and `createContractClient` imports no zod either
77
+ (`packages/web/src/contractBundle.test.ts` bundles the client with esbuild and asserts it). What does reach the bundle is **your contract module**: `z.object(...)`
78
+ and friends are module-level calls, side effects a bundler must keep, so a SPA that imports the contract object imports zod with it, whether or not
79
+ `validateResponses` is on. Making the contract schemas lazy would change `defineEndpoint`'s shape for every repo, and a bundler still keeps what a retained thunk
80
+ calls, so it is not worth a breaking change.
81
+
82
+ If the SPA's size matters: keep `validateResponses` off, and consider writing the contract's schemas with `zod/mini` (a smaller, tree-shakeable zod API, a few KB
83
+ instead of the classic API's ~tens). Know the cost first: `zod/mini` schemas are not assignable to this package's `z.ZodType` / `z.ZodObject` slots (the classic
84
+ types), and chanfana's OpenAPI generation expects classic schemas on the Worker, so a single shared contract cannot switch without a type-level change here. Until
85
+ that lands, the supported shape is the classic zod, shared by both ends.
86
+
74
87
  ## Where the adapters live, and why
75
88
 
76
89
  | Adapter | Package | Reason |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rexezuge/contracts",
3
- "version": "1.13.0",
3
+ "version": "1.15.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "repository": {