Skip to content

Commit 8be87d8

Browse files
committed
don't add comma to last export
1 parent e2c8bce commit 8be87d8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,17 @@ function wrapExportsInQuotes(exports, code) {
157157
}
158158

159159
function separateExportsWithCommas(exports, code) {
160-
let codeLines = code.split("\n").map((line) => {
160+
let codeLines = code.split("\n").map((line, lineIndex) => {
161161
let newLine = line;
162-
exports.forEach((name) => {
162+
exports.forEach((name, exportIndex) => {
163163
if (line.startsWith(`"${name}"`)) {
164-
newLine = newLine.replace(";", ",");
164+
newLine = newLine.replace(
165+
";",
166+
exportIndex === exports.length ? "," : ""
167+
);
165168
}
166169
});
167-
if (newLine === "}") {
170+
if (newLine === "}" && lineIndex !== codeLines.length) {
168171
newLine = "},";
169172
}
170173
return newLine;

0 commit comments

Comments
 (0)