$ npm install babel-plugin-zod-hoistHoists Zod schema definitions to the top of the file.
This:
function getSchema() {
return z.object({ name: z.string() });
}
Becomes this:
const _schema_94b7f = z.object({
name: z.string(),
});
function getSchema() {
return _schema_94b7f;
}
Initializing Zod schemas is expensive.
By hoisting the schema to the top of the file, we can avoid re-initializing the schema every time we use it.
npm install --save-dev babel-plugin-zod-hoist
Add the plugin to your Babel configuration:
{
"plugins": ["babel-plugin-zod-hoist"]
}