Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render emtpy block comments after tree-shaken statements #5231

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/renderHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function findFirstLineBreakOutsideComment(code: string): [number, number]
// With our assumption, '/' always starts a comment. Determine comment type:
charCodeAfterSlash = code.charCodeAt(start + 1);
if (charCodeAfterSlash === 47 /*"/"*/) return [start, lineBreakPos + 1];
start = code.indexOf('*/', start + 3) + 2;
start = code.indexOf('*/', start + 2) + 2;
if (start > lineBreakPos) {
lineBreakPos = code.indexOf('\n', start);
}
Expand Down
3 changes: 3 additions & 0 deletions test/form/samples/empty-block-comment/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = defineTest({
description: 'renders empty block comments after tree-shaken statements (#5230)'
});
4 changes: 4 additions & 0 deletions test/form/samples/empty-block-comment/_expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function instance() {
}

export { instance };
3 changes: 3 additions & 0 deletions test/form/samples/empty-block-comment/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function instance() {
const b = 2; /**/
}