Registry / devops / webpack-remove-debug

webpack-remove-debug

JSON →
library0.1.0jsnpmunverified

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.

npm install webpack-remove-debug
INSTALL
IMPORT
SIG · WEBPACK-REMOVE-DEB
W
webpack-remove-debug
devopsjavascriptv0.1.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

webpack-remove-debug (loader)
✓ module.exports = { module: { rules: [{ test: /\.js$/, loader: 'webpack-remove-debug' }] } };
✗ import webpackRemoveDebug from 'webpack-remove-debug';
This is not a JavaScript import, but a Webpack loader rule. It only works with require-style debug imports, not ES module imports.
debug
✓ const debug = require('debug')('myapp');
✗ import debug from 'debug';
The loader only strips CommonJS require patterns for debug. ES import syntax is not recognized and will not be removed.
debug()
✓ debug('some message', data);
✗ debug?.('message');
Only simple function call syntax with parentheses is removed. Optional chaining or template literals may not be stripped.

Shows Webpack configuration and the difference between require and import: only require-style debug usage is stripped.

// webpack.config.js module.exports = { module: { rules: [ { test: /\.js$/, loader: 'webpack-remove-debug' } ] } }; // In your source code (will be stripped): const debug = require('debug')('myapp'); debug('This will be removed in production'); // In your source code (will NOT be stripped): import debug from 'debug'; debug('This will remain, not removed');
Debug
Known issues
gotchaDoes not strip ES module imports (`import debug from 'debug'`). Only CommonJS `require` is supported.
fix
Use `const debug = require('debug')('...')` instead of import, or use an alternative loader that supports ES modules.
affects: >=0.1.0
gotchaOnly removes simple `debug(...)` calls. Complex expressions like `debug && debug('msg')` or chained calls are not stripped.
fix
Ensure debug calls are in the form `debug('message', ...);` for removal.
affects: >=0.1.0
gotchaIf you have other code using debug variable (e.g., pass it around), the loader may break scope inadvertently.
fix
Use a more thorough stripping tool like strip-loader or babel-plugin-transform-remove-console for production.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Module not found: Error: Can't resolve 'webpack-remove-debug'
Loader not installed or missing from node_modules.
fix
Run `npm install --save-dev webpack-remove-debug`.
Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type.
Webpack expects a loader rule, but the loader might be misconfigured or order is wrong.
fix
Ensure the rule is added before other loaders (e.g., babel-loader). Example: `{ test: /\.js$/, use: [{ loader: 'webpack-remove-debug' }, { loader: 'babel-loader' }] }`
debug is not defined
The require statement was stripped but debug calls remain (maybe due to import syntax).
fix
Change `import debug from 'debug'` to `const debug = require('debug')('...')`. Or omit loader and handle differently.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
Resources
webpack-remove-debug — npm install webpack-remove-debug · libregistry