@putout/plugin-nodejs 18.8.0 → 18.9.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.
|
@@ -8,7 +8,7 @@ const {
|
|
|
8
8
|
isObjectExpression,
|
|
9
9
|
isStringLiteral,
|
|
10
10
|
isImportDefaultSpecifier,
|
|
11
|
-
|
|
11
|
+
exportNamespaceSpecifier,
|
|
12
12
|
} = types;
|
|
13
13
|
|
|
14
14
|
const {replaceWith} = operator;
|
|
@@ -107,7 +107,11 @@ function addExportToBinding(name, path) {
|
|
|
107
107
|
if (isImportDefaultSpecifier(bindingPath)) {
|
|
108
108
|
const {local} = bindingPath.node;
|
|
109
109
|
const {source} = bindingPath.parentPath.node;
|
|
110
|
-
const
|
|
110
|
+
const specifiers = [
|
|
111
|
+
exportNamespaceSpecifier(local),
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
const exportNode = exportNamedDeclaration(null, specifiers, source);
|
|
111
115
|
|
|
112
116
|
replaceWith(bindingPath.parentPath, exportNode);
|
|
113
117
|
return '';
|
|
@@ -39,6 +39,12 @@ const createFnDeclaration = template('const NAME1 = FN(NAME2)');
|
|
|
39
39
|
const isPackage = ({value}) => /package(\.json)?$/.test(value);
|
|
40
40
|
|
|
41
41
|
export const match = () => ({
|
|
42
|
+
'export const __a = require("__b")': ({__a}, path) => {
|
|
43
|
+
if (!isIdentifier(__a))
|
|
44
|
+
return true;
|
|
45
|
+
|
|
46
|
+
return path.scope.bindings[__a.name].references === 1;
|
|
47
|
+
},
|
|
42
48
|
'const __a = require("__b").default': (vars, path) => {
|
|
43
49
|
if (isProgram(path.parentPath))
|
|
44
50
|
return true;
|
|
@@ -159,6 +165,12 @@ export const replace = () => ({
|
|
|
159
165
|
const __a = ${name}.__c(__args);
|
|
160
166
|
}`;
|
|
161
167
|
},
|
|
168
|
+
'export const __a = require("__b")': ({__a}) => {
|
|
169
|
+
if (isObjectPattern(__a))
|
|
170
|
+
return 'export __a from "__b"';
|
|
171
|
+
|
|
172
|
+
return 'export * as __a from "__b"';
|
|
173
|
+
},
|
|
162
174
|
});
|
|
163
175
|
|
|
164
176
|
function checkCall({__b}, path) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-nodejs",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.9.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",
|