fix(compiler): preserve coverage pragmas in JSX - #3301
Conversation
🦋 Changeset detectedLatest commit: 3d20da1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merging this PR will not alter performance
Comparing Footnotes
|
|
4361585 to
961bd14
Compare
Thanks for your review! |
ryansolid
left a comment
There was a problem hiding this comment.
This is now exactly the shape we asked for — thanks. The injection is gone, the
(istanbul|c8)\s+ignore\bmatch is right, and the Oxc port is a real one (the closing-}span trick for comment attachment is a good way to do it) with the shared fixture driving both compilers.One blocker: the native compiler doesn't build.
source()was added to theModeLowertrait and implemented forAstDomTransformandAstUniversalTransform, butAstSsrTransform(packages/compiler/src/ssr/transform.rs, theimpl ModeLowernear the bottom) was missed:error[E0046]: not all trait items implemented, missing: `source`Same three lines as the other two impls:
fn source(&self) -> &str { self.source }Please also rebase onto
next— the CodSpeed and Size failures are inherited from the base at the time you branched and will clear — and run the Rust side before pushing (cargo build/pnpm --filter @solidjs/compiler test), since the JS tests alone can't see this.Two nits, take or leave: the Babel test is in
ref-spread.spec.js, which is about intrinsic ref/spread sources — acoverage-pragmas.spec.js(or the shared-fixtures runner) would be a more findable home. And the Oxc path re-emits every comment ahead of the}, so{/* note */ /* c8 ignore next */}prints both where Babel prints only the pragma; fine as is, just noting the fidelity difference.Once it builds green this merges.
— Claude via Cursor
961bd14 to
03073b2
Compare
|
Addressed the build blocker by implementing ModeLower::source() for AstSsrTransform and rebased onto the latest next. Verified with cargo build, the full compiler test suite (5944 tests), and the targeted Babel/Oxc coverage pragma tests. Everything passes now. Thanks and sorry about my vacation) |
Both compilers now agree on which authored pragmas lead a component's
`children` getter:
- Block comments only: line comments are never carried (Oxc dropped
`{// c8 ignore next}` and misread `// c8 ignore` inside a block comment).
- Pragmas from consecutive empty containers are all carried, in order
(Oxc kept only the last container).
- A pragma followed by text still leads the getter (Babel dropped it when
the next child was text or a same-line space).
- Only pragmas print, not neighboring notes in the same container.
Oxc re-anchors each run's pragma comments to the first pragma's start and
spans the getter there. The shared fixture covers every case with
expectations both test suites assert across dom/ssr/universal.
Co-authored-by: Claude via Cursor <noreply@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
ryansolid
left a comment
There was a problem hiding this comment.
Thanks @nickshiro — the SSR
source()fix and the rebase are exactly what was needed, and the native build is green.On a final parity pass we ran both compilers side by side across DOM, SSR and universal and found four edge cases that were already there at our last review. Rather than ask for another round, we fixed them ourselves in 3d20da1:
- Line comments: Oxc dropped
{// c8 ignore next}and misread// c8 ignoreinside a block comment. Both compilers now carry block-comment pragmas only.- Consecutive pragma containers: Oxc kept only the last
{/* … */}. Both now carry every pragma, in order.- Pragma followed by text: Babel dropped the pragma when the next child was text or a same-line space. Both now keep it on the getter.
- Note beside a pragma: Oxc printed neighboring non-pragma comments too. Both now print only the pragmas.
The shared fixture now covers every case, and both test suites assert one shared set of expectations. It lands in rc.14.
— Claude via Cursor
Summary
ref #2138
Preserve JSX Istanbul ignore comments when compiling component children, and annotate compiler-generated ref dispatch branches so they do not count toward coverage.
/* istanbul ignore next */annotations to compiler-generated conditionalrefdispatches.How did you test this change?
pnpm --filter @solidjs/babel-plugin exec vitest run
28 test files passed, 259 tests passed
pnpm --filter @solidjs/babel-plugin typecheck