{"name":"load-plugin","version":"2.0.0","description":"Load a submodule, plugin, or file","license":"MIT","keywords":["load","submodule","package","plugin"],"repository":{"type":"git","url":"git+https://github.com/wooorm/load-plugin.git"},"bugs":{"url":"https://github.com/wooorm/load-plugin/issues"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"http://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"http://wooorm.com"}],"dependencies":{"npm-prefix":"^1.2.0","resolve-from":"^2.0.0"},"files":["index.js"],"devDependencies":{"istanbul":"^0.4.0","remark-cli":"^1.0.0","remark-comment-config":"^4.0.0","remark-github":"^5.0.0","remark-lint":"^4.0.0","remark-validate-links":"^4.0.0","tape":"^4.0.0","xo":"^0.16.0"},"scripts":{"build-md":"remark . --quiet --frail","build":"npm run build-md","lint":"xo","test-api":"node test/index.js","test-coverage":"istanbul cover test/index.js","test":"npm run build && npm run lint && npm run test-coverage"},"xo":{"space":true,"rules":{"no-eq-null":"off","eqeqeq":"off"}},"nyc":{"check-coverage":true,"lines":100,"functions":100,"branches":100},"remarkConfig":{"output":true,"plugins":{"comment-config":null,"github":null,"lint":{"heading-increment":false,"list-item-spacing":false},"validate-links":null},"settings":{"bullet":"*"}},"gitHead":"152e4fe9a75d93049cd27480321b548994c65aaa","homepage":"https://github.com/wooorm/load-plugin#readme","_id":"load-plugin@2.0.0","_shasum":"bfcc69aa2916263c45befcbb2b54cc4ec0e3b4d5","_from":".","_npmVersion":"3.8.6","_nodeVersion":"6.0.0","_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"dist":{"shasum":"bfcc69aa2916263c45befcbb2b54cc4ec0e3b4d5","tarball":"http://registry-npm.ywwl.com/load-plugin/download/load-plugin-2.0.0.tgz","integrity":"sha512-BcGpk3EjK3DRAXnLd8vkIHp6hKCQTiCSG3aaYFpUHt752QPXz97H5c/ZoNed+uphm8iI8sT2VvTovIVQyONQSQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGONdzDbfWg6oZDm33OGSg0s4P3xJuc+NhSfjSyftNquAiBhkWIk/oOlaI4WQwGTNTuha+xbVqniFKbubZ9TDdliDQ=="}],"size":2691,"noattachment":false,"key":"/load-plugin/-/load-plugin-2.0.0.tgz"},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/load-plugin-2.0.0.tgz_1471793914280_0.7949218756984919"},"directories":{},"readme":"# load-plugin\n\n[![Build][badge-build-image]][badge-build-url]\n[![Coverage][badge-coverage-image]][badge-coverage-url]\n[![Downloads][badge-downloads-image]][badge-downloads-url]\n\nLoad a submodule, plugin, or file.\n\n## Contents\n\n* [What is this?](#what-is-this)\n* [When to use this?](#when-to-use-this)\n* [Install](#install)\n* [Use](#use)\n* [API](#api)\n  * [`loadPlugin(name[, options])`](#loadpluginname-options)\n  * [`resolvePlugin(name[, options])`](#resolvepluginname-options)\n  * [`LoadOptions`](#loadoptions)\n  * [`ResolveOptions`](#resolveoptions)\n* [Compatibility](#compatibility)\n* [Security](#security)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis package is useful when you want to load plugins.\nIt resolves things like Node.js does,\nbut supports a prefix (when given a prefix `remark` and the user provided value\n`gfm` it can find `remark-gfm`),\ncan load from several places,\nand optionally global too.\n\n## When to use this?\n\nThis package is particularly useful when you want users to configure something\nwith plugins.\nOne example is `remark-cli` which can load remark plugins from configuration\nfiles.\n\n## Install\n\nThis package is [ESM only][github-gist-esm].\nIn Node.js (version 16+),\ninstall with [npm][npm-install]:\n\n```sh\nnpm install load-plugin\n```\n\n## Use\n\nSay we’re in this project (with dependencies installed):\n\n```js\nimport {loadPlugin, resolvePlugin} from 'load-plugin'\n\nconsole.log(await resolvePlugin('lint', {prefix: 'remark'}))\n// => 'file:///Users/tilde/Projects/oss/load-plugin/node_modules/remark-lint/index.js'\n\nconsole.log(\n  await resolvePlugin('validator-identifier', {prefix: '@babel/helper'})\n)\n// => 'file:///Users/tilde/Projects/oss/load-plugin/node_modules/@babel/helper-validator-identifier/lib/index.js'\n\nconsole.log(await resolvePlugin('./index.js', {prefix: 'remark'}))\n// => 'file:///Users/tilde/Projects/oss/load-plugin/index.js'\n\nconsole.log(await loadPlugin('lint', {prefix: 'remark'}))\n// => [Function: remarkLint]\n```\n\n## API\n\nThis package exports the identifiers\n[`loadPlugin`][api-load-plugin] and [`resolvePlugin`][api-resolve-plugin].\nThere is no default export.\n\nIt exports the [TypeScript][] types\n[`LoadOptions`][api-load-options] and [`ResolveOptions`][api-resolve-options].\n\n### `loadPlugin(name[, options])`\n\nImport `name` from `from` (and optionally the global `node_modules` directory).\n\nUses the Node.js [resolution algorithm][nodejs-resolution-algo] (through\n[`import-meta-resolve`][github-import-meta-resolve]) to resolve CJS and ESM\npackages and files.\n\nIf a `prefix` is given and `name` is not a path,\n`$prefix-$name` is also searched (preferring these over non-prefixed\nmodules).\nIf `name` starts with a scope (`@scope/name`),\nthe prefix is applied after it: `@scope/$prefix-name`.\n\n###### Parameters\n\n* `name` (`string`)\n  — specifier\n* `options` ([`LoadOptions`][api-load-options], optional)\n  — configuration\n\n###### Returns\n\nPromise to a whole module or specific export (`Promise<unknown>`).\n\n### `resolvePlugin(name[, options])`\n\nResolve `name` from `from`.\n\n###### Parameters\n\n* `name` (`string`)\n  — specifier\n* `options` ([`ResolveOptions`][api-resolve-options], optional)\n  — configuration\n\n###### Returns\n\nPromise to a file URL (`Promise<string>`).\n\n### `LoadOptions`\n\nConfiguration for `loadPlugin` (TypeScript type).\n\nThis type extends `ResolveOptions` and adds:\n\n###### Fields\n\n* `key` (`boolean` or `string`, default: `'default'`)\n  — identifier to take from the exports;\n  for example when given `'x'`,\n  the value of `export const x = 1` will be returned;\n  when given `'default'`,\n  the value of `export default …` is used,\n  and when `false` the whole module object is returned\n\n### `ResolveOptions`\n\nConfiguration for `resolvePlugin` (TypeScript type).\n\n###### Fields\n\n* `from` (`Array<URL | string> | URL | string`, optional)\n  — place or places to search from;\n  defaults to the current working directory\n* `global` (`boolean`, default: whether global is detected)\n  — whether to look for `name` in [global places][npm-node-modules];\n  if this is nullish,\n  `load-plugin` will detect if it’s currently running in global mode: either\n  because it’s in Electron or because a globally installed package is running\n  it;\n  note that Electron runs its own version of Node instead of your system Node,\n  meaning global packages cannot be found,\n  unless you’ve set-up a [`prefix`][npm-prefix] in your `.npmrc` or are using\n  [nvm][github-nvm] to manage your system node\n* `prefix` (`string`, optional)\n  — prefix to search for\n\n## Compatibility\n\nThis projects is compatible with maintained versions of Node.js.\n\nWhen we cut a new major release,\nwe drop support for unmaintained versions of Node.\nThis means we try to keep the current release line,\n`load-plugin@6`,\ncompatible with Node.js 16.\n\n## Security\n\nThis package reads the file system and imports things into Node.js.\n\n## Contribute\n\nYes please!\nSee [How to Contribute to Open Source][open-source-guide-contribute].\n\n## License\n\n[MIT][file-license] © [Titus Wormer][wooorm]\n\n<!-- Definitions -->\n\n[api-load-plugin]: #loadpluginname-options\n\n[api-load-options]: #loadoptions\n\n[api-resolve-plugin]: #resolvepluginname-options\n\n[api-resolve-options]: #resolveoptions\n\n[badge-build-image]: https://github.com/wooorm/load-plugin/workflows/main/badge.svg\n\n[badge-build-url]: https://github.com/wooorm/load-plugin/actions\n\n[badge-coverage-image]: https://img.shields.io/codecov/c/github/wooorm/load-plugin.svg\n\n[badge-coverage-url]: https://codecov.io/github/wooorm/load-plugin\n\n[badge-downloads-image]: https://img.shields.io/npm/dm/load-plugin.svg\n\n[badge-downloads-url]: https://www.npmjs.com/package/load-plugin\n\n[file-license]: license\n\n[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[github-import-meta-resolve]: https://github.com/wooorm/import-meta-resolve\n\n[github-nvm]: https://github.com/nvm-sh/nvm\n\n[nodejs-resolution-algo]: https://nodejs.org/api/esm.html#esm_resolution_algorithm\n\n[npm-install]: https://docs.npmjs.com/cli/install\n\n[npm-node-modules]: https://docs.npmjs.com/cli/v10/configuring-npm/folders#node-modules\n\n[npm-prefix]: https://docs.npmjs.com/cli/v10/using-npm/config\n\n[open-source-guide-contribute]: https://opensource.guide/how-to-contribute/\n\n[typescript]: https://www.typescriptlang.org\n\n[wooorm]: https://wooorm.com\n","publish_time":1471793915636,"_cnpm_publish_time":1471793915636,"dist-tags":{"latest":"6.0.3"}}