# babel-plugin-undebug

> Babel plugin to remove `debug` from code

Latest version **3.0.0** (published 2024-09-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-undebug
pnpm add babel-plugin-undebug
yarn add babel-plugin-undebug
bun add babel-plugin-undebug
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2024-09-02 |
| First published | 2020-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Titus Wormer |
| Maintainers | wooorm |
| Keywords | babel, plugin, debug, undebug |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-undebug
- Repository: https://github.com/wooorm/babel-plugin-undebug
- Homepage: https://github.com/wooorm/babel-plugin-undebug#readme
- Issues: https://github.com/wooorm/babel-plugin-undebug/issues
- Funding: https://github.com/sponsors/wooorm
- npm.io page: https://npm.io/package/babel-plugin-undebug

## Dependencies (1)

- [@types/babel__core](https://npm.io/package/@types/babel__core.md) ^7.0.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2024-09-02
- 2.0.1 — 2021-11-07
- 2.0.0 — 2021-03-13
- 1.0.1 — 2020-12-06
- 1.0.0 — 2020-12-04

## README

# babel-plugin-undebug

[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]

Babel plugin to remove `debug` from code.

## Contents

* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
  * [`babelPluginUndebug`](#babelpluginundebug)
* [Syntax tree](#syntax-tree)
* [Types](#types)
* [Compatibility](#compatibility)
* [Security](#security)
* [Related](#related)
* [Contribute](#contribute)
* [License](#license)

## What is this?

This package is a [Babel][] plugin to remove [`debug`][debug] from code.

## When should I use this?

This package is useful when `debug` is used to debug development code but can be
stripped in production.
An example is `micromark`, which is a complex state machine that can be plugged
into with extensions but it’s also supposed to be small in browsers.

## Install

This package is [ESM only][esm].
In Node.js (version 18+), install with [npm][]:

```sh
npm install babel-plugin-undebug
```

In Deno with [`esm.sh`][esmsh]:

```js
import babelPluginUndebug from 'https://esm.sh/babel-plugin-undebug@2'
```

In browsers with [`esm.sh`][esmsh]:

```html
<script type="module">
  import babelPluginUndebug from 'https://esm.sh/babel-plugin-undebug@2?bundle'
</script>
```

## Use

`example.js`:

```js
const debug = require('debug')('math')

let value = 1
debug('Value was %d', value)
value++
debug('Now we have %d', value)
```

Then (with `@babel/cli` and `@babel/core` installed):

```sh
babel example.js --plugins babel-plugin-undebug
```

Yields:

```js
let value = 1;
value++;
```

## API

This package exports no identifiers.
The default export is `babelPluginUndebug`.

### `babelPluginUndebug`

Plugin to remove `debug` from code.
See [Babel’s documentation][babel-plugins] on how to use Babel plugins.

## Syntax tree

This package operates on the Babel (JavaScript) AST.

* looks for ESM (`import`) and CJS (`require`) loading `'debug'`
* looks for code calling that function and assigning it, whether `createDebug`
  (`const createDebug = require('debug'), d = createDebug('math')`)
  or direct use
  (`const d = require('debug')('math')`)
* looks for calls of those assigned identifiers and remove whole debug calls,
  so side effects (`d(value++)`) will be dropped

## Types

This package is fully typed with [TypeScript][].
It exports no additional types.

## Compatibility

This package is at least compatible with all maintained versions of Node.js.
As of now, that is Node.js 18+.
It also works in Deno and modern browsers.

## Security

This package is safe.

## Related

* [`babel-plugin-unassert`](https://github.com/unassert-js/babel-plugin-unassert)
  — remove `assert`

## Contribute

Yes please!
See [How to Contribute to Open Source][contribute].

## License

[MIT][license] © [Titus Wormer][author]

<!-- Definitions -->

[build-badge]: https://github.com/wooorm/babel-plugin-undebug/workflows/main/badge.svg

[build]: https://github.com/wooorm/babel-plugin-undebug/actions

[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/babel-plugin-undebug.svg

[coverage]: https://codecov.io/github/wooorm/babel-plugin-undebug

[downloads-badge]: https://img.shields.io/npm/dm/babel-plugin-undebug.svg

[downloads]: https://www.npmjs.com/package/babel-plugin-undebug

[size-badge]: https://img.shields.io/bundlephobia/minzip/babel-plugin-undebug.svg

[size]: https://bundlephobia.com/result?p=babel-plugin-undebug

[npm]: https://docs.npmjs.com/cli/install

[esmsh]: https://esm.sh

[license]: license

[author]: https://wooorm.com

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[typescript]: https://www.typescriptlang.org

[contribute]: https://opensource.guide/how-to-contribute/

[debug]: https://github.com/visionmedia/debug

[babel]: https://babeljs.io

[babel-plugins]: https://babeljs.io/docs/plugins

---
_Source: https://npm.io/package/babel-plugin-undebug · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
