# babel-plugin-stub-import

> Test importing variable specifier and filepath, then replace to stub.

Latest version **0.0.0** (published 2020-05-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-stub-import
pnpm add babel-plugin-stub-import
yarn add babel-plugin-stub-import
bun add babel-plugin-stub-import
```

## 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.0.0 |
| Published | 2020-05-04 |
| First published | 2020-05-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | keik |
| Maintainers | keik |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-stub-import
- Repository: https://github.com/keik/babel-plugin-stub-import
- Homepage: https://github.com/keik/babel-plugin-stub-import#readme
- Issues: https://github.com/keik/babel-plugin-stub-import/issues
- npm.io page: https://npm.io/package/babel-plugin-stub-import

## Recent versions

- 0.0.0 (latest) — 2020-05-04

## README

# babel-plugin-stub-import

[![npm-version](https://img.shields.io/npm/v/babel-plugin-stub-import.svg?style=flat-square)](https://npmjs.org/package/babel-plugin-stub-import)
[![downloads](http://img.shields.io/npm/dm/babel-plugin-stub-import.svg?style=flat-square)](https://npmjs.org/package/babel-plugin-stub-import)
[![circleci](https://img.shields.io/circleci/build/github/keik/babel-plugin-stub-import?style=flat-square)](https://app.circleci.com/pipelines/github/keik/babel-plugin-stub-import)
[![codecov](https://codecov.io/gh/keik/babel-plugin-stub-import/branch/master/graph/badge.svg)](https://codecov.io/gh/keik/babel-plugin-stub-import)

Test importing variable specifier and filepath, then replace to stub.

## Limitation

Stub is imported from *default export*, named exports is unavailable.

## Usage

babel.config.js

```js
module.exports = {
  "plugins": [
    [
      "babel-plugin-stub-import",
      {
        "test": {
          "importName": "^foo$",
        },
        "stubTo": "<rootDir>/Stub"
      }
    ]
  ]
}
```

Input

```js
import bar, { foo, baz, foo as qux } from './bar;

foo();
```

Output

```js
import bar, { baz, foo as qux } from './bar'; // unmatched specifiers are imported fron original
import foo from './Stub';                     // matched specifier is imported from stub

foo();                                        // import is stubbed but specifier is preserved.
```

For details, see [tests](./index.test.js)

## Options

| Name | Type | Description|
|---|---|---|
| `test.importName` | `string\|RegExp` | Pattern to test import name and replace stub if matched. |
| `test.importPath` | `string\|RegExp` | Pattern to test import path and replace stub if matched. |
| `stubTo` | `string` | String to replace stub module. `<rootDir>` is replaced to root directory path. |

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