Skip to content

Commit

Permalink
Move sourcemap declaration at the top
Browse files Browse the repository at this point in the history
  • Loading branch information
AlisCode committed Dec 3, 2024
1 parent d04c430 commit c747d28
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions compiler-core/src/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,28 +198,28 @@ impl<'a> Generator<'a> {

if imports.is_empty() && statements.is_empty() {
Ok(docvec![
sourcemap_reference,
type_reference,
"export {}",
line(),
sourcemap_reference,
])
} else if imports.is_empty() {
statements.push(line());
Ok(docvec![type_reference, statements, sourcemap_reference])
Ok(docvec![sourcemap_reference, type_reference, statements])
} else if statements.is_empty() {
Ok(docvec![
sourcemap_reference,
type_reference,
imports.into_doc(JavaScriptCodegenTarget::JavaScript, self.line_numbers),
sourcemap_reference,
])
} else {
Ok(docvec![
sourcemap_reference,
type_reference,
imports.into_doc(JavaScriptCodegenTarget::JavaScript, self.line_numbers),
line(),
statements,
line(),
sourcemap_reference,
])
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ note:
1fn add_2(x) {
^ This code
┌─ generated.js:1:1
┌─ generated.js:2:1
1function add_2(x) {
2function add_2(x) {
^ Gets mapped to this

---
Expand All @@ -20,9 +20,9 @@ note:
2x + 2
^ This code
┌─ generated.js:2:3
┌─ generated.js:3:3
2return x + 2;
3return x + 2;
^ Gets mapped to this

---
Expand All @@ -32,9 +32,9 @@ note:
2x + 2
^ This code
┌─ generated.js:2:10
┌─ generated.js:3:10
2return x + 2;
3return x + 2;
^ Gets mapped to this

---
Expand All @@ -44,7 +44,7 @@ note:
2x + 2
^ This code
┌─ generated.js:2:14
┌─ generated.js:3:14
2return x + 2;
3return x + 2;
^ Gets mapped to this

0 comments on commit c747d28

Please sign in to comment.