Skip to content

perf(bundler-plugins): Use fast component annotation for HTML injection mode - #24440

Merged
timfish merged 2 commits into
developfrom
feat/fast-annotation-html-injection
Sep 23, 2026
Merged

timfish merged 2 commits into
developfrom
feat/fast-annotation-html-injection

Conversation

@timfish

@timfish timfish commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #24437.

When reactComponentAnnotation._experimentalInjectIntoHtml was set, annotation always went through Babel, even on Vite 8. This PR ports that mode to the fast walker, so every Rollup and Vite build now uses the fast path. The next step moves Webpack and the Next.js Turbopack loader over, and after that Babel can be removed.

HTML mode finds components the same way as the normal mode. The difference is in how it handles JSX. It adds only data-sentry-component, and only to the first HTML elements below each component root, looking through fragments and component elements to find them. The port keeps two Babel quirks so the output stays the same: element names starting with _ or $ count as HTML elements, and anonymous classes get data-sentry-component="".

The new tests compare the walker with the Babel HTML plugin on both @babel/parser and oxc-parser output.

Ref #24415

@timfish
timfish added this pull request to stack #24441 September 16, 2026 11:32
@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.16 kB - -
@sentry/browser - with treeshaking flags 27.42 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.33 kB - -
@sentry/browser (incl. Tracing) 50.62 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 50.64 kB - -
@sentry/browser (incl. Tracing, Profiling) 53.62 kB - -
@sentry/browser (incl. Tracing, Replay) 90.21 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.31 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 94.9 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 107.85 kB - -
@sentry/browser (incl. Feedback) 46.69 kB - -
@sentry/browser (incl. sendFeedback) 34.22 kB - -
@sentry/browser (incl. FeedbackAsync) 39.32 kB - -
@sentry/browser (incl. Metrics) 30.18 kB - -
@sentry/browser (incl. Logs) 30.43 kB - -
@sentry/browser (incl. Metrics & Logs) 31.09 kB - -
@sentry/react 30.91 kB - -
@sentry/react (incl. Tracing) 52.91 kB - -
@sentry/vue 36.41 kB - -
@sentry/vue (incl. Tracing) 52.9 kB - -
@sentry/svelte 29.18 kB - -
CDN Bundle 30.86 kB - -
CDN Bundle (incl. Tracing) 51.12 kB - -
CDN Bundle (incl. Logs, Metrics) 33.12 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.09 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.84 kB - -
CDN Bundle (incl. Tracing, Replay) 88.7 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 90.63 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 94.76 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 96.75 kB - -
CDN Bundle - uncompressed 91.25 kB - -
CDN Bundle (incl. Tracing) - uncompressed 152.53 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.82 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 158.48 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 227.39 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 272.26 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 278.2 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 285.96 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 291.89 kB - -
@sentry/nextjs (client) 55.24 kB - -
@sentry/sveltekit (client) 51.04 kB - -
@sentry/core/server 39.93 kB - -
@sentry/core/browser 13.63 kB - -
@sentry/node 133.38 kB +0.02% +19 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.15 kB - -
@sentry/node - without tracing 89.93 kB +0.03% +23 B 🔺
@sentry/node - without channel injection 112.17 kB +0.03% +25 B 🔺
@sentry/aws-serverless 98.2 kB +0.02% +18 B 🔺
@sentry/cloudflare (withSentry) - minified 205.06 kB - -
@sentry/cloudflare (withSentry) 510.44 kB - -

View base workflow run

@timfish
timfish force-pushed the feat/fast-annotation-html-injection branch from b9714bb to f9fc3b3 Compare September 16, 2026 16:09
Base automatically changed from feat/rollup-vite-fast-component-annotation to develop September 16, 2026 17:02
@timfish
timfish force-pushed the feat/fast-annotation-html-injection branch from f9fc3b3 to 66f9e6b Compare September 16, 2026 17:02
@timfish
timfish marked this pull request as ready for review September 16, 2026 17:02
@timfish
timfish requested a review from chargome September 16, 2026 17:02
@timfish
timfish force-pushed the feat/fast-annotation-html-injection branch 2 times, most recently from d6d9305 to 4e4aaf1 Compare September 20, 2026 12:51
@github-actions

Copy link
Copy Markdown
Contributor

👋 @chargome — Please review this PR when you get a chance!

@timfish
timfish requested a review from s1gr1d September 21, 2026 11:33
@timfish
timfish force-pushed the feat/fast-annotation-html-injection branch from 4e4aaf1 to c1264e7 Compare September 21, 2026 22:02
@timfish
timfish force-pushed the feat/fast-annotation-html-injection branch from c1264e7 to fea650c Compare September 22, 2026 10:50
@timfish
timfish requested a review from logaretm September 22, 2026 12:33
@timfish
timfish merged commit 7070bd6 into develop Sep 23, 2026
229 of 230 checks passed
@timfish
timfish deleted the feat/fast-annotation-html-injection branch September 23, 2026 10:23
timfish added a commit that referenced this pull request Sep 23, 2026
…Turbopack (#24448)

Stacked on #24440. Webpack and the Next.js Turbopack loader still
annotated React components with Babel. This PR moves them to the fast
oxc-based path, so every bundler integration now uses it. Babel stays as
the fallback when `oxc-parser` cannot load or cannot parse a file. The
next PR in the stack removes that fallback.

`createComponentNameAnnotateHooks` now tries the fast path first and
uses Babel only when the fast path does not handle the file. Webpack,
the Rollup and Vite plugins, and the Turbopack loader already call this
function, so the Rollup plugin no longer needs its own fast-path setup.

The fast path's source maps listed each annotated file by its base name
only, which dropped the directory. That is the bug from #23561, which
was fixed for the Babel path, and it would have come back for Webpack.
The maps now keep the full path, so Rollup and Vite builds that use the
fast path get full paths too.

Ref #24415
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.

2 participants