Skip to content

Commit

Permalink
Update Valibot bundle size specifications
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-hiller committed Oct 11, 2024
1 parent c25643c commit 17c38fe
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ First you create a schema that describes a structured data set. A schema can be

<!-- prettier-ignore -->
```ts
import * as v from 'valibot'; // 1.2 kB
import * as v from 'valibot'; // 1.24 kB

// Create login schema with email and password
const LoginSchema = v.object({
Expand Down
2 changes: 1 addition & 1 deletion library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ First you create a schema that describes a structured data set. A schema can be

<!-- prettier-ignore -->
```ts
import * as v from 'valibot'; // 1.2 kB
import * as v from 'valibot'; // 1.24 kB

// Create login schema with email and password
const LoginSchema = v.object({
Expand Down
4 changes: 2 additions & 2 deletions website/src/routes/guides/(get-started)/comparison/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This can make a big difference, especially for client-side validation, as it red

{/* prettier-ignore */}
```ts
import * as v from 'valibot'; // 1.07 kB
import * as v from 'valibot'; // 1.19 kB

const LoginSchema = v.object({
email: v.pipe(
Expand All @@ -43,7 +43,7 @@ const LoginSchema = v.object({

### Comparison with Zod

For example, to validate a simple login form, [Zod](https://zod.dev/) requires [12.9 kB](https://bundlejs.com/?q=zod&treeshake=%5B%7B+object%2Cstring+%7D%5D) whereas I require only [1.07 kB](https://bundlejs.com/?q=valibot&treeshake=%5B%7B+email%2CminLength%2Cobject%2Cstring%2Cpipe+%7D%5D). That's a 92 % reduction in bundle size. This is due to the fact that Zod's functions have several methods with additional functionalities, that cannot be easily removed by current bundlers when they are not executed in your source code.
For example, to validate a simple login form, [Zod](https://zod.dev/) requires [12.9 kB](https://bundlejs.com/?q=zod&treeshake=%5B%7B+object%2Cstring+%7D%5D) whereas I require only [1.19 kB](https://bundlejs.com/?q=valibot&treeshake=%5B%7B+email%2CminLength%2Cobject%2Cstring%2Cpipe+%7D%5D). That's a 92 % reduction in bundle size. This is due to the fact that Zod's functions have several methods with additional functionalities, that cannot be easily removed by current bundlers when they are not executed in your source code.

{/* prettier-ignore */}
```ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ First you create a schema that describes a structured data set. A schema can be

{/* prettier-ignore */}
```ts
import * as v from 'valibot'; // 1.2 kB
import * as v from 'valibot'; // 1.24 kB

// Create login schema with email and password
const LoginSchema = v.object({
Expand Down

0 comments on commit 17c38fe

Please sign in to comment.