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

fix(es/codegen): Skip lo of a program if body is not empty #6773

Merged
merged 11 commits into from
Jan 10, 2023
Merged
Changes from 7 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
9 changes: 7 additions & 2 deletions crates/swc_ecma_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ where
#[emitter]
pub fn emit_module(&mut self, node: &Module) -> Result {
self.emit_leading_comments_of_span(node.span(), false)?;
srcmap!(node, true);

if node.body.is_empty() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This is still required to fix #6767

srcmap!(node, true);
}

if let Some(ref shebang) = node.shebang {
punct!("#!");
Expand All @@ -115,7 +118,9 @@ where
pub fn emit_script(&mut self, node: &Script) -> Result {
self.emit_leading_comments_of_span(node.span(), false)?;

srcmap!(node, true);
if node.body.is_empty() {
srcmap!(node, true);
}

if let Some(ref shebang) = node.shebang {
punct!("#!");
Expand Down