@putout/plugin-nodejs 17.5.0 → 17.6.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/lib/group-require-by-id/index.js +34 -39
- package/package.json +1 -1
|
@@ -30,50 +30,45 @@ export const fix = ({grouped}) => {
|
|
|
30
30
|
replaceWithMultiple(first, nodes);
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
export const traverse = ({
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
export const traverse = ({push}) => ({
|
|
34
|
+
Program(path) {
|
|
35
|
+
const external = [];
|
|
36
|
+
const internal = [];
|
|
37
|
+
const builtin = [];
|
|
38
|
+
const all = path.get('body').filter(compareWithRequire);
|
|
39
|
+
|
|
40
|
+
if (!all.length)
|
|
36
41
|
return;
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
exit(path) {
|
|
42
|
-
const external = [];
|
|
43
|
-
const internal = [];
|
|
44
|
-
const builtin = [];
|
|
45
|
-
const all = pathStore().filter(compareWithRequire);
|
|
43
|
+
for (const current of all) {
|
|
44
|
+
const [declaration] = current.node.declarations;
|
|
45
|
+
const {value} = declaration.init.arguments[0];
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!value || value.startsWith('.')) {
|
|
52
|
-
internal.push(current);
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (value.startsWith('node:')) {
|
|
57
|
-
builtin.push(current);
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
external.push(current);
|
|
47
|
+
if (!value || value.startsWith('.')) {
|
|
48
|
+
internal.push(current);
|
|
49
|
+
continue;
|
|
62
50
|
}
|
|
63
51
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
if (isDeepStrictEqual(all, grouped))
|
|
71
|
-
return;
|
|
52
|
+
if (value.startsWith('node:')) {
|
|
53
|
+
builtin.push(current);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
72
56
|
|
|
73
|
-
push(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
57
|
+
external.push(current);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const grouped = [
|
|
61
|
+
...builtin,
|
|
62
|
+
...external,
|
|
63
|
+
...internal,
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
if (isDeepStrictEqual(all, grouped))
|
|
67
|
+
return;
|
|
68
|
+
|
|
69
|
+
push({
|
|
70
|
+
path,
|
|
71
|
+
grouped,
|
|
72
|
+
});
|
|
78
73
|
},
|
|
79
74
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-nodejs",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout plugin adds ability to transform code to new API of Node.js",
|