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

@game-infra/build-utils

v0.1.0

Published

Build-time git metadata injection for Vite builds, plus runtime access to it via BuildInfo and a small ServiceConfig holder

Readme

@game-infra/build-utils

Build-time git metadata injection for Vite builds, plus runtime access to it. At build time, @game-infra/build-utils/git-info reads the current revision, branch, commit message, and dirty state and turns them into Vite define constants. At runtime, the BuildInfo class reads those constants back, with safe fallbacks when they were never injected. The package also ships ServiceConfig, a small process-wide holder for the backend API config a game talks to.

Linking

This package is consumed as a sibling source checkout, not from npm (see docs/CONSUMING.md).

// pnpm consumer
{ "dependencies": { "@game-infra/build-utils": "link:../../../game-infra/packages/build-utils" } }

// npm consumer
{ "dependencies": { "@game-infra/build-utils": "file:../../../game-infra/packages/build-utils" } }

Usage

Inject git info in a Vite config (./git-info subpath)

// vite.config.ts
import { defineConfig } from "vite";
import { getGitInfo, getGitDefines, formatGitVersion } from "@game-infra/build-utils/git-info";

const gitInfo = getGitInfo();
console.log(`Building ${formatGitVersion(gitInfo)}`);

export default defineConfig({
  define: getGitDefines(gitInfo, "production"),
});

getGitDefines produces the full __GIT_*__ / __BUILD_*__ constant map. If git is unavailable, getGitInfo returns fallback values instead of failing the build.

Read build info at runtime

import { BuildInfo } from "@game-infra/build-utils";

BuildInfo.getVersion(); // "2bdf112 (main)"
BuildInfo.getDetailedVersion(); // "2bdf112 (main) - Built: 2025-01-15T10:30:00Z [production]"
BuildInfo.getRevision(); // "2bdf112" or "2bdf112-dirty"
BuildInfo.isDirty(); // true when built from an unclean working tree
BuildInfo.logInfo(); // dump everything to the console

Any accessor returns "unknown" (or the current time / false) when the constants were not injected, so the same code runs in dev servers and tests.

Configure backend services at startup

import { BuildInfo, ServiceConfig } from "@game-infra/build-utils";

ServiceConfig.initialize(
  ServiceConfig.createAutoConfig("my-game", BuildInfo.getVersion(), "https://api.example.com"),
);

// anywhere later:
const { apiBaseUrl, gameId, gameVersion } = ServiceConfig.get();

createAutoConfig picks a http://localhost:8787 dev config when the page is served from localhost (matching wrangler dev's default port) and the production config otherwise.

Exports

  • . (TypeScript source): BuildInfo, ServiceConfig, GameServiceConfig
  • ./git-info (plain .mjs, importable from Vite configs before any TS tooling runs): getGitInfo, formatGitVersion, getGitDefines, GitInfo (type)

Internal deps

None. Runtime deps: none (node builtins only at build time).

Consumers

Game repos that display a build version in the UI or report it to backend services, and their Vite configs.