{"name":"@putout/engine-loader","version":"15.1.0","keywords":["putout","putout-engine","loader"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"@putout/engine-loader@15.1.0","homepage":"https://github.com/coderaiser/putout/tree/master/packages/engine-loader#readme","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"tag":false,"dist":{"shasum":"e143e6f6fa34ad8057ccf7c67df7fb15b53f91b9","tarball":"http://registry-npm.ywwl.com/@putout/engine-loader/download/@putout/engine-loader-15.1.0.tgz","fileCount":19,"integrity":"sha512-kAgHiahRW+MRxLq9bvioFgeQoux2SvBQrhK8zaIvZEzINDZ/cjxAYUaeSgjqIkQhr+B4Bwm6Zf80csi7YBvOxQ==","signatures":[{"sig":"MEQCIHIzlczC4kuZmnslf4CkFTw8qjXXREQ6bcLu/1UN/3PUAiA9ggjkqxUSYkqLogD2jTdxz5Do9G3qMhkXCnUU1TH7Ag==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25408,"size":7166,"noattachment":false,"key":"/@putout/engine-loader/-/@putout/engine-loader-15.1.0.tgz"},"main":"lib/index.js","type":"commonjs","engines":{"node":">=18"},"gitHead":"8dc96c98e574f86afae675b96a772d4c206ffcb0","release":false,"scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","coverage":"madrun coverage","fix:lint":"madrun fix:lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:test":"madrun watch:test"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"changelog":false,"repository":{"url":"git+https://github.com/coderaiser/putout.git","type":"git"},"_npmVersion":"10.9.0","description":"load plugins and prepare them to run","directories":{},"_nodeVersion":"22.13.0","dependencies":{"once":"^1.4.0","try-catch":"^3.0.0","nano-memoize":"^3.0.11","try-to-catch":"^3.0.1","diff-match-patch":"^1.0.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","lerna":"^6.0.1","eslint":"^9.0.0","madrun":"^10.0.0","montag":"^1.0.0","putout":"*","estrace":"*","nodemon":"^3.0.1","supertape":"^10.0.0","mock-require":"^3.0.3","eslint-plugin-n":"^17.0.0","just-camel-case":"^6.2.0","eslint-plugin-putout":"^23.0.0","@putout/plugin-nodejs":"*","@putout/formatter-progress":"*","@putout/processor-markdown":"*","@putout/processor-javascript":"*","@putout/plugin-convert-commonjs-to-esm":"*","@putout/plugin-remove-unused-variables":"*","@putout/plugin-apply-nullish-coalescing":"*"},"peerDependencies":{"putout":"*"},"_npmOperationalInternal":{"tmp":"tmp/engine-loader_15.1.0_1737205753533_0.07825273227565854","host":"s3://npm-registry-packages-npm-production"},"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\nIf you want to load from custom directory (for Visual Studio Code Extension, for example) use `PUTOUT_LOAD_DIR`.\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    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    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":1737205753761,"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_cnpm_publish_time":1737205753761,"dist-tags":{"latest":"17.4.0"}}