Registry / devops / vite-plugin-stripper

vite-plugin-stripper

JSON →
library0.10.1jsnpmunverified

A Vite plugin that strips out specified functions from your browser bundle, removing debug or development-only code in production. Current stable version is 0.10.1, released as part of the KitQL monorepo. It uses oxc (since v0.10.0) for fast parsing instead of babel/recast. Works with Vite 5, 6, 7, or 8. Key differentiator: lightweight, tree-shakable, and focused on stripping function calls, not entire files. Requires Node ^16.14 || >=18.

npm install vite-plugin-stripper
INSTALL
IMPORT
SIG · VITE-PLUGIN-STRIPP
V
vite-plugin-stripper
devopsjavascriptv0.10.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

vitePluginStripper
import vitePluginStripper from 'vite-plugin-stripper'
const vitePluginStripper = require('vite-plugin-stripper')
ESM-only; CJS require will fail.
StripperOptions
import type { StripperOptions } from 'vite-plugin-stripper'
Type import; available since 0.10.0.
default (plugin function)
import vitePluginStripper from 'vite-plugin-stripper' export default { plugins: [vitePluginStripper()] }
import { vitePluginStripper } from 'vite-plugin-stripper'
The default export is the plugin function; named export does not exist.

Configures vite-plugin-stripper to remove console.log, debug, and myCustomDebug from source files in production build.

// vite.config.ts import { defineConfig } from 'vite' import vitePluginStripper from 'vite-plugin-stripper' export default defineConfig({ plugins: [ vitePluginStripper({ strip: ['console.log', 'debug', 'myCustomDebug'], include: ['src/**/*.ts'], exclude: ['node_modules/**'], sourcemap: true }) ] })
Debug
Known issues
breakingSince v0.10.0, the option `log_on_throw_is_not_a_new_class` has been removed.
fix
Remove usage of `log_on_throw_is_not_a_new_class`. If needed, open a GitHub issue to request re-implementation.
affects: >=0.10.0
breakingParsing engine changed from babel/recast to oxc in v0.10.0, which may produce different AST results and potentially different stripping behavior.
fix
Test your build after upgrading; verify that targeted functions are still stripped correctly.
affects: >=0.10.0
gotchaThe plugin is only active in production builds by default. It does not strip functions in dev mode.
fix
To test in dev, set `apply: 'build'` or use `apply: (config, { command }) => command === 'build'` in plugin options.
affects: *
gotchaIf using Vite 5, ensure vite-plugin-stripper version is at least 0.10.0 (which supports Vite 5). Older versions may not work.
fix
Upgrade to vite-plugin-stripper@^0.10.0.
affects: <0.10.0
deprecatedNode 16 support is deprecated as of v0.10.0? The engine field allows ^16.14, but Node 16 is end-of-life.
fix
Use Node 18 or later for security and performance.
affects: >=0.10.0
Errors
Common errors & fixes
require() of ES Module /path/to/node_modules/vite-plugin-stripper/dist/index.mjs not supported
Using CommonJS require() to import an ESM-only package.
fix
Change to import statement or use dynamic import().
ERR_MODULE_NOT_FOUND: Cannot find package 'vite'
Missing peer dependency 'vite'.
fix
Install vite: npm install -D vite
TypeError: vitePluginStripper is not a function
Using named import instead of default import.
fix
Use import vitePluginStripper from 'vite-plugin-stripper' (no curly braces).
Upgrade
Version history
0.10.1latest on npm
Audit
Dependencies
viterequiredpeer dependency: plugin runs as a Vite plugin
Agent activity
8 hits · last 30 days
node
8
Resources
vite-plugin-stripper — npm install vite-plugin-stripper · libregistry