[![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]
npm install 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]
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 using npm or yarn:
``bash`
npm i externalityor
yarn add externality
`js`
import { rollupExternals } from 'externality'
`js`
import { webpackExternals } from 'externality'
This utility is powered by 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'
// }
`
`js
import { isExternal } from 'externality'
await isExternal('my-lib', '.')
// {
// id: 'my-lib',
// external: true
// }
``
[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