Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl Gen for Hashbang<'_> {

impl Gen for Directive<'_> {
fn r#gen(&self, p: &mut Codegen, _ctx: Context) {
p.print_comments_at(self.span.start);
p.add_source_mapping(self.span);
p.print_indent();
// A Use Strict Directive may not contain an EscapeSequence or LineContinuation.
Expand Down
2 changes: 2 additions & 0 deletions crates/oxc_codegen/tests/integration/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ pub mod legal {
* @preserve
*/
",
// Issue #14953: legal comments above directives
"/*!\n * legal comment\n */\n\n\"use strict\";\n\nexport const foo = 'foo';",
]
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: crates/oxc_codegen/tests/integration/main.rs
source: crates/oxc_codegen/tests/integration/tester.rs
---
########## 0
/* @license */
Expand Down Expand Up @@ -127,3 +127,19 @@ function foo() {
/**
* @preserve
*/

########## 9
/*!
* legal comment
*/

"use strict";

export const foo = 'foo';
----------
'use strict';
export const foo = 'foo';

/*!
* legal comment
*/
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: crates/oxc_codegen/tests/integration/main.rs
source: crates/oxc_codegen/tests/integration/tester.rs
---
########## 0
/* @license */
Expand Down Expand Up @@ -109,3 +109,17 @@ function foo(){(()=>{
/**
* @preserve
*/

########## 9
/*!
* legal comment
*/

"use strict";

export const foo = 'foo';
----------
'use strict';export const foo=`foo`;
/*!
* legal comment
*/
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: crates/oxc_codegen/tests/integration/main.rs
source: crates/oxc_codegen/tests/integration/tester.rs
---
########## 0
/* @license */
Expand Down Expand Up @@ -112,3 +112,18 @@ function foo() {
/**
* @preserve
*/

########## 9
/*!
* legal comment
*/

"use strict";

export const foo = 'foo';
----------
/*!
* legal comment
*/
'use strict';
export const foo = 'foo';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: crates/oxc_codegen/tests/integration/main.rs
source: crates/oxc_codegen/tests/integration/tester.rs
---
########## 0
/* @license */
Expand Down Expand Up @@ -108,3 +108,16 @@ function foo() {
*/

/*! For license information please see test.js */
########## 9
/*!
* legal comment
*/

"use strict";

export const foo = 'foo';
----------
'use strict';
export const foo = 'foo';

/*! For license information please see test.js */
Loading