Skip to content

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Oct 27, 2025

Summary

Fixes #14953

Legal comments (e.g., /*! ... */) that appear before directives like "use strict" are now properly preserved in the generated code.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings October 27, 2025 12:51
@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 27, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added A-codegen Area - Code Generation C-bug Category - Bug labels Oct 27, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the handling of legal comments that appear before directives (like "use strict"), ensuring they are preserved in the generated code rather than being dropped.

Key changes:

  • Modified the Directive::gen implementation to print leading comments before outputting the directive itself
  • Added test coverage for legal comments appearing above directives

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

File Description
crates/oxc_codegen/src/gen.rs Added print_comments_at call to preserve legal comments before directives
crates/oxc_codegen/tests/integration/comments.rs Added test case for legal comments above directives
crates/oxc_codegen/tests/integration/snapshots/*.snap Updated snapshots to reflect the fix and test framework changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 27, 2025

CodSpeed Performance Report

Merging #14993 will not alter performance

Comparing fix/legal-comment-directives (09ea312) with main (384ea3c)1

Summary

✅ 37 untouched

Footnotes

  1. No successful run was found on main (7bcc6b0) during the generation of this report, so 384ea3c was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Boshen Boshen force-pushed the fix/legal-comment-directives branch from 098c973 to 09ea312 Compare October 27, 2025 13:05
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Oct 27, 2025
Copy link
Member Author

Boshen commented Oct 27, 2025

Merge activity

## Summary

Fixes #14953

Legal comments (e.g., `/*! ... */`) that appear before directives like `"use strict"` are now properly preserved in the generated code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@graphite-app graphite-app bot force-pushed the fix/legal-comment-directives branch from 09ea312 to 4904710 Compare October 27, 2025 13:14
@graphite-app graphite-app bot merged commit 4904710 into main Oct 27, 2025
20 checks passed
@graphite-app graphite-app bot deleted the fix/legal-comment-directives branch October 27, 2025 13:19
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-codegen Area - Code Generation C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Legal comments above directives are not preserved

2 participants