Writing Zod code that minifies
Blog post from Speakeasy
Zod, a powerful tool for writing safe TypeScript code, has significantly influenced how developers build TypeScript SDKs, particularly at Speakeasy, where it has been integral to their SDK generator design. When optimizing SDK sizes for better browser performance, the traditional method of writing Zod schemas, which involves importing the entire library as a single variable, proved less effective in achieving substantial minification. A revised approach involves importing standalone functions from Zod and using local variables, allowing for more efficient minification by tools like esbuild, resulting in a 43% reduction in code size from 512 bytes to 290 bytes. This method, although slightly more cumbersome due to the necessity of importing individual functions, provides a beneficial strategy for developers prioritizing bundle size optimization.
No tracked trend matches for this post yet.
Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.