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

rolldown-plugin-strip

v0.1.0

Published

Rolldown plugin to remove debug-only code paths.

Readme

rolldown-plugin-strip

rolldown-plugin-strip removes debug-only code from Rolldown build output.

It currently supports:

  • stripping configured function-call statements (for example console.log(...));
  • stripping standalone debugger statements;
  • stripping configured labeled statements and labeled blocks;
  • safe handling for chained/non-statement call matches via chainedCalls.

Install

npm install rolldown-plugin-strip

Usage (production build)

The plugin is build-only (apply: "build") and runs as a pre transform (enforce: "pre").

import { defineConfig } from "rolldown";
import { strip } from "rolldown-plugin-strip";

export default defineConfig({
  plugins: [
    strip({
      debugger: true,
      functions: ["console.log", "console.debug"],
      labels: ["dev", "debug"],
      chainedCalls: "warn"
    })
  ]
});

Options

type ChainedCallsPolicy = "skip" | "warn" | "error";

interface StripOptions {
  functions?: string[];
  debugger?: boolean;
  labels?: string[];
  chainedCalls?: ChainedCallsPolicy; // default: "skip"
}
  • functions
    • A list of function names to strip when they appear as a full statement on a line.
    • Example removable line: console.log("debug");
  • debugger
    • When true, removes full lines containing only debugger (with optional semicolon).
  • labels
    • A list of labels to remove, including single-line labeled statements and labeled blocks.
    • Examples: dev: doThing();, dev: { doThing(); }, dev: while (cond) { ... }
  • chainedCalls
    • Controls behavior when a configured function matches but cannot be safely removed as a whole statement.
    • "skip" (default): keep the line unchanged.
    • "warn": keep the line and emit a warning to console.warn.
    • "error": throw and fail the build.

Chained-call behavior

Given:

strip({ functions: ["debug"], chainedCalls: "skip" });

Safe removable line (always stripped):

debug("trace");

Chained/non-statement line (not safely removable):

debug("trace").trim();

Outcomes for the chained/non-statement line:

  • chainedCalls: "skip" -> line is left as-is.
  • chainedCalls: "warn" -> line is left as-is and a warning is logged.
  • chainedCalls: "error" -> an error is thrown and the build fails.

Notes

  • When the transform changes the module source, transform returns a non-null source map (VLQ v3) so debuggers and error stacks can map generated output back to the original file. Unchanged modules keep map: null.
  • When functions is enabled, line endings are normalized the same way as the stripper (split(/\r?\n/).join("\n")); if that step runs, the map is composed from the removal map and the newline-normalization map.
  • Call-expression matching is line-based and intentionally conservative to avoid unsafe removals.

Local development and test

npm install
npm run check
npm run build
  • npm run check runs type-check/lint (tsc --noEmit) and tests (vitest run).
  • npm run build emits dist/ using tsconfig.build.json.