@putout/plugin-nodejs 18.8.1 → 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.
@@ -110,6 +110,7 @@ function addExportToBinding(name, path) {
110
110
  const specifiers = [
111
111
  exportNamespaceSpecifier(local),
112
112
  ];
113
+
113
114
  const exportNode = exportNamedDeclaration(null, specifiers, source);
114
115
 
115
116
  replaceWith(bindingPath.parentPath, exportNode);
@@ -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.8.1",
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",