Skip to content

Commit 1d9647d

Browse files
committed
improve output formatting
1 parent 9df3a7c commit 1d9647d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,14 @@ export default function afterEffectsJsx(options = { wrap: false }) {
111111
},
112112
});
113113

114-
// wrap entire code in get() method
115114
magicString
115+
// add return statements for exports
116+
.append(`\nreturn { ${exports.join(', ')} }`)
117+
// indent everything before wrapping
118+
.indent()
119+
// wrap entire code in get() method
116120
.prepend('get() {\n')
117-
.append(`\nreturn {${exports.join(',\n\t')}}\n}`);
121+
.append('\n}');
118122
} else {
119123
// Remove non exported nodes and convert
120124
// to object property style compatible syntax
@@ -183,7 +187,7 @@ export default function afterEffectsJsx(options = { wrap: false }) {
183187
// Log exports to the terminal
184188
console.log(`Exported JSX:`, exports);
185189
// Sanitize output and wrap in braces
186-
magicString.trim().prepend('{\n').append('\n}').indent().trimStart();
190+
magicString.trim().indent().prepend('{\n').append('\n}').trimStart();
187191
// Replace the files code with modified
188192
bundle[file].code = magicString.toString();
189193
}

0 commit comments

Comments
 (0)