{"id":20645,"library":"unplugin-remove","title":"unplugin-remove","description":"A build tool plugin that automatically removes `console.*` calls (log, warn, error, info, debug) and `debugger` statements in production mode. Version 1.0.3 is the current stable release. It supports Vite, Webpack, Rollup, esbuild, Rspack (experimental), and Rolldown (experimental) with a unified API via the unplugin framework. Key differentiators: zero-config defaults, configurable console types, include/exclude patterns, and source map support. Built on babel for AST transformation. Releases are infrequent, focused on bug fixes and new bundler support.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/Talljack/unplugin-remove","tags":["javascript","unplugin","vite","webpack","rollup","esbuild","rspack","rolldown","transform","typescript"],"install":[{"cmd":"npm install unplugin-remove","lang":"bash","label":"npm"},{"cmd":"yarn add unplugin-remove","lang":"bash","label":"yarn"},{"cmd":"pnpm add unplugin-remove","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for filtering transforms based on include/exclude patterns","package":"@rollup/pluginutils","optional":false},{"reason":"Used for source map generation when removing code","package":"magic-string","optional":false},{"reason":"Core unplugin framework providing the unified plugin interface across bundlers","package":"unplugin","optional":false}],"imports":[{"note":"Import from the specific bundler subpath, not the main package. Default export for each bundler.","wrong":"import { viteRemove } from 'unplugin-remove'","symbol":"viteRemove","correct":"import viteRemove from 'unplugin-remove/vite'"},{"note":"Webpack expects a function that returns a plugin instance. Use require or dynamic import.","wrong":"const Remove = require('unplugin-remove')","symbol":"webpack plugin","correct":"const webpackRemove = require('unplugin-remove/webpack')"},{"note":"Named exports are not available; always use default export from the subpath.","wrong":"import { rollupRemove } from 'unplugin-remove'","symbol":"Rollup plugin","correct":"import rollupRemove from 'unplugin-remove/rollup'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite'\nimport viteRemove from 'unplugin-remove/vite'\n\nexport default defineConfig({\n  plugins: [\n    viteRemove({\n      // remove only console.log and debugger (default)\n      external: [],\n      consoleType: ['log'],\n      include: [/\\.[jt]sx?$/, /\\.vue\\??/],\n      exclude: [/node_modules/, /\\.git/]\n    })\n  ]\n})","lang":"typescript","description":"Shows how to configure and use unplugin-remove with Vite, removing console.log and debugger in production."},"warnings":[{"fix":"Upgrade to 1.0.0+ and verify your codebase for any removed console statements that were previously kept.","message":"Version 1.0.0 switched from custom AST parsing to babel, altering transform behavior and potentially removing code differently.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Conditionally add the plugin only in production: e.g., `process.env.NODE_ENV === 'production' ? viteRemove() : undefined`.","message":"The plugin does NOT check process.env.NODE_ENV by default; it runs on all builds unless you guard its inclusion.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Test thoroughly or avoid using these bundler integrations in production.","message":"Rspack and Rolldown support are marked as experimental and may have bugs or incomplete features.","severity":"gotcha","affected_versions":">=0.1.1"},{"fix":"Use `.default` when using CommonJS require for the rspack plugin.","message":"The rspack example uses `require('unplugin-remove/rspack').default` — omitting `.default` will result in a constructor error.","severity":"gotcha","affected_versions":">=0.1.1"},{"fix":"Set `consoleType: ['log', 'warn', 'error', 'info', 'debug']` to remove all console calls.","message":"By default, only `console.log` is removed. Other console methods (warn, error, info, debug) are NOT removed unless explicitly added to `consoleType`.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use `include`/`exclude` patterns instead to filter files.","message":"The `external` option (an array of module names) is still supported but may be removed in a future major version.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use `require('unplugin-remove/rspack').default` or `import RspackPlugin from 'unplugin-remove/rspack'` in ESM.","cause":"Using `new RspackPlugin()` without `.default` in CommonJS require.","error":"TypeError: RspackPlugin is not a constructor"},{"fix":"Import from the specific bundler subpath: `import viteRemove from 'unplugin-remove/vite'`.","cause":"Importing from 'unplugin-remove' directly instead of 'unplugin-remove/vite', etc.","error":"Error: [unplugin-remove] No bundler specified. Did you forget to use a subpath import?"},{"fix":"Review code to ensure removal does not change behavior; wrap console calls in blocks if needed.","cause":"The plugin may remove console.log from inside conditional expressions like `a && console.log('test')` where removal could alter logic.","error":"WARNING: Removing 'console.log' but it might be used in a logical expression."},{"fix":"Upgrade to v1.0.3 or later which uses magic-string for proper source map generation.","cause":"Older versions (<1.0.3) did not use magic-string for source maps, causing incorrect mappings.","error":"Source map mismatch warnings from bundler"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}