perf(transformer): only scan comments before first statement for JSX pragmas#20675
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merging this PR will not alter performance
Comparing Footnotes
|
a740466 to
225ded7
Compare
9ce3b27 to
af50cc8
Compare
df98a5e to
fa8b679
Compare
da1550c to
9439b5d
Compare
fa8b679 to
cd25e3f
Compare
|
@sapphi-red I'd like to hear your thoughts on this, as this would diverge from |
sapphi-red
left a comment
There was a problem hiding this comment.
I think this behavior makes sense and I wouldn't expect any code to break by this change.
Maybe we should clarify the behavior in https://oxc.rs/docs/guide/usage/transformer/jsx.html, adding a section about how pragma comments are parsed
Thank you for reminding me. I will send a PR to follow it later |
Merge activity
|
…pragmas (#20675) ## Summary - Restrict JSX pragma scanning to only comments appearing before the first statement, since pragmas are file-level directives - Pass `first_statement_start` position to `update_options_with_comments` and skip comments at or after that position ## Motivation Previously all comments in a file were scanned for JSX pragmas, which meant pragmas in doc comments on functions could override file-level pragmas. This aligns Oxc with TypeScript and SWC, which both restrict pragma scanning to leading comments. | Tool | Pragma scan scope | |------|-------------------| | TypeScript | Leading comments before first token | | SWC | Leading block comments, stops at first pragma-bearing statement | | Babel | All comments (last wins) | | esbuild | All comments (last wins) | | **Oxc (after)** | Comments before first statement | ## Test plan - [x] All transformer tests pass - [x] Conformance tests pass (including `issue-20669` fixture from parent PR) - [x] Clippy clean 🤖 Generated with [Claude Code](https://claude.com/claude-code)
9439b5d to
3931b98
Compare
cd25e3f to
bd10021
Compare
Clarify that Oxc only scans comments before the first statement for JSX pragmas, aligning with TypeScript and SWC behavior. This was requested in oxc-project/oxc#20675 review feedback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Clarify that Oxc only scans comments before the first statement for JSX pragmas, aligning with TypeScript and SWC behavior. This was requested in oxc-project/oxc#20675 review feedback. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

Summary
first_statement_startposition toupdate_options_with_commentsand skip comments at or after that positionMotivation
Previously all comments in a file were scanned for JSX pragmas, which meant pragmas in doc comments on functions could override file-level pragmas. This aligns Oxc with TypeScript and SWC, which both restrict pragma scanning to leading comments.
Test plan
issue-20669fixture from parent PR)🤖 Generated with Claude Code