diff --git a/changelog/0.30.0.md b/changelog/0.30.0.md index 29b6f9153..c8d537ab1 100644 --- a/changelog/0.30.0.md +++ b/changelog/0.30.0.md @@ -13,6 +13,7 @@ This revision includes breaking representation changes to Extended Types and Mod - [Optional and Readonly](#Optional-and-Readonly) - [Iterator and AsyncIterator](#Iterator-and-AsyncIterator) - [Order Independent References](#Order-Independent-References) + - [Value Submodules](#Value-Submodules) - [Additional Array Constaints](#Additional-Array-Constaints) - [Reducing Package Size](#Reducing-Package-Size) - Breaking @@ -24,9 +25,11 @@ This revision includes breaking representation changes to Extended Types and Mod ## Extended Type Representations -Revision 0.30.0 updates representations for all extended types. These changes are made due to TypeBox's observed role as a general purpose JavaScript validation library as well as to deprecate support for extended type validation in Ajv. For some history, attempts were made on Revision 0.25.0 to restructure extended type respresentations to provide Ajv hooks for custom type configuration. These hooks used the `type` property where `{ type: 'object', instanceOf: 'TypeName' }` was used to configure schematics for JavaScript objects, and `{type: 'null', typeOf: 'PrimitiveName' }` was used for JavaScript primitives. Despite providing these hooks, Ajv would still struggle with validation of primitive types (such as `undefined`), and generally types of `Function`, `Constructor` and `Promise` were meaningless to Ajv (and TypeBox) in terms of validation. For this reason, expressing hooks for Ajv for non-validatable schematics does not seem to make much sense in the long term, particularily when these schematics are used principally as framing schematics to describe callable interfaces. +Revision 0.30.0 updates representations for all extended types. This change is made due to TypeBox's observed role as a general purpose JavaScript validation library as well as to deprecate support for extended type validation in Ajv (which was partially functional at best) -This change mostly represents a move towards a formal specification to express pure JavaScript constructs. This change however will implicate the use of `Uint8Array` and `Date` objects when configuring for Ajv. A supplimentary fallback will be provided in the `/examples` directory. +Attempts were made on Revision 0.25.0 to restructure extended types to provide Ajv hooks for custom type configuration. These hooks used the `type` property where `{ type: 'object', instanceOf: 'TypeName' }` was used to configure schematics for JavaScript objects, and `{ type: 'null', typeOf: 'PrimitiveName' }` was used for JavaScript primitives. Despite these hooks, Ajv would still struggle with validation of primitive types (such as `undefined`), and for the types `Function`, `Constructor` and `Promise`; these were meaningless to Ajv and it did not make sense to try provide hooks for a validator that could not use them anyway. + +This change mostly represents a move towards a formal specification to express pure JavaScript constructs. The change will implicate the use of `Uint8Array` and `Date` objects when configuring for Ajv. A supplimentary fallback will be provided in the `/examples` directory using `Type.Unsafe` ```typescript // Revision 0.29.0 @@ -46,9 +49,7 @@ const U = Type.Undefined() // const U: TUndefined = { ty ## Optional and Readonly -Revision 0.30.0 deprecates the `[Modifier]` symbol and introduces the `[Readonly]` and `[Optional]` symbols. This change was carried out to simplify internal type inference as well as to streamline runtime mapping logic where adding and removing individual `[Readonly]` and `[Optional]` symbols is cleaner than conditionally checking 3 variants states of `[Modifier]`. - -This change should not implicate users leveraging the `Type.*` for type construction, however implementors building runtime mapping utilities should update to use the new symbols. +Revision 0.30.0 deprecates the `[Modifier]` symbol and introduces two new symbols, `[Readonly]` and `[Optional]`. This change is carried out to simplify internal type inference as well as to simplify runtime mapping logic. This change should not implicate users leveraging the `Type.*` for type construction, however implementors building runtime mapping utilities should update to use the new symbols. ```typescript // Revision 0.29.0 @@ -142,6 +143,28 @@ const T = Type.Object({ }, { $id: 'T' }) ``` + + +## Value Submodules + +Revision 0.30.0 refactors the `Value.*` module to allow each submodule to be imported individually. This change is part of larger refactoring to reduce the size of the Value module, but also to address issues with bundlers unable to tree-shake against the internal namespaces. + +The `Value.*` namespace is retained on Revision 0.30.0 + +```typescript +// Revision 0.29.0 +// +import { Value } from '@sinclair/typebox/value' // Value.* namespace + +const A = Value.Create(Type.String()) + +// Revision 0.30.0 +// +import { Create } from '@sinclair/typebox/value/create' // Create function only + +const B = Create(Type.String()) +``` + ## Additional Array Constaints @@ -206,7 +229,7 @@ For information on configuring custom formats on Ajv, refer to https://ajv.js.or ## Reducing Package Size -Revision 0.30.0 marks a more concentrated effort to try and reduce TypeBox installable package sizes with initial work carried out on `typebox.ts` to refactor `TypeExtends` on the 0.30.0 Revision. Additional work will be carried out over the next few revisions to try and optimize compression, as well as investigating techniques more condusive to tree shaking. +Revision 0.30.0 implements a number of code refactorings to attempt to reduce package size. These changes were primarily focused on the `Value` module which has increased in size due to functionality being introduced over the past several revisions. ```typescript // Revision 0.29.0 @@ -226,10 +249,10 @@ Revision 0.30.0 marks a more concentrated effort to try and reduce TypeBox insta ┌──────────────────────┬────────────┬────────────┬─────────────┐ │ (index) │ Compiled │ Minified │ Compression │ ├──────────────────────┼────────────┼────────────┼─────────────┤ -│ typebox/compiler │ '130.3 kb' │ ' 59.0 kb' │ '2.21 x' │ -│ typebox/errors │ '112.0 kb' │ ' 50.1 kb' │ '2.24 x' │ +│ typebox/compiler │ '129.5 kb' │ ' 58.7 kb' │ '2.21 x' │ +│ typebox/errors │ '111.2 kb' │ ' 49.8 kb' │ '2.23 x' │ │ typebox/system │ ' 75.4 kb' │ ' 31.3 kb' │ '2.41 x' │ -│ typebox/value │ '181.7 kb' │ ' 79.2 kb' │ '2.29 x' │ +│ typebox/value │ '174.3 kb' │ ' 76.4 kb' │ '2.28 x' │ │ typebox │ ' 74.3 kb' │ ' 30.8 kb' │ '2.41 x' │ └──────────────────────┴────────────┴────────────┴─────────────┘ ``` \ No newline at end of file