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

@loydjs/vite

v1.1.0

Published

Loyd vite - Vite/Rollup AOT plugin

Readme

CI License Bundle TypeScript npm downloads


Overview

@loydjs/vite is a Vite and Rollup plugin that performs Ahead-of-Time (AOT) compilation of Loyd schemas. When enabled, it replaces compile(schema) calls in your source code with the flat inline validator functions at build time — so your production bundle contains zero compilation overhead and no dependency on @loydjs/compiler at runtime.

In development, the plugin is a no-op — JIT compilation runs as normal for fast HMR.


Installation

npm install @loydjs/vite

Requires @loydjs/core · @loydjs/compiler · Vite ≥ 5.0.0 · Node.js ≥ 20 · TypeScript ≥ 5.4


Setup

Vite

// vite.config.ts
import { defineConfig } from "vite";
import { loydPlugin } from "@loydjs/vite";

export default defineConfig({
  plugins: [
    loydPlugin({
      // Schemas to resolve statically at build time.
      // Key = variable name as it appears in your source code.
      schemas: {
        UserSchema,
        PostSchema,
        CommentSchema,
      },
    }),
  ],
});

Rollup

// rollup.config.js
import { loydPlugin } from "@loydjs/vite";

export default {
  input: "src/index.ts",
  plugins: [
    loydPlugin({ schemas: { UserSchema } }),
  ],
};

How it works

Your source code, untouched:

import { compile } from "@loydjs/compiler";
import { UserSchema } from "./schemas";

const validate = compile(UserSchema);
const result = validate(req.body);

After AOT transform — what ships in your production bundle:

// @loydjs/compiler: AOT-inlined validator for UserSchema
function __loyd_UserSchema__(input) {
  "use strict";
  let __input__ = input;
  const __issues__ = [];
  if (typeof __input__ !== "object" || __input__ === null || Array.isArray(__input__)) {
    __issues__.push({ code: "ERR_OBJECT_INVALID_TYPE", path: [] });
  } else {
    const __fname__ = __input__["name"];
    if (typeof __fname__ !== "string") {
      __issues__.push({ code: "ERR_STRING_INVALID_TYPE", path: ["name"] });
    } else {
      if (__fname__.length < 2) { __issues__.push({ code: "ERR_STRING_TOO_SHORT", path: ["name"], meta: { min: 2, actual: __fname__.length } }); }
      if (__fname__.length > 100) { __issues__.push({ code: "ERR_STRING_TOO_LONG", path: ["name"], meta: { max: 100, actual: __fname__.length } }); }
    }
    // ...
  }
  if (__issues__.length > 0) return { success: false, data: undefined, issues: __issues__ };
  return { success: true, data: __input__, issues: [] };
}
const validate = __loyd_UserSchema__;
const result = validate(req.body);

Plugin options

interface LoydVitePluginOptions {
  /**
   * Schemas to resolve statically at build time.
   * Key = variable name as it appears in source code.
   */
  schemas?: Record<string, LoydSchema<unknown>>;

  /**
   * Enable/disable the plugin entirely.
   * @default true
   */
  enabled?: boolean;

  /**
   * Log transformed files.
   * @default false
   */
  verbose?: boolean;

  /**
   * Force AOT even in development mode.
   * By default, AOT is only active during production builds.
   * @default false
   */
  forceAot?: boolean;

  /**
   * Generate sourcemaps for transformed files.
   * @default true
   */
  sourcemap?: boolean;
}

Emit standalone validators

Use the emit() function from @loydjs/compiler to generate standalone .js + .d.ts validator files, independent of the Vite plugin.

import { emit } from "@loydjs/compiler";
import { UserSchema } from "./schemas";

await emit(UserSchema, {
  outFile:    "./dist/validators/user.js",
  exportName: "validateUser",
  format:     "esm",
  dts:        true,
});

// dist/validators/user.js    — flat inline validator, no imports
// dist/validators/user.d.ts  — TypeScript declarations

Dependencies

| Package | Role | |:---|:---| | @loydjs/core | LoydSchema type | | @loydjs/compiler | generateCode, optimize for AOT codegen |

Peer dependencies

| Package | Version | |:---|:---| | vite | ≥ 5.0.0 |


Documentation

loyddev-psi.vercel.app


License

MIT © b3nito404