Skip to content

Commit 09ea312

Browse files
committed
u
1 parent 384ea3c commit 09ea312

File tree

6 files changed

+65
-4
lines changed

6 files changed

+65
-4
lines changed

crates/oxc_codegen/src/gen.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ impl Gen for Hashbang<'_> {
6868

6969
impl Gen for Directive<'_> {
7070
fn r#gen(&self, p: &mut Codegen, _ctx: Context) {
71+
p.print_comments_at(self.span.start);
7172
p.add_source_mapping(self.span);
7273
p.print_indent();
7374
// A Use Strict Directive may not contain an EscapeSequence or LineContinuation.

crates/oxc_codegen/tests/integration/comments.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ pub mod legal {
224224
* @preserve
225225
*/
226226
",
227+
// Issue #14953: legal comments above directives
228+
"/*!\n * legal comment\n */\n\n\"use strict\";\n\nexport const foo = 'foo';",
227229
]
228230
}
229231

crates/oxc_codegen/tests/integration/snapshots/legal_eof_comments.snap

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: crates/oxc_codegen/tests/integration/main.rs
2+
source: crates/oxc_codegen/tests/integration/tester.rs
33
---
44
########## 0
55
/* @license */
@@ -127,3 +127,19 @@ function foo() {
127127
/**
128128
* @preserve
129129
*/
130+
131+
########## 9
132+
/*!
133+
* legal comment
134+
*/
135+
136+
"use strict";
137+
138+
export const foo = 'foo';
139+
----------
140+
'use strict';
141+
export const foo = 'foo';
142+
143+
/*!
144+
* legal comment
145+
*/

crates/oxc_codegen/tests/integration/snapshots/legal_eof_minify_comments.snap

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: crates/oxc_codegen/tests/integration/main.rs
2+
source: crates/oxc_codegen/tests/integration/tester.rs
33
---
44
########## 0
55
/* @license */
@@ -109,3 +109,17 @@ function foo(){(()=>{
109109
/**
110110
* @preserve
111111
*/
112+
113+
########## 9
114+
/*!
115+
* legal comment
116+
*/
117+
118+
"use strict";
119+
120+
export const foo = 'foo';
121+
----------
122+
'use strict';export const foo=`foo`;
123+
/*!
124+
* legal comment
125+
*/

crates/oxc_codegen/tests/integration/snapshots/legal_inline_comments.snap

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: crates/oxc_codegen/tests/integration/main.rs
2+
source: crates/oxc_codegen/tests/integration/tester.rs
33
---
44
########## 0
55
/* @license */
@@ -112,3 +112,18 @@ function foo() {
112112
/**
113113
* @preserve
114114
*/
115+
116+
########## 9
117+
/*!
118+
* legal comment
119+
*/
120+
121+
"use strict";
122+
123+
export const foo = 'foo';
124+
----------
125+
/*!
126+
* legal comment
127+
*/
128+
'use strict';
129+
export const foo = 'foo';

crates/oxc_codegen/tests/integration/snapshots/legal_linked_comments.snap

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: crates/oxc_codegen/tests/integration/main.rs
2+
source: crates/oxc_codegen/tests/integration/tester.rs
33
---
44
########## 0
55
/* @license */
@@ -108,3 +108,16 @@ function foo() {
108108
*/
109109

110110
/*! For license information please see test.js */
111+
########## 9
112+
/*!
113+
* legal comment
114+
*/
115+
116+
"use strict";
117+
118+
export const foo = 'foo';
119+
----------
120+
'use strict';
121+
export const foo = 'foo';
122+
123+
/*! For license information please see test.js */

0 commit comments

Comments
 (0)