{"name":"load-plugin","version":"5.1.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":{"@npmcli/config":"^6.0.0","import-meta-resolve":"^2.0.0"},"devDependencies":{"@types/node":"^18.0.0","c8":"^7.0.0","prettier":"^2.0.0","remark-cli":"^11.0.0","remark-lint":"^9.0.0","remark-preset-wooorm":"^9.0.0","type-coverage":"^2.0.0","typescript":"^4.0.0","xo":"^0.53.0"},"scripts":{"prepack":"npm run build && npm run format","build":"tsc --build --clean && tsc --build && type-coverage","format":"remark . -qfo && prettier . -w --loglevel warn && xo --fix","test-api":"node --conditions development test/index.js","test-coverage":"c8 --check-coverage --100 --reporter lcov npm run test-api","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":{"unicorn/prefer-node-protocol":"off","no-await-in-loop":"off"}},"remarkConfig":{"plugins":["preset-wooorm"]},"typeCoverage":{"atLeast":100,"detail":true,"strict":true,"ignoreCatch":true},"gitHead":"28ff874623de8f6bd2a700ba1f66113bf3ffbee6","homepage":"https://github.com/wooorm/load-plugin#readme","_id":"load-plugin@5.1.0","_nodeVersion":"19.0.0","_npmVersion":"8.19.2","dist":{"integrity":"sha512-Lg1CZa1CFj2CbNaxijTL6PCbzd4qGTlZov+iH2p5Xwy/ApcZJh+i6jMN2cYePouTfjJfrNu3nXFdEw8LvbjPFQ==","shasum":"15600f5191c742b16e058cfc908c227c13db0104","tarball":"http://registry-npm.ywwl.com/load-plugin/download/load-plugin-5.1.0.tgz","fileCount":5,"unpackedSize":14792,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDONPKPmjb6/BuHJWn+03z+d+rPCseD8UobHFdmyDmsdAiEAiTgoKO2PCqcYmmgkOVsYNdrvUvhBcnvJZSuZy7Qvpdk="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjellYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqyTg//VLZZyv/LM8/k/SGTiLn3d7Ntu8loPNB5QIC8mw/jd/ou4Ezw\r\nMDDaa3QHeSuBRJYxILoMDmSXEfzo6DKVz0Z1L0OiRekgil4BxqBjP+EiW3Jm\r\nOd7gV1DEbM2gbJUJVtMaqSS0oS2gdVNzbi/oxbwKCm6HRohbZwzWtVfxjp86\r\nCt20V5T97M4KXVVJCfvilSZU08iU2xk1Dw9e3PZUMWhdJLvoXaNBwVAEWvAg\r\ns+2m7zXAssKptr4clJkuHfLJc74/uCwE9d50Rmd4Z/qXUZ3IByADh4E7JGKH\r\nEFDsuqqbf8c0bZrIc0lQbCpe+/4VAjtqr6rwuxcwjhUL20Jwdbrr2N3cqKg7\r\nmDLHEo4JxORe/J7EkIlLlNuf/25uMPV5Ab4+yDzpVl5tbEiOmjyXNVFjVeva\r\nOeJjfDvtM3ynTnvVI0TS9sBPOghiIrONyTZBBrtL22fQIG6wkZ/xXmt3MTOV\r\nkH9CTAZ7/auIcQUfbbYfjn/9HcYLZCQrcF9QQoglzZsa5Z1mz9RbDFL8F8E3\r\nJce7rcM7cngxtygifjRRIzgI4wG18U0vwPrIEOxj4OJSl2C5NvImpAUZ+AXu\r\n9H+KCzRmNWzFRFft2MiL0iQYGp71bC/wHtYmKKbh4Z+Fbsvhm0lqdXFXQAtW\r\nu+AOc2qhFW+6o6Js2rnBEEvC/QfD7+JGfVU=\r\n=1kHL\r\n-----END PGP SIGNATURE-----\r\n","size":5694,"noattachment":false,"key":"/load-plugin/-/load-plugin-5.1.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_5.1.0_1668962648524_0.15525878879568844"},"_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":1668962648676,"_cnpm_publish_time":1668962648676,"dist-tags":{"latest":"6.0.3"}}