externality
Advanced tools
Comparing version
{ | ||
"name": "externality", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"exports": { | ||
@@ -9,5 +10,7 @@ ".": { | ||
"import": "./dist/index.mjs" | ||
} | ||
}, | ||
"./*": "./*" | ||
}, | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
@@ -18,27 +21,33 @@ "files": [ | ||
"scripts": { | ||
"build": "siroc build", | ||
"lint": "eslint --ext .js,.ts .", | ||
"prepublishOnly": "yarn build", | ||
"build": "unbuild", | ||
"dev": "vitest", | ||
"lint": "eslint --ext .ts .", | ||
"prepack": "yarn build", | ||
"release": "yarn test && standard-version && git push --follow-tags && npm publish", | ||
"test": "yarn lint && jest" | ||
"test": "yarn lint && vitest run" | ||
}, | ||
"dependencies": { | ||
"allowlist": "^0.1.1", | ||
"enhanced-resolve": "^5.8.3", | ||
"mlly": "^0.3.10", | ||
"enhanced-resolve": "^5.9.2", | ||
"mlly": "^0.4.3", | ||
"pathe": "^0.2.0", | ||
"ufo": "^0.7.9" | ||
"ufo": "^0.7.11" | ||
}, | ||
"devDependencies": { | ||
"@nuxtjs/eslint-config-typescript": "^8.0.0", | ||
"@types/jest": "^27.0.2", | ||
"@types/node": "^17.0.9", | ||
"eslint": "^8.7.0", | ||
"jest": "^27.2.5", | ||
"rollup": "^2.58.0", | ||
"siroc": "^0.16.0", | ||
"@types/node": "^17.0.21", | ||
"allowlist": "^0.1.1", | ||
"c8": "^7.11.0", | ||
"eslint": "^8.10.0", | ||
"rollup": "^2.70.0", | ||
"standard-version": "^9.3.1", | ||
"ts-jest": "^27.0.6", | ||
"webpack": "^5.58.2" | ||
"unbuild": "^0.7.0", | ||
"vite": "^2.8.6", | ||
"vitest": "^0.6.0", | ||
"webpack": "^5.70.0" | ||
}, | ||
"build": { | ||
"externals": [ | ||
"rollup" | ||
] | ||
} | ||
} |
@@ -0,3 +1,23 @@ | ||
[![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 | ||
@@ -19,4 +39,13 @@ | ||
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' | ||
// } | ||
``` | ||
@@ -28,2 +57,28 @@ | ||
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 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4
-20%364
1.11%83
196.43%15209
-2.57%11
10%+ Added
- Removed
- Removed
- Removed
Updated
Updated
Updated