{"name":"@putout/engine-loader","version":"15.0.1","type":"commonjs","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"load plugins and prepare them to run","homepage":"https://github.com/coderaiser/putout/tree/master/packages/engine-loader#readme","main":"lib/index.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git+https://github.com/coderaiser/putout.git"},"scripts":{"test":"madrun test","watch:test":"madrun watch:test","lint":"madrun lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","fix:lint":"madrun fix:lint","coverage":"madrun coverage","report":"madrun report"},"dependencies":{"diff-match-patch":"^1.0.4","nano-memoize":"^3.0.11","once":"^1.4.0","try-catch":"^3.0.0","try-to-catch":"^3.0.1"},"keywords":["putout","putout-engine","loader"],"peerDependencies":{"putout":"*"},"devDependencies":{"@putout/formatter-progress":"*","@putout/plugin-apply-nullish-coalescing":"*","@putout/plugin-convert-commonjs-to-esm":"*","@putout/plugin-nodejs":"*","@putout/plugin-remove-unused-variables":"*","@putout/processor-javascript":"*","@putout/processor-markdown":"*","c8":"^10.0.0","eslint":"^9.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^23.0.0","estrace":"*","just-camel-case":"^6.2.0","lerna":"^6.0.1","madrun":"^10.0.0","mock-require":"^3.0.3","montag":"^1.0.0","nodemon":"^3.0.1","putout":"*","supertape":"^10.0.0"},"license":"MIT","engines":{"node":">=18"},"publishConfig":{"access":"public"},"_id":"@putout/engine-loader@15.0.1","gitHead":"8f15b758e62cb84eba3d4702f65c3aeb60cf235c","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"22.8.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-97D0zOtjXVvAovMalaSqeXRsAKMQJW+NipOJjQnBL6Za7GBwlEejrgEdZj2Ke/FfUfIBKc7oQ91tZEZwgwh/hg==","shasum":"e3912e38f7282a0cce4db02b08e802e86fc80293","tarball":"http://registry-npm.ywwl.com/@putout/engine-loader/download/@putout/engine-loader-15.0.1.tgz","fileCount":19,"unpackedSize":25452,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDQzWZQlZek2cEY0sGlzkqhgmw5bQfRXmFrDDMsVKV16AIhANPgMC3sliPVMHGOfYl2Zay4ZWYaopi2Ugxcbl7o8uK+"}],"size":7157,"noattachment":false,"key":"/@putout/engine-loader/-/@putout/engine-loader-15.0.1.tgz"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/engine-loader_15.0.1_1729948502366_0.5160124197386149"},"_hasShrinkwrap":false,"readme":"# @putout/engine-loader [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/engine-loader.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/engine-loader\"npm\"\n\n🐊[**Putout**](https://github.com/coderaiser/putout) loader for `plugins` and `processors`.\n\n## Install\n\n```\nnpm i @putout/engine-loader\n```\n\n## Plugins\n\nLoader supports two kinds of plugins:\n\n- ☝️ [**Simple**](#simple-plugin)\n- ☝️ [**Nested**](#nested-plugin)\n\n### Simple Plugin\n\nSimplest type of plugin support by [`@putout/engine-runner`](https://github.com/coderaiser/putout/tree/master/packages/engine-runner#supported-plugin-types), contains one rule.\n\n### Nested Plugin\n\nNested contains one or more rules:\n\n```js\nmodule.exports.rules = {\n    'remove-unused-variables': require('@putout/plugin-remove-unused-variables'),\n};\n```\n\nWhen you want to make it disabled by default, use:\n\n```js\nmodule.exports.rules = {\n    'remove-unused-variables': ['off', require('@putout/plugin-remove-unused-variables')],\n};\n```\n\nSo when someone using your plugin, he needs to enable it:\n\n```json\n{\n    \"rules\": {\n        \"nested/remove-unused-variables\": \"on\"\n    },\n    \"plugins\": [\"nested\"]\n}\n```\n\n## Env Variables\n\nWhen you need to get things working with Yarn OnP, and using custom `plugins` `formatters` or `processors`, add env variable\n`PUTOUT_YARN_PNP` with name of a package that contains dependencies you need.\n\n## API\n\n### loadPlugins\n\n```js\nconst {loadPlugins} = require('@putout/engine-loader');\n\nconst pluginNames = [\n    'remove-unusede-variables',\n];\n\nconst rules = {\n    'remove-unused-variables': 'on',\n};\n\nconst plugins = loadPlugins({\n    cache: true, //default\n    pluginNames,\n    rules,\n});\n```\n\n#### `import`\n\nYou can also use schema like this one:\n\n```\nimport:escover/plugin\n```\n\n```js\nconst plugins = loadPlugins({\n    pluginNames: [\n        'import:commonjs-putout-plugin',\n    ],\n});\n```\n\n### loadPluginsAsync\n\nLoad **ESM** plugins:\n\n```js\nconst {loadPluginsAsync} = require('@putout/engine-loader');\n\nconst pluginNames = [\n    'remove-unusede-variables',\n];\n\nconst rules = {\n    'remove-unused-variables': 'on',\n};\n\nconst plugins = await loadPluginsAsync({\n    cache: true, //default\n    pluginNames,\n    rules,\n});\n```\n\n#### `import`\n\nYou can also use schema like this one:\n\n```\nimport:escover/plugin\n```\n\n```js\nconst plugins = await loadPluginsAsync({\n    pluginNames: [\n        'import:escover/plugin',\n    ],\n});\n```\n\nOr when used `putoutAsync`:\n\n```js\nimport {putoutAsync} from 'putout';\n\nawait putoutAsync(`module.exports.hello = 'world'`, {\n    plugins: [\n        'import:escover/plugin',\n    ],\n});\n```\n\nWhich is the same as:\n\n```js\nimport {putoutAsync} from 'putout';\nimport * as plugin from 'escover/plugin';\n\nawait putoutAsync(`module.exports.hello = 'world'`, {\n    plugins: [\n        ['escover/plugin', plugin],\n    ],\n});\n```\n\nOr used inside `.putout.json`:\n\n```json\n{\n    \"plugins\": [\n        \"import:escover/plugin\"\n    ]\n}\n```\n\n### loadProcessorsAsync\n\n```js\nconst {loadProcessors} = require('@putout/engine-loader');\nconst optionalLoad = async (a) => await import(a);\n\nconst plugins = await loadProcessorsAsync({\n    processors: [\n        ['javascript', 'on'],\n        ['markdown', 'off'],\n    ],\n}, optionalLoad);\n```\n\n### createAsyncLoader\n\nGives ability to create loader for `processor` or `formatter`.\n\n```js\nconst {createAsyncLoader} = require('@putout/engine-loader');\nconst {loadProcessor} = createAsyncLoader('processor');\n\n// load @putout/processor-markdown\nawait loadProcessors('markdown');\n// load @putout/processor-json using custom loader\nawait loadProcess('json', () => {\n    return Promise.resolve(`will be called instead of 'import'`);\n});\n```\n\n### validateRules\n\n```js\nconst {validateRules} = require('@putout/engine-loader');\n\nconst pluginNames = [];\nconst rules = {\n    'remove-unused-variables': 'on',\n};\n\nvalidateRules({\n    pluginNames,\n    rules,\n});\n\n// throws since there is no plugin name passed that matches rule 'remove-unused-variables'\n```\n\n## License\n\nMIT\n","publish_time":1729948502595,"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_cnpm_publish_time":1729948502595,"dist-tags":{"latest":"17.4.0"}}