npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plugin-zod-decoupling

v0.0.1-0

Published

`vite-plugin-zod-decoupling` is a Vite plugin designed to transform Zod schemas into JSON schemas and back into Zod schemas.

Readme

vite-plugin-zod-decoupling

vite-plugin-zod-decoupling is a Vite plugin designed to transform Zod schemas into JSON schemas and back into Zod schemas.

Why ? It was mainly made to prevent leaking database schemas and dependencies when reusing schema generated from drizzle-zod in the front end.

Warning: This plugin is a highly experimental proof of concept. Do not use in profuction, in fact do not use at all.

Installation

To install the plugin, use your favorite package manager:

npm install vite-plugin-zod-decoupling
# or
yarn add vite-plugin-zod-decoupling
# or
bun add vite-plugin-zod-decoupling

Usage

To use the plugin, import it and include it in your Vite configuration. You have to specify a regular expression to match the files you want to transform.

// vite.config.ts
import { defineConfig } from "vite";
import ZodDecoupling from "vite-plugin-zod-decoupling";

export default defineConfig({
  plugins: [
    ZodDecoupling({ regex: /\.schema\.ts$/, debug: true }), // Apply the plugin to files ending with .schema.ts
  ],
});

Example

Suppose you have a drizzle entity in user.ts :

import { pgTable, text, integer } from "drizzle-orm/pg-core";
import { createSelectSchema } from "drizzle-zod";

const users = pgTable("users", {
  id: integer().generatedAlwaysAsIdentity().primaryKey(),
  name: text().notNull(),
  age: integer().notNull(),
});

export const userSelectSchema = createSelectSchema(users);

Importing userSelectSchema in the front end would bring many unwanted dependencies and of course the table schema.

Instead of directly importing userSelectSchema in your front end code, you can add a user.schema.ts file in your codebase :

export { userSelectSchema } from "user";

This plugin will then dynamically transform the user.schema.ts file, which will be transpiled to :

import { z } from "/node_modules/.vite/deps/zod.js";
export const userSelectSchema = z
  .object({
    id: z.number().int().gte(-2147483648).lte(2147483647),
    name: z.string(),
    age: z.number().int().gte(-2147483648).lte(2147483647),
  })
  .strict();

Warning: .schema.ts files must only export Zod schemas. Ensure that these files do not contain any other exports as the transformed files will not contains those exports. Also, some data might get lost during the decoupling, more info on the zod-to-json-schema and json-schema-to-zod pages.

License

This project is licensed under the MIT License.