Removes usages of the npm debug module
Last updated a year ago by gpittarelli .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-plugin-remove-debug 
SYNC missed versions from official npm registry.


Removes usage of the popular debug library from code.

The following:

import foo from './foo';
import Debug from 'debug';
const debug = Debug('bar');

function bar(x) {
   debug('Doing something');
   foo(1, x);

will be transformed into:

import foo from './foo';

function bar(x) {
   foo(1, x);

This is useful to help save on bundle size and be sure that log messages aren't being shown to clients. It also makes it safe to leave in potentially-expensive logging messages for development and be confident they won't impact production runtimes at all.


  • Will only work if debug is imported with ES6 import syntax. require('debug') is not supported.
  • Doesn't do any particularly advanced flow analysis -- if you do weird things like aliasing the value you import from debug, the best we can do is replace the import with a dummy assignment instead of totally removing it. (eg import Debug from 'debug'; const x = Debug; x('hi')('yo'); will be safely neutered but won't be reduced to nothing even though it theoretically could. Notably, all the arguments in the x('hi')('yo') line will still be evaluated.)


A typical setup

    "plugins": ["babel-plugin-remove-debug"]

By default this will apply to all import of 'debug'. If you are using a compatible but differently named package, or otherwise have the import name aliased, you can specify that using the libraries option. It accepts an array of regular expressions (as strings). For example:

    "plugins": [
        ["babel-plugin-remove-debug", {
           "libraries": [

Current Tags

  • 0.0.4                                ...           latest (a year ago)

4 Versions

  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2017 © |