@putout/engine-loader
load plugins and prepare them to run
Last updated 4 years ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @putout/engine-loader 
SYNC missed versions from official npm registry.

@putout/engine-loader NPM version

🐊Putout loader for plugins and processors.

Install

npm i @putout/engine-loader

Plugins

Loader supports two kinds of plugins:

Simple Plugin

Simplest type of plugin support by @putout/engine-runner, contains one rule.

Nested Plugin

Nested contains one or more rules:

module.exports.rules = {
    'remove-unused-variables': require('@putout/plugin-remove-unused-variables'),
};

When you want to make it disabled by default, use:

module.exports.rules = {
    'remove-unused-variables': ['off', require('@putout/plugin-remove-unused-variables')],
};

So when someone using your plugin, he needs to enable it:

{
    "rules": {
        "nested/remove-unused-variables": "on"
    },
    "plugins": ["nested"]
}

Env Variables

When you need to get things working with Yarn PnP, and using custom plugins formatters or processors, add env variable PUTOUT_YARN_PNP with name of a package that contains dependencies you need.

API

loadPlugins

const {loadPlugins} = require('@putout/engine-loader');

const pluginNames = [
    'remove-unusede-variables',
];

const rules = {
    'remove-unused-variables': 'on',
};

const plugins = loadPlugins({
    cache: true, //default
    pluginNames,
    rules,
});

import

You can also use schema like this one:

import:escover/plugin
const plugins = loadPlugins({
    pluginNames: [
        'import:commonjs-putout-plugin',
    ],
});

loadPluginsAsync

Load ESM plugins:

const {loadPluginsAsync} = require('@putout/engine-loader');

const pluginNames = [
    'remove-unusede-variables',
];

const rules = {
    'remove-unused-variables': 'on',
};

const plugins = await loadPluginsAsync({
    cache: true, //default
    pluginNames,
    rules,
});

import

You can also use schema like this one:

import:escover/plugin
const plugins = await loadPluginsAsync({
    pluginNames: [
        'import:escover/plugin',
    ],
});

Or when used putoutAsync:

import {putoutAsync} from 'putout';

await putoutAsync(`module.exports.hello = 'world'`, {
    plugins: [
        'import:escover/plugin',
    ],
});

Which is the same as:

import {putoutAsync} from 'putout';
import * as plugin from 'escover/plugin';

await putoutAsync(`module.exports.hello = 'world'`, {
    plugins: [
        ['escover/plugin', plugin],
    ],
});

Or used inside .putout.json:

{
    "plugins": [
        "import:escover/plugin"
    ]
}

loadProcessorsAsync

const {loadProcessors} = require('@putout/engine-loader');
const optionalLoad = async (a) => await import(a);

const plugins = await loadProcessorsAsync({
    processors: [
        ['javascript', 'on'],
        ['markdown', 'off'],
    ],
}, optionalLoad);

createAsyncLoader

Gives ability to create loader for processor or formatter.

const {createAsyncLoader} = require('@putout/engine-loader');
const {loadProcessor} = createAsyncLoader('processor');

// load @putout/processor-markdown
await loadProcessors('markdown');
// load @putout/processor-json using custom loader
await loadProcess('json', () => {
    return Promise.resolve(`will be called instead of 'import'`);
});

License

MIT

Current Tags

  • 14.0.0                                ...           latest (3 months ago)

86 Versions

  • 14.0.0                                ...           3 months ago
  • 13.1.1                                ...           5 months ago
  • 13.1.0                                ...           6 months ago
  • 13.0.0                                ...           a year ago
  • 12.4.0                                ...           a year ago
  • 12.3.1                                ...           a year ago
  • 12.3.0                                ...           a year ago
  • 12.2.0                                ...           a year ago
  • 12.1.0                                ...           a year ago
  • 12.0.0                                ...           a year ago
  • 11.6.0                                ...           a year ago
  • 11.5.0                                ...           a year ago
  • 11.4.0                                ...           a year ago
  • 11.3.0                                ...           a year ago
  • 11.2.0                                ...           a year ago
  • 11.1.2                                ...           a year ago
  • 11.1.1                                ...           a year ago
  • 11.1.0                                ...           a year ago
  • 11.0.2                                ...           a year ago
  • 11.0.1                                ...           a year ago
  • 11.0.0                                ...           a year ago
  • 10.0.0                                ...           a year ago
  • 9.2.1                                ...           a year ago
  • 9.2.0                                ...           2 years ago
  • 9.1.0                                ...           2 years ago
  • 9.0.0                                ...           2 years ago
  • 8.1.0                                ...           2 years ago
  • 8.0.0                                ...           2 years ago
  • 7.2.0                                ...           2 years ago
  • 7.1.2                                ...           2 years ago
  • 7.1.1                                ...           2 years ago
  • 7.1.0                                ...           2 years ago
  • 7.0.1                                ...           3 years ago
  • 7.0.0                                ...           3 years ago
  • 6.0.1                                ...           3 years ago
  • 6.0.0                                ...           3 years ago
  • 5.1.0                                ...           3 years ago
  • 5.0.0                                ...           3 years ago
  • 4.12.0                                ...           3 years ago
  • 4.11.0                                ...           3 years ago
  • 4.10.0                                ...           3 years ago
  • 4.9.1                                ...           3 years ago
  • 4.9.0                                ...           3 years ago
  • 4.8.0                                ...           3 years ago
  • 4.7.0                                ...           3 years ago
  • 4.6.0                                ...           3 years ago
  • 4.5.0                                ...           3 years ago
  • 4.4.1                                ...           3 years ago
  • 4.4.0                                ...           3 years ago
  • 4.3.1                                ...           4 years ago
  • 4.3.0                                ...           4 years ago
  • 4.2.0                                ...           4 years ago
  • 4.1.1                                ...           4 years ago
  • 4.1.0                                ...           4 years ago
  • 4.0.0                                ...           4 years ago
  • 3.3.0                                ...           4 years ago
  • 3.2.1                                ...           4 years ago
  • 3.2.0                                ...           4 years ago
  • 3.1.1                                ...           4 years ago
  • 3.1.0                                ...           4 years ago
  • 3.0.2                                ...           4 years ago
  • 3.0.1                                ...           4 years ago
  • 3.0.0                                ...           4 years ago
  • 2.2.1                                ...           4 years ago
  • 2.2.0                                ...           4 years ago
  • 2.1.3                                ...           4 years ago
  • 2.1.2                                ...           4 years ago
  • 2.1.1                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.5.2                                ...           4 years ago
  • 1.5.1                                ...           4 years ago
  • 1.5.0                                ...           4 years ago
  • 1.4.0                                ...           5 years ago
  • 1.3.2                                ...           5 years ago
  • 1.3.1                                ...           5 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.5                                ...           5 years ago
  • 1.2.4                                ...           5 years ago
  • 1.2.3                                ...           5 years ago
  • 1.2.2                                ...           5 years ago
  • 1.2.1                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (7)

© 2010 - cnpmjs.org x YWFE | Home | YWFE