# babel-plugin-shortcut-import

> Babel plugin for shortcut imports

Latest version **1.0.13** (published 2018-10-07) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.13 |
| Published | 2018-10-07 |
| First published | 2018-06-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Radosław Kłos |
| Maintainers | rklos |
| Keywords | babel, plugin, require, import, shortcut, module, modules, short, path |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-shortcut-import
- Repository: https://github.com/rklos/babel-plugin-shortcut-import
- Issues: https://github.com/rklos/babel-plugin-shortcut-import/issues
- npm.io page: https://npm.io/package/babel-plugin-shortcut-import

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.0.13 (latest) — 2018-10-07
- 1.0.12 — 2018-08-29
- 1.0.11 — 2018-07-07
- 1.0.10 — 2018-07-07
- 1.0.9 — 2018-07-07
- 1.0.8 — 2018-06-23
- 1.0.7 — 2018-06-16
- 1.0.6 — 2018-06-16
- 1.0.5 — 2018-06-04

## README

# Shortcut import
[![npm](https://img.shields.io/npm/v/babel-plugin-shortcut-import.svg)](https://www.npmjs.com/package/babel-plugin-shortcut-import) [![downloads](https://img.shields.io/npm/dt/babel-plugin-shortcut-import.svg)](https://www.npmjs.com/package/babel-plugin-shortcut-import) [![dependencies](https://img.shields.io/david/rklos/babel-plugin-shortcut-import.svg)](https://www.npmjs.com/package/babel-plugin-shortcut-import) [![devdependencies](https://img.shields.io/david/dev/rklos/babel-plugin-shortcut-import.svg)](https://www.npmjs.com/package/babel-plugin-shortcut-import) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/8a2aa941d8014d85864d8327fb9052f8)](https://www.codacy.com/app/rklos/babel-plugin-shortcut-import?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=rklos/babel-plugin-shortcut-import&amp;utm_campaign=Badge_Grade) [![Build Status](https://travis-ci.org/rklos/babel-plugin-shortcut-import.svg?branch=master)](https://travis-ci.org/rklos/babel-plugin-shortcut-import) [![Coverage Status](https://coveralls.io/repos/github/rklos/babel-plugin-shortcut-import/badge.svg?branch=master)](https://coveralls.io/github/rklos/babel-plugin-shortcut-import?branch=master)

Dependency-free, lightweight babel plugin that allows using shortcuts in `import` and `require` declarations.

## Installation
```
npm install babel-plugin-shortcut-import --save-dev
```

## Configuration
In `.babelrc` write:
```json
{
  "plugins": [
    ["babel-plugin-shortcut-import"]
  ]
}
```

Then you can define your own shortcuts for directiories. For example:
```json
{
  "plugins": [
    ["babel-plugin-shortcut-import", [
        {
          "pathPrefix": "#",
          "pathSuffix": "src/"
        },
        {
          "pathPrefix": "~",
          "pathSuffix": "src/shared/"
        }
    ]]
  ]
}
```

Now every shortcutted import like:
```javascript
import Test from '~test.js';
```
Will be translated by babel to:
```javascript
import Test from './shared/test.js';
```
Translated path is relative, so it may be different depending on the location of the source file.

It works for `require` function also.

Inspired by [babel-plugin-root-import][1]

[1]: https://www.npmjs.com/package/babel-plugin-root-import

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