# remove-module

> Remove code to which related specific module using AST.

Latest version **0.1.0** (published 2016-03-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install remove-module
pnpm add remove-module
yarn add remove-module
bun add remove-module
```

Provides the commands `rmmodule`, `remove-module`.

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-03-18 |
| First published | 2016-03-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | keik |
| Maintainers | keik |
| Keywords | ast, console, debug, log, logger, transform |

## Links

- npm: https://www.npmjs.com/package/remove-module
- Repository: https://github.com/keik/remove-module
- Homepage: https://github.com/keik/remove-module#readme
- Issues: https://github.com/keik/remove-module/issues
- npm.io page: https://npm.io/package/remove-module

## Dependencies (7)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [esprima](https://npm.io/package/esprima.md) ^2.7.2
- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [escodegen](https://npm.io/package/escodegen.md) ^1.8.0
- [estraverse](https://npm.io/package/estraverse.md) ^4.2.0
- [merge-source-map](https://npm.io/package/merge-source-map.md) ^1.0.1
- [convert-source-map](https://npm.io/package/convert-source-map.md) ^1.2.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [@luma.gl/experimental](https://npm.io/package/@luma.gl/experimental.md) — 77.1K weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2016-03-18

## README

# remove-module

[![travis-ci](https://img.shields.io/travis/keik/remove-module.svg?style=flat-square)](https://travis-ci.org/keik/remove-module)
[![npm-version](https://img.shields.io/npm/v/remove-module.svg?style=flat-square)](https://npmjs.org/package/remove-module)

Remove code to which related specific module using AST.


# Install

```
npm install remove-module
```


# CLI

```
Usage: rmmodule [modules] <file> [options]

Options:

     --module, -m  A module name you want to remove.

       --file, -f  A file you want to transform.

    --outfile, -o  Write the debug striped code to this file.
                   If unspecified, rmmodule prints to stdout.

      --debug, -d  Enable source maps that allow you to debug your files
                   separately.

       --help, -h  Show this message.
```

For example, if you want to remove `debug` from your code,

```
rmmodule debug src.js
```

will remove code to which related `debug` module from src.js and print results to stdout, or

```
rmmodule debug src.js -o dist.js
```

will output to the file with `-o` option.

You can pass `-d` option to enable source map.

Stdin is also available:

```
% echo 'var debug = require("debug"), fs = require("fs")' | rmmodule debug
var fs = require('fs');
```


# API

```javascript
var remove = require('remove-module')
```


## `remove(modules, code[, opts])`

Remove [visionmedia/debug](https://github.com/visionmedia/debug) related code from `code` using AST.

<dl>
  <dt>
    <code>modules</code> : <code>array.&lt;string&gt;</code>
  </dt>
  <dd>
    array of module names we want to remove
  </dd>

  <dt>
    <code>code</code> : <code>string</code>
  </dt>
  <dd>
    target code
  </dd>

  <dt>
    <code>opts.filepath</code> : <code>string</code>
  </dt>
  <dd>
    filepath to attach source map
  </dd>

  <dt>
    <code>opts.debug</code> : <code>boolean</code>
  </dt>
  <dd>
    attach source map or not
  </dd>
</dl>


# Example
```js
var remove = require('remove-module')

var code = [
  'var debug = require("debug"),',
  '    d     = debug("MYAPP")   ',
  '                             ',
  'function greet() {           ',
  '  d("#greet called")         ',
  '  return "hi"                ',
  '}                            '
].join('\n')

process.stdout.write(remove('debug', code, {filepath: 'a.js', debug: true}))
```

will output:

```js
function greet() {
    return 'hi';
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImEuanMiXSwibmFtZXMiOlsiZ3JlZXQiXSwibWFwcGluZ3MiOiJBQUdBLFNBQVNBLEtBQVQsR0FBaUI7QUFBQSxJQUVmLE9BQU8sSUFBUCxDQUZlO0FBQUEiLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZGVidWcgPSByZXF1aXJlKFwiZGVidWdcIiksXG4gICAgZCAgICAgPSBkZWJ1ZyhcIk1ZQVBQXCIpICAgXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxuZnVuY3Rpb24gZ3JlZXQoKSB7ICAgICAgICAgICBcbiAgZChcIiNncmVldCBjYWxsZWRcIikgICAgICAgICBcbiAgcmV0dXJuIFwiaGlcIiAgICAgICAgICAgICAgICBcbn0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIl19
```


# Test

```
% npm install
% npm test
```


# License

MIT (c) keik

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