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

esbuild-plugin-eval

v1.0.3

Published

A plugin that evaluates a module before importing it.

Readme

esbuild-plugin-eval (for Node.JS)

This is an esbuild plugin that evaluates a module before importing it. It's useful in cases where you want to render static parts of your application at build time to prune runtime dependencies, such as pre-rendering html from JSX, or pre-calculating CSP header hashes.

This plugin will evaluate any imported module with .eval before the extension (example.eval.ts or example.eval.jsx and so on). It does this by bundling the module into a data url, dynamically importing it, and then re-exporting the results.

Usage

Install the dependency:

npm install esbuild-plugin-eval --save-dev

yarn add esbuild-plugin-eval -D

Add it to your esbuild plugins:

import { build } from 'esbuild'
import evalPlugin from 'esbuild-plugin-eval'

await build({
  ...yourConfig
  plugins: [evalPlugin],
})

Example input:

// index.js (entry point)
export * from './schema.eval.js'

// schema.eval.js
import { z } from 'zod'
import { zodToJsonSchema } from 'zod-to-json-schema'

const mySchema = z
  .object({
    myString: z.string().min(5),
    myUnion: z.union([z.number(), z.boolean()]),
  })
  .describe('My neat object schema')

export const jsonSchema = zodToJsonSchema(mySchema, 'mySchema')

Example after building:

// build/index.js

var jsonSchema = { "$ref": "#/definitions/mySchema", "definitions": { "mySchema": { "type": "object", "properties": { "myString": { "type": "string", "minLength": 5 }, "myUnion": { "type": ["number", "boolean"] } }, "required": ["myString", "myUnion"], "additionalProperties": false, "description": "My neat object schema" } }, "$schema": "http://json-schema.org/draft-07/schema#" };

In this case, we generate JSON schema at build time, and then serve it as a static file at runtime. The two dependecies used to create the schema, namely zod and zod-to-json-schema, are not included in the final bundle, thus reducing its size from 299KB to just 712 bytes.

Caveats

A best effort is made to properly handle function exports, but keep in mind that all variables accessed from exported functions will need to be exported as well.

So this won't work:

let message = 'Hello, world!'

export default () => console.log(message)

But this will:

export let message = 'Hello, world!'
//^^^^
export default () => console.log(message)

Thanks to @jed for the original Deno implementation.