@putout/engine-loader 17.1.2 → 17.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @putout/engine-loader [![NPM version][NPMIMGURL]][NPMURL]
|
|
2
2
|
|
|
3
3
|
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/engine-loader.svg?style=flat&longCache=true
|
|
4
|
-
[NPMURL]: https://npmjs.org/package/@putout/engine-loader"npm"
|
|
4
|
+
[NPMURL]: https://npmjs.org/package/@putout/engine-loader "npm"
|
|
5
5
|
|
|
6
6
|
🐊[**Putout**](https://github.com/coderaiser/putout) loader for `plugins` and `processors`.
|
|
7
7
|
|
|
@@ -11,7 +11,11 @@ const loadPluginAsync = createAsyncLoader('plugin');
|
|
|
11
11
|
export const loadPluginsAsync = async (options) => {
|
|
12
12
|
check(options);
|
|
13
13
|
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
pluginNames = [],
|
|
16
|
+
rules = {},
|
|
17
|
+
} = options;
|
|
18
|
+
|
|
15
19
|
const {
|
|
16
20
|
items,
|
|
17
21
|
loadedRules,
|
|
@@ -34,9 +38,15 @@ export const loadPluginsAsync = async (options) => {
|
|
|
34
38
|
|
|
35
39
|
const splitRule = (rule) => [rule, 'putout'];
|
|
36
40
|
|
|
41
|
+
// The reason we don't use 'Promise.all' here:
|
|
42
|
+
//
|
|
43
|
+
// Error [ERR_INTERNAL_ASSERTION]: @putout/plugin-apply-at: Unexpected module status 0. Cannot require() ES Module /Users/coderaiser/putout/packages/engine-parser/lib/parser.js because it is not yet fully loaded.
|
|
44
|
+
// This may be caused by a race condition if the module is simultaneously dynamically import()-ed via Promise.all().
|
|
45
|
+
// Try await-ing the import() sequentially in a loop instead.
|
|
46
|
+
// (From /Users/coderaiser/putout/packages/putout/lib/index.cjs in non-loader-hook thread)
|
|
37
47
|
async function loadPlugins({items, loadedRules}) {
|
|
38
|
-
const promises = [];
|
|
39
48
|
const enabledRules = [];
|
|
49
|
+
const resolvedPlugins = [];
|
|
40
50
|
|
|
41
51
|
for (const [rule, itemPlugin] of items) {
|
|
42
52
|
if (!isEnabled(rule, loadedRules))
|
|
@@ -45,13 +55,12 @@ async function loadPlugins({items, loadedRules}) {
|
|
|
45
55
|
checkRule(rule);
|
|
46
56
|
|
|
47
57
|
const [name] = splitRule(rule);
|
|
48
|
-
const plugin = itemPlugin || loadPluginAsync(name);
|
|
58
|
+
const plugin = itemPlugin || await loadPluginAsync(name);
|
|
49
59
|
|
|
50
60
|
enabledRules.push(parseRuleName(rule));
|
|
51
|
-
|
|
61
|
+
resolvedPlugins.push(plugin);
|
|
52
62
|
}
|
|
53
63
|
|
|
54
|
-
const resolvedPlugins = await Promise.all(promises);
|
|
55
64
|
const plugins = [];
|
|
56
65
|
|
|
57
66
|
for (const [i, rule] of enabledRules.entries()) {
|
|
@@ -10,7 +10,11 @@ const {isArray} = Array;
|
|
|
10
10
|
export const loadPlugins = (options) => {
|
|
11
11
|
check(options);
|
|
12
12
|
|
|
13
|
-
const {
|
|
13
|
+
const {
|
|
14
|
+
pluginNames = [],
|
|
15
|
+
rules = {},
|
|
16
|
+
} = options;
|
|
17
|
+
|
|
14
18
|
const {
|
|
15
19
|
items,
|
|
16
20
|
loadedRules,
|
|
@@ -43,10 +47,11 @@ function loadAllPlugins({items, loadedRules}) {
|
|
|
43
47
|
const plugins = [];
|
|
44
48
|
|
|
45
49
|
for (const [rule, itemPlugin] of items) {
|
|
50
|
+
checkRule(rule);
|
|
51
|
+
|
|
46
52
|
if (!isEnabled(rule, loadedRules))
|
|
47
53
|
continue;
|
|
48
54
|
|
|
49
|
-
checkRule(rule);
|
|
50
55
|
const parsedRule = parseRule(rule);
|
|
51
56
|
|
|
52
57
|
const [name, namespace] = splitRule(rule);
|
|
@@ -5,7 +5,11 @@ import {check} from '../check/index.js';
|
|
|
5
5
|
export const validateRulesRelations = (options) => {
|
|
6
6
|
check(options);
|
|
7
7
|
|
|
8
|
-
const {
|
|
8
|
+
const {
|
|
9
|
+
pluginNames = [],
|
|
10
|
+
rules = {},
|
|
11
|
+
} = options;
|
|
12
|
+
|
|
9
13
|
const items = parsePluginNames(pluginNames);
|
|
10
14
|
|
|
11
15
|
validateRules({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/engine-loader",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "load plugins and prepare them to run",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"putout": "*"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@putout/eslint-flat": "^
|
|
40
|
+
"@putout/eslint-flat": "^4.0.0",
|
|
41
41
|
"@putout/formatter-progress": "*",
|
|
42
42
|
"@putout/plugin-apply-nullish-coalescing": "*",
|
|
43
43
|
"@putout/plugin-nodejs": "*",
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"@putout/processor-markdown": "*",
|
|
47
47
|
"@putout/test": "^15.0.0",
|
|
48
48
|
"c8": "^10.0.0",
|
|
49
|
-
"eslint": "^10.0.0
|
|
49
|
+
"eslint": "^10.0.0",
|
|
50
50
|
"eslint-plugin-n": "^17.0.0",
|
|
51
|
-
"eslint-plugin-putout": "^
|
|
51
|
+
"eslint-plugin-putout": "^31.0.0",
|
|
52
52
|
"estrace": "^6.0.0",
|
|
53
53
|
"just-camel-case": "^6.2.0",
|
|
54
|
-
"madrun": "^
|
|
54
|
+
"madrun": "^13.0.0",
|
|
55
55
|
"montag": "^1.0.0",
|
|
56
56
|
"nodemon": "^3.0.1",
|
|
57
57
|
"putout": "*",
|