Skip to content

perf(vite): add fast component annotation transform#22089

Merged
Lms24 merged 2 commits into
developfrom
timfish/perf/vite-add-fast-component-annotation-transform
Jul 9, 2026
Merged

perf(vite): add fast component annotation transform#22089
Lms24 merged 2 commits into
developfrom
timfish/perf/vite-add-fast-component-annotation-transform

Conversation

@timfish

@timfish timfish commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Credit to @TheAlexLichter who opened this PR against the bundler plugins repo after we moved the functionality to this repo but before we managed to remove the orphaned package!

Resolves getsentry/sentry-javascript-bundler-plugins#943

This PR adds a port of the Babel transform forreactComponentAnnotation.enabled that works with Vite 8 + magic string, dramatically decreasing build time.

I've also added parity tests and consolidated values to avoid drift of both implementations.

Vite 7 and fallback cases will use the existing Babel transform.
Both Babel and the Vite annotation backend are lazy-loaded to avoid unnecessary startup cost.

"data-sentry-source-file": "app.jsx"
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 4,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The updated line numbers are on purpose and actually "more correct" as they now point to the actual JSX component, not just the span around it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Noticed this as it was porting over!

@@ -0,0 +1,314 @@
import { transformAsync, traverse, types as t } from '@babel/core';
import { parse } from '@babel/parser';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, this does use babel for testing as it is more convenient API-wise 😄

@timfish
timfish requested review from Lms24, isaacs and mydea July 8, 2026 13:14
@timfish
timfish marked this pull request as ready for review July 8, 2026 14:17

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e04ab6a. Configure here.

Comment thread packages/bundler-plugins/src/core/component-annotation-vite.ts Outdated

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for contributing @TheAlexLichter and for porting this over Tim!

@Lms24
Lms24 merged commit 48b1434 into develop Jul 9, 2026
594 of 598 checks passed
@Lms24
Lms24 deleted the timfish/perf/vite-add-fast-component-annotation-transform branch July 9, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vite 8 /Rolldown: Do not use Babel for annotating react components

3 participants