{"name":"@putout/engine-loader","version":"17.0.9","keywords":["putout","putout-engine","loader"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"@putout/engine-loader@17.0.9","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"https://github.com/coderaiser/putout/tree/master/packages/engine-loader#readme","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"tag":false,"dist":{"shasum":"85fe388027ca4cc5d7d11c0b1f5037bc5a156334","tarball":"http://registry-npm.ywwl.com/@putout/engine-loader/download/@putout/engine-loader-17.0.9.tgz","fileCount":24,"integrity":"sha512-OkDo6oQ4qOTGrKD2bMNfVa2Ljl7pLuXSpKlI7NJ1DliQZ055N2G20d8I0bYjX97WX0oHXnUuSdcBE2bl4yhFtA==","signatures":[{"sig":"MEQCIH5tHSTkOTgucqC5BemtV8liISS6+zABnNo8ejq0nKNoAiAwqEx1a3N0ngnPPCxfktr7ZEnawk6WCwuLnw8dQpH7lA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":28800,"size":8010,"noattachment":false,"key":"/@putout/engine-loader/-/@putout/engine-loader-17.0.9.tgz"},"main":"lib/index.js","type":"module","engines":{"node":">=22"},"gitHead":"22874d53a5defef5962d491c8f2a376d8d4e4373","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":"11.4.2","description":"load plugins and prepare them to run","directories":{},"_nodeVersion":"25.2.1","dependencies":{"try-catch":"^4.0.0","nano-memoize":"^3.0.16","try-to-catch":"^4.0.0","diff-match-patch":"^1.0.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","eslint":"^10.0.0-alpha.0","madrun":"^12.0.0","montag":"^1.0.0","putout":"*","estrace":"^6.0.0","nodemon":"^3.0.1","supertape":"^11.0.3","@putout/test":"^15.0.0","eslint-plugin-n":"^17.0.0","just-camel-case":"^6.2.0","@putout/eslint-flat":"^3.0.0","eslint-plugin-putout":"^29.0.0","@putout/plugin-nodejs":"*","@putout/formatter-progress":"*","@putout/processor-markdown":"*","@putout/processor-javascript":"*","@putout/plugin-remove-debugger":"*","@putout/plugin-apply-nullish-coalescing":"*"},"peerDependencies":{"putout":"*"},"_npmOperationalInternal":{"tmp":"tmp/engine-loader_17.0.9_1767443747921_0.14520445398769466","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\nimport * as removeDebugger from '@putout/plugin-remove-debugger';\n\nexport const rules = {\n    'remove-debugger': removeDebugger,\n};\n```\n\nWhen you want to make it disabled by default, use:\n\n```js\nimport * as removeDebugger from '@putout/plugin-remove-debugger';\n\nexport const rules = {\n    'remove-debugger': ['off', removeDebugger],\n};\n```\n\nSo when someone using your plugin, he needs to enable it:\n\n```json\n{\n    \"rules\": {\n        \"nested/remove-debugger\": \"on\"\n    },\n    \"plugins\": [\"nested\"]\n}\n```\n\n## Env Variables\n\nWhen you need to get things working with Yarn P'n'P, and using custom `plugins` `formatters` or `processors`, add env variable `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\nimport {loadPlugins} from '@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\nimport {loadPluginsAsync} from '@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\nimport {loadProcessors} from '@putout/engine-loader';\n\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\nimport {createAsyncLoader} from '@putout/engine-loader';\n\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\nimport {validateRules} from '@putout/engine-loader';\n\nconst pluginNames = [];\nconst rules = {\n    'remove-unused-variables': 'on',\n};\n\n// throws since there is no plugin name passed that matches rule 'remove-unused-variables'\nvalidateRules({\n    pluginNames,\n    rules,\n});\n```\n\n## License\n\nMIT\n","publish_time":1767443748084,"_cnpm_publish_time":1767443748084,"dist-tags":{"latest":"17.4.0"}}