{"id":20815,"library":"webpack-remove-debug","title":"webpack-remove-debug","description":"A Webpack loader that removes all calls to the `debug` library and its associated require statements from your production code. v0.1.0, last release in 2021, no active maintenance. It specifically targets `debug(…)` function calls and `require('debug')` patterns, with no configuration parameters. Similar to strip-loader but limited to debug and only works for CommonJS require, not ES module imports. No updates or security patches since release.","status":"abandoned","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/johngodley/webpack-remove-debug","tags":["javascript","webpack","debug","strip","remove"],"install":[{"cmd":"npm install webpack-remove-debug","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-remove-debug","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-remove-debug","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is not a JavaScript import, but a Webpack loader rule. It only works with require-style debug imports, not ES module imports.","wrong":"import webpackRemoveDebug from 'webpack-remove-debug';","symbol":"webpack-remove-debug (loader)","correct":"module.exports = { module: { rules: [{ test: /\\.js$/, loader: 'webpack-remove-debug' }] } };"},{"note":"The loader only strips CommonJS require patterns for debug. ES import syntax is not recognized and will not be removed.","wrong":"import debug from 'debug';","symbol":"debug","correct":"const debug = require('debug')('myapp');"},{"note":"Only simple function call syntax with parentheses is removed. Optional chaining or template literals may not be stripped.","wrong":"debug?.('message');","symbol":"debug()","correct":"debug('some message', data);"}],"quickstart":{"code":"// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        loader: 'webpack-remove-debug'\n      }\n    ]\n  }\n};\n\n// In your source code (will be stripped):\nconst debug = require('debug')('myapp');\ndebug('This will be removed in production');\n\n// In your source code (will NOT be stripped):\nimport debug from 'debug';\ndebug('This will remain, not removed');","lang":"javascript","description":"Shows Webpack configuration and the difference between require and import: only require-style debug usage is stripped."},"warnings":[{"fix":"Use `const debug = require('debug')('...')` instead of import, or use an alternative loader that supports ES modules.","message":"Does not strip ES module imports (`import debug from 'debug'`). Only CommonJS `require` is supported.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure debug calls are in the form `debug('message', ...);` for removal.","message":"Only removes simple `debug(...)` calls. Complex expressions like `debug && debug('msg')` or chained calls are not stripped.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use a more thorough stripping tool like strip-loader or babel-plugin-transform-remove-console for production.","message":"If you have other code using debug variable (e.g., pass it around), the loader may break scope inadvertently.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev webpack-remove-debug`.","cause":"Loader not installed or missing from node_modules.","error":"Error: Module not found: Error: Can't resolve 'webpack-remove-debug'"},{"fix":"Ensure the rule is added before other loaders (e.g., babel-loader). Example: `{ test: /\\.js$/, use: [{ loader: 'webpack-remove-debug' }, { loader: 'babel-loader' }] }`","cause":"Webpack expects a loader rule, but the loader might be misconfigured or order is wrong.","error":"Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type."},{"fix":"Change `import debug from 'debug'` to `const debug = require('debug')('...')`. Or omit loader and handle differently.","cause":"The require statement was stripped but debug calls remain (maybe due to import syntax).","error":"debug is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}