@putout/bundle 1.8.2 → 1.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.
- package/bundle/plugin-putout.js +21 -28
- package/bundle/putout-iife.js +37 -37
- package/bundle/putout.js +60855 -61045
- package/package.json +1 -1
package/bundle/plugin-putout.js
CHANGED
|
@@ -490,8 +490,7 @@ function requireCheckReplaceCode () {
|
|
|
490
490
|
}
|
|
491
491
|
|
|
492
492
|
function hasMatch(path) {
|
|
493
|
-
const {body} = path.scope
|
|
494
|
-
.getProgramParent().path.node;
|
|
493
|
+
const {body} = path.scope.getProgramParent().path.node;
|
|
495
494
|
|
|
496
495
|
for (const current of body) {
|
|
497
496
|
if (compare(current, 'module.exports.match = __a'))
|
|
@@ -547,17 +546,20 @@ function requireConvertBabelTypes () {
|
|
|
547
546
|
|
|
548
547
|
function isRequire(path) {
|
|
549
548
|
return path
|
|
550
|
-
.get('callee')
|
|
549
|
+
.get('callee')
|
|
550
|
+
.isIdentifier({
|
|
551
551
|
name: 'require',
|
|
552
552
|
});
|
|
553
553
|
}
|
|
554
554
|
|
|
555
555
|
function isBabelTypes(path) {
|
|
556
556
|
return path
|
|
557
|
-
.get('arguments.0')
|
|
557
|
+
.get('arguments.0')
|
|
558
|
+
.isStringLiteral({
|
|
558
559
|
value: '@babel/types',
|
|
559
560
|
});
|
|
560
561
|
}
|
|
562
|
+
|
|
561
563
|
convertBabelTypes.traverse = ({push}) => ({
|
|
562
564
|
CallExpression(path) {
|
|
563
565
|
if (!isRequire(path))
|
|
@@ -716,9 +718,7 @@ function requireConvertFindToTraverse () {
|
|
|
716
718
|
|
|
717
719
|
path.traverse({
|
|
718
720
|
CallExpression(path) {
|
|
719
|
-
if (!path.get('callee').isIdentifier({
|
|
720
|
-
name: 'traverse',
|
|
721
|
-
}))
|
|
721
|
+
if (!path.get('callee').isIdentifier({name: 'traverse'}))
|
|
722
722
|
return;
|
|
723
723
|
|
|
724
724
|
result = path;
|
|
@@ -1091,6 +1091,7 @@ function requireConvertReplaceWith () {
|
|
|
1091
1091
|
|
|
1092
1092
|
return insertAfter.path;
|
|
1093
1093
|
}
|
|
1094
|
+
|
|
1094
1095
|
convertReplaceWith.traverse = ({push}) => {
|
|
1095
1096
|
const isInserted = fullstore();
|
|
1096
1097
|
|
|
@@ -1187,6 +1188,7 @@ function requireConvertReplaceWithMultiple () {
|
|
|
1187
1188
|
|
|
1188
1189
|
return insertAfter.path;
|
|
1189
1190
|
}
|
|
1191
|
+
|
|
1190
1192
|
convertReplaceWithMultiple.traverse = ({push}) => ({
|
|
1191
1193
|
CallExpression(path) {
|
|
1192
1194
|
const calleePath = path.get('callee');
|
|
@@ -1313,10 +1315,9 @@ function requireConvertTraverseToInclude () {
|
|
|
1313
1315
|
const {StringLiteral} = types;
|
|
1314
1316
|
const {compare} = operator;
|
|
1315
1317
|
|
|
1316
|
-
const isPush = (path) => path
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
});
|
|
1318
|
+
const isPush = (path) => path.get('value').isIdentifier({
|
|
1319
|
+
name: 'push',
|
|
1320
|
+
});
|
|
1320
1321
|
|
|
1321
1322
|
convertTraverseToInclude.report = () => 'Includer should be used instead of Traverser';
|
|
1322
1323
|
|
|
@@ -1398,9 +1399,7 @@ function requireConvertTraverseToReplace () {
|
|
|
1398
1399
|
'module.exports.traverse = (__args) => __a': ({__args}, path) => {
|
|
1399
1400
|
const program = path.scope.getProgramParent().path;
|
|
1400
1401
|
|
|
1401
|
-
const withFix = contains(program, [
|
|
1402
|
-
'module.exports.fix = __a',
|
|
1403
|
-
]);
|
|
1402
|
+
const withFix = contains(program, ['module.exports.fix = __a']);
|
|
1404
1403
|
|
|
1405
1404
|
if (withFix)
|
|
1406
1405
|
return false;
|
|
@@ -1411,9 +1410,7 @@ function requireConvertTraverseToReplace () {
|
|
|
1411
1410
|
if (!__args.length)
|
|
1412
1411
|
return true;
|
|
1413
1412
|
|
|
1414
|
-
const withPush = contains(__args[0], [
|
|
1415
|
-
'push',
|
|
1416
|
-
]);
|
|
1413
|
+
const withPush = contains(__args[0], ['push']);
|
|
1417
1414
|
|
|
1418
1415
|
if (withPush)
|
|
1419
1416
|
return false;
|
|
@@ -1505,12 +1502,11 @@ function requireCreateTest () {
|
|
|
1505
1502
|
getProperty,
|
|
1506
1503
|
} = operator;
|
|
1507
1504
|
|
|
1508
|
-
const selector = 'createTest(__dirname, __object)';
|
|
1509
|
-
|
|
1510
1505
|
createTest.report = () => `Apply modifications to 'createTest()' options`;
|
|
1511
1506
|
|
|
1512
1507
|
createTest.include = () => [
|
|
1513
|
-
|
|
1508
|
+
'createTest(__dirname, __object)',
|
|
1509
|
+
'createTest(import.meta.url, __object)',
|
|
1514
1510
|
];
|
|
1515
1511
|
|
|
1516
1512
|
createTest.fix = (path, {options}) => {
|
|
@@ -2871,6 +2867,7 @@ function requireOperator () {
|
|
|
2871
2867
|
isESM: `const {isESM} = operator`,
|
|
2872
2868
|
getProperty: `const {getProperty} = operator`,
|
|
2873
2869
|
getProperties: `const {getProperties} = operator`,
|
|
2870
|
+
isSimple: `const {isSimple} = operator`,
|
|
2874
2871
|
};
|
|
2875
2872
|
return operator;
|
|
2876
2873
|
}
|
|
@@ -3030,8 +3027,7 @@ function requireMoveRequireOnTopLevel () {
|
|
|
3030
3027
|
const buildRequire = template(`const NAME = REQUIRE`);
|
|
3031
3028
|
|
|
3032
3029
|
function declareRequire({__a, __b}, path) {
|
|
3033
|
-
const shortName = __a.value || __a.name
|
|
3034
|
-
.split('/').pop();
|
|
3030
|
+
const shortName = __a.value || __a.name.split('/').pop();
|
|
3035
3031
|
|
|
3036
3032
|
const name = justCamelCase(shortName);
|
|
3037
3033
|
|
|
@@ -3043,8 +3039,7 @@ function requireMoveRequireOnTopLevel () {
|
|
|
3043
3039
|
if (path.scope.hasBinding(name))
|
|
3044
3040
|
return name;
|
|
3045
3041
|
|
|
3046
|
-
const programPath = path.scope
|
|
3047
|
-
.getProgramParent().path;
|
|
3042
|
+
const programPath = path.scope.getProgramParent().path;
|
|
3048
3043
|
|
|
3049
3044
|
programPath.node.body.unshift(requireNode);
|
|
3050
3045
|
|
|
@@ -3114,6 +3109,7 @@ function requireReplaceTestMessage () {
|
|
|
3114
3109
|
|
|
3115
3110
|
replaceTestMessage.fix = ({path, incorrect, correct}) => {
|
|
3116
3111
|
path.node.value = path.node.value.replace(incorrect, correct);
|
|
3112
|
+
path.node.raw = path.node.raw.replace(incorrect, correct);
|
|
3117
3113
|
};
|
|
3118
3114
|
|
|
3119
3115
|
replaceTestMessage.traverse = ({push}) => ({
|
|
@@ -3176,10 +3172,7 @@ function requireReplaceTestMessage () {
|
|
|
3176
3172
|
const {value} = messagePath.node;
|
|
3177
3173
|
const is = !incorrect.test(value);
|
|
3178
3174
|
|
|
3179
|
-
return [
|
|
3180
|
-
is,
|
|
3181
|
-
messagePath,
|
|
3182
|
-
];
|
|
3175
|
+
return [is, messagePath];
|
|
3183
3176
|
}
|
|
3184
3177
|
return replaceTestMessage;
|
|
3185
3178
|
}
|