@putout/printer 16.5.0 → 16.6.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/ChangeLog
CHANGED
|
@@ -20,6 +20,7 @@ const {
|
|
|
20
20
|
isExportNamespaceSpecifier,
|
|
21
21
|
isVariableDeclaration,
|
|
22
22
|
isExportNamedDeclaration,
|
|
23
|
+
isExportDefaultSpecifier,
|
|
23
24
|
} = types;
|
|
24
25
|
|
|
25
26
|
const isDeclarationNewline = (path) => isMarkedAfter(path.get('declaration'));
|
|
@@ -47,6 +48,10 @@ module.exports.ExportNamespaceSpecifier = (path, {print}) => {
|
|
|
47
48
|
print('__exported');
|
|
48
49
|
};
|
|
49
50
|
|
|
51
|
+
module.exports.ExportDefaultSpecifier = (path, {print}) => {
|
|
52
|
+
print('__exported');
|
|
53
|
+
};
|
|
54
|
+
|
|
50
55
|
module.exports.ExportNamedDeclaration = {
|
|
51
56
|
beforeIf(path) {
|
|
52
57
|
const prev = path.getPrevSibling();
|
|
@@ -88,15 +93,30 @@ module.exports.ExportNamedDeclaration = {
|
|
|
88
93
|
|
|
89
94
|
if (specifiers && !path.node.declaration) {
|
|
90
95
|
print.space();
|
|
91
|
-
print('{');
|
|
92
96
|
|
|
93
|
-
|
|
97
|
+
const [first, ...rest] = specifiers;
|
|
98
|
+
|
|
99
|
+
if (!specifiers.length) {
|
|
100
|
+
print('{}');
|
|
101
|
+
} else if (isExportDefaultSpecifier(first) && !rest.length) {
|
|
102
|
+
traverse(first);
|
|
103
|
+
} else {
|
|
104
|
+
if (isExportDefaultSpecifier(first)) {
|
|
105
|
+
traverse(first);
|
|
106
|
+
print(',');
|
|
107
|
+
print.space();
|
|
108
|
+
} else {
|
|
109
|
+
rest.unshift(first);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
print('{');
|
|
113
|
+
|
|
94
114
|
indent.inc();
|
|
95
115
|
maybe.print.newline(isNewline);
|
|
96
116
|
|
|
97
117
|
const lastIndex = n - 1;
|
|
98
118
|
|
|
99
|
-
for (const [i, spec] of
|
|
119
|
+
for (const [i, spec] of rest.entries()) {
|
|
100
120
|
const isType = spec.node.exportKind === 'type';
|
|
101
121
|
const isLast = i < lastIndex;
|
|
102
122
|
|
|
@@ -114,9 +134,9 @@ module.exports.ExportNamedDeclaration = {
|
|
|
114
134
|
|
|
115
135
|
indent.dec();
|
|
116
136
|
indent();
|
|
137
|
+
print('}');
|
|
117
138
|
}
|
|
118
139
|
|
|
119
|
-
print('}');
|
|
120
140
|
const source = path.get('source');
|
|
121
141
|
|
|
122
142
|
if (exists(source)) {
|
|
@@ -156,3 +176,4 @@ module.exports.ExportNamedDeclaration = {
|
|
|
156
176
|
markAfter(path);
|
|
157
177
|
},
|
|
158
178
|
};
|
|
179
|
+
|
package/package.json
CHANGED