strip-console weekly downloads statistics
By i-m-anurag · npm · Webpack plugins
Strip console.* calls from JavaScript and TypeScript code
strip-console has 21 recorded weekly downloads on npm, a decrease of 4.5% over the past 30 days, ranking #2981 of 3,247 tracked listings.
About strip-console
strip-console
Strip console.* calls and debugger statements from JavaScript and TypeScript code, without
breaking the code around them.
// before
console.log('user', user);
console.log(i++);
const done = () => console.log('done');
console.warn('slow');
// after
i++;
const done = () => void 0;
console.warn('slow');
- Works as a plugin for Vite, Rollup, Rolldown, webpack, Rspack and esbuild.
- Ships a CLI that rewrites a build folder in place, or audits it in CI.
- Keeps arguments with side effects, keeps
console.warnandconsole.errorby default, and produces source maps.
Contents
- Install
- Bundler plugin
- CLI
- Audit in CI
- Next.js
- Angular
- What gets removed
- Options
- JavaScript API
- Compared with other tools
- Versioning
- Development
Install
npm install --save-dev strip-console
Requires Node.js 22.12 or newer.
Bundler plugin
Every entry exports one function that takes the options below.
Vite
// vite.config.js
import { defineConfig } from 'vite';
import stripConsole from 'strip-console/vite';
export default defineConfig({
plugins: [stripConsole()],
});
The Vite plugin only runs during vite build, so console.log still works in the dev server.
Rollup
// rollup.config.js
import stripConsole from 'strip-console/rollup';
export default {
input: 'src/index.js',
output: { dir: 'dist' },
plugins: [stripConsole()],
};
Rolldown
// rolldown.config.js
import stripConsole from 'strip-console/rolldown';
export default {
input: 'src/index.js',
plugins: [stripConsole()],
};
webpack
// webpack.config.js
const stripConsole = require('strip-console/webpack');
module.exports = (env, argv) => ({
entry: './src/index.js',
plugins: argv.mode === 'production' ? [stripConsole()] : [],
});
Rspack
// rspack.config.js
const stripConsole = require('strip-console/rspack');
module.exports = (env, argv) => ({
entry: './src/index.js',
plugins: argv.mode === 'production' ? [stripConsole()] : [],
});
The webpack and Rspack plugins run in every mode, so add them only to production builds as shown.
esbuild
// build.mjs
import { build } from 'esbuild';
import stripConsole from 'strip-console/esbuild';
await build({
entryPoints: ['src/index.js'],
bundle: true,
outdir: 'dist',
plugins: [stripConsole()],
});
Plugin-only options
| Option | Default | Meaning |
|---|---|---|
include | JS, TS, JSX, TSX, .vue, .svelte, .astro | Modules to process |
exclude | node_modules | Modules to skip |
chunks | false | Also process the final output chunks (Vite, Rollup and Rolldown only) |
runtimeGuard | false | Add a runtime stub that silences the removed methods (see below) |
By default the plugin skips node_modules. Set chunks: true to also clean the bundled output,
which catches console calls in dependencies and in compiled framework files. Files that fail to
parse are skipped with a warning instead of failing the build.
Runtime guard
Static removal cannot see calls whose method name is only known at runtime, such as
console[level](message). With runtimeGuard: true, the plugin adds a small script to the top of
each entry chunk that replaces the listed methods with empty functions:
stripConsole({ runtimeGuard: true });
The guard silences every call to those methods, including ones kept with a /* keep */ comment,
and leaves console.warn and console.error alone unless you list them. It works with every
bundler above. For other setups, createRuntimeGuard(methods) from strip-console returns the
script as a string, ready to inline at the top of your entry file.
CLI
The CLI works on files that are already built, so it fits any toolchain, including ones without a plugin hook.
npx strip-console dist/ # rewrite .js/.mjs/.cjs files in place
npx strip-console dist/ --dry-run # show what would change without writing
npx strip-console audit dist/ # list remaining calls; exits 1 if any are found
npx strip-console audit dist/ --json
With no folder given, both commands use dist. When a file has a .map next to it, the rewrite
updates the map so it still points at your original sources.
| Flag | Meaning |
|---|---|
--methods <list> | Console methods to remove, such as log,debug |
--loggers <list> | Extra callees to remove, such as logger.debug |
--keep-comment <text> | Comment text that keeps the next call |
--no-debugger | Keep debugger statements |
--include <glob> | Files to process (default **/*.{js,mjs,cjs}) |
--exclude <glob> | Files to skip (default **/node_modules/**) |
--config <file> | Read settings from this file |
--json | Print a machine-readable report |
--dry-run | Rewrite command only: report without writing |
Config file
Settings can live in strip-console.config.json, strip-console.config.mjs,
strip-console.config.js, or a "stripConsole" key in package.json. Flags override the file.
{
"dirs": ["dist", "build/public"],
"methods": ["log", "debug", "info", "trace"],
"loggers": ["logger.debug"],
"exclude": ["**/vendor/**"]
}
Audit in CI
strip-console audit exits with code 1 when any console call is left, so it can guard a build
even if you never rewrite files.
# .github/workflows/ci.yml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- run: npm run build
- run: npx strip-console audit dist/
A failing run prints one line per call, so the log shows exactly where to look:…
Description from the npm listing.
- build
- console
- console.log
- esbuild-plugin
- remove
- rollup-plugin
- strip
- unplugin
- vite-plugin
- webpack-plugin
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (170)Similar npm Webpack plugins plugins
All 20 strip-console alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/strip-console. First seen Oct 16, 2026; last successful collection Nov 8, 2026. See the methodology.