包详细信息

externality

unjs2.5mMIT1.0.2

[![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 version npm downloads Github Actions Codecov bundle

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:

npm i externality
# or
yarn add externality

Rollup plugin

import { rollupExternals } from 'externality'

Webpack plugin

import { webpackExternals } from 'externality'

Utils

resolveId

This utility is powered by enhanced-resolve and will resolve a given module/path with support for extensions, CJS/ESM and more.

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

import { isExternal } from 'externality'

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

License

MIT

更新日志

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.0.2 (2023-06-06)

Bug Fixes

  • handle false return from enhanced-resolve (97af2bb)

1.0.1 (2023-06-06)

1.0.0 (2022-11-15)

0.2.2 (2022-05-17)

0.2.1 (2022-03-10)

Bug Fixes

  • revert enhanced-resolve import (6c0d404)

0.2.0 (2022-03-10)

Bug Fixes

  • handle pnpm-style paths (16db4c7)

0.1.6 (2022-01-18)

Bug Fixes

  • exclude nested node_modules from inline matcher (#5) (2676ef4)

0.1.5 (2021-11-02)

Bug Fixes

  • exclude windows drive letters from protocols (8ea3fa9)

0.1.4 (2021-10-28)

Features

0.1.3 (2021-10-21)

Bug Fixes

  • do external check after inline checks (067c657)

0.1.2 (2021-10-21)

Features

0.1.1 (2021-10-20)

Features

0.1.0 (2021-10-19)

⚠ BREAKING CHANGES

  • External inline and external options will now be converted from strings -> RE. For previous string behaviour (positive for any string included in an id), just pass an unbounded RE, such as /\?/

  • also fix incorrect type in ResolvedId

  • convert all strings to RE (in inline and external opts) (0166d70)

0.0.5 (2021-10-19)

Features

  • expose toPathRegExp utility (f2bf6c2)

0.0.4 (2021-10-15)

Bug Fixes

  • import default export from enhanced-resolve (838e691)

0.0.3 (2021-10-15)

Bug Fixes

  • fallback to root if base is invalid id (c92311f)
  • pass opts.resolve to resolveId function (b345ea1)

0.0.2 (2021-06-18)

0.0.1 (2021-06-18)