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

comptime

v0.1.0

Published

A Zig-inspired build-time evaluation primitive, exposed as Vite and Rolldown plugins.

Downloads

849

Readme

comptime

A Zig-inspired build-time evaluation primitive, exposed as Vite and Rolldown plugins.

import { comptime } from "comptime";
import { fibonacci } from "./math";

export const value = comptime(() => fibonacci(10));

With the plugin enabled, the call is evaluated during the build and replaced with a serialized expression:

export const value = 55;

If the plugin is not enabled, the runtime helper throws so missed transforms fail loudly.

View more complex examples

Install

# via rolldown
bun add --dev comptime rolldown

# via vite
bun add --dev comptime vite

Vite

import { defineConfig } from "vite";
import { comptime } from "comptime/vite";

export default defineConfig({
  plugins: [comptime()],
});

Rolldown

import { defineConfig } from "rolldown";
import { comptime } from "comptime/rolldown";

export default defineConfig({
  input: "src/app.ts",
  plugins: [comptime()],
});

API

import { comptime } from "comptime";

let value = comptime(() => expensivePureWork());

comptime<T>(fn: () => T | Promise<T>): T is typed as an identity helper. The plugin requires a single zero-argument arrow function or function expression.

Supported behavior:

  • Imported comptime bindings from "comptime", including aliases.
  • Shadowed local bindings are ignored.
  • Referenced value imports are captured into virtual modules with absolute import paths.
  • Referenced top-level declarations from the origin module are copied into the virtual module.
  • Promise-returning bodies are awaited.
  • Values are serialized with devalue.
  • Build errors include the original call-site location.
  • Vite dev uses server.ssrLoadModule; Vite build and Rolldown build use an internal Rolldown evaluator.

Options

type ComptimeOptions = {
  include?: string | string[];
  exclude?: string | string[];
  timeout?: number;
  env?: string[] | "all" | "declared";
  serializers?: Array<{
    test: (value: unknown) => boolean;
    serialize: (value: unknown) => string;
  }>;
};

Defaults:

  • timeout: 10_000
  • env: "all"

When env is a string list, static process.env.KEY reads must be listed. Dynamic env reads are rejected unless env is "all".

Common Errors

These fail during transform:

comptime(1);
// comptime() requires a single arrow function with no parameters
comptime((value) => value);
// comptime() requires a single arrow function with no parameters
comptime(() => () => 1);
// comptime returned a value that cannot be serialized
comptime(() => {
  throw new Error("something happened");
});
// build fails

Limits

This package does not add browser-side evaluation, disk caching, Webpack support, or esbuild standalone support.

License

MIT © Luke Edwards