@putout/engine-loader 9.2.1 → 11.0.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 +1 -1
- package/lib/async-loader.js +1 -4
- package/lib/build-paths.js +1 -3
- package/lib/index.js +4 -16
- package/lib/parse-rules.js +2 -10
- package/lib/transforms/babel.js +5 -5
- package/lib/wrap-plugin.js +8 -3
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ module.exports.rules = {
|
|
|
34
34
|
|
|
35
35
|
## Env Variables
|
|
36
36
|
|
|
37
|
-
When you need to get things working with Yarn PnP, and using custom `plugins` `formatters` or `
|
|
37
|
+
When you need to get things working with Yarn PnP, and using custom `plugins` `formatters` or `processors`, add env variable
|
|
38
38
|
`PUTOUT_YARN_PNP` with name of a package that contains dependencies you need.
|
|
39
39
|
|
|
40
40
|
## API
|
package/lib/async-loader.js
CHANGED
|
@@ -10,10 +10,7 @@ module.exports.createAsyncLoader = (type) => async (name, load) => {
|
|
|
10
10
|
if (name === 'none')
|
|
11
11
|
return stub();
|
|
12
12
|
|
|
13
|
-
const [e, reporter] = await cleverLoad([
|
|
14
|
-
`@putout/${type}-${name}`,
|
|
15
|
-
`putout-${type}-${name}`,
|
|
16
|
-
], load);
|
|
13
|
+
const [e, reporter] = await cleverLoad([`@putout/${type}-${name}`, `putout-${type}-${name}`], load);
|
|
17
14
|
|
|
18
15
|
if (e)
|
|
19
16
|
throw e;
|
package/lib/build-paths.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -21,10 +21,7 @@ const mergeRules = ([rule, plugin], rules) => {
|
|
|
21
21
|
if (currentRule.rule !== rule)
|
|
22
22
|
continue;
|
|
23
23
|
|
|
24
|
-
const {
|
|
25
|
-
msg,
|
|
26
|
-
options,
|
|
27
|
-
} = currentRule;
|
|
24
|
+
const {msg, options} = currentRule;
|
|
28
25
|
|
|
29
26
|
return {
|
|
30
27
|
rule,
|
|
@@ -127,15 +124,9 @@ function splitRule(rule) {
|
|
|
127
124
|
const name = rule.replace('babel/', '');
|
|
128
125
|
|
|
129
126
|
if (rule.startsWith('babel'))
|
|
130
|
-
return [
|
|
131
|
-
name,
|
|
132
|
-
'babel',
|
|
133
|
-
];
|
|
127
|
+
return [name, 'babel'];
|
|
134
128
|
|
|
135
|
-
return [
|
|
136
|
-
name,
|
|
137
|
-
'putout',
|
|
138
|
-
];
|
|
129
|
+
return [name, 'putout'];
|
|
139
130
|
}
|
|
140
131
|
|
|
141
132
|
function loadPlugins({items, loadedRules}) {
|
|
@@ -177,10 +168,7 @@ function extendRules(rule, plugin) {
|
|
|
177
168
|
const entries = Object.entries(plugin);
|
|
178
169
|
|
|
179
170
|
for (const [name, plugin] of entries) {
|
|
180
|
-
result.push([
|
|
181
|
-
`${rule}/${name}`,
|
|
182
|
-
plugin,
|
|
183
|
-
]);
|
|
171
|
+
result.push([`${rule}/${name}`, plugin]);
|
|
184
172
|
}
|
|
185
173
|
|
|
186
174
|
return result;
|
package/lib/parse-rules.js
CHANGED
|
@@ -67,11 +67,7 @@ function parseArray(rule, args) {
|
|
|
67
67
|
const state = parseState(rule, rawState);
|
|
68
68
|
|
|
69
69
|
if (args.length === 3) {
|
|
70
|
-
const [
|
|
71
|
-
,
|
|
72
|
-
msg,
|
|
73
|
-
options,
|
|
74
|
-
] = args;
|
|
70
|
+
const [, msg, options] = args;
|
|
75
71
|
|
|
76
72
|
return {
|
|
77
73
|
rule,
|
|
@@ -82,11 +78,7 @@ function parseArray(rule, args) {
|
|
|
82
78
|
};
|
|
83
79
|
}
|
|
84
80
|
|
|
85
|
-
const [
|
|
86
|
-
,
|
|
87
|
-
msg = '',
|
|
88
|
-
options = defaultOptions(),
|
|
89
|
-
] = args;
|
|
81
|
+
const [, msg = '', options = defaultOptions()] = args;
|
|
90
82
|
|
|
91
83
|
if (args.length === 2 && !isStr(msg)) {
|
|
92
84
|
return {
|
package/lib/transforms/babel.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
|
-
|
|
4
|
+
createConfigItemSync,
|
|
5
5
|
transformFromAstSync,
|
|
6
6
|
} = require('@babel/core');
|
|
7
7
|
|
|
@@ -10,12 +10,12 @@ const isString = (a) => typeof a === 'string';
|
|
|
10
10
|
module.exports = (ast, code, name) => {
|
|
11
11
|
const plugin = !isString(name) ? name : require(name);
|
|
12
12
|
|
|
13
|
+
// globally installed modules support
|
|
14
|
+
const configItem = createConfigItemSync(plugin);
|
|
15
|
+
|
|
13
16
|
transformFromAstSync(ast, code, {
|
|
14
17
|
cloneInputAst: false,
|
|
15
|
-
plugins: [
|
|
16
|
-
// globally installed modules support
|
|
17
|
-
createConfigItem(plugin),
|
|
18
|
-
],
|
|
18
|
+
plugins: [configItem],
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
return ast;
|
package/lib/wrap-plugin.js
CHANGED
|
@@ -32,11 +32,16 @@ module.exports = (name, namespace) => {
|
|
|
32
32
|
const getPlugin = ({name, transform, message}) => ({
|
|
33
33
|
report: () => message,
|
|
34
34
|
fix: () => {},
|
|
35
|
-
|
|
36
35
|
find(ast, {push}) {
|
|
37
|
-
const oldCode = print(ast
|
|
36
|
+
const oldCode = print(ast, {
|
|
37
|
+
printer: 'putout',
|
|
38
|
+
});
|
|
39
|
+
|
|
38
40
|
transform(ast, oldCode, name);
|
|
39
|
-
|
|
41
|
+
|
|
42
|
+
const newCode = print(ast, {
|
|
43
|
+
printer: 'putout',
|
|
44
|
+
});
|
|
40
45
|
|
|
41
46
|
if (newCode === oldCode)
|
|
42
47
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/engine-loader",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "load plugins and prepare them to run",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"report": "madrun report"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@babel/core": "^
|
|
28
|
-
"@putout/engine-parser": "^
|
|
27
|
+
"@babel/core": "^8.0.0-alpha.1",
|
|
28
|
+
"@putout/engine-parser": "^7.1.0",
|
|
29
29
|
"diff-match-patch": "^1.0.4",
|
|
30
30
|
"nano-memoize": "^3.0.11",
|
|
31
31
|
"once": "^1.4.0",
|
|
@@ -49,17 +49,17 @@
|
|
|
49
49
|
"@putout/processor-markdown": "*",
|
|
50
50
|
"babel-plugin-angularjs-annotate": "https://github.com/putoutjs/babel-plugin-angularjs-annotate",
|
|
51
51
|
"babel-plugin-transform-inline-consecutive-adds": "^0.4.3",
|
|
52
|
-
"c8": "^
|
|
52
|
+
"c8": "^8.0.0",
|
|
53
53
|
"eslint": "^8.0.1",
|
|
54
54
|
"eslint-plugin-n": "^16.0.0",
|
|
55
|
-
"eslint-plugin-putout": "^
|
|
55
|
+
"eslint-plugin-putout": "^19.0.0",
|
|
56
56
|
"estrace": "*",
|
|
57
57
|
"just-camel-case": "^4.0.2",
|
|
58
58
|
"lerna": "^6.0.1",
|
|
59
59
|
"madrun": "^9.0.0",
|
|
60
60
|
"mock-require": "^3.0.3",
|
|
61
61
|
"montag": "^1.0.0",
|
|
62
|
-
"nodemon": "^
|
|
62
|
+
"nodemon": "^3.0.1",
|
|
63
63
|
"putout": "*",
|
|
64
64
|
"supertape": "^8.0.0"
|
|
65
65
|
},
|