# rollup-plugin-node-resolve-and-alias

> Fork of rollup-plugin-node-resolve with aliases

Latest version **3.0.0** (published 2017-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-node-resolve-and-alias
pnpm add rollup-plugin-node-resolve-and-alias
yarn add rollup-plugin-node-resolve-and-alias
bun add rollup-plugin-node-resolve-and-alias
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2017-06-18 |
| First published | 2017-06-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | rektide |
| Maintainers | rektide |
| Keywords | rollup, rollup-plugin, es2015, npm, modules |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-node-resolve-and-alias
- Repository: https://github.com/rektide/rollup-plugin-node-resolve-with-alias
- Homepage: https://github.com/rollup/rollup-plugin-node-resolve#readme
- Issues: https://github.com/rollup/rollup-plugin-node-resolve/issues
- npm.io page: https://npm.io/package/rollup-plugin-node-resolve-and-alias

## Dependencies (4)

- [resolve](https://npm.io/package/resolve.md) ^1.1.6
- [is-module](https://npm.io/package/is-module.md) ^1.0.0
- [browser-resolve](https://npm.io/package/browser-resolve.md) ^1.11.0
- [builtin-modules](https://npm.io/package/builtin-modules.md) ^1.1.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2017-06-18

## README

# rollup-plugin-node-resolve

*This plugin used to be called rollup-plugin-npm*

Locate modules using the [Node resolution algorithm](https://nodejs.org/api/modules.html#modules_all_together), for using third party modules in `node_modules`

## Installation

```bash
npm install --save-dev rollup-plugin-node-resolve
```

## Usage

```js
// rollup.config.js
import { rollup } from 'rollup';
import resolve from 'rollup-plugin-node-resolve';

export default {
  entry: 'main.js',
  dest: 'bundle.js',
  moduleName: 'MyModule',
  format: 'iife'
  plugins: [
    resolve({
      // use "module" field for ES6 module if possible
      module: true, // Default: true

      // use "jsnext:main" if possible
      // – see https://github.com/rollup/rollup/wiki/jsnext:main
      jsnext: true,  // Default: false

      // use "main" field or index.js, even if it's not an ES6 module
      // (needs to be converted from CommonJS to ES6
      // – see https://github.com/rollup/rollup-plugin-commonjs
      main: true,  // Default: true

      // some package.json files have a `browser` field which
      // specifies alternative files to load for people bundling
      // for the browser. If that's you, use this option, otherwise
      // pkg.browser will be ignored
      browser: true,  // Default: false

      // not all files you want to resolve are .js files
      extensions: [ '.js', '.json' ],  // Default: ['.js']

      // whether to prefer built-in modules (e.g. `fs`, `path`) or
      // local ones with the same names
      preferBuiltins: false,  // Default: true

      // Lock the module search in this path (like a chroot). Module defined
      // outside this path will be mark has external
      jail: '/my/jail/path', // Default: '/'

      // If true, inspect resolved files to check that they are
      // ES2015 modules
      modulesOnly: true, // Default: false

      // Any additional options that should be passed through
      // to node-resolve
      customResolveOptions: {
        moduleDirectory: 'js_modules'
      },

      // if the imported module starts with the key, replace that with the value
      alias: {
        path: "special-path-module"
      }
    })
  ]
};
```

## Using with rollup-plugin-commonjs

Since most packages in your node_modules folder are probably legacy CommonJS rather than JavaScript modules, you may need to use [rollup-plugin-commonjs](https://github.com/rollup/rollup-plugin-commonjs):

```js
// rollup.config.js
import { rollup } from 'rollup';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';

export default {
  entry: 'main.js',
  dest: 'bundle.js',
  moduleName: 'MyModule',
  format: 'iife'
  plugins: [
    resolve({ jsnext: true, main: true }),
    commonjs()
  ]
};
```


## License

MIT

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