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

stub-workspace

v0.1.0

Published

Generate minimal package.json stubs for monorepo workspaces — for Docker layer caching

Readme

stub-workspace

Generate minimal package.json stubs for every workspace in a monorepo lockfile, so Docker can cache the dependency-install layer.

Why

The standard Docker pattern for a Bun or Node monorepo is to copy the lockfile and every package.json first, run install, and only then copy the application source. That way the install layer is cached and only invalidates when dependencies actually change:

COPY package.json bun.lock ./
COPY packages/foo/package.json packages/foo/package.json
COPY packages/bar/package.json packages/bar/package.json
# ...one line for every workspace
RUN bun install --frozen-lockfile

Adding or renaming a workspace means editing every Dockerfile by hand. Forget one and the build breaks — silently if the missing workspace happens to be a transitive consumer.

stub-workspace reads the lockfile, infers every workspace path, and writes minimal package.json stubs that contain just enough metadata (name, version, dependency declarations) for the package manager to resolve the graph identically:

COPY package.json bun.lock ./
RUN bunx -y stub-workspace
RUN bun install --frozen-lockfile

The stub list is derived from the lockfile, so the Dockerfile never lies about which workspaces exist.

Usage

Zero install, via npx or bunx:

npx -y stub-workspace
bunx -y stub-workspace

The CLI auto-detects the lockfile in the current directory.

Dockerfile examples

Runnable examples (with real lockfiles) live under examples/bun and examples/npm.

Bun monorepo

FROM oven/bun:1 AS deps
WORKDIR /app

# Layer 1 — only invalidates when the lockfile or root package.json changes.
COPY package.json bun.lock ./
RUN bunx -y stub-workspace
RUN bun install --frozen-lockfile

FROM oven/bun:1 AS app
WORKDIR /app

# Reuse the cached install layer; the real package.json files overwrite the
# stubs when source is copied in.
COPY --from=deps /app/node_modules ./node_modules
COPY . .

CMD ["bun", "packages/api/index.js"]

npm workspaces monorepo

FROM node:22-alpine AS deps
WORKDIR /app

COPY package.json package-lock.json ./
RUN npx -y stub-workspace
RUN npm ci

FROM node:22-alpine AS app
WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

CMD ["node", "packages/api/index.js"]

CLI options

stub-workspace [options]

  --cwd <path>       Working directory (default: process.cwd())
  --lockfile <path>  Explicit lockfile path (auto-detected if omitted)
  --dry-run          Print paths without writing files
  --silent           Suppress output
  -h, --help         Show this help

Auto-detection order: package-lock.jsonbun.lock.

Supported lockfiles

  • package-lock.json (npm v7+)
  • bun.lock (Bun's JSONC text lockfile)

yarn.lock and pnpm-lock.yaml aren't supported.

Stub format

Each stub mirrors what the lockfile recorded for that workspace:

{
  "name": "@example/api",
  "version": "1.0.0",
  "dependencies": {
    "@example/db": "workspace:*",
    "lodash": "^4.17.21"
  },
  "devDependencies": {
    "vitest": "^1.0.0"
  }
}

Preserved fields: name, version, dependencies, devDependencies, peerDependencies, optionalDependencies, peerDependenciesMeta. Workspace specifiers like workspace:* are passed through verbatim so cross-workspace links resolve against the sibling stubs.

License

MIT