{"name":"load-plugin","version":"3.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"},"funding":{"type":"github","url":"https://github.com/sponsors/wooorm"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"main":"index.js","browser":"browser.js","dependencies":{"libnpmconfig":"^1.0.0","resolve-from":"^5.0.0"},"devDependencies":{"nyc":"^15.0.0","prettier":"^1.0.0","remark-cli":"^7.0.0","remark-lint":"^6.0.0","remark-preset-wooorm":"^6.0.0","tape":"^4.0.0","xo":"^0.25.0"},"scripts":{"format":"remark . -qfo && prettier --write \"**/*.js\" && xo --fix","test-api":"node test","test-coverage":"nyc --reporter lcov tape test/index.js","test":"npm run format && npm run test-coverage"},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true,"esnext":false},"nyc":{"check-coverage":true,"lines":100,"functions":100,"branches":100},"remarkConfig":{"plugins":["preset-wooorm"]},"gitHead":"1f4850c45f29e1581ad58791924f1dbcd5e88ba6","homepage":"https://github.com/wooorm/load-plugin#readme","_id":"load-plugin@3.0.0","_nodeVersion":"13.0.1","_npmVersion":"6.13.6","dist":{"integrity":"sha512-od7eKCCZ62ITvFf8nHHrIiYmgOHb4xVNDRDqxBWSaao5FZyyZVX8OmRCbwjDGPrSrgIulwPNyBsWCGnhiDC0oQ==","shasum":"8f3ce57cf4e5111639911012487bc1c2ba3d0e6c","tarball":"http://registry-npm.ywwl.com/load-plugin/download/load-plugin-3.0.0.tgz","fileCount":5,"unpackedSize":10242,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeHErZCRA9TVsSAnZWagAAWRwP/ROxyFYlrJTrQUlIqGur\nGHWjhUL6UNhuEzOd2ZMuAy6zwZ6NmZd+SBWvbXa1eyDZ9C1qEYu9td5JlbID\nXW5YWu0forFdId4xhP0nxA2o2iuGaOO5Hq6yHFArzIqRL6t0XoEgMVmSpUGN\ncjS7HUF+Kzv3h8tNH2KqTfFQ/KHKFnONsupCqu/fF89W6idGE88t3SjhxwH5\n3HLUTQhwRObxXaGbZrNvOk6fdUHVWFCIEs6SEiSrLFjP9+lFkEPQNLLbYPEx\n/VuWrC1B2pmXll0Y34r+C5X1H6od37fshrQRXzi5+p7k+JgDGYcppsRJ7L8f\nMa+rEA0KIcoaQoh00FQ8+WGJYA7AqAly6mQo5PBIVYyUp7RgJLHh1G94UGjr\nSAKkVKROXoQLVXYWnFKnvod97GYEkw8gZUVcMVq4DEXkFTd2W40VDrg8eIpJ\nGxUn/cIe/Eqfbzh9VDAPjHUEpU7PurgdqM7pwLvxLIFoH77gGj/PwUfEB9j5\nqtNq08a6b1oclvu8sMAdxoWGhXuFyxkcJAdLBlDoKhlo+AHcZGiHQu3AH91H\n73W7qK7qY5EdXBMWRc3UO3j+LNbzK1uil+0khzV9OgMPxTcTYuL4UEXZZ8r0\nDzU3z0cKC2LRRzdoASCH6W9yeWrTDHa5WST3BFrkwY42/itglJad4jUnvs7m\njPsx\r\n=nWHm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDJhLfk4Lk/0ihhLa1cau+2SWO1qkYmJ0OiPUtqo4r7LAIgKfVer9v2NEJ9/AHEzDF4S7fhQKh4RZJ3lALEJD5Mouw="}],"size":4346,"noattachment":false,"key":"/load-plugin/-/load-plugin-3.0.0.tgz"},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/load-plugin_3.0.0_1578912473008_0.9168410197196153"},"_hasShrinkwrap":false,"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":1578912473099,"_cnpm_publish_time":1578912473099,"dist-tags":{"latest":"6.0.3"}}