Skip to content

test: Add build-time tests for node & bundler plugins - #23618

Open
mydea wants to merge 4 commits into
developfrom
fn/bundler-tests
Open

test: Add build-time tests for node & bundler plugins#23618
mydea wants to merge 4 commits into
developfrom
fn/bundler-tests

Conversation

@mydea

@mydea mydea commented Aug 26, 2026

Copy link
Copy Markdown
Member

This adds test for webpack, vite, rollup, rolldown, esbuild to verify that build-time injection with orchestrion generally works.

@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.57 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.63 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.65 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.56 kB - -
@sentry/browser (incl. Tracing, Replay) 88.11 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.51 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.82 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.51 kB - -
@sentry/browser (incl. Feedback) 45.79 kB - -
@sentry/browser (incl. sendFeedback) 33.35 kB - -
@sentry/browser (incl. FeedbackAsync) 38.46 kB - -
@sentry/browser (incl. Metrics) 29.51 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.43 kB - -
@sentry/react 30.31 kB - -
@sentry/react (incl. Tracing) 50.84 kB - -
@sentry/vue 35.69 kB - -
@sentry/vue (incl. Tracing) 50.88 kB - -
@sentry/svelte 28.59 kB - -
CDN Bundle 30.36 kB - -
CDN Bundle (incl. Tracing) 49.12 kB - -
CDN Bundle (incl. Logs, Metrics) 32.56 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.01 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73 kB - -
CDN Bundle (incl. Tracing, Replay) 86.62 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.52 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.4 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.33 kB - -
CDN Bundle - uncompressed 89.97 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.82 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.26 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.51 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.42 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.32 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.01 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.68 kB - -
@sentry/nextjs (client) 53.41 kB - -
@sentry/sveltekit (client) 49.08 kB - -
@sentry/core/server 65.3 kB - -
@sentry/core/browser 52.37 kB - -
@sentry/node 122.35 kB +0.02% +22 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.22 kB - -
@sentry/node - without tracing 87.67 kB +0.03% +23 B 🔺
@sentry/node - without channel injection 102.05 kB +0.02% +18 B 🔺
@sentry/aws-serverless 95.83 kB +0.03% +27 B 🔺
@sentry/cloudflare (withSentry) - minified 199.57 kB - -
@sentry/cloudflare (withSentry) 495.71 kB - -

View base workflow run

Comment thread dev-packages/e2e-tests/test-applications/node-esbuild/build.mjs Outdated
Comment thread dev-packages/e2e-tests/test-applications/node-vite/assert.mjs
@mydea
mydea force-pushed the fn/bundler-tests branch from 87c2113 to 66d93fa Compare August 26, 2026 09:02
@mydea
mydea marked this pull request as ready for review August 26, 2026 12:00
@mydea
mydea requested review from logaretm and s1gr1d August 27, 2026 07:13
@mydea
mydea force-pushed the fn/bundler-tests branch from 66d93fa to cf5f1d1 Compare August 27, 2026 08:25

@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.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cf5f1d1. Configure here.

Comment thread dev-packages/e2e-tests/test-applications/node-esbuild/assert.mjs Outdated
mydea and others added 4 commits August 27, 2026 11:33
… plugin excludes runtime injection

Build the entry twice: plain webpack (runtime channel injection bundled by default) and with
`sentryWebpackPlugin` (build-time instrumentation), which defaults `excludeChannelInjection` to true
and tree-shakes the runtime injection out. assert.mjs verifies the marker is present in the plain
build and absent in the plugin build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

test(e2e): Minify node-webpack builds so runtime-injection tree-shaking runs

The dead `if (useChannelInjection)` branch is only pruned by the minifier, so `minimize: false` left
the runtime injection in the bundle. Verified: with `minimize: true`, the real `sentryWebpackPlugin`
excludes the runtime injection while a plain build keeps it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

test(e2e): Add node-vite and node-rollup runtime-injection-exclusion tests

Mirror node-webpack for Vite and Rollup: build the entry plain and with the respective Sentry plugin,
and assert the runtime channel-injection marker is present in the plain build but tree-shaken out with
the plugin (build-time instrumentation defaults `excludeChannelInjection` to true). Verified locally
that both bundlers tree-shake the runtime injection.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

test(e2e): Use esnext target for node-vite so top-level await builds

Vite defaults to a browser target that rejects the entry's top-level await; set a node target.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

test(e2e): Add node-esbuild build-time instrumentation test

Build the entry plain and with `sentryEsbuildPlugin`. esbuild's single-pass tree-shaking keeps the
(now dead) runtime injection in the bundle unlike webpack/vite/rollup, so this app only asserts the
plain build bundles the runtime injection and the plugin build succeeds; the runtime-behavior side is
covered separately.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

fixes...
The plugin-build assertion searched a whitespace-stripped bundle for
`g.bundler=g.bundler||[]`, but `ORCHESTRION_BUNDLER_MARKER_BANNER` initializes the
set with `new Set()` (stripped: `newSet()`), so the marker never matched and the
`plugin` assertion always failed. Rolldown additionally emits a `/* @__PURE__ */`
annotation inside the banner, which whitespace-stripping leaves intact.

Match the real banner: strip block comments as well as whitespace before searching,
and look for `g.bundler=g.bundler||newSet()`. Verified against the plugin bundles of
all five bundlers (webpack, esbuild, vite, rollup, rolldown).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mydea
mydea force-pushed the fn/bundler-tests branch from 3d0dbfe to 99cf169 Compare August 27, 2026 09:34
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.

1 participant