@putout/plugin-nodejs 18.12.0 β†’ 18.13.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
@@ -380,6 +380,8 @@ const args = minimist({
380
380
 
381
381
  ### exports
382
382
 
383
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/39dd730c35e488db3e2cf8d4b4df0c5a/feb042a49539e6b4b2165558a1c636b705726c47).
384
+
383
385
  ### ❌ Example of incorrect code
384
386
 
385
387
  ```js
@@ -5,7 +5,6 @@ import {
5
5
  } from 'putout';
6
6
 
7
7
  const {
8
- arrowFunctionExpression,
9
8
  exportSpecifier,
10
9
  isIdentifier,
11
10
  isImportSpecifier,
@@ -16,10 +15,11 @@ const {
16
15
  exportNamespaceSpecifier,
17
16
  isSpreadElement,
18
17
  isObjectMethod,
18
+ isFunction,
19
19
  } = types;
20
20
 
21
21
  const {replaceWith} = operator;
22
- const createFn = template('export const NAME = BODY');
22
+ const createFn = template('export const NAME = (PARAMS) => BODY');
23
23
 
24
24
  export const report = () => `Use 'ESM' instead of 'CommonJS'`;
25
25
 
@@ -78,11 +78,29 @@ export const replace = () => ({
78
78
  const {key, value} = property;
79
79
 
80
80
  if (isObjectMethod(property)) {
81
+ const {params, body} = property;
82
+
81
83
  declareFunction({
82
84
  object: __a,
83
85
  property,
84
86
  index,
85
87
  programPath,
88
+ params,
89
+ body,
90
+ });
91
+ continue;
92
+ }
93
+
94
+ if (isFunction(value)) {
95
+ const {params, body} = property.value;
96
+
97
+ declareFunction({
98
+ object: __a,
99
+ property,
100
+ index,
101
+ programPath,
102
+ params,
103
+ body,
86
104
  });
87
105
  continue;
88
106
  }
@@ -163,11 +181,12 @@ function parseBindingPath(path) {
163
181
  return path;
164
182
  }
165
183
 
166
- function declareFunction({index, property, object, programPath}) {
167
- const {key, body} = property;
184
+ function declareFunction({index, property, object, params, body, programPath}) {
185
+ const {key} = property;
168
186
  const fnNode = createFn({
169
187
  NAME: key,
170
- BODY: arrowFunctionExpression([], body),
188
+ PARAMS: params,
189
+ BODY: body,
171
190
  });
172
191
 
173
192
  delete object.properties[index];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-nodejs",
3
- "version": "18.12.0",
3
+ "version": "18.13.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",