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

@entwico/bonsai

v3.0.2

Published

Ship the smallest correct production node_modules: full runtime-closure tracing + rolldown rebundle

Readme

@entwico/bonsai

CLI for shrinking Node.js Docker images. Computes the true runtime closure of your entrypoint(s) — including what static analysis misses (__require, literal import.meta.resolve(), native bindings, worker threads, loader patchers) — rebundles with rolldown, and deletes the rest of node_modules/.

Designed to be run via npx inside e. g. a Dockerfile — not a project dependency.

Commands

install

Full Docker-build cycle: install (with hoisted linker for pnpm) → rebundle → prune.

npx @entwico/bonsai install ./dist/server/entry.mjs

prune

Rebundle + trace + delete pass on an existing node_modules/. For pnpm projects, the install that produced node_modules/ must have used --node-linker=hoisted — symlinked layouts cannot be pruned reliably.

npx @entwico/bonsai prune ./dist/server/entry.mjs

Arguments

Entrypoints are positional — pass one or more, space-separated (e.g. server + worker preload):

npx @entwico/bonsai prune ./dist/server/entry.mjs ./src/instrument.mjs

Flags

| Flag | Description | | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | -p <glob>, --preserve <glob> | Extra files to keep regardless of trace output (fontsource woffs, locale JSONs, anything referenced via non-literal import.meta.resolve(expr) or require(varName) — literal calls are traced automatically). Repeatable. Patterns matching nothing throw. | | --no-rewrite | Disable the rolldown rebundle and only trace + delete. Default: on. | | --no-minify | Disable minification of the rewritten bundle. Default: on. | | --no-sourcemap | Skip emitting .mjs.map files. Default: on. With sourcemaps, run with node --enable-source-maps for symbolicated stack traces. | | -v, --verbose | Verbose logs |

Dockerfile examples

Build in CI, prune in Docker

FROM node:24-alpine

RUN corepack enable pnpm
WORKDIR /srv
RUN addgroup -S app && adduser -S app -G app && apk add --no-cache tini

COPY package.json pnpm-lock.yaml /srv/
COPY dist/ /srv/dist/

RUN npx @entwico/bonsai install ./dist/server/entry.mjs

USER app
ENTRYPOINT ["tini", "--", "node", "--enable-source-maps", "./dist/server/entry.mjs"]

Install, build, and prune inside Docker

FROM node:24-alpine AS builder

RUN corepack enable pnpm
WORKDIR /srv

COPY package.json pnpm-lock.yaml /srv/
RUN pnpm install --frozen-lockfile --node-linker=hoisted

COPY . /srv/
RUN pnpm run build

RUN npx @entwico/bonsai prune ./dist/server/entry.mjs

# --- final image ---
FROM node:24-alpine
WORKDIR /srv
RUN addgroup -S app && adduser -S app -G app && apk add --no-cache tini

COPY --from=builder --chown=app:app /srv/node_modules /srv/node_modules/
COPY --from=builder --chown=app:app /srv/dist /srv/dist/

USER app
ENTRYPOINT ["tini", "--", "node", "--enable-source-maps", "./dist/server/entry.mjs"]

For npm projects, swap the lockfile and drop the corepack line.

With --preserve for assets

npx @entwico/bonsai install \
  ./dist/server/main.mjs \
  -p './node_modules/@fontsource/poppins/**' \
  -p './node_modules/some-i18n-pack/locales/*.json'

With --no-rewrite to trace only

Skip the rolldown rebundle and just trace + delete — larger images, but the entry files are left byte-for-byte as your build emitted them.

npx @entwico/bonsai prune --no-rewrite ./dist/server/entry.mjs

License

MIT