# rollup-plugin-resolve-id

> Resolves import statements using aliases and file extensions, (sync with webpack resolve specs)

Latest version **1.0.2** (published 2018-08-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-resolve-id
pnpm add rollup-plugin-resolve-id
yarn add rollup-plugin-resolve-id
bun add rollup-plugin-resolve-id
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-08-07 |
| First published | 2018-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=5.12.0 |
| Dependencies | 0 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Allex Wang |
| Maintainers | allex |
| Keywords | rollup, rollup-plugin, resolveId, import, alias, aliases, extensions, resolver, mainFields |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-resolve-id
- Repository: https://github.com/allex/rollup-plugin-resolve-id
- Issues: https://github.com/allex/rollup-plugin-resolve-id/issues
- npm.io page: https://npm.io/package/rollup-plugin-resolve-id

## 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.2 (latest) — 2018-08-07
- 1.0.1 — 2018-07-17

## README

# rollup-plugin-resolve-id

Rollup plugin for resolves module by using aliases and file extensions,
Also resolves the file when importing a directory. Migrate from [rollup-plugin-resolve2](https://www.npmjs.com/package/rollup-plugin-resolve2)

**(sync with webpack resolve specs)**

## Install

```bash
yarn add --dev rollup-plugin-resolve-id
```

## Options

```js
import importResolver from "rollup-plugin-resolve-id";

importResolver({
  // a list of file extensions to check, default = ['.js']
  extensions: ['.js', '.vue'],
  // a list of aliases, default = {}
  alias: {
    'lib': './node_modules/otherlib/src'
  },
  // index file name without extension, default = 'index'
  indexFile: 'index'
});

// if called without options, the defaults are
defaultOptions = {
  extensions: ['js'],
  alias: {},
  indexFile: 'index'
};
```

## Usage scenarios

Consider the following project structure

    |-- .. 
    '-- src
       |-- ..
       |-- index.js
       '-- utils
           |-- ..
           |-- util1.js
           |-- util2.jsm
           '-- index.js


and plugin options

```json
{
  "extensions": [".js", ".jsm"],
  "alias": {
    "somelib": "./node_modules/other_lib/src/"
  }
}
```

### Resolve "index" file if import points to a directory

```js
// src/index.js

import * as utils from "./utils"; 
// resolved to ./utils/index.js
```

### Resolve extensions

```js
// src/utils/index.js

import util1 from "./util1"; 
// resolved to ./util1.js
import util2 from "./util2"; 
// resolved to ./util2.jsm

export {util1 as u1, util2 as u2};
```

### Resolve aliases

```js
// src/utils/util1.js

import somelib from "somelib";
// resolved to ./node_modules/other_lib/src/index.js

import component1 from "somelib/component1";
// resolved to ./node_modules/other_lib/src/component1.js
// OR if component1 is a folder ./node_modules/other_lib/src/component1/index.js
```

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