# externality

> [![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Github Actions][github-actions-src]][github-actions-href] [![Codecov][codecov-src]][codecov-href] [![bundle][bundle-src]][bundle-href]

Latest version **1.0.2** (published 2023-06-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install externality
pnpm add externality
yarn add externality
bun add externality
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-06-06 |
| First published | 2021-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 20.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 32 |
| Maintainers | pi0, danielroe |

## Links

- npm: https://www.npmjs.com/package/externality
- Repository: https://github.com/unjs/externality
- Homepage: https://github.com/unjs/externality#readme
- Issues: https://github.com/unjs/externality/issues
- npm.io page: https://npm.io/package/externality

## Dependencies (4)

- [ufo](https://npm.io/package/ufo.md) ^1.1.2
- [mlly](https://npm.io/package/mlly.md) ^1.3.0
- [pathe](https://npm.io/package/pathe.md) ^1.1.1
- [enhanced-resolve](https://npm.io/package/enhanced-resolve.md) ^5.14.1

## Recent versions

- 1.0.2 (latest) — 2023-06-06
- 1.0.0 — 2022-11-15
- 0.2.2 — 2022-05-17
- 0.2.1 — 2022-03-10
- 0.2.0 — 2022-03-10
- 0.1.6 — 2022-01-18
- 0.1.5 — 2021-11-02
- 0.1.4 — 2021-10-28
- 0.1.3 — 2021-10-21
- 0.1.2 — 2021-10-21
- 0.1.1 — 2021-10-20
- 0.1.0 — 2021-10-19
- 0.0.5 — 2021-10-19
- 0.0.4 — 2021-10-15
- 0.0.3 — 2021-10-15
- … 3 more at https://npm.io/package/externality/versions

## README

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Github Actions][github-actions-src]][github-actions-href]
[![Codecov][codecov-src]][codecov-href]
[![bundle][bundle-src]][bundle-href]

# Externality

Externality is a set of utilities for handling identifying whether a given package or path should be considered an external package that can be imported at runtime, or whether is should be bundled in a build step.

It also contains a webpack and rollup plugin for encapsulating this functionality.

## Install

Install using npm or yarn:

```bash
npm i externality
# or
yarn add externality
```

## Rollup plugin

```js
import { rollupExternals } from 'externality'
```

## Webpack plugin

```js
import { webpackExternals } from 'externality'
```

## Utils

### `resolveId`

This utility is powered by [`enhanced-resolve`](https://github.com/webpack/enhanced-resolve) and will resolve a given module/path with support for extensions, CJS/ESM and more.

```js
import { resolveId } from 'externality'

await resolveId('my-lib', { type: 'commonjs' })
// {
//   id: 'my-lib',
//   path: '/path/to/node_modules/my-lib/index.js',
//   type: 'commonjs'
// }
```

### `isExternal`

```js
import { isExternal } from 'externality'

await isExternal('my-lib', '.')
// {
//   id: 'my-lib',
//   external: true
// }
```

## License

[MIT](./LICENSE)

<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/externality?style=flat-square
[npm-version-href]: https://npmjs.com/package/externality

[npm-downloads-src]: https://img.shields.io/npm/dm/externality?style=flat-square
[npm-downloads-href]: https://npmjs.com/package/externality

[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/externality/ci/main?style=flat-square
[github-actions-href]: https://github.com/unjs/externality/actions?query=workflow%3Aci

[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/externality/main?style=flat-square
[codecov-href]: https://codecov.io/gh/unjs/externality

[bundle-src]: https://img.shields.io/bundlephobia/minzip/externality?style=flat-square
[bundle-href]: https://bundlephobia.com/result?p=externality

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