@putout/plugin-nodejs 13.1.1 → 14.0.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
|
@@ -415,7 +415,6 @@ const m = require(x);
|
|
|
415
415
|
const c = 5;
|
|
416
416
|
```
|
|
417
417
|
|
|
418
|
-
|
|
419
418
|
## convert-esm-to-commonjs
|
|
420
419
|
|
|
421
420
|
> **CommonJS** is a module system supported in Node, it provides a `require` function, which can be used to access the `exports` object exposed by another file.
|
|
@@ -73,9 +73,7 @@ module.exports.replace = () => ({
|
|
|
73
73
|
}`,
|
|
74
74
|
'require("__a")': 'import("__a")',
|
|
75
75
|
'const __a = require(__b)': ({__a}, path) => {
|
|
76
|
-
let {value} = path
|
|
77
|
-
.get(__B)
|
|
78
|
-
.evaluate();
|
|
76
|
+
let {value} = path.get(__B).evaluate();
|
|
79
77
|
|
|
80
78
|
if (value.includes('./') && !/\.m?js(on)?$/.test(value) && !value.endsWith('..'))
|
|
81
79
|
value += '.js';
|
|
@@ -20,18 +20,12 @@ module.exports.report = ({path}) => {
|
|
|
20
20
|
return `Declare '${id}' after last 'require()'`;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
module.exports.fix = ({path,
|
|
23
|
+
module.exports.fix = ({path, lastRequire}) => {
|
|
24
24
|
const {node} = path;
|
|
25
|
-
const {comments} = node;
|
|
26
25
|
|
|
27
26
|
delete node.loc;
|
|
28
27
|
node.__putoutNodeDeclareAfterRequire = true;
|
|
29
28
|
|
|
30
|
-
if (comments) {
|
|
31
|
-
firstRequire.node.comments = comments;
|
|
32
|
-
delete path.node.comments;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
29
|
remove(path);
|
|
36
30
|
insertAfter(lastRequire, node);
|
|
37
31
|
};
|
|
@@ -31,13 +31,6 @@ module.exports.traverse = ({push, store}) => ({
|
|
|
31
31
|
},
|
|
32
32
|
'Program': {
|
|
33
33
|
exit(path) {
|
|
34
|
-
const [strictPath, ...paths] = path.get('body');
|
|
35
|
-
|
|
36
|
-
for (const path of paths) {
|
|
37
|
-
if (path.isExpressionStatement() && path.node.expression.value === 'use strict')
|
|
38
|
-
push(path);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
34
|
const directives = path.get('directives');
|
|
42
35
|
|
|
43
36
|
if (directives.length)
|
|
@@ -52,9 +45,6 @@ module.exports.traverse = ({push, store}) => ({
|
|
|
52
45
|
directives
|
|
53
46
|
.filter(isStrictMode)
|
|
54
47
|
.forEach(push);
|
|
55
|
-
|
|
56
|
-
if (strictPath.isExpressionStatement() && strictPath.node.expression.value === 'use strict')
|
|
57
|
-
push(strictPath);
|
|
58
48
|
},
|
|
59
49
|
},
|
|
60
50
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-nodejs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.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",
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"c8": "^10.0.0",
|
|
50
50
|
"eslint": "^9.0.0",
|
|
51
51
|
"eslint-plugin-n": "^17.0.0",
|
|
52
|
-
"eslint-plugin-putout": "^
|
|
52
|
+
"eslint-plugin-putout": "^24.0.0",
|
|
53
53
|
"lerna": "^6.0.1",
|
|
54
54
|
"madrun": "^10.0.0",
|
|
55
55
|
"montag": "^1.2.1",
|
|
56
56
|
"nodemon": "^3.0.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"putout": ">=
|
|
59
|
+
"putout": ">=38"
|
|
60
60
|
},
|
|
61
61
|
"license": "MIT",
|
|
62
62
|
"engines": {
|