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

unplugin-drop-committed

v0.1.0

Published

An unplugin that automatically removes committed code (like console.log) from your codebase based on Git history.

Readme

unplugin-drop-committed

npm version License

🔌 An unplugin that automatically removes committed code (like console.log) from your codebase based on Git history.

Features

Multiple Removal Modes: Choose how to identify code to remove

  • 🎯 Strict Mode: Remove code on committed lines
  • 📁 File Mode: Remove code from committed files
  • 👤 User Mode: Remove code from other authors
  • Time Mode: Remove code older than a specified time

🚀 Framework Agnostic: Works with Vite, Webpack, Rollup, Rspack, and more

🎨 File Type Support: JavaScript, TypeScript, JSX, Vue, and Svelte

Performance Optimized: Git operation caching and incremental processing

🛡️ Dev Only: Automatically disabled in production builds

Installation

npm install unplugin-drop-committed --save-dev

Usage

Vite

// vite.config.ts
import DropCommitted from 'unplugin-drop-committed/vite'

export default defineConfig({
  plugins: [
    DropCommitted({
      mode: 'strict',
      removeMethods: ['console.log'],
    }),
  ],
})

Webpack

// webpack.config.js
module.exports = {
  plugins: [
    require('unplugin-drop-committed/webpack')({
      mode: 'strict',
      removeMethods: ['console.log'],
    }),
  ],
}

Rollup

// rollup.config.js
import DropCommitted from 'unplugin-drop-committed/rollup'

export default {
  plugins: [
    DropCommitted({
      mode: 'strict',
      removeMethods: ['console.log'],
    }),
  ],
}

Configuration

interface Options {
  /**
   * Removal mode
   * @default 'strict'
   */
  mode?: 'strict' | 'file' | 'user' | 'time'

  /**
   * Method names to remove (supports dot notation)
   * @default ['console.log']
   */
  removeMethods?: string[]

  /**
   * File inclusion patterns
   * @default [/\.[jt]sx?$/, /\.vue$/, /\.vue\?vue/, /\.svelte$/]
   */
  include?: (string | RegExp)[]

  /**
   * File exclusion patterns
   * @default []
   */
  exclude?: (string | RegExp)[]

  /**
   * Expiration time for 'time' mode
   * Supports: ISO dates, relative time (e.g., '30d', '1y', '6M')
   */
  expiration?: string
}

Removal Modes

Strict Mode (Default)

Removes method calls on lines that have been committed to Git.

DropCommitted({
  mode: 'strict',
  removeMethods: ['console.log'],
})

Example:

// If this line is committed:
console.log('This will be removed') // ✅ Removed

// If this line is uncommitted:
console.log('This will stay') // ❌ Kept

File Mode

Removes all method calls from files that are fully committed (not modified, added, or deleted).

DropCommitted({
  mode: 'file',
})

Use case: Clean up debug logs from stable files while keeping them in files you're actively working on.

User Mode

Removes method calls authored by other developers (based on Git blame).

DropCommitted({
  mode: 'user',
})

Use case: Remove debug logs from other team members while keeping your own.

Time Mode

Removes method calls older than a specified time.

DropCommitted({
  mode: 'time',
  expiration: '30d', // Remove logs older than 30 days
})

Supported formats:

  • ISO dates: '2024-01-01'
  • Relative days: '30d'
  • Relative months: '6M'
  • Relative years: '1y'

Advanced Usage

Custom Method Names

Remove any method calls, including nested ones:

DropCommitted({
  removeMethods: [
    'console.log',
    'console.debug',
    'logger.info',
    'debug.trace',
  ],
})

File Patterns

Customize which files to process:

DropCommitted({
  include: [/\.[jt]sx?$/, /\.vue$/],
  exclude: ['**/*.test.js', '**/*.spec.ts'],
})

Vue and Svelte Support

The plugin automatically extracts and processes <script> blocks:

<template>
  <div>{{ message }}</div>
</template>

<script>
export default {
  mounted() {
    console.log('Component mounted') // Will be removed if committed
  }
}
</script>

How It Works

  1. Environment Check: Only runs in development mode
  2. Git Integration: Uses Git blame and status to determine removal
  3. AST Parsing: Uses Babel to accurately find method calls
  4. Smart Replacement: Replaces calls with ((..._args) => {}) to maintain code structure
  5. Caching: Caches Git operations for better performance

Performance

The plugin implements several optimizations:

  • ✅ Git operation results are cached
  • ✅ Automatic skip in production builds

Requirements

  • Node.js >= 18
  • Git repository
  • Development environment (automatically skipped in production)

Examples

Remove old debug logs

DropCommitted({
  mode: 'time',
  expiration: '90d',
  removeMethods: ['console.log', 'console.debug'],
})

Clean up team logs

DropCommitted({
  mode: 'user',
  removeMethods: ['console.log', 'debugger'],
})

Production-ready files only

DropCommitted({
  mode: 'file',
  removeMethods: ['console.log', 'console.warn'],
})

License

MIT License © 2024 KID-joker

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Related

  • unplugin - Unified plugin system for build tools