{"name":"load-plugin","version":"4.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"}],"sideEffects":false,"type":"module","main":"index.js","types":"index.d.ts","dependencies":{"import-meta-resolve":"^1.0.0","libnpmconfig":"^1.0.0"},"devDependencies":{"@types/tape":"^4.0.0","c8":"^7.0.0","prettier":"^2.0.0","remark-cli":"^9.0.0","remark-lint":"^8.0.0","remark-preset-wooorm":"^8.0.0","rimraf":"^3.0.0","tape":"^5.0.0","type-coverage":"^2.0.0","typescript":"^4.0.0","xo":"^0.39.0"},"scripts":{"prepack":"npm run build && npm run format","build":"rimraf \"{test/**,}*.d.ts\" && tsc && type-coverage","format":"remark . -qfo && prettier . -w --loglevel warn && xo --fix","test-api":"node test/index.js","test-coverage":"c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test/index.js","test":"npm run build && npm run format && npm run test-coverage"},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true,"rules":{"no-await-in-loop":"off"}},"remarkConfig":{"plugins":["preset-wooorm"]},"typeCoverage":{"atLeast":100,"detail":true,"strict":true,"ignoreCatch":true},"gitHead":"c7c598815de84a4e498329fc15768c80f529a55f","homepage":"https://github.com/wooorm/load-plugin#readme","_id":"load-plugin@4.0.0","_nodeVersion":"16.1.0","_npmVersion":"7.12.1","dist":{"integrity":"sha512-JuALIjy0SD6nPIuasdEsv8eoKW9E3tswpNx81dyIgX/wX9zbtgcAtJkP2+mDjVpIvA+zGvTndgi6ec5SCIZV+g==","shasum":"44f0d55f43d191c860228af3fa98cfeffd304ece","tarball":"http://registry-npm.ywwl.com/load-plugin/download/load-plugin-4.0.0.tgz","fileCount":5,"unpackedSize":13961,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgnmCgCRA9TVsSAnZWagAAEMkQAIK4RZGNO1j5t8+eZeE4\n+8hGEKWcvI/Zd66/kCUnu1pk9XIViRCzY+1WJqvUntCU1gu+p+u96o4bZtRo\nqj1ZIsPnqMQ25kNd37gKZl2Bk9EKKIERKWBZBJjgqbFlMmj5yjOqOG4NgE3N\n+iq6h/MGaheUZv/yibZlrjtUMibbL3zWmomJsFJ4804VBqUQkA5kVdSuYCrO\nS+Qziy+UQZ704HC+XWELxuPfDBk4GRpB0va55q5NdFCqbKuciE/A/yjeLzEB\nRcZRa37/QKgK5YsRJqs2EJyts1FRtMXKwNsJuY5RmBtinTV7QTjUs9E8JCrl\nOSH6/bU7fT3s5h1afefbZRAw7hlJou6I6hfl2gv/j5iNWk8So1+s2Y1VGLHB\nDcxrVCsb3NITc1kLkafObG5Lfsl7LTrrasTPVZcwNXoQISgu4wnjmBdgEy1i\nt2JPIxukCHglWq1qXvhcmBwKv3/muilKuLEIpF+K+XMv5ew7GLDg+EoB/m7X\nsk0NW3PUjejC30Q/W2yRvz5KWRRfBF8tOrXJUUOa5bQOubmqcHBHuaRgihfI\n1rxgGyzQA6jC+yclhde95YmSikmltEB+Qqh3llxHIy2YBCpwOj/udZXOthnA\njP1FldoBPG9459WWdQUrPkwDSqkMNswl38tGkPCeh/of3VhDcQ4P4F1bvgwF\ncdp9\r\n=/bF4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDTDzamP0LMk2SPURurhOiPmlve72rIzMTsZXOso+3LpAiEA8rD/QE4eEVJYZ4tJWFwD4Hvp2gGjWpyTbJiTHbC6Z48="}],"size":5425,"noattachment":false,"key":"/load-plugin/-/load-plugin-4.0.0.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/load-plugin_4.0.0_1620992160274_0.6543370538733482"},"_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":1620992160412,"_cnpm_publish_time":1620992160412,"dist-tags":{"latest":"6.0.3"}}