@putout/plugin-nodejs 4.6.1 → 4.7.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.
@@ -55,7 +55,7 @@ module.exports.traverse = ({push, listStore}) => ({
55
55
  if (path.node.__putoutNodeDeclareAfterRequire)
56
56
  continue;
57
57
 
58
- if (path.node.declarations[0].id.name === 'require')
58
+ if (path.isVariableDeclaration() && path.node.declarations[0].id.name === 'require')
59
59
  continue;
60
60
 
61
61
  if (compareAny(path, REQUIRE_LIST)) {
@@ -117,6 +117,11 @@ function getReferenceLine(path) {
117
117
  if (!referencePaths.length)
118
118
  return Infinity;
119
119
 
120
- return referencePaths[0].node.loc.start.line;
120
+ const [firstReference] = referencePaths;
121
+
122
+ if (!firstReference.node.loc)
123
+ return -1;
124
+
125
+ return firstReference.node.loc.start.line;
121
126
  }
122
127
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-nodejs",
3
- "version": "4.6.1",
3
+ "version": "4.7.0",
4
4
  "type": "commonjs",
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",
@@ -31,6 +31,7 @@
31
31
  "nodejs"
32
32
  ],
33
33
  "devDependencies": {
34
+ "@putout/plugin-convert-commonjs-to-esm": "^9.0.0",
34
35
  "@putout/plugin-convert-esm-to-commonjs": "*",
35
36
  "@putout/plugin-putout": "*",
36
37
  "@putout/test": "^5.0.0",