fix(transformer): ignore @jsxImportSource inside inline code spans in comments#20674
fix(transformer): ignore @jsxImportSource inside inline code spans in comments#20674graphite-app[bot] merged 1 commit intomainfrom
@jsxImportSource inside inline code spans in comments#20674Conversation
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. |
af50cc8 to
da1550c
Compare
Merging this PR will improve performance by 3.2%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | mangler[RadixUIAdoptionSection.jsx_keep_names] |
20.1 µs | 19.5 µs | +3.2% |
Comparing fix/jsx-pragma-backtick (9439b5d) with main (2917bb2)2
Footnotes
-
7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
No successful run was found on
main(6b5cd8c) during the generation of this report, so 2917bb2 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
da1550c to
9439b5d
Compare
sapphi-red
left a comment
There was a problem hiding this comment.
It seems TypeScript has the same behavior with us (and esbuild).
TS playground
That said, I think it is safe to diverge for this bit.
Merge activity
|
…in comments (#20674) ## Summary - Fix JSX pragma scanner incorrectly matching `@jsxImportSource` inside backtick code spans (e.g. `` `@jsxImportSource custom/source` ``) in doc comments - Add validation that `@` must be preceded by whitespace, `*`, or be at the start of the comment ## Problem The `memchr`-based `@` search found pragma directives anywhere in a comment, including inside inline code spans. This caused: 1. A `@jsxImportSource` inside a doc comment overriding the actual file-level pragma 2. The trailing backtick being included in the import specifier (`` custom/source` ``) This broke Vite 8 dev server when `.tsx` files had JSDoc comments mentioning `@jsxImportSource`. ## Design | Tool | `@` position check | |------|-------------------| | esbuild | None — matches `@jsx` anywhere in comment | | Babel | Full start-of-line regex (`^\s*(?:\*\s*)?@jsx`) | | **Oxc (this PR)** | Preceding byte must be whitespace, `*`, or start of comment | We intentionally sit between esbuild and Babel — checking only the immediately preceding byte is sufficient for the backtick case without being as strict as Babel's full start-of-line regex. Fixes #20669 ## Test plan - [x] Unit tests added for backtick-wrapped pragmas - [x] Conformance test fixture added (`issue-20669`) - [x] All existing transformer tests pass - [x] Clippy clean 🤖 Generated with [Claude Code](https://claude.com/claude-code)
9439b5d to
3931b98
Compare

Summary
@jsxImportSourceinside backtick code spans (e.g.`@jsxImportSource custom/source`) in doc comments@must be preceded by whitespace,*, or be at the start of the commentProblem
The
memchr-based@search found pragma directives anywhere in a comment, including inside inline code spans. This caused:@jsxImportSourceinside a doc comment overriding the actual file-level pragmacustom/source`)This broke Vite 8 dev server when
.tsxfiles had JSDoc comments mentioning@jsxImportSource.Design
@position check@jsxanywhere in comment^\s*(?:\*\s*)?@jsx)*, or start of commentWe intentionally sit between esbuild and Babel — checking only the immediately preceding byte is sufficient for the backtick case without being as strict as Babel's full start-of-line regex.
Fixes #20669
Test plan
issue-20669)🤖 Generated with Claude Code